OpenMesh
Loading...
Searching...
No Matches
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
73namespace OpenMesh {
74namespace Smoother {
75
76//== CLASS DEFINITION =========================================================
77
80template <class Mesh>
82{
83public:
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
97
98 enum Continuity {
99 C0,
100 C1,
101 C2
102 };
103
104public:
105
110 SmootherT( Mesh& _mesh );
111 virtual ~SmootherT();
112
113
114public:
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
161
172 void skip_features( bool _state ){ skip_features_ = _state; };
173
174
177private:
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
199protected:
200
201 // override these
202 virtual void compute_new_positions_C0() = 0;
203 virtual void compute_new_positions_C1() = 0;
204
205
206
207protected:
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
229protected:
230
231 Mesh& mesh_;
232 bool skip_features_;
233
234
235private:
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_;
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
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition MeshItems.hh:64
Handle for a vertex entity.
Definition Handles.hh:126
Polygonal mesh based on the ArrayKernel.
Definition PolyMesh_ArrayKernelT.hh:100
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition PolyMeshT.hh:139
Kernel::Scalar Scalar
Scalar type.
Definition PolyMeshT.hh:113
Kernel::EdgeHandle EdgeHandle
Scalar type.
Definition PolyMeshT.hh:141
Kernel::Normal Normal
Normal type.
Definition PolyMeshT.hh:117
Kernel::Point Point
Coordinate type.
Definition PolyMeshT.hh:115
This class demonstrates the non copyable idiom.
Definition Noncopyable.hh:77
Handle representing a vertex property.
Definition Property.hh:488
Base class for smoothing algorithms.
Definition SmootherT.hh:82
virtual void smooth(unsigned int _n)
Do _n smoothing iterations.
Definition SmootherT.cc:307
Component
Definition SmootherT.hh:92
@ Tangential_and_Normal
Smooth tangential and normal direction.
Definition SmootherT.hh:95
@ Tangential
Smooth tangential direction.
Definition SmootherT.hh:93
@ Normal
Smooth normal direction.
Definition SmootherT.hh:94
void initialize(Component _comp, Continuity _cont)
Initialize smoother.
Definition SmootherT.cc:127
void set_absolute_local_error(Scalar _err)
Set local error as an absolute value.
Definition SmootherT.cc:283
void disable_local_error_check()
Disable error control of the smoother.
Definition SmootherT.cc:295
void set_relative_local_error(Scalar _err)
Set local error relative to bounding box.
Definition SmootherT.cc:253
void skip_features(bool _state)
enable or disable feature handling
Definition SmootherT.hh:172

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