Developer Documentation
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 
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 #if defined(OM_CC_MIPS) // avoid warnings
68 # define MIPS_WARN_WA( Item ) \
69  void raise(typename M:: ## Item ## Handle &_h, state_t _target_state ) \
70  { Inherited::raise(_h, _target_state); }
71 #else
72 # define MIPS_WARN_WA( Item )
73 #endif
74 
75 //== NAMESPACE ================================================================
76 
77 namespace OpenMesh { // BEGIN_NS_OPENMESH
78 namespace Subdivider { // BEGIN_NS_SUBDIVIDER
79 namespace Adaptive { // BEGIN_NS_ADAPTIVE
80 
81 
82 //== CLASS DEFINITION =========================================================
83 
88 //=============================================================================
89 
92 template <class M> class Tvv3 : public RuleInterfaceT<M>
93 {
94  COMPOSITE_RULE( Tvv3, M );
95 private:
96  typedef RuleInterfaceT<M> Base;
97 
98 public:
99 
101 
102  explicit Tvv3(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(3); };
103 
104  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
105  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
106  MIPS_WARN_WA(Edge) // avoid warning
107 };
108 
109 
110 //=============================================================================
111 
112 
115 template <class M> class Tvv4 : public RuleInterfaceT<M>
116 {
117  COMPOSITE_RULE( Tvv4, M );
118 
119 private:
120  typedef RuleInterfaceT<M> Base;
121 public:
122  typedef typename M::HalfedgeHandle HEH;
123  typedef typename M::VertexHandle VH;
124 
126 
127  explicit Tvv4(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(4); };
128 
129  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
130  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
131  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
132 
133 private:
134 
135  void split_edge(HEH& _hh, VH& _vh, state_t _target_state);
136  void check_edge(const typename M::HalfedgeHandle& _hh,
137  state_t _target_state);
138 };
139 
140 
141 //=============================================================================
142 
143 
146 template <class M> class VF : public RuleInterfaceT<M>
147 {
148  COMPOSITE_RULE( VF, M );
149 private:
150  typedef RuleInterfaceT<M> Base;
151 
152 public:
154 
155  explicit VF(M& _mesh) : Inherited(_mesh) {}
156 
157  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
158  MIPS_WARN_WA(Edge)
159  MIPS_WARN_WA(Vertex)
160 };
161 
162 
163 //=============================================================================
164 
165 
168 template <class M> class FF : public RuleInterfaceT<M>
169 {
170  COMPOSITE_RULE( FF, M );
171 private:
172  typedef RuleInterfaceT<M> Base;
173 
174 public:
176 
177  explicit FF(M& _mesh) : Inherited(_mesh) {}
178 
179  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
180  MIPS_WARN_WA(Vertex) // avoid warning
181  MIPS_WARN_WA(Edge ) // avoid warning
182 };
183 
184 
185 //=============================================================================
186 
187 
190 template <class M> class FFc : public RuleInterfaceT<M>
191 {
192  COMPOSITE_RULE( FFc, M );
193 private:
194  typedef RuleInterfaceT<M> Base;
195 
196 public:
198 
199  explicit FFc(M& _mesh) : Inherited(_mesh) {}
200 
201  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
202  MIPS_WARN_WA(Vertex) // avoid warning
203  MIPS_WARN_WA(Edge ) // avoid warning
204 };
205 
206 
207 //=============================================================================
208 
209 
212 template <class M> class FV : public RuleInterfaceT<M>
213 {
214  COMPOSITE_RULE( FV, M );
215 private:
216  typedef RuleInterfaceT<M> Base;
217 
218 public:
220 
221  explicit FV(M& _mesh) : Inherited(_mesh) {}
222 
223  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
224  MIPS_WARN_WA(Face) // avoid warning
225  MIPS_WARN_WA(Edge) // avoid warning
226 };
227 
228 
229 //=============================================================================
230 
231 
234 template <class M> class FVc : public RuleInterfaceT<M>
235 {
236  COMPOSITE_RULE( FVc, M );
237 private:
238  typedef RuleInterfaceT<M> Base;
239 
240 public:
242 
243  explicit FVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
244 
245  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
246  MIPS_WARN_WA(Face) // avoid warning
247  MIPS_WARN_WA(Edge) // avoid warning
248 
249  static void init_coeffs(size_t _max_valence);
250  static const std::vector<double>& coeffs() { return coeffs_; }
251 
252  double coeff( size_t _valence )
253  {
254  assert(_valence < coeffs_.size());
255  return coeffs_[_valence];
256  }
257 
258 private:
259 
260  static std::vector<double> coeffs_;
261 
262 };
263 
264 
265 //=============================================================================
266 
267 
270 template <class M> class VV : public RuleInterfaceT<M>
271 {
272  COMPOSITE_RULE( VV, M );
273 private:
274  typedef RuleInterfaceT<M> Base;
275 
276 public:
277 
279 
280  explicit VV(M& _mesh) : Inherited(_mesh) {}
281 
282  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
283  MIPS_WARN_WA(Face) // avoid warning
284  MIPS_WARN_WA(Edge) // avoid warning
285 };
286 
287 
288 //=============================================================================
289 
290 
293 template <class M> class VVc : public RuleInterfaceT<M>
294 {
295  COMPOSITE_RULE( VVc, M );
296 private:
297  typedef RuleInterfaceT<M> Base;
298 
299 public:
301 
302  explicit VVc(M& _mesh) : Inherited(_mesh) {}
303 
304  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
305  MIPS_WARN_WA(Face) // avoid warning
306  MIPS_WARN_WA(Edge) // avoid warning
307 };
308 
309 
310 //=============================================================================
311 
312 
315 template <class M> class VE : public RuleInterfaceT<M>
316 {
317  COMPOSITE_RULE( VE, M );
318 private:
319  typedef RuleInterfaceT<M> Base;
320 
321 public:
323 
324  explicit VE(M& _mesh) : Inherited(_mesh) {}
325 
326  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
327  MIPS_WARN_WA(Face ) // avoid warning
328  MIPS_WARN_WA(Vertex) // avoid warning
329 };
330 
331 
332 //=============================================================================
333 
334 
337 template <class M> class VdE : public RuleInterfaceT<M>
338 {
339  COMPOSITE_RULE( VdE, M );
340 private:
341  typedef RuleInterfaceT<M> Base;
342 
343 public:
345 
346  explicit VdE(M& _mesh) : Inherited(_mesh) {}
347 
348  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
349  MIPS_WARN_WA(Face ) // avoid warning
350  MIPS_WARN_WA(Vertex) // avoid warning
351 };
352 
353 
354 //=============================================================================
355 
356 
359 template <class M> class VdEc : public RuleInterfaceT<M>
360 {
361  COMPOSITE_RULE( VdEc, M );
362 private:
363  typedef RuleInterfaceT<M> Base;
364 
365 public:
367 
368  explicit VdEc(M& _mesh) : Inherited(_mesh) {}
369 
370  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
371  MIPS_WARN_WA(Face ) // avoid warning
372  MIPS_WARN_WA(Vertex) // avoid warning
373 };
374 
375 
376 //=============================================================================
377 
378 
381 template <class M> class EV : public RuleInterfaceT<M>
382 {
383  COMPOSITE_RULE( EV, M );
384 private:
385  typedef RuleInterfaceT<M> Base;
386 
387 public:
389 
390  explicit EV(M& _mesh) : Inherited(_mesh) {}
391 
392  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
393  MIPS_WARN_WA(Face) // avoid warning
394  MIPS_WARN_WA(Edge) // avoid warning
395 };
396 
397 
398 //=============================================================================
399 
400 
403 template <class M> class EVc : public RuleInterfaceT<M>
404 {
405  COMPOSITE_RULE( EVc, M );
406 private:
407  typedef RuleInterfaceT<M> Base;
408 
409 public:
410 
412 
413  explicit EVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
414 
415  void raise(typename M::VertexHandle& _vh, state_t _target_state) override;
416  MIPS_WARN_WA(Face) // avoid warning
417  MIPS_WARN_WA(Edge) // avoid warning
418 
419  static void init_coeffs(size_t _max_valence);
420  static const std::vector<double>& coeffs() { return coeffs_; }
421 
422  double coeff( size_t _valence )
423  {
424  assert(_valence < coeffs_.size());
425  return coeffs_[_valence];
426  }
427 
428 private:
429 
430  static std::vector<double> coeffs_;
431 
432 };
433 
434 
435 //=============================================================================
436 
437 
440 template <class M> class EF : public RuleInterfaceT<M>
441 {
442  COMPOSITE_RULE( EF, M );
443 private:
444  typedef RuleInterfaceT<M> Base;
445 
446 public:
448 
449  explicit EF(M& _mesh) : Inherited(_mesh) {}
450 
451  void raise(typename M::FaceHandle& _fh, state_t _target_state) override;
452  MIPS_WARN_WA(Edge ) // avoid warning
453  MIPS_WARN_WA(Vertex) // avoid warning
454 };
455 
456 
457 //=============================================================================
458 
459 
462 template <class M> class FE : public RuleInterfaceT<M>
463 {
464  COMPOSITE_RULE( FE, M );
465 private:
466  typedef RuleInterfaceT<M> Base;
467 
468 public:
470 
471  explicit FE(M& _mesh) : Inherited(_mesh) {}
472 
473  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
474  MIPS_WARN_WA(Face ) // avoid warning
475  MIPS_WARN_WA(Vertex) // avoid warning
476 };
477 
478 
479 //=============================================================================
480 
481 
484 template <class M> class EdE : public RuleInterfaceT<M>
485 {
486  COMPOSITE_RULE( EdE, M );
487 private:
488  typedef RuleInterfaceT<M> Base;
489 
490 public:
492 
493  explicit EdE(M& _mesh) : Inherited(_mesh) {}
494 
495  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
496  MIPS_WARN_WA(Face ) // avoid warning
497  MIPS_WARN_WA(Vertex) // avoid warning
498 };
499 
500 
501 //=============================================================================
502 
503 
506 template <class M> class EdEc : public RuleInterfaceT<M>
507 {
508  COMPOSITE_RULE( EdEc, M );
509 private:
510  typedef RuleInterfaceT<M> Base;
511 
512 public:
514 
515  explicit EdEc(M& _mesh) : Inherited(_mesh) {}
516 
517  void raise(typename M::EdgeHandle& _eh, state_t _target_state) override;
518  MIPS_WARN_WA(Face ) // avoid warning
519  MIPS_WARN_WA(Vertex) // avoid warning
520 };
521 
522 // ----------------------------------------------------------------------------
523 
524 #undef MIPS_WARN_WA
525 
526 //=============================================================================
527 } // END_NS_ADAPTIVE
528 } // END_NS_SUBDIVIDER
529 } // END_NS_OPENMESH
530 //=============================================================================
531 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC)
532 # define OPENMESH_SUBDIVIDER_TEMPLATES
533 # include "RulesT_impl.hh"
534 #endif
535 //=============================================================================
536 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH defined
537 //=============================================================================
538 
scalar_t coeff() const
Get coefficient - ignored by non-parameterized rules.
CompositeTraits::state_t state_t