Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00046
00047
00048
00049
00050
00051
00052 #ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
00053 #define OPENMESH_SMOOTHER_SMOOTHERT_HH
00054
00055
00056
00057
00058 #include <OpenMesh/Core/System/config.hh>
00059 #include <OpenMesh/Core/Utils/Property.hh>
00060 #include <OpenMesh/Core/Utils/Noncopyable.hh>
00061
00062
00063
00064
00065
00066 namespace OpenMesh {
00067 namespace Smoother {
00068
00069
00070
00073 template <class Mesh>
00074 class SmootherT : private Utils::Noncopyable
00075 {
00076 public:
00077
00078 typedef typename Mesh::Scalar Scalar;
00079 typedef typename Mesh::Point Point;
00080 typedef typename Mesh::Normal NormalType;
00081 typedef typename Mesh::VertexHandle VertexHandle;
00082 typedef typename Mesh::EdgeHandle EdgeHandle;
00083
00084
00085 enum Component {
00086 Tangential,
00087 Normal,
00088 Tangential_and_Normal
00089 };
00090
00091 enum Continuity {
00092 C0,
00093 C1,
00094 C2
00095 };
00096
00097 public:
00098
00103 SmootherT( Mesh& _mesh );
00104 virtual ~SmootherT();
00105
00106
00107 public:
00108
00113 void initialize(Component _comp, Continuity _cont);
00114
00115
00117
00118 void set_relative_local_error(Scalar _err);
00119 void set_absolute_local_error(Scalar _err);
00120 void disable_local_error_check();
00122
00128 void skip_features( bool _state ){ skip_features_ = _state; };
00129
00131 virtual void smooth(unsigned int _n);
00132
00133
00134
00136 void set_active_vertices();
00137
00138
00139 private:
00140
00141
00142 void compute_new_positions();
00143 void project_to_tangent_plane();
00144 void local_error_check();
00145 void move_points();
00146
00147
00148
00149 protected:
00150
00151
00152 virtual void compute_new_positions_C0() = 0;
00153 virtual void compute_new_positions_C1() = 0;
00154
00155
00156
00157 protected:
00158
00159
00160
00161 const Point& orig_position(VertexHandle _vh) const
00162 { return mesh_.property(original_positions_, _vh); }
00163
00164 const NormalType& orig_normal(VertexHandle _vh) const
00165 { return mesh_.property(original_normals_, _vh); }
00166
00167 const Point& new_position(VertexHandle _vh) const
00168 { return mesh_.property(new_positions_, _vh); }
00169
00170 void set_new_position(VertexHandle _vh, const Point& _p)
00171 { mesh_.property(new_positions_, _vh) = _p; }
00172
00173 bool is_active(VertexHandle _vh) const
00174 { return mesh_.property(is_active_, _vh); }
00175
00176 Component component() const { return component_; }
00177 Continuity continuity() const { return continuity_; }
00178
00179 protected:
00180
00181 Mesh& mesh_;
00182 bool skip_features_;
00183
00184
00185 private:
00186
00187 Scalar tolerance_;
00188 Scalar normal_deviation_;
00189 Component component_;
00190 Continuity continuity_;
00191
00192 OpenMesh::VPropHandleT<Point> original_positions_;
00193 OpenMesh::VPropHandleT<NormalType> original_normals_;
00194 OpenMesh::VPropHandleT<Point> new_positions_;
00195 OpenMesh::VPropHandleT<bool> is_active_;
00196 };
00197
00198
00199
00200 }
00201 }
00202
00203 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
00204 #define OPENMESH_SMOOTHERT_TEMPLATES
00205 #include "SmootherT.cc"
00206 #endif
00207
00208 #endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
00209
00210