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
00035
00036
00037
00038
00039
00040
00041 #ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
00042 #define OPENMESH_SMOOTHER_SMOOTHERT_HH
00043
00044
00045
00046
00047 #include <OpenMesh/Core/System/config.hh>
00048 #include <OpenMesh/Core/Utils/Property.hh>
00049 #include <OpenMesh/Core/Utils/Noncopyable.hh>
00050
00051
00052
00053
00054
00055 namespace OpenMesh {
00056 namespace Smoother {
00057
00058
00059
00062 template <class Mesh>
00063 class SmootherT : private Utils::Noncopyable
00064 {
00065 public:
00066
00067 typedef typename Mesh::Scalar Scalar;
00068 typedef typename Mesh::Point Point;
00069 typedef typename Mesh::Normal NormalType;
00070 typedef typename Mesh::VertexHandle VertexHandle;
00071 typedef typename Mesh::EdgeHandle EdgeHandle;
00072
00073
00074 enum Component {
00075 Tangential,
00076 Normal,
00077 Tangential_and_Normal
00078 };
00079
00080 enum Continuity {
00081 C0,
00082 C1,
00083 C2
00084 };
00085
00086 public:
00087
00088
00089 SmootherT( Mesh& _mesh );
00090 virtual ~SmootherT();
00091
00092
00093 public:
00094
00098 void initialize(Component _comp, Continuity _cont);
00099
00100
00102
00103 void set_relative_local_error(Scalar _err);
00104 void set_absolute_local_error(Scalar _err);
00105 void disable_local_error_check();
00107
00108
00110 virtual void smooth(unsigned int _n);
00111
00112
00113
00115 void set_active_vertices();
00116
00117
00118 private:
00119
00120
00121 void compute_new_positions();
00122 void project_to_tangent_plane();
00123 void local_error_check();
00124 void move_points();
00125
00126
00127
00128 protected:
00129
00130
00131 virtual void compute_new_positions_C0() = 0;
00132 virtual void compute_new_positions_C1() = 0;
00133
00134
00135
00136 protected:
00137
00138
00139
00140 const Point& orig_position(VertexHandle _vh) const
00141 { return mesh_.property(original_positions_, _vh); }
00142
00143 const NormalType& orig_normal(VertexHandle _vh) const
00144 { return mesh_.property(original_normals_, _vh); }
00145
00146 const Point& new_position(VertexHandle _vh) const
00147 { return mesh_.property(new_positions_, _vh); }
00148
00149 void set_new_position(VertexHandle _vh, const Point& _p)
00150 { mesh_.property(new_positions_, _vh) = _p; }
00151
00152 bool is_active(VertexHandle _vh) const
00153 { return mesh_.property(is_active_, _vh); }
00154
00155 Component component() const { return component_; }
00156 Continuity continuity() const { return continuity_; }
00157
00158 protected:
00159
00160 Mesh& mesh_;
00161
00162
00163 private:
00164
00165 Scalar tolerance_;
00166 Scalar normal_deviation_;
00167 Component component_;
00168 Continuity continuity_;
00169
00170 OpenMesh::VPropHandleT<Point> original_positions_;
00171 OpenMesh::VPropHandleT<NormalType> original_normals_;
00172 OpenMesh::VPropHandleT<Point> new_positions_;
00173 OpenMesh::VPropHandleT<bool> is_active_;
00174 };
00175
00176
00177
00178 }
00179 }
00180
00181 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SMOOTHERT_C)
00182 #define OPENMESH_SMOOTHERT_TEMPLATES
00183 #include "SmootherT.cc"
00184 #endif
00185
00186 #endif // OPENMESH_SMOOTHER_SMOOTHERT_HH defined
00187
00188