OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompositeT.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh 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 * OpenMesh 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 OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08. Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
46 //=============================================================================
47 //
48 // CLASS CompositeT
49 //
50 //=============================================================================
51
52 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
53 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_HH
54
55
56 //== INCLUDES =================================================================
57
58 #include <string>
59 #include <vector>
60 // --------------------
61 #include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
62
63 //== NAMESPACE ================================================================
64
65 namespace OpenMesh { // BEGIN_NS_OPENMESH
66 namespace Subdivider { // BEGIN_NS_DECIMATER
67 namespace Uniform { // BEGIN_NS_UNIFORM
68
69
70 //== CLASS DEFINITION =========================================================
71
86 template <typename MeshType, typename RealType=float >
87 class CompositeT : public SubdividerT< MeshType, RealType >
88 {
89 public:
90
91 typedef RealType real_t;
92 typedef MeshType mesh_t;
93 typedef SubdividerT< mesh_t, real_t > parent_t;
94
95 public:
96
97 CompositeT(void) : parent_t(), p_mesh_(NULL) {}
98 CompositeT(MeshType& _mesh) : parent_t(_mesh), p_mesh_(NULL) {};
99 virtual ~CompositeT() { }
100
101 public: // inherited interface
102
103 virtual const char *name( void ) const = 0;
104
105 protected: // inherited interface
106
107 bool prepare( MeshType& _m );
108
109 bool subdivide( MeshType& _m, size_t _n, const bool _update_points = true )
110 {
111 assert( p_mesh_ == &_m );
112
113 while(_n--)
114 {
115 apply_rules();
116 commit(_m);
117 }
118
119 return true;
120 }
121
122 #ifdef NDEBUG
123 bool cleanup( MeshType& )
124 #else
125 bool cleanup( MeshType& _m )
126 #endif
127 {
128 assert( p_mesh_ == &_m );
129 p_mesh_=NULL;
130 return true;
131 }
132
133 protected:
134
137 virtual void apply_rules(void) = 0;
138
139 protected:
140
143 void commit( MeshType &_m)
144 {
145 typename MeshType::VertexIter v_it;
146
147 for (v_it=_m.vertices_begin(); v_it != _m.vertices_end(); ++v_it)
148 _m.set_point(v_it.handle(), _m.data(v_it).position());
149 }
150
151
152 public:
153
155 struct Coeff
156 {
157 virtual ~Coeff() { }
158 virtual double operator() (size_t _valence) = 0;
159 };
160
161
162 protected:
163
164 typedef typename MeshType::Scalar scalar_t;
165 typedef typename MeshType::VertexHandle VertexHandle;
166 typedef typename MeshType::FaceHandle FaceHandle;
167 typedef typename MeshType::EdgeHandle EdgeHandle;
168 typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
169
171
172
173
174 void Tvv3();
175 void Tvv4();
176 void Tfv();
177
178 void FF();
179 void FFc(Coeff& _coeff);
180 void FFc(scalar_t _c);
181
182 void FV();
183 void FVc(Coeff& _coeff);
184 void FVc(scalar_t _c);
185
186 void FE();
187
188 void VF();
189 void VFa(Coeff& _coeff);
190 void VFa(scalar_t _alpha);
191
192 void VV();
193 void VVc(Coeff& _coeff);
194 void VVc(scalar_t _c);
195
196 void VE();
197
198
199 void VdE();
200 void VdEc(scalar_t _c);
201
204 void VdEg(Coeff& _coeff);
207 void VdEg(scalar_t _gamma);
208
209 void EF();
210
211 void EV();
212 void EVc(Coeff& _coeff);
213 void EVc(scalar_t _c);
214
215 void EdE();
216 void EdEc(scalar_t _c);
217
218
220
221 void corner_cutting(HalfedgeHandle _heh);
222
223 VertexHandle split_edge(HalfedgeHandle _heh);
224
225 private:
226
227 MeshType* p_mesh_;
228
229 };
230
231
232 //=============================================================================
233 } // END_NS_UNIFORM
234 } // END_NS_SUBDIVIDER
235 } // END_NS_OPENMESH
236 //=============================================================================
237 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITE_CC)
238 #define OPENMESH_SUBDIVIDER_TEMPLATES
239 #include "CompositeT.cc"
240 #endif
241 //=============================================================================
242 #endif // COMPOSITET_HH defined
243 //=============================================================================
244