OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CompositeSqrt3T.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 
53 //=============================================================================
54 //
55 // CLASS SQRT3T
56 //
57 //=============================================================================
58 
59 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH
60 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH
61 
62 
63 //== INCLUDES =================================================================
64 
65 #include "Composite/CompositeT.hh"
66 #include "Composite/CompositeTraits.hh"
67 
68 
69 //== NAMESPACE ================================================================
70 
71 namespace OpenMesh { // BEGIN_NS_OPENMESH
72 namespace Subdivider { // BEGIN_NS_DECIMATER
73 namespace Uniform { // BEGIN_NS_UNIFORM
74 
75 
76 //== CLASS DEFINITION =========================================================
77 
80 template <typename MeshType, typename RealType=float>
81 class CompositeSqrt3T : public CompositeT<MeshType, RealType>
82 {
83 public:
84 
86 
87 public:
88 
89  CompositeSqrt3T() : Inherited() {};
90  CompositeSqrt3T(MeshType& _mesh) : Inherited(_mesh) {};
91  ~CompositeSqrt3T() {}
92 
93 public:
94 
95  const char *name() const { return "Uniform Composite Sqrt3"; }
96 
97 protected: // inherited interface
98 
99  void apply_rules(void)
100  {
101  Inherited::Tvv3();
102  Inherited::VF();
103  Inherited::FF();
104  Inherited::FVc(coeffs_);
105  }
106 
107 protected:
108 
109  typedef typename Inherited::Coeff Coeff;
110 
114  struct FVCoeff : public Coeff
115  {
116  FVCoeff() : Coeff() { init(50); }
117 
118  void init(size_t _max_valence)
119  {
120  weights_.resize(_max_valence);
121  std::generate(weights_.begin(),
122  weights_.end(), compute_weight() );
123  }
124 
125  double operator()(size_t _valence) { return weights_[_valence]; }
126 
130  {
131  compute_weight() : val_(0) { }
132 
133  double operator()(void) // sqrt(3) weights for non-boundary vertices
134  {
135  return 2.0/3.0 * (cos(2.0*M_PI/val_++)+1.0);
136  }
137  size_t val_;
138  };
139 
140  std::vector<double> weights_;
141 
142  } coeffs_;
143 
144 };
145 
146 
147 //=============================================================================
148 } // END_NS_UNIFORM
149 } // END_NS_SUBDIVIDER
150 } // END_NS_OPENMESH
151 //=============================================================================
152 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH defined
153 //=============================================================================
void apply_rules(void)
Assemble here the rule sequence, by calling the constructor of the wanted rules.
Definition: CompositeSqrt3T.hh:99
Uniform composite sqrt(3) subdivision algorithm.
Definition: CompositeSqrt3T.hh:81
This class provides the composite subdivision rules for the uniform case.
Definition: CompositeT.hh:94
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
const char * name() const
Return name of subdivision algorithm.
Definition: CompositeSqrt3T.hh:95
Helper class.
Definition: CompositeSqrt3T.hh:114

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