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

SubdividerT.hh

Go to the documentation of this file.
00001 //=============================================================================
00002 //                                                                            
00003 //                               OpenMesh                                     
00004 //        Copyright (C) 2003 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.2 $
00027 //   $Date: 2004/01/20 14:41:57 $
00028 //                                                                            
00029 //=============================================================================
00030 
00035 //=============================================================================
00036 //
00037 //  CLASS SubdividerT
00038 //
00039 //=============================================================================
00040 
00041 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_SUDIVIDERT_HH
00042 #define OPENMESH_SUBDIVIDER_UNIFORM_SUDIVIDERT_HH
00043 
00044 //== INCLUDE ==================================================================
00045 
00046 #include <OpenMesh/Core/System/config.hh>
00047 #include <OpenMesh/Core/Utils/Noncopyable.hh>
00048 #if defined(_DEBUG) || defined(DEBUG)
00049 // Makes life lot easier, when playing/messing around with low-level topology
00050 // changing methods of OpenMesh
00051 #  include <OpenMesh/Tools/Utils/MeshCheckerT.hh>
00052 #  define ASSERT_CONSISTENCY( T, m ) \
00053      assert(OpenMesh::Utils::MeshCheckerT<T>(m).check())
00054 #else
00055 #  define ASSERT_CONSISTENCY( T, m )
00056 #endif
00057 
00058 //== NAMESPACE ================================================================
00059 
00060 namespace OpenMesh   {
00061 namespace Subdivider {
00062 namespace Uniform    {
00063 
00064 
00065 //== CLASS DEFINITION =========================================================
00066 
00075 template <typename MeshType, typename RealType=float>
00076 class SubdividerT : private Utils::Noncopyable
00077 {
00078 public:
00079 
00080   typedef MeshType mesh_t;
00081   typedef RealType real_t;
00082 
00083 public:
00084 
00086 
00087 
00088 
00089   SubdividerT(void) : attached_(NULL) { }
00090 
00093   SubdividerT( MeshType &_m ) : attached_(NULL) {  attach(_m); }
00094 
00096 
00098   virtual ~SubdividerT() 
00099   { detach(); }
00100 
00102   virtual const char *name( void ) const = 0;
00103 
00104 
00105 public: 
00106 
00108 
00109 
00110   bool operator () ( MeshType& _m, size_t _n )
00111   {    
00112     return prepare(_m) && subdivide( _m, _n ) && cleanup( _m );
00113   }
00115 
00116 public: 
00117 
00118 
00119 
00120   bool attach( MeshType& _m )
00121   {
00122     if ( attached_ == &_m )
00123       return true;
00124 
00125     detach();
00126     if (prepare( _m ))
00127     {
00128       attached_ = &_m;
00129       return true;
00130     }
00131     return false;
00132   }
00133 
00136   bool operator()( size_t _n )
00137   {
00138     return attached_ ? subdivide( *attached_, _n ) : false;
00139   }
00140 
00143   void detach(void)
00144   {
00145     if ( attached_ )
00146     {
00147       cleanup( *attached_ );
00148       attached_ = NULL;
00149     }
00150   }
00152 
00153 protected: 
00154 
00156 
00157 
00158   virtual bool prepare( MeshType& _m ) = 0;
00159 
00161   virtual bool subdivide( MeshType& _m, size_t _n ) = 0;
00162 
00164   virtual bool cleanup( MeshType& _m ) = 0;
00166 
00167 private:
00168  
00169   MeshType *attached_;
00170 
00171 };
00172 
00173 //=============================================================================
00174 } // namespace Uniform
00175 } // namespace Subdivider
00176 } // namespace OpenMesh
00177 //=============================================================================
00178 #endif // OPENMESH_SUBDIVIDER_UNIFORM_SUBDIVIDERT_HH
00179 //=============================================================================

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