OpenMesh
RulesT.hh
Go to the documentation of this file.
1/* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2025, 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
49//=============================================================================
50//
51// Composite Subdivision and Averaging Rules
52//
53//=============================================================================
54
55#ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
56#define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
57
58
59//== INCLUDES =================================================================
60
61#include <OpenMesh/Core/System/config.hh>
62#include <OpenMesh/Tools/Subdivider/Adaptive/Composite/RuleInterfaceT.hh>
63// -------------------- STL
64#include <vector>
65
66
67//== NAMESPACE ================================================================
68
69namespace OpenMesh { // BEGIN_NS_OPENMESH
70namespace Subdivider { // BEGIN_NS_SUBDIVIDER
71namespace Adaptive { // BEGIN_NS_ADAPTIVE
72
73
74//== CLASS DEFINITION =========================================================
75
80//=============================================================================
81
84template <class M> class Tvv3 : public RuleInterfaceT<M>
85{
86 COMPOSITE_RULE( Tvv3, M );
87private:
88 typedef RuleInterfaceT<M> Base;
89
90public:
91
93
94 explicit Tvv3(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(3); };
95
96 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
97 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
98};
99
100
101//=============================================================================
102
103
106template <class M> class Tvv4 : public RuleInterfaceT<M>
107{
108 COMPOSITE_RULE( Tvv4, M );
109
110private:
111 typedef RuleInterfaceT<M> Base;
112public:
113 typedef typename M::HalfedgeHandle HEH;
114 typedef typename M::VertexHandle VH;
115
117
118 explicit Tvv4(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(4); };
119
120 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
121 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
122 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
123
124private:
125
126 void split_edge(HEH& _hh, VH& _vh, state_t _target_state);
127 void check_edge(const typename M::HalfedgeHandle& _hh,
128 state_t _target_state);
129};
130
131
132//=============================================================================
133
134
137template <class M> class VF : public RuleInterfaceT<M>
138{
139 COMPOSITE_RULE( VF, M );
140private:
141 typedef RuleInterfaceT<M> Base;
142
143public:
145
146 explicit VF(M& _mesh) : Inherited(_mesh) {}
147
148 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
149};
150
151
152//=============================================================================
153
154
157template <class M> class FF : public RuleInterfaceT<M>
158{
159 COMPOSITE_RULE( FF, M );
160private:
161 typedef RuleInterfaceT<M> Base;
162
163public:
165
166 explicit FF(M& _mesh) : Inherited(_mesh) {}
167
168 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
169};
170
171
172//=============================================================================
173
174
177template <class M> class FFc : public RuleInterfaceT<M>
178{
179 COMPOSITE_RULE( FFc, M );
180private:
181 typedef RuleInterfaceT<M> Base;
182
183public:
185
186 explicit FFc(M& _mesh) : Inherited(_mesh) {}
187
188 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
189};
190
191
192//=============================================================================
193
194
197template <class M> class FV : public RuleInterfaceT<M>
198{
199 COMPOSITE_RULE( FV, M );
200private:
201 typedef RuleInterfaceT<M> Base;
202
203public:
205
206 explicit FV(M& _mesh) : Inherited(_mesh) {}
207
208 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
209};
210
211
212//=============================================================================
213
214
217template <class M> class FVc : public RuleInterfaceT<M>
218{
219 COMPOSITE_RULE( FVc, M );
220private:
221 typedef RuleInterfaceT<M> Base;
222
223public:
225
226 explicit FVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
227
228 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
229
230 static void init_coeffs(size_t _max_valence);
231 static const std::vector<double>& coeffs() { return coeffs_; }
232
233 double coeff( size_t _valence )
234 {
235 assert(_valence < coeffs_.size());
236 return coeffs_[_valence];
237 }
238
239private:
240
241 static std::vector<double> coeffs_;
242
243};
244
245
246//=============================================================================
247
248
251template <class M> class VV : public RuleInterfaceT<M>
252{
253 COMPOSITE_RULE( VV, M );
254private:
255 typedef RuleInterfaceT<M> Base;
256
257public:
258
260
261 explicit VV(M& _mesh) : Inherited(_mesh) {}
262
263 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
264};
265
266
267//=============================================================================
268
269
272template <class M> class VVc : public RuleInterfaceT<M>
273{
274 COMPOSITE_RULE( VVc, M );
275private:
276 typedef RuleInterfaceT<M> Base;
277
278public:
280
281 explicit VVc(M& _mesh) : Inherited(_mesh) {}
282
283 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
284};
285
286
287//=============================================================================
288
289
292template <class M> class VE : public RuleInterfaceT<M>
293{
294 COMPOSITE_RULE( VE, M );
295private:
296 typedef RuleInterfaceT<M> Base;
297
298public:
300
301 explicit VE(M& _mesh) : Inherited(_mesh) {}
302
303 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
304};
305
306
307//=============================================================================
308
309
312template <class M> class VdE : public RuleInterfaceT<M>
313{
314 COMPOSITE_RULE( VdE, M );
315private:
316 typedef RuleInterfaceT<M> Base;
317
318public:
320
321 explicit VdE(M& _mesh) : Inherited(_mesh) {}
322
323 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
324};
325
326
327//=============================================================================
328
329
332template <class M> class VdEc : public RuleInterfaceT<M>
333{
334 COMPOSITE_RULE( VdEc, M );
335private:
336 typedef RuleInterfaceT<M> Base;
337
338public:
340
341 explicit VdEc(M& _mesh) : Inherited(_mesh) {}
342
343 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
344};
345
346
347//=============================================================================
348
349
352template <class M> class EV : public RuleInterfaceT<M>
353{
354 COMPOSITE_RULE( EV, M );
355private:
356 typedef RuleInterfaceT<M> Base;
357
358public:
360
361 explicit EV(M& _mesh) : Inherited(_mesh) {}
362
363 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
364};
365
366
367//=============================================================================
368
369
372template <class M> class EVc : public RuleInterfaceT<M>
373{
374 COMPOSITE_RULE( EVc, M );
375private:
376 typedef RuleInterfaceT<M> Base;
377
378public:
379
381
382 explicit EVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
383
384 void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
385
386 static void init_coeffs(size_t _max_valence);
387 static const std::vector<double>& coeffs() { return coeffs_; }
388
389 double coeff( size_t _valence )
390 {
391 assert(_valence < coeffs_.size());
392 return coeffs_[_valence];
393 }
394
395private:
396
397 static std::vector<double> coeffs_;
398
399};
400
401
402//=============================================================================
403
404
407template <class M> class EF : public RuleInterfaceT<M>
408{
409 COMPOSITE_RULE( EF, M );
410private:
411 typedef RuleInterfaceT<M> Base;
412
413public:
415
416 explicit EF(M& _mesh) : Inherited(_mesh) {}
417
418 void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
419};
420
421
422//=============================================================================
423
424
427template <class M> class FE : public RuleInterfaceT<M>
428{
429 COMPOSITE_RULE( FE, M );
430private:
431 typedef RuleInterfaceT<M> Base;
432
433public:
435
436 explicit FE(M& _mesh) : Inherited(_mesh) {}
437
438 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
439};
440
441
442//=============================================================================
443
444
447template <class M> class EdE : public RuleInterfaceT<M>
448{
449 COMPOSITE_RULE( EdE, M );
450private:
451 typedef RuleInterfaceT<M> Base;
452
453public:
455
456 explicit EdE(M& _mesh) : Inherited(_mesh) {}
457
458 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
459};
460
461
462//=============================================================================
463
464
467template <class M> class EdEc : public RuleInterfaceT<M>
468{
469 COMPOSITE_RULE( EdEc, M );
470private:
471 typedef RuleInterfaceT<M> Base;
472
473public:
475
476 explicit EdEc(M& _mesh) : Inherited(_mesh) {}
477
478 void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
479};
480
481// ----------------------------------------------------------------------------
482
483
484//=============================================================================
485} // END_NS_ADAPTIVE
486} // END_NS_SUBDIVIDER
487} // END_NS_OPENMESH
488//=============================================================================
489#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC)
490# define OPENMESH_SUBDIVIDER_TEMPLATES
491# include "RulesT_impl.hh"
492#endif
493//=============================================================================
494#endif // OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH defined
495//=============================================================================
496
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
CompositeTraits::state_t state_t
Adaptive Composite Subdivision framework.
Definition: CompositeTraits.hh:250
Base class for adaptive composite subdivision rules.
Definition: RuleInterfaceT.hh:109
scalar_t coeff() const
Get coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:351
Adaptive Composite Subdivision framework.
Definition: RulesT.hh:85
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Definition: RulesT_impl.hh:99
Topological composite rule Tvv,4 doing a 1-4 split of a face.
Definition: RulesT.hh:107
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Definition: RulesT_impl.hh:338
Composite rule VF.
Definition: RulesT.hh:138
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule FF.
Definition: RulesT.hh:158
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule FFc.
Definition: RulesT.hh:178
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule FV.
Definition: RulesT.hh:198
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule FVc.
Definition: RulesT.hh:218
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule VV.
Definition: RulesT.hh:252
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule VVc.
Definition: RulesT.hh:273
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule VE.
Definition: RulesT.hh:293
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule VdE.
Definition: RulesT.hh:313
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule VdEc.
Definition: RulesT.hh:333
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule EV.
Definition: RulesT.hh:353
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule EVc.
Definition: RulesT.hh:373
void raise(typename M::VertexHandle &_vh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule EF.
Definition: RulesT.hh:408
void raise(typename M::FaceHandle &_fh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule FE.
Definition: RulesT.hh:428
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule EdE.
Definition: RulesT.hh:448
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.
Composite rule EdEc.
Definition: RulesT.hh:468
void raise(typename M::EdgeHandle &_eh, state_t _target_state) override
Raise item to target state _target_state.

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .