OpenMesh
CompositeSqrt3T.hh
Go to the documentation of this file.
1/* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2023, 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
48//=============================================================================
49//
50// CLASS SQRT3T
51//
52//=============================================================================
53
54#ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH
55#define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH
56
57
58//== INCLUDES =================================================================
59
60#include "Composite/CompositeT.hh"
61#include "Composite/CompositeTraits.hh"
62
63
64//== NAMESPACE ================================================================
65
66namespace OpenMesh { // BEGIN_NS_OPENMESH
67namespace Subdivider { // BEGIN_NS_DECIMATER
68namespace Uniform { // BEGIN_NS_UNIFORM
69
70
71//== CLASS DEFINITION =========================================================
72
75template <typename MeshType, typename RealType = double>
76class CompositeSqrt3T : public CompositeT<MeshType, RealType>
77{
78public:
79
81
82public:
83
85 explicit CompositeSqrt3T(MeshType& _mesh) : Inherited(_mesh) {};
87
88public:
89
90 const char *name() const override { return "Uniform Composite Sqrt3"; }
91
92protected: // inherited interface
93
94 void apply_rules(void) override
95 {
96 Inherited::Tvv3();
97 Inherited::VF();
98 Inherited::FF();
99 Inherited::FVc(coeffs_);
100 }
101
102protected:
103
104 typedef typename Inherited::Coeff Coeff;
105
109 struct FVCoeff : public Coeff
110 {
111 FVCoeff() : Coeff() { init(50); }
112
113 void init(size_t _max_valence)
114 {
115 weights_.resize(_max_valence);
116 std::generate(weights_.begin(),
117 weights_.end(), compute_weight() );
118 }
119
120 double operator()(size_t _valence) override { return weights_[_valence]; }
121
125 {
126 compute_weight() : val_(0) { }
127
128 double operator()(void) // sqrt(3) weights for non-boundary vertices
129 {
130 return 2.0/3.0 * (cos(2.0*M_PI/val_++)+1.0);
131 }
132 size_t val_;
133 };
134
135 std::vector<double> weights_;
136
137 } coeffs_;
138
139};
140
141
142//=============================================================================
143} // END_NS_UNIFORM
144} // END_NS_SUBDIVIDER
145} // END_NS_OPENMESH
146//=============================================================================
147#endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITESQRT3T_HH defined
148//=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
This class provides the composite subdivision rules for the uniform case.
Definition: CompositeT.hh:90
Abstract base class for coefficient functions.
Definition: CompositeT.hh:158
Uniform composite sqrt(3) subdivision algorithm.
Definition: CompositeSqrt3T.hh:77
const char * name() const override
Return name of subdivision algorithm.
Definition: CompositeSqrt3T.hh:90
void apply_rules(void) override
Assemble here the rule sequence, by calling the constructor of the wanted rules.
Definition: CompositeSqrt3T.hh:94
Helper class.
Definition: CompositeSqrt3T.hh:110

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