Developer Documentation

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SmootherT.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 SmootherT
56 //
57 //=============================================================================
58
59 #ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
60 #define OPENMESH_SMOOTHER_SMOOTHERT_HH
61
62
63 //== INCLUDES =================================================================
64
65 #include <OpenMesh/Core/System/config.hh>
66 #include <OpenMesh/Core/Utils/Property.hh>
67 #include <OpenMesh/Core/Utils/Noncopyable.hh>
68
69 //== FORWARDDECLARATIONS ======================================================
70
71 //== NAMESPACES ===============================================================
72
73 namespace OpenMesh {
74 namespace Smoother {
75
76 //== CLASS DEFINITION =========================================================
77
80 template <class Mesh>
81 class SmootherT : private Utils::Noncopyable
82 {
83 public:
84
85 typedef typename Mesh::Scalar Scalar;
86 typedef typename Mesh::Point Point;
87 typedef typename Mesh::Normal NormalType;
88 typedef typename Mesh::VertexHandle VertexHandle;
89 typedef typename Mesh::EdgeHandle EdgeHandle;
90
91 // initialize smoother
92 enum Component {
93 Tangential,
94 Normal,
95 Tangential_and_Normal
96 };
97
98 enum Continuity {
99 C0,
100 C1,
101 C2
102 };
103
104 public:
105
110 SmootherT( Mesh& _mesh );
111 virtual ~SmootherT();
112
113
114 public:
115
116 //===========================================================================
119 //===========================================================================
120
125 void initialize(Component _comp, Continuity _cont);
126
128 virtual void smooth(unsigned int _n);
129
132 //===========================================================================
135 //===========================================================================
136
146 void set_relative_local_error(Scalar _err);
147
154 void set_absolute_local_error(Scalar _err);
155
160 void disable_local_error_check();
161
172 void skip_features( bool _state ){ skip_features_ = _state; };
173
174
177 private:
178
189 void set_active_vertices();
190
191 // single steps of smoothing
192 void compute_new_positions();
193 void project_to_tangent_plane();
194 void local_error_check();
195 void move_points();
196
197
198
199 protected:
200
201 // override these
202 virtual void compute_new_positions_C0() = 0;
203 virtual void compute_new_positions_C1() = 0;
204
205
206
207 protected:
208
209 // misc helpers
210
211 const Point& orig_position(VertexHandle _vh) const
212 { return mesh_.property(original_positions_, _vh); }
213
214 const NormalType& orig_normal(VertexHandle _vh) const
215 { return mesh_.property(original_normals_, _vh); }
216
217 const Point& new_position(VertexHandle _vh) const
218 { return mesh_.property(new_positions_, _vh); }
219
220 void set_new_position(VertexHandle _vh, const Point& _p)
221 { mesh_.property(new_positions_, _vh) = _p; }
222
223 bool is_active(VertexHandle _vh) const
224 { return mesh_.property(is_active_, _vh); }
225
226 Component component() const { return component_; }
227 Continuity continuity() const { return continuity_; }
228
229 protected:
230
231 Mesh& mesh_;
232 bool skip_features_;
233
234
235 private:
236
237 Scalar tolerance_;
238 Scalar normal_deviation_;
239 Component component_;
240 Continuity continuity_;
241
242 OpenMesh::VPropHandleT<Point> original_positions_;
243 OpenMesh::VPropHandleT<NormalType> original_normals_;
244 OpenMesh::VPropHandleT<Point> new_positions_;
245 OpenMesh::VPropHandleT<bool> is_active_;
246 };
247
248
249 //=============================================================================
250 } // namespace Smoother
251 } // namespace OpenMesh
252 //=============================================================================
253 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
254 #define OPENMESH_SMOOTHERT_TEMPLATES
255 #include "SmootherT.cc"
256 #endif
257 //=============================================================================
258 #endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
259 //=============================================================================
260
SmootherT.cc
OpenMesh::Smoother::SmootherT::Normal
Smooth normal direction.
Definition: SmootherT.hh:94
OpenMesh
Definition: MeshItems.hh:64
OpenMesh::Smoother::SmootherT::initialize
void initialize(Component _comp, Continuity _cont)
Definition: SmootherT.cc:127
OpenMesh::Smoother::SmootherT::skip_features
void skip_features(bool _state)
enable or disable feature handling
Definition: SmootherT.hh:172
OpenMesh::TriMesh_ArrayKernelT< CustomTraits >
OpenMesh::Smoother::SmootherT::disable_local_error_check
void disable_local_error_check()
Disable error control of the smoother.
Definition: SmootherT.cc:295
OpenMesh::Smoother::SmootherT::set_active_vertices
void set_active_vertices()
Find active vertices. Resets tagged status !
Definition: SmootherT.cc:157
OpenMesh::Smoother::SmootherT::Component
Component
Definition: SmootherT.hh:92
OpenMesh::VPropHandleT< Point >
OpenMesh::Smoother::SmootherT::set_absolute_local_error
void set_absolute_local_error(Scalar _err)
Set local error as an absolute value.
Definition: SmootherT.cc:283
OpenMesh::Utils::Noncopyable
Definition: Noncopyable.hh:76
OpenMesh::Smoother::SmootherT::smooth
virtual void smooth(unsigned int _n)
Do _n smoothing iterations.
Definition: SmootherT.cc:307
OpenMesh::Smoother::SmootherT::SmootherT
SmootherT(Mesh &_mesh)
constructor & destructor
Definition: SmootherT.cc:78
OpenMesh::Smoother::SmootherT::Tangential_and_Normal
Smooth tangential and normal direction.
Definition: SmootherT.hh:95
OpenMesh::PolyMeshT::Scalar
Kernel::Scalar Scalar
Scalar type.
Definition: PolyMeshT.hh:113
OpenMesh::Smoother::SmootherT
Definition: SmootherT.hh:81
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
OpenMesh::Smoother::SmootherT::Tangential
Smooth tangential direction.
Definition: SmootherT.hh:93
OpenMesh::Smoother::SmootherT::set_relative_local_error
void set_relative_local_error(Scalar _err)
Set local error relative to bounding box.
Definition: SmootherT.cc:253
OpenMesh::PolyMeshT::Normal
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117