Developer Documentation
ColorAttribT_impl.hh
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 (const auto vh: kernel_.vertices()) {
78  vcolor_prop_[vh] = default_color_;
79  }
80  vertex_colors_available_ = false;
81 }
82 
83 template <class ColT>
84 void ColorAttrib<ColT>::clear_halfedge_colors()
85 {
86  for (const auto heh: kernel_.halfedges()) {
87  hecolor_prop_[heh] = default_color_;
88  }
89  halfedge_colors_available_ = false;
90 }
91 
92 template <class ColT>
93 void ColorAttrib<ColT>::clear_edge_colors()
94 {
95  for (const auto eh: kernel_.edges()) {
96  ecolor_prop_[eh] = default_color_;
97  }
98  edge_colors_available_ = false;
99 }
100 
101 template <class ColT>
102 void ColorAttrib<ColT>::clear_halfface_colors()
103 {
104  for (const auto hfh: kernel_.halffaces()) {
105  hfcolor_prop_[hfh] = default_color_;
106  }
107  halfface_colors_available_ = false;
108 }
109 
110 template <class ColT>
111 void ColorAttrib<ColT>::clear_face_colors()
112 {
113  for (const auto fh: kernel_.faces()) {
114  fcolor_prop_[fh] = default_color_;
115  }
116  face_colors_available_ = false;
117 }
118 
119 template <class ColT>
120 void ColorAttrib<ColT>::clear_cell_colors()
121 {
122  for (const auto ch: kernel_.cells()) {
123  ccolor_prop_[ch] = default_color_;
124  }
125  cell_colors_available_ = false;
126 }
127 
128 } // Namespace OpenVolumeMesh