Developer Documentation
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 
48 //=============================================================================
49 //
50 // CLASS CompositeT
51 //
52 //=============================================================================
53 
54 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
55 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
56 
57 
58 //== INCLUDES =================================================================
59 
60 #include <string>
61 #include <vector>
62 // --------------------
64 
65 //== NAMESPACE ================================================================
66 
67 namespace OpenMesh { // BEGIN_NS_OPENMESH
68 namespace Subdivider { // BEGIN_NS_DECIMATER
69 namespace Uniform { // BEGIN_NS_UNIFORM
70 
71 
72 //== CLASS DEFINITION =========================================================
73 
88 template <typename MeshType, typename RealType=float >
89 class CompositeT : public SubdividerT< MeshType, RealType >
90 {
91 public:
92 
93  typedef RealType real_t;
94  typedef MeshType mesh_t;
96 
97 public:
98 
99  CompositeT(void) : parent_t(), p_mesh_(NULL) {}
100  explicit CompositeT(MeshType& _mesh) : parent_t(_mesh), p_mesh_(NULL) {};
101  virtual ~CompositeT() { }
102 
103 public: // inherited interface
104 
105  virtual const char *name( void ) const = 0;
106 
107 protected: // inherited interface
108 
109  bool prepare( MeshType& _m );
110 
111  bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true )
112  {
113  assert( p_mesh_ == &_m );
114 
115  while(_n--)
116  {
117  apply_rules();
118  commit(_m);
119  }
120 
121  return true;
122  }
123 
124 #ifdef NDEBUG
125  bool cleanup( MeshType& )
126 #else
127  bool cleanup( MeshType& _m )
128 #endif
129  {
130  assert( p_mesh_ == &_m );
131  p_mesh_=NULL;
132  return true;
133  }
134 
135 protected:
136 
139  virtual void apply_rules(void) = 0;
140 
141 protected:
142 
145  void commit( MeshType &_m)
146  {
147  typename MeshType::VertexIter v_it;
148 
149  for (v_it=_m.vertices_begin(); v_it != _m.vertices_end(); ++v_it)
150  _m.set_point(*v_it, _m.data(*v_it).position());
151  }
152 
153 
154 public:
155 
157  struct Coeff
158  {
159  virtual ~Coeff() { }
160  virtual double operator() (size_t _valence) = 0;
161  };
162 
163 
164 protected:
165 
166  typedef typename MeshType::Scalar scalar_t;
167  typedef typename MeshType::VertexHandle VertexHandle;
168  typedef typename MeshType::FaceHandle FaceHandle;
169  typedef typename MeshType::EdgeHandle EdgeHandle;
170  typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
171 
173 
174 
175 
176  void Tvv3();
177  void Tvv4();
178  void Tfv();
179 
180  void FF();
181  void FFc(Coeff& _coeff);
182  void FFc(scalar_t _c);
183 
184  void FV();
185  void FVc(Coeff& _coeff);
186  void FVc(scalar_t _c);
187 
188  void FE();
189 
190  void VF();
191  void VFa(Coeff& _coeff);
192  void VFa(scalar_t _alpha);
193 
194  void VV();
195  void VVc(Coeff& _coeff);
196  void VVc(scalar_t _c);
197 
198  void VE();
199 
200 
201  void VdE();
202  void VdEc(scalar_t _c);
203 
206  void VdEg(Coeff& _coeff);
209  void VdEg(scalar_t _gamma);
210 
211  void EF();
212 
213  void EV();
214  void EVc(Coeff& _coeff);
215  void EVc(scalar_t _c);
216 
217  void EdE();
218  void EdEc(scalar_t _c);
219 
220 
222 
223  void corner_cutting(HalfedgeHandle _heh);
224 
225  VertexHandle split_edge(HalfedgeHandle _heh);
226 
227 private:
228 
229  MeshType* p_mesh_;
230 
231 };
232 
233 
234 //=============================================================================
235 } // END_NS_UNIFORM
236 } // END_NS_SUBDIVIDER
237 } // END_NS_OPENMESH
238 //=============================================================================
239 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC)
240 #define OPENMESH_SUBDIVIDER_TEMPLATES
241 #include "CompositeT_impl.hh"
242 #endif
243 //=============================================================================
244 #endif // COMPOSITET_HH defined
245 //=============================================================================
246 
bool prepare(MeshType &_m)
Prepare mesh, e.g. add properties.
void EV()
Edge to vertex averaging.
void VdE()
Vertex to edge averaging, using diamond of edges.
void FE()
Face to edge averaging.
void VV()
Vertex to vertex averaging.
void VdEc(scalar_t _c)
Weighted vertex to edge averaging, using diamond of edges.
void corner_cutting(HalfedgeHandle _heh)
Corner Cutting.
void FFc(Coeff &_coeff)
Weighted face to face averaging.
void Tfv()
Split Face, using Face Information.
void VVc(Coeff &_coeff)
Vertex to vertex averaging, weighted.
void FF()
Face to face averaging.
bool cleanup(MeshType &_m)
Cleanup mesh after usage, e.g. remove added properties.
Definition: CompositeT.hh:127
void EVc(Coeff &_coeff)
Weighted edge to vertex averaging.
void EdEc(scalar_t _c)
Weighted edge to edge averaging w/ flap rule.
void EdE()
Edge to edge averaging w/ flap rule.
void Tvv4()
Split Face, using Vertex information (1-4 split)
void VF()
Vertex to Face Averaging.
bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Subdivide mesh _m _n times.
Definition: CompositeT.hh:111
void FV()
Face to vertex averaging.
VertexHandle split_edge(HalfedgeHandle _heh)
Split Edge.
void Tvv3()
Split Face, using Vertex information (1-3 split)
void EF()
Edge to face averaging.
void VE()
VE Step (Vertex to Edge Averaging)
Abstract base class for coefficient functions.
Definition: CompositeT.hh:157
virtual const char * name(void) const =0
Return name of subdivision algorithm.
void VFa(Coeff &_coeff)
Vertex to Face Averaging, weighted.
void FVc(Coeff &_coeff)
Weighted face to vertex Averaging with flaps.