Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SmootherT.hh

Go to the documentation of this file.
00001 //=============================================================================
00002 //                                                                            
00003 //                               OpenMesh                                     
00004 //      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen       
00005 //                           www.openmesh.org                                 
00006 //                                                                            
00007 //-----------------------------------------------------------------------------
00008 //                                                                            
00009 //                                License                                     
00010 //                                                                            
00011 //   This library is free software; you can redistribute it and/or modify it 
00012 //   under the terms of the GNU Library General Public License as published  
00013 //   by the Free Software Foundation, version 2.                             
00014 //                                                                             
00015 //   This library is distributed in the hope that it will be useful, but       
00016 //   WITHOUT ANY WARRANTY; without even the implied warranty of                
00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00018 //   Library General Public License for more details.                          
00019 //                                                                            
00020 //   You should have received a copy of the GNU Library General Public         
00021 //   License along with this library; if not, write to the Free Software       
00022 //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 
00023 //                                                                            
00024 //-----------------------------------------------------------------------------
00025 //                                                                            
00026 //   $Revision: 1.1.1.1 $
00027 //   $Date: 2004/09/06 12:37:08 $
00028 //                                                                            
00029 //=============================================================================
00030 
00035 //=============================================================================
00036 //
00037 //  CLASS SmootherT
00038 //
00039 //=============================================================================
00040 
00041 #ifndef OPENMESH_SMOOTHER_SMOOTHERT_HH
00042 #define OPENMESH_SMOOTHER_SMOOTHERT_HH
00043 
00044 
00045 //== INCLUDES =================================================================
00046 
00047 #include <OpenMesh/Core/System/config.hh>
00048 #include <OpenMesh/Core/Utils/Property.hh>
00049 #include <OpenMesh/Core/Utils/Noncopyable.hh>
00050 
00051 //== FORWARDDECLARATIONS ======================================================
00052 
00053 //== NAMESPACES ===============================================================
00054 
00055 namespace OpenMesh {
00056 namespace Smoother {
00057 
00058 //== CLASS DEFINITION =========================================================
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   // initialize smoother
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   // constructor & destructor
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   // single steps of smoothing
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   // override these
00131   virtual void compute_new_positions_C0() = 0;
00132   virtual void compute_new_positions_C1() = 0;
00133 
00134 
00135 
00136 protected:
00137 
00138   // misc helpers
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 } // namespace Smoother
00179 } // namespace OpenMesh
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 

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