OpenMesh
SmootherT.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 SmootherT
51//
52//=============================================================================
53
54#ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
55#define OPENMESH_SMOOTHER_SMOOTHERT_HH
56
57
58//== INCLUDES =================================================================
59
60#include <OpenMesh/Core/System/config.hh>
61#include <OpenMesh/Core/Utils/Property.hh>
62#include <OpenMesh/Core/Utils/Noncopyable.hh>
63
64//== FORWARDDECLARATIONS ======================================================
65
66//== NAMESPACES ===============================================================
67
68namespace OpenMesh {
69namespace Smoother {
70
71//== CLASS DEFINITION =========================================================
72
75template <class Mesh>
77{
78public:
79
80 typedef typename Mesh::Scalar Scalar;
81 typedef typename Mesh::Point Point;
82 typedef typename Mesh::Normal NormalType;
83 typedef typename Mesh::VertexHandle VertexHandle;
84 typedef typename Mesh::EdgeHandle EdgeHandle;
85
86 // initialize smoother
87 enum Component {
91 };
92
93 enum Continuity {
94 C0,
95 C1,
96 C2
97 };
98
99public:
100
105 SmootherT( Mesh& _mesh );
106 virtual ~SmootherT();
107
108
109public:
110
111 //===========================================================================
114 //===========================================================================
115
120 void initialize(Component _comp, Continuity _cont);
121
123 virtual void smooth(unsigned int _n);
124
127 //===========================================================================
130 //===========================================================================
131
141 void set_relative_local_error(Scalar _err);
142
149 void set_absolute_local_error(Scalar _err);
150
156
167 void skip_features( bool _state ){ skip_features_ = _state; };
168
169
172private:
173
184 void set_active_vertices();
185
186 // single steps of smoothing
187 void compute_new_positions();
188 void project_to_tangent_plane();
189 void local_error_check();
190 void move_points();
191
192
193
194protected:
195
196 // override these
197 virtual void compute_new_positions_C0() = 0;
198 virtual void compute_new_positions_C1() = 0;
199
200
201
202protected:
203
204 // misc helpers
205
206 const Point& orig_position(VertexHandle _vh) const
207 { return mesh_.property(original_positions_, _vh); }
208
209 const NormalType& orig_normal(VertexHandle _vh) const
210 { return mesh_.property(original_normals_, _vh); }
211
212 const Point& new_position(VertexHandle _vh) const
213 { return mesh_.property(new_positions_, _vh); }
214
215 void set_new_position(VertexHandle _vh, const Point& _p)
216 { mesh_.property(new_positions_, _vh) = _p; }
217
218 bool is_active(VertexHandle _vh) const
219 { return mesh_.property(is_active_, _vh); }
220
221 Component component() const { return component_; }
222 Continuity continuity() const { return continuity_; }
223
224protected:
225
226 Mesh& mesh_;
227 bool skip_features_;
228
229
230private:
231
232 Scalar tolerance_;
233 Scalar normal_deviation_;
234 Component component_;
235 Continuity continuity_;
236
237 OpenMesh::VPropHandleT<Point> original_positions_;
238 OpenMesh::VPropHandleT<NormalType> original_normals_;
239 OpenMesh::VPropHandleT<Point> new_positions_;
241};
242
243
244//=============================================================================
245} // namespace Smoother
246} // namespace OpenMesh
247//=============================================================================
248#if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
249#define OPENMESH_SMOOTHERT_TEMPLATES
250#include "SmootherT_impl.hh"
251#endif
252//=============================================================================
253#endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
254//=============================================================================
255
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Handle for a vertex entity.
Definition: Handles.hh:121
Polygonal mesh based on the ArrayKernel.
Definition: PolyMesh_ArrayKernelT.hh:96
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
Kernel::EdgeHandle EdgeHandle
Scalar type.
Definition: PolyMeshT.hh:138
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:114
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
This class demonstrates the non copyable idiom.
Definition: Noncopyable.hh:72
Base class for smoothing algorithms.
Definition: SmootherT.hh:77
virtual void smooth(unsigned int _n)
Do _n smoothing iterations.
Definition: SmootherT_impl.hh:302
Component
Definition: SmootherT.hh:87
@ Tangential_and_Normal
Smooth tangential and normal direction.
Definition: SmootherT.hh:90
@ Tangential
Smooth tangential direction.
Definition: SmootherT.hh:88
@ Normal
Smooth normal direction.
Definition: SmootherT.hh:89
void initialize(Component _comp, Continuity _cont)
Initialize smoother.
Definition: SmootherT_impl.hh:122
void set_absolute_local_error(Scalar _err)
Set local error as an absolute value.
Definition: SmootherT_impl.hh:278
void disable_local_error_check()
Disable error control of the smoother.
Definition: SmootherT_impl.hh:290
void set_relative_local_error(Scalar _err)
Set local error relative to bounding box.
Definition: SmootherT_impl.hh:248
SmootherT(Mesh &_mesh)
constructor & destructor
Definition: SmootherT_impl.hh:73
void skip_features(bool _state)
enable or disable feature handling
Definition: SmootherT.hh:167

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