OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SmootherT.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 736 $ *
38 * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08. Okt 2012) $ *
39 * *
40 \*===========================================================================*/
41
46 //=============================================================================
47 //
48 // CLASS SmootherT
49 //
50 //=============================================================================
51
52 #ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
53 #define OPENMESH_SMOOTHER_SMOOTHERT_HH
54
55
56 //== INCLUDES =================================================================
57
58 #include <OpenMesh/Core/System/config.hh>
59 #include <OpenMesh/Core/Utils/Property.hh>
60 #include <OpenMesh/Core/Utils/Noncopyable.hh>
61
62 //== FORWARDDECLARATIONS ======================================================
63
64 //== NAMESPACES ===============================================================
65
66 namespace OpenMesh {
67 namespace Smoother {
68
69 //== CLASS DEFINITION =========================================================
70
73 template <class Mesh>
74 class SmootherT : private Utils::Noncopyable
75 {
76 public:
77
78 typedef typename Mesh::Scalar Scalar;
79 typedef typename Mesh::Point Point;
80 typedef typename Mesh::Normal NormalType;
81 typedef typename Mesh::VertexHandle VertexHandle;
82 typedef typename Mesh::EdgeHandle EdgeHandle;
83
84 // initialize smoother
85 enum Component {
86 Tangential,
87 Normal,
88 Tangential_and_Normal
89 };
90
91 enum Continuity {
92 C0,
93 C1,
94 C2
95 };
96
97 public:
98
103 SmootherT( Mesh& _mesh );
104 virtual ~SmootherT();
105
106
107 public:
108
113 void initialize(Component _comp, Continuity _cont);
114
115
117
118 void set_relative_local_error(Scalar _err);
119 void set_absolute_local_error(Scalar _err);
120 void disable_local_error_check();
122
128 void skip_features( bool _state ){ skip_features_ = _state; };
129
131 virtual void smooth(unsigned int _n);
132
133
134
136 void set_active_vertices();
137
138
139 private:
140
141 // single steps of smoothing
142 void compute_new_positions();
143 void project_to_tangent_plane();
144 void local_error_check();
145 void move_points();
146
147
148
149 protected:
150
151 // override these
152 virtual void compute_new_positions_C0() = 0;
153 virtual void compute_new_positions_C1() = 0;
154
155
156
157 protected:
158
159 // misc helpers
160
161 const Point& orig_position(VertexHandle _vh) const
162 { return mesh_.property(original_positions_, _vh); }
163
164 const NormalType& orig_normal(VertexHandle _vh) const
165 { return mesh_.property(original_normals_, _vh); }
166
167 const Point& new_position(VertexHandle _vh) const
168 { return mesh_.property(new_positions_, _vh); }
169
170 void set_new_position(VertexHandle _vh, const Point& _p)
171 { mesh_.property(new_positions_, _vh) = _p; }
172
173 bool is_active(VertexHandle _vh) const
174 { return mesh_.property(is_active_, _vh); }
175
176 Component component() const { return component_; }
177 Continuity continuity() const { return continuity_; }
178
179 protected:
180
181 Mesh& mesh_;
182 bool skip_features_;
183
184
185 private:
186
187 Scalar tolerance_;
188 Scalar normal_deviation_;
189 Component component_;
190 Continuity continuity_;
191
192 OpenMesh::VPropHandleT<Point> original_positions_;
193 OpenMesh::VPropHandleT<NormalType> original_normals_;
194 OpenMesh::VPropHandleT<Point> new_positions_;
195 OpenMesh::VPropHandleT<bool> is_active_;
196 };
197
198
199 //=============================================================================
200 } // namespace Smoother
201 } // namespace OpenMesh
202 //=============================================================================
203 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
204 #define OPENMESH_SMOOTHERT_TEMPLATES
205 #include "SmootherT.cc"
206 #endif
207 //=============================================================================
208 #endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
209 //=============================================================================
210