OpenMesh
RulesT.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 
54 //=============================================================================
55 //
56 // Composite Subdivision and Averaging Rules
57 //
58 //=============================================================================
59 
60 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
61 #define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
62 
63 
64 //== INCLUDES =================================================================
65 
66 #include <OpenMesh/Core/System/config.hh>
67 #include <OpenMesh/Tools/Subdivider/Adaptive/Composite/RuleInterfaceT.hh>
68 // -------------------- STL
69 #include <vector>
70 
71 
72 #if defined(OM_CC_MIPS) // avoid warnings
73 # define MIPS_WARN_WA( Item ) \
74  void raise(typename M:: ## Item ## Handle &_h, state_t _target_state ) \
75  { Inherited::raise(_h, _target_state); }
76 #else
77 # define MIPS_WARN_WA( Item )
78 #endif
79 
80 //== NAMESPACE ================================================================
81 
82 namespace OpenMesh { // BEGIN_NS_OPENMESH
83 namespace Subdivider { // BEGIN_NS_SUBDIVIDER
84 namespace Adaptive { // BEGIN_NS_ADAPTIVE
85 
86 
87 //== CLASS DEFINITION =========================================================
88 
93 //=============================================================================
94 
97 template <class M> class Tvv3 : public RuleInterfaceT<M>
98 {
99  COMPOSITE_RULE( Tvv3, M );
100 private:
101  typedef RuleInterfaceT<M> Base;
102 
103 public:
104 
106 
107  explicit Tvv3(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(3); };
108 
109  void raise(typename M::FaceHandle& _fh, state_t _target_state);
110  void raise(typename M::VertexHandle& _vh, state_t _target_state);
111  MIPS_WARN_WA(Edge) // avoid warning
112 };
113 
114 
115 //=============================================================================
116 
117 
120 template <class M> class Tvv4 : public RuleInterfaceT<M>
121 {
122  COMPOSITE_RULE( Tvv4, M );
123 
124 private:
125  typedef RuleInterfaceT<M> Base;
126 public:
127  typedef typename M::HalfedgeHandle HEH;
128  typedef typename M::VertexHandle VH;
129 
131 
132  explicit Tvv4(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(4); };
133 
134  void raise(typename M::FaceHandle& _fh, state_t _target_state);
135  void raise(typename M::VertexHandle& _vh, state_t _target_state);
136  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
137 
138 private:
139 
140  void split_edge(HEH& _hh, VH& _vh, state_t _target_state);
141  void check_edge(const typename M::HalfedgeHandle& _hh,
142  state_t _target_state);
143 };
144 
145 
146 //=============================================================================
147 
148 
151 template <class M> class VF : public RuleInterfaceT<M>
152 {
153  COMPOSITE_RULE( VF, M );
154 private:
155  typedef RuleInterfaceT<M> Base;
156 
157 public:
159 
160  explicit VF(M& _mesh) : Inherited(_mesh) {}
161 
162  void raise(typename M::FaceHandle& _fh, state_t _target_state);
163  MIPS_WARN_WA(Edge)
164  MIPS_WARN_WA(Vertex)
165 };
166 
167 
168 //=============================================================================
169 
170 
173 template <class M> class FF : public RuleInterfaceT<M>
174 {
175  COMPOSITE_RULE( FF, M );
176 private:
177  typedef RuleInterfaceT<M> Base;
178 
179 public:
181 
182  explicit FF(M& _mesh) : Inherited(_mesh) {}
183 
184  void raise(typename M::FaceHandle& _fh, state_t _target_state);
185  MIPS_WARN_WA(Vertex) // avoid warning
186  MIPS_WARN_WA(Edge ) // avoid warning
187 };
188 
189 
190 //=============================================================================
191 
192 
195 template <class M> class FFc : public RuleInterfaceT<M>
196 {
197  COMPOSITE_RULE( FFc, M );
198 private:
199  typedef RuleInterfaceT<M> Base;
200 
201 public:
203 
204  explicit FFc(M& _mesh) : Inherited(_mesh) {}
205 
206  void raise(typename M::FaceHandle& _fh, state_t _target_state);
207  MIPS_WARN_WA(Vertex) // avoid warning
208  MIPS_WARN_WA(Edge ) // avoid warning
209 };
210 
211 
212 //=============================================================================
213 
214 
217 template <class M> class FV : public RuleInterfaceT<M>
218 {
219  COMPOSITE_RULE( FV, M );
220 private:
221  typedef RuleInterfaceT<M> Base;
222 
223 public:
225 
226  explicit FV(M& _mesh) : Inherited(_mesh) {}
227 
228  void raise(typename M::VertexHandle& _vh, state_t _target_state);
229  MIPS_WARN_WA(Face) // avoid warning
230  MIPS_WARN_WA(Edge) // avoid warning
231 };
232 
233 
234 //=============================================================================
235 
236 
239 template <class M> class FVc : public RuleInterfaceT<M>
240 {
241  COMPOSITE_RULE( FVc, M );
242 private:
243  typedef RuleInterfaceT<M> Base;
244 
245 public:
247 
248  explicit FVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
249 
250  void raise(typename M::VertexHandle& _vh, state_t _target_state);
251  MIPS_WARN_WA(Face) // avoid warning
252  MIPS_WARN_WA(Edge) // avoid warning
253 
254  static void init_coeffs(size_t _max_valence);
255  static const std::vector<double>& coeffs() { return coeffs_; }
256 
257  double coeff( size_t _valence )
258  {
259  assert(_valence < coeffs_.size());
260  return coeffs_[_valence];
261  }
262 
263 private:
264 
265  static std::vector<double> coeffs_;
266 
267 };
268 
269 
270 //=============================================================================
271 
272 
275 template <class M> class VV : public RuleInterfaceT<M>
276 {
277  COMPOSITE_RULE( VV, M );
278 private:
279  typedef RuleInterfaceT<M> Base;
280 
281 public:
282 
283  typedef RuleInterfaceT<M> Inherited;
284 
285  explicit VV(M& _mesh) : Inherited(_mesh) {}
286 
287  void raise(typename M::VertexHandle& _vh, state_t _target_state);
288  MIPS_WARN_WA(Face) // avoid warning
289  MIPS_WARN_WA(Edge) // avoid warning
290 };
291 
292 
293 //=============================================================================
294 
295 
298 template <class M> class VVc : public RuleInterfaceT<M>
299 {
300  COMPOSITE_RULE( VVc, M );
301 private:
302  typedef RuleInterfaceT<M> Base;
303 
304 public:
305  typedef RuleInterfaceT<M> Inherited;
306 
307  explicit VVc(M& _mesh) : Inherited(_mesh) {}
308 
309  void raise(typename M::VertexHandle& _vh, state_t _target_state);
310  MIPS_WARN_WA(Face) // avoid warning
311  MIPS_WARN_WA(Edge) // avoid warning
312 };
313 
314 
315 //=============================================================================
316 
317 
320 template <class M> class VE : public RuleInterfaceT<M>
321 {
322  COMPOSITE_RULE( VE, M );
323 private:
324  typedef RuleInterfaceT<M> Base;
325 
326 public:
327  typedef RuleInterfaceT<M> Inherited;
328 
329  explicit VE(M& _mesh) : Inherited(_mesh) {}
330 
331  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
332  MIPS_WARN_WA(Face ) // avoid warning
333  MIPS_WARN_WA(Vertex) // avoid warning
334 };
335 
336 
337 //=============================================================================
338 
339 
342 template <class M> class VdE : public RuleInterfaceT<M>
343 {
344  COMPOSITE_RULE( VdE, M );
345 private:
346  typedef RuleInterfaceT<M> Base;
347 
348 public:
349  typedef RuleInterfaceT<M> Inherited;
350 
351  explicit VdE(M& _mesh) : Inherited(_mesh) {}
352 
353  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
354  MIPS_WARN_WA(Face ) // avoid warning
355  MIPS_WARN_WA(Vertex) // avoid warning
356 };
357 
358 
359 //=============================================================================
360 
361 
364 template <class M> class VdEc : public RuleInterfaceT<M>
365 {
366  COMPOSITE_RULE( VdEc, M );
367 private:
368  typedef RuleInterfaceT<M> Base;
369 
370 public:
371  typedef RuleInterfaceT<M> Inherited;
372 
373  explicit VdEc(M& _mesh) : Inherited(_mesh) {}
374 
375  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
376  MIPS_WARN_WA(Face ) // avoid warning
377  MIPS_WARN_WA(Vertex) // avoid warning
378 };
379 
380 
381 //=============================================================================
382 
383 
386 template <class M> class EV : public RuleInterfaceT<M>
387 {
388  COMPOSITE_RULE( EV, M );
389 private:
390  typedef RuleInterfaceT<M> Base;
391 
392 public:
393  typedef RuleInterfaceT<M> Inherited;
394 
395  explicit EV(M& _mesh) : Inherited(_mesh) {}
396 
397  void raise(typename M::VertexHandle& _vh, state_t _target_state);
398  MIPS_WARN_WA(Face) // avoid warning
399  MIPS_WARN_WA(Edge) // avoid warning
400 };
401 
402 
403 //=============================================================================
404 
405 
408 template <class M> class EVc : public RuleInterfaceT<M>
409 {
410  COMPOSITE_RULE( EVc, M );
411 private:
412  typedef RuleInterfaceT<M> Base;
413 
414 public:
415 
416  typedef RuleInterfaceT<M> Inherited;
417 
418  explicit EVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
419 
420  void raise(typename M::VertexHandle& _vh, state_t _target_state);
421  MIPS_WARN_WA(Face) // avoid warning
422  MIPS_WARN_WA(Edge) // avoid warning
423 
424  static void init_coeffs(size_t _max_valence);
425  static const std::vector<double>& coeffs() { return coeffs_; }
426 
427  double coeff( size_t _valence )
428  {
429  assert(_valence < coeffs_.size());
430  return coeffs_[_valence];
431  }
432 
433 private:
434 
435  static std::vector<double> coeffs_;
436 
437 };
438 
439 
440 //=============================================================================
441 
442 
445 template <class M> class EF : public RuleInterfaceT<M>
446 {
447  COMPOSITE_RULE( EF, M );
448 private:
449  typedef RuleInterfaceT<M> Base;
450 
451 public:
452  typedef RuleInterfaceT<M> Inherited;
453 
454  explicit EF(M& _mesh) : Inherited(_mesh) {}
455 
456  void raise(typename M::FaceHandle& _fh, state_t _target_state);
457  MIPS_WARN_WA(Edge ) // avoid warning
458  MIPS_WARN_WA(Vertex) // avoid warning
459 };
460 
461 
462 //=============================================================================
463 
464 
467 template <class M> class FE : public RuleInterfaceT<M>
468 {
469  COMPOSITE_RULE( FE, M );
470 private:
471  typedef RuleInterfaceT<M> Base;
472 
473 public:
474  typedef RuleInterfaceT<M> Inherited;
475 
476  explicit FE(M& _mesh) : Inherited(_mesh) {}
477 
478  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
479  MIPS_WARN_WA(Face ) // avoid warning
480  MIPS_WARN_WA(Vertex) // avoid warning
481 };
482 
483 
484 //=============================================================================
485 
486 
489 template <class M> class EdE : public RuleInterfaceT<M>
490 {
491  COMPOSITE_RULE( EdE, M );
492 private:
493  typedef RuleInterfaceT<M> Base;
494 
495 public:
496  typedef RuleInterfaceT<M> Inherited;
497 
498  explicit EdE(M& _mesh) : Inherited(_mesh) {}
499 
500  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
501  MIPS_WARN_WA(Face ) // avoid warning
502  MIPS_WARN_WA(Vertex) // avoid warning
503 };
504 
505 
506 //=============================================================================
507 
508 
511 template <class M> class EdEc : public RuleInterfaceT<M>
512 {
513  COMPOSITE_RULE( EdEc, M );
514 private:
515  typedef RuleInterfaceT<M> Base;
516 
517 public:
518  typedef RuleInterfaceT<M> Inherited;
519 
520  explicit EdEc(M& _mesh) : Inherited(_mesh) {}
521 
522  void raise(typename M::EdgeHandle& _eh, state_t _target_state);
523  MIPS_WARN_WA(Face ) // avoid warning
524  MIPS_WARN_WA(Vertex) // avoid warning
525 };
526 
527 // ----------------------------------------------------------------------------
528 
529 #undef MIPS_WARN_WA
530 
531 //=============================================================================
532 } // END_NS_ADAPTIVE
533 } // END_NS_SUBDIVIDER
534 } // END_NS_OPENMESH
535 //=============================================================================
536 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC)
537 # define OPENMESH_SUBDIVIDER_TEMPLATES
538 # include "RulesT.cc"
539 #endif
540 //=============================================================================
541 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH defined
542 //=============================================================================
543 
Adaptive Composite Subdivision framework.
Definition: RulesT.hh:97
Composite rule VF.
Definition: RulesT.hh:151
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
Composite rule VV.
Definition: RulesT.hh:275
Composite rule FFc.
Definition: RulesT.hh:195
Composite rule EV.
Definition: RulesT.hh:386
Composite rule VE.
Definition: RulesT.hh:320
scalar_t coeff() const
Get coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:356
Composite rule EdEc.
Definition: RulesT.hh:511
Composite rule EF.
Definition: RulesT.hh:445
CompositeTraits::state_t state_t
Adaptive Composite Subdivision framework.
Definition: CompositeTraits.hh:255
Composite rule FVc.
Definition: RulesT.hh:239
Composite rule FF.
Definition: RulesT.hh:173
Composite rule VdEc.
Definition: RulesT.hh:364
Composite rule VVc.
Definition: RulesT.hh:298
Composite rule FV.
Definition: RulesT.hh:217
Composite rule EdE.
Definition: RulesT.hh:489
Composite rule EVc.
Definition: RulesT.hh:408
Composite rule VdE.
Definition: RulesT.hh:342
Base class for adaptive composite subdivision rules.
Definition: CompositeT.hh:84
Composite rule FE.
Definition: RulesT.hh:467
Topological composite rule Tvv,4 doing a 1-4 split of a face.
Definition: RulesT.hh:120

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