OpenMesh
CompositeT.hh
Go to the documentation of this file.
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 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Date$ *
46  * *
47 \*===========================================================================*/
48 
53 //=============================================================================
54 //
55 // CLASS CompositeT
56 //
57 //=============================================================================
58 
59 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
60 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
61 
62 
63 //== INCLUDES =================================================================
64 
65 #include <string>
66 #include <vector>
67 // --------------------
69 
70 //== NAMESPACE ================================================================
71 
72 namespace OpenMesh { // BEGIN_NS_OPENMESH
73 namespace Subdivider { // BEGIN_NS_DECIMATER
74 namespace Uniform { // BEGIN_NS_UNIFORM
75 
76 
77 //== CLASS DEFINITION =========================================================
78 
93 template <typename MeshType, typename RealType=float >
94 class CompositeT : public SubdividerT< MeshType, RealType >
95 {
96 public:
97 
98  typedef RealType real_t;
99  typedef MeshType mesh_t;
101 
102 public:
103 
104  CompositeT(void) : parent_t(), p_mesh_(NULL) {}
105  CompositeT(MeshType& _mesh) : parent_t(_mesh), p_mesh_(NULL) {};
106  virtual ~CompositeT() { }
107 
108 public: // inherited interface
109 
110  virtual const char *name( void ) const = 0;
111 
112 protected: // inherited interface
113 
114  bool prepare( MeshType& _m );
115 
116  bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true )
117  {
118  assert( p_mesh_ == &_m );
119 
120  while(_n--)
121  {
122  apply_rules();
123  commit(_m);
124  }
125 
126  return true;
127  }
128 
129 #ifdef NDEBUG
130  bool cleanup( MeshType& )
131 #else
132  bool cleanup( MeshType& _m )
133 #endif
134  {
135  assert( p_mesh_ == &_m );
136  p_mesh_=NULL;
137  return true;
138  }
139 
140 protected:
141 
144  virtual void apply_rules(void) = 0;
145 
146 protected:
147 
150  void commit( MeshType &_m)
151  {
152  typename MeshType::VertexIter v_it;
153 
154  for (v_it=_m.vertices_begin(); v_it != _m.vertices_end(); ++v_it)
155  _m.set_point(*v_it, _m.data(*v_it).position());
156  }
157 
158 
159 public:
160 
162  struct Coeff
163  {
164  virtual ~Coeff() { }
165  virtual double operator() (size_t _valence) = 0;
166  };
167 
168 
169 protected:
170 
171  typedef typename MeshType::Scalar scalar_t;
172  typedef typename MeshType::VertexHandle VertexHandle;
173  typedef typename MeshType::FaceHandle FaceHandle;
174  typedef typename MeshType::EdgeHandle EdgeHandle;
175  typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
176 
178 
179 
180 
181  void Tvv3();
182  void Tvv4();
183  void Tfv();
184 
185  void FF();
186  void FFc(Coeff& _coeff);
187  void FFc(scalar_t _c);
188 
189  void FV();
190  void FVc(Coeff& _coeff);
191  void FVc(scalar_t _c);
192 
193  void FE();
194 
195  void VF();
196  void VFa(Coeff& _coeff);
197  void VFa(scalar_t _alpha);
198 
199  void VV();
200  void VVc(Coeff& _coeff);
201  void VVc(scalar_t _c);
202 
203  void VE();
204 
205 
206  void VdE();
207  void VdEc(scalar_t _c);
208 
211  void VdEg(Coeff& _coeff);
214  void VdEg(scalar_t _gamma);
215 
216  void EF();
217 
218  void EV();
219  void EVc(Coeff& _coeff);
220  void EVc(scalar_t _c);
221 
222  void EdE();
223  void EdEc(scalar_t _c);
224 
225 
227 
228  void corner_cutting(HalfedgeHandle _heh);
229 
230  VertexHandle split_edge(HalfedgeHandle _heh);
231 
232 private:
233 
234  MeshType* p_mesh_;
235 
236 };
237 
238 
239 //=============================================================================
240 } // END_NS_UNIFORM
241 } // END_NS_SUBDIVIDER
242 } // END_NS_OPENMESH
243 //=============================================================================
244 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC)
245 #define OPENMESH_SUBDIVIDER_TEMPLATES
246 #include "CompositeT.cc"
247 #endif
248 //=============================================================================
249 #endif // COMPOSITET_HH defined
250 //=============================================================================
251 
void EF()
Edge to face averaging.
Definition: CompositeT.cc:928
void VdE()
Vertex to edge averaging, using diamond of edges.
Definition: CompositeT.cc:651
VertexHandle split_edge(HalfedgeHandle _heh)
Split Edge.
Definition: CompositeT.cc:1237
void VdEc(scalar_t _c)
Weighted vertex to edge averaging, using diamond of edges.
Definition: CompositeT.cc:687
void Tvv4()
Split Face, using Vertex information (1-4 split)
Definition: CompositeT.cc:161
void FV()
Face to vertex averaging.
Definition: CompositeT.cc:539
void FVc(Coeff &_coeff)
Weighted face to vertex Averaging with flaps.
Definition: CompositeT.cc:564
void VFa(Coeff &_coeff)
Vertex to Face Averaging, weighted.
Definition: CompositeT.cc:316
virtual const char * name(void) const =0
Return name of subdivision algorithm.
void FE()
Face to edge averaging.
Definition: CompositeT.cc:952
Abstract base class for uniform subdivision algorithms.
Definition: SubdividerT.hh:94
void EdEc(scalar_t _c)
Weighted edge to edge averaging w/ flap rule.
Definition: CompositeT.cc:1145
void VVc(Coeff &_coeff)
Vertex to vertex averaging, weighted.
Definition: CompositeT.cc:1032
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition: CompositeT.hh:116
void VdEg(Coeff &_coeff)
Weigthed vertex to edge averaging, using diamond of edges for irregular vertices. ...
Definition: CompositeT.cc:778
virtual void apply_rules(void)=0
Assemble here the rule sequence, by calling the constructor of the wanted rules.
void EVc(Coeff &_coeff)
Weighted edge to vertex averaging.
Definition: CompositeT.cc:866
void FFc(Coeff &_coeff)
Weighted face to face averaging.
Definition: CompositeT.cc:464
void VE()
VE Step (Vertex to Edge Averaging)
Definition: CompositeT.cc:980
void commit(MeshType &_m)
Move vertices to new positions after the rules have been applied to the mesh (called by subdivide())...
Definition: CompositeT.hh:150
void VV()
Vertex to vertex averaging.
Definition: CompositeT.cc:998
void Tvv3()
Split Face, using Vertex information (1-3 split)
Definition: CompositeT.cc:97
bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
Definition: CompositeT.cc:81
void EdE()
Edge to edge averaging w/ flap rule.
Definition: CompositeT.cc:1104
Abstract base class for coefficient functions.
Definition: CompositeT.hh:162
void EV()
Edge to vertex averaging.
Definition: CompositeT.cc:840
void corner_cutting(HalfedgeHandle _heh)
Corner Cutting.
Definition: CompositeT.cc:1188
bool cleanup(MeshType &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition: CompositeT.hh:132
void FF()
Face to face averaging.
Definition: CompositeT.cc:428
This class provides the composite subdivision rules for the uniform case.
Definition: CompositeT.hh:94
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
void VF()
Vertex to Face Averaging.
Definition: CompositeT.cc:292
void Tfv()
Split Face, using Face Information.
Definition: CompositeT.cc:216

Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .