Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SmartTaggerT.hh
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
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 //=============================================================================
43 //
44 // CLASS SmartTaggerVT
45 //
46 //
47 // original Author: David Bommes <bommes@cs.rwth-aachen.de>
48 // $Revision$
49 // $Author$
50 // $Date$
51 //
52 //=============================================================================
53 
54 
55 #ifndef ACG_SMARTTAGGERT_HH
56 #define ACG_SMARTTAGGERT_HH
57 
58 
59 //== INCLUDES =================================================================
60 
61 // OpenMesh
62 #include <OpenMesh/Core/Utils/Property.hh>
64 
65 
66 //== DEFINES ==================================================================
67 
68 #define STV_DEBUG_CHECKS
69 
70 //== NAMESPACES ===============================================================
71 
72 namespace ACG {
73 
74 //== FORWARD DECLARATIONS =====================================================
75 
76 // Smarttagging for vertices
77 template< class Mesh> class SmartTaggerVT;
78 // Smarttagging for edges
79 template< class Mesh> class SmartTaggerET;
80 // Smarttagging for faces
81 template< class Mesh> class SmartTaggerFT;
82 // Smarttagging for halfedges
83 template< class Mesh> class SmartTaggerHT;
84 
85 
86 //== CLASS DEFINITION =========================================================
87 
88 
112 template <class Mesh, class EHandle, class EPHandle>
114 {
115 public:
116 
118  SmartTaggerT(Mesh& _mesh, unsigned int _tag_range = 1);
119 
121  ~SmartTaggerT();
122 
126  inline void untag_all();
127 
132  inline void untag_all( const unsigned int _new_tag_range);
133 
139  inline void set_tag ( const EHandle _eh, unsigned int _tag = 1);
140 
146  inline unsigned int get_tag ( const EHandle _eh) const;
147 
153  inline bool is_tagged( const EHandle _eh) const;
154 
161  inline void set_tag_range( const unsigned int _tag_range);
162 
163 protected:
164 
165  inline void all_tags_to_zero();
166 
167 protected:
168 
169  // Reference to Mesh
170  Mesh& mesh_;
171 
172  // property which holds the current tags
173  EPHandle ep_tag_;
174 
175  // current tags range is [current_base_+1...current_base_+tag_range_]
176  unsigned int current_base_;
177 
178  // number of different tagvalues available
179  unsigned int tag_range_;
180 };
181 
182 
183 //== SPECIALIZATION ===========================================================
184 
185  // define standard Tagger
186  template< class Mesh>
187  class SmartTaggerVT
188  : public SmartTaggerT< Mesh, typename Mesh::VertexHandle, OpenMesh::VPropHandleT<unsigned int> >
189  {
190  public:
192  SmartTaggerVT(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
193  };
194 
195  template< class Mesh>
196  class SmartTaggerET
197  : public SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> >
198  {
199  public:
200  typedef SmartTaggerT< Mesh, typename Mesh::EdgeHandle, OpenMesh::EPropHandleT<unsigned int> > BaseType;
201  SmartTaggerET(Mesh& _mesh, unsigned int _tag_range = 1) : BaseType(_mesh, _tag_range) {}
202  };
203 
204  template< class Mesh>
205  class SmartTaggerFT
206  : public SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> >
207  {
208  public:
209  typedef SmartTaggerT< Mesh, typename Mesh::FaceHandle, OpenMesh::FPropHandleT<unsigned int> > BaseType;
210  SmartTaggerFT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range) {}
211  };
212 
213  template< class Mesh>
214  class SmartTaggerHT
215  : public SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> >
216  {
217  public:
218  typedef SmartTaggerT< Mesh, typename Mesh::HalfedgeHandle, OpenMesh::HPropHandleT<unsigned int> > BaseType;
219  SmartTaggerHT(Mesh& _mesh, unsigned int _tag_range = 1): BaseType(_mesh, _tag_range){}
220  };
221 
222 
223 //=============================================================================
224 } // namespace ACG
225 //=============================================================================
226 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_SMARTTAGGERT_C)
227 #define ACG_SMARTTAGGERT_TEMPLATES
228 #include "SmartTaggerT.cc"
229 #endif
230 //=============================================================================
231 #endif // ACG_SMARTTAGGERT_HH defined
232 //=============================================================================
233 
bool is_tagged(const EHandle _eh) const
overloaded member for boolean tags
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
void set_tag_range(const unsigned int _tag_range)
set new tag range and untag_all
Smart Tagger.
~SmartTaggerT()
Destructor.
Definition: SmartTaggerT.cc:95
unsigned int get_tag(const EHandle _eh) const
get tag value in range [0..tag_range]
SmartTaggerT(Mesh &_mesh, unsigned int _tag_range=1)
Constructor.
Definition: SmartTaggerT.cc:77
void untag_all()
untag all elements
void set_tag(const EHandle _eh, unsigned int _tag=1)
set tag to a value in [0..tag_range]