| OpenMesh

SmartTaggerT.hh
1 /* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openmesh.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenMesh. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 * ========================================================================= */
41
42 #pragma once
43
44
45 //== INCLUDES =================================================================
46
47 // OpenMesh
48 #include <OpenMesh/Core/Utils/Property.hh>
49 #include <OpenMesh/Core/System/omstream.hh>
50
51
52 //== DEFINES ==================================================================
53
54 #define STV_DEBUG_CHECKS
55
56 //== NAMESPACES ===============================================================
57
58 namespace OpenMesh {
59
60 //== FORWARD DECLARATIONS =====================================================
61
62 // Smarttagging for vertices
63 template< class Mesh> class SmartTaggerVT;
64 // Smarttagging for edges
65 template< class Mesh> class SmartTaggerET;
66 // Smarttagging for faces
67 template< class Mesh> class SmartTaggerFT;
68 // Smarttagging for halfedges
69 template< class Mesh> class SmartTaggerHT;
70
71
72 //== CLASS DEFINITION =========================================================
73
74
123 template <class Mesh, class EHandle, class EPHandle>
124 class SmartTaggerT
125 {
126 public:
127
129 SmartTaggerT(Mesh& _mesh, unsigned int _tag_range = 1);
130
132 ~SmartTaggerT();
133
137 inline void untag_all();
138
143 inline void untag_all( const unsigned int _new_tag_range);
144
150 inline void set_tag ( const EHandle _eh, unsigned int _tag = 1);
151
157 inline unsigned int get_tag ( const EHandle _eh) const;
158
164 inline bool is_tagged( const EHandle _eh) const;
165
172 inline void set_tag_range( const unsigned int _tag_range);
173
174 protected:
175
176 inline void all_tags_to_zero();
177
178 protected:
179
180 // Reference to Mesh
181 Mesh& mesh_;
182
183 // property which holds the current tags
184 EPHandle ep_tag_;
185
186 // current tags range is [current_base_+1...current_base_+tag_range_]
187 unsigned int current_base_;
188
189 // number of different tagvalues available
190 unsigned int tag_range_;
191 };
192
193
194 //== SPECIALIZATION ===========================================================
195
196 // define standard Tagger
197 template< class Mesh>
198 class SmartTaggerVT
199 : public SmartTaggerT< Mesh, typename Mesh::VertexHandle, OpenMesh::VPropHandleT<unsigned int> >
200 {
201 public:
202 typedef SmartTaggerT< Mesh, typename Mesh::VertexHandle, OpenMesh::VPropHandleT<unsigned int> > BaseType;
203 SmartTaggerVT(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
204 };
205
206 template< class Mesh>
207 class SmartTaggerET
208 : public SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> >
209 {
210 public:
211 typedef SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> > BaseType;
212 SmartTaggerET(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
213 };
214
215 template< class Mesh>
216 class SmartTaggerFT
217 : public SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> >
218 {
219 public:
220 typedef SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> > BaseType;
221 SmartTaggerFT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range) {}
222 };
223
224 template< class Mesh>
225 class SmartTaggerHT
226 : public SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> >
227 {
228 public:
229 typedef SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> > BaseType;
230 SmartTaggerHT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range){}
231 };
232
233
234 //=============================================================================
235 } // namespace OpenMesh
236 //=============================================================================
237 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMARTTAGGERT_C)
238 #define OPENMESH_SMARTTAGGERT_TEMPLATES
239 #include "SmartTaggerT_impl.hh"
240 #endif
241
OpenMesh::SmartTaggerT::set_tag_range
void set_tag_range(const unsigned int _tag_range)
set new tag range and untag_all
Definition: SmartTaggerT_impl.hh:173
OpenMesh::SmartTaggerT::set_tag
void set_tag(const EHandle _eh, unsigned int _tag=1)
set tag to a value in [0..tag_range]
Definition: SmartTaggerT_impl.hh:124
OpenMesh::SmartTaggerT
Smart Tagger.
Definition: SmartTaggerT.hh:124
OpenMesh::SmartTaggerT::SmartTaggerT
SmartTaggerT(Mesh &_mesh, unsigned int _tag_range=1)
Constructor.
Definition: SmartTaggerT_impl.hh:59
omstream.hh
This file provides the streams omlog, omout, and omerr.
OpenMesh::SmartTaggerET
Definition: SmartTaggerT.hh:65
OpenMesh::SmartTaggerHT
Definition: SmartTaggerT.hh:69
OpenMesh::SmartTaggerVT
Definition: SmartTaggerT.hh:63
OpenMesh::SmartTaggerT::~SmartTaggerT
~SmartTaggerT()
Destructor.
Definition: SmartTaggerT_impl.hh:77
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
OpenMesh::SmartTaggerFT
Definition: SmartTaggerT.hh:67
OpenMesh::SmartTaggerT::untag_all
void untag_all()
untag all elements
Definition: SmartTaggerT_impl.hh:89
OpenMesh::SmartTaggerT::get_tag
unsigned int get_tag(const EHandle _eh) const
get tag value in range [0..tag_range]
Definition: SmartTaggerT_impl.hh:141
OpenMesh::SmartTaggerT::is_tagged
bool is_tagged(const EHandle _eh) const
overloaded member for boolean tags
Definition: SmartTaggerT_impl.hh:161