Developer Documentation
ColorAttribT.cc
1 /*===========================================================================*\
2  * *
3  * OpenVolumeMesh *
4  * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5  * www.openvolumemesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenVolumeMesh. *
9  * *
10  * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenVolumeMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenVolumeMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 36 $ *
38  * $Date: 2012-01-10 18:00:06 +0100 (Di, 10 Jan 2012) $ *
39  * $LastChangedBy: kremer $ *
40  * *
41 \*===========================================================================*/
42 
43 #define COLORATTRIBT_CC
44 
45 #include "ColorAttrib.hh"
46 
47 namespace OpenVolumeMesh {
48 
49 template <class ColT>
50 ColorAttrib<ColT>::ColorAttrib(TopologyKernel& _kernel, const ColT _def) :
51  vcolor_prop_(_kernel.request_vertex_property<ColT>("vertex_color", _def)),
52  ecolor_prop_(_kernel.request_edge_property<ColT>("edge_color", _def)),
53  hecolor_prop_(_kernel.request_halfedge_property<ColT>("halfedge_color", _def)),
54  fcolor_prop_(_kernel.request_face_property<ColT>("face_color", _def)),
55  hfcolor_prop_(_kernel.request_halfface_property<ColT>("halfface_color", _def)),
56  ccolor_prop_(_kernel.request_cell_property<ColT>("cell_color", _def)),
57  kernel_(_kernel),
58  vertex_colors_available_(false),
59  halfedge_colors_available_(false),
60  edge_colors_available_(false),
61  halfface_colors_available_(false),
62  face_colors_available_(false),
63  cell_colors_available_(false),
64  default_color_ (_def)
65 {
66 
67 }
68 
69 template <class ColT>
70 ColorAttrib<ColT>::~ColorAttrib() {
71 
72 }
73 
74 template <class ColT>
75 void ColorAttrib<ColT>::clear_vertex_colors()
76 {
77  for (VertexIter v_it = kernel_.vertices_begin(); v_it != kernel_.vertices_end(); ++v_it)
78  vcolor_prop_[v_it->idx()] = default_color_;
79  vertex_colors_available_ = false;
80 }
81 
82 template <class ColT>
83 void ColorAttrib<ColT>::clear_halfedge_colors()
84 {
85  for (HalfEdgeIter he_it = kernel_.halfedges_begin(); he_it != kernel_.halfedges_end(); ++he_it)
86  hecolor_prop_[he_it->idx()] = default_color_;
87  halfedge_colors_available_ = false;
88 }
89 
90 template <class ColT>
91 void ColorAttrib<ColT>::clear_edge_colors()
92 {
93  for (EdgeIter e_it = kernel_.edges_begin(); e_it != kernel_.edges_end(); ++e_it)
94  ecolor_prop_[e_it->idx()] = default_color_;
95  edge_colors_available_ = false;
96 }
97 
98 template <class ColT>
99 void ColorAttrib<ColT>::clear_halfface_colors()
100 {
101  for (HalfFaceIter hf_it = kernel_.halffaces_begin(); hf_it != kernel_.halffaces_end(); ++hf_it)
102  hfcolor_prop_[hf_it->idx()] = default_color_;
103  halfface_colors_available_ = false;
104 }
105 
106 template <class ColT>
107 void ColorAttrib<ColT>::clear_face_colors()
108 {
109  for (FaceIter f_it = kernel_.faces_begin(); f_it != kernel_.faces_end(); ++f_it)
110  fcolor_prop_[f_it->idx()] = default_color_;
111  face_colors_available_ = false;
112 }
113 
114 template <class ColT>
115 void ColorAttrib<ColT>::clear_cell_colors()
116 {
117  for (CellIter c_it = kernel_.cells_begin(); c_it != kernel_.cells_end(); ++c_it)
118  ccolor_prop_[c_it->idx()] = default_color_;
119  cell_colors_available_ = false;
120 }
121 
122 } // Namespace OpenVolumeMesh