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

SubdividerT.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:23 $
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 
00085 
00089   SubdividerT(void) : attached_(NULL) { }
00090 
00091 
00093   virtual ~SubdividerT() 
00094   { detach(); }
00095 
00097   virtual const char *name( void ) const = 0;
00098 
00099 
00100 public: 
00101 
00103 
00104 
00105   bool operator () ( MeshType& _m, size_t _n )
00106   {    
00107     return prepare(_m) && subdivide( _m, _n ) && cleanup( _m );
00108   }
00110 
00111 public: 
00112 
00113 
00114 
00115   bool attach( MeshType& _m )
00116   {
00117     if ( attached_ == &_m )
00118       return true;
00119 
00120     detach();
00121     if (prepare( _m ))
00122     {
00123       attached_ = &_m;
00124       return true;
00125     }
00126     return false;
00127   }
00128 
00131   bool operator()( size_t _n )
00132   {
00133     return attached_ ? subdivide( *attached_, _n ) : false;
00134   }
00135 
00138   void detach(void)
00139   {
00140     if ( attached_ )
00141     {
00142       cleanup( *attached_ );
00143       attached_ = NULL;
00144     }
00145   }
00147 
00148 protected: 
00149 
00151 
00152 
00153   virtual bool prepare( MeshType& _m ) = 0;
00154 
00156   virtual bool subdivide( MeshType& _m, size_t _n ) = 0;
00157 
00159   virtual bool cleanup( MeshType& _m ) = 0;
00161 
00162 private:
00163  
00164   MeshType *attached_;
00165 
00166 };
00167 
00168 //=============================================================================
00169 } // namespace Uniform
00170 } // namespace Subdivider
00171 } // namespace OpenMesh
00172 //=============================================================================
00173 #endif // OPENMESH_SUBDIVIDER_UNIFORM_SUBDIVIDERT_HH
00174 //=============================================================================

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