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

ArrayKernelT.hh

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:36:56 $
00028 //                                                                            
00029 //=============================================================================
00030 
00031 
00032 //=============================================================================
00033 //
00034 //  CLASS OSGArrayKernelT
00035 //
00036 //=============================================================================
00037 
00038 
00039 #ifndef OPENMESH_KERNELOSG_ARRAY_KERNEL_HH
00040 #define OPENMEHS_KERNELOSG_ARRAY_KERNEL_HH
00041 
00042 
00043 //== INCLUDES =================================================================
00044 
00045 #include <vector>
00046 // --------------------
00047 #include <OpenMesh/Core/System/config.hh>
00048 #include <OpenMesh/Core/Utils/GenProg.hh>
00049 #include <OpenMesh/Core/Mesh/Kernels/ArrayKernel/ArrayKernelT.hh>
00050 // --------------------
00051 #include <OpenMesh/Tools/Kernel_OSG/AttribKernelT.hh>
00052 
00053 
00054 
00055 //== NAMESPACES ===============================================================
00056 
00057 
00058 namespace OpenMesh {
00059 namespace Kernel_OSG {
00060 
00061 //== CLASS DEFINITION =========================================================
00062 
00063 
00074 //     \see OpenMesh::ArrayHandleT
00075 //     \see \ref mesh_type 
00076 
00077 
00078 template <class AttribKernel, class FinalMeshItems>
00079 class ArrayKernelT 
00080   : public OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems>
00081 {
00082 public:
00083   
00084   typedef ArrayKernelT<AttribKernel, FinalMeshItems>           This;
00085   typedef OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems> Base;
00086 
00087   // attributes
00088 //   typedef typename Base::HasVertexNormals             HasVertexNormals;
00089 //   typedef typename Base::HasVertexColors              HasVertexColors;
00090 //   typedef typename Base::HasVertexTexCoords           HasVertexTexCoords;
00091 //   typedef typename Base::HasVertexStatus              HasVertexStatus;
00092   typedef typename Base::HasPrevHalfedge              HasPrevHalfedge;
00093 //   typedef typename Base::HasEdgeStatus                HasEdgeStatus;
00094 //   typedef typename Base::HasFaceNormals               HasFaceNormals;
00095 //   typedef typename Base::HasFaceColors                HasFaceColors;
00096 //   typedef typename Base::HasFaceStatus                HasFaceStatus;
00097 
00098   // item types
00099   typedef typename FinalMeshItems::Vertex             Vertex;
00100   typedef typename FinalMeshItems::Halfedge           Halfedge;
00101   typedef typename FinalMeshItems::Edge               Edge;
00102   typedef typename FinalMeshItems::Face               Face;
00103   typedef typename FinalMeshItems::Point              Point;
00104   typedef typename FinalMeshItems::Normal             Normal;
00105   typedef typename FinalMeshItems::Color              Color;
00106   typedef typename FinalMeshItems::TexCoord2D         TexCoord2D;
00107   typedef typename FinalMeshItems::Scalar             Scalar;
00108 
00109 //   // handles
00110 //   typedef typename OpenMesh::VertexHandle       VertexHandle;    
00111 //   typedef typename FinalMeshItems::HalfedgeHandle     HalfedgeHandle;  
00112 //   typedef typename FinalMeshItems::EdgeHandle         EdgeHandle;      
00113 //   typedef typename FinalMeshItems::FaceHandle         FaceHandle;      
00114 
00115   // iterators
00116   typedef std::vector<Vertex>                         VertexContainer;
00117   typedef std::vector<Edge>                           EdgeContainer;
00118   typedef std::vector<Face>                           FaceContainer;
00119   typedef typename VertexContainer::iterator          KernelVertexIter;
00120   typedef typename VertexContainer::const_iterator    KernelConstVertexIter;
00121   typedef typename EdgeContainer::iterator            KernelEdgeIter;
00122   typedef typename EdgeContainer::const_iterator      KernelConstEdgeIter;
00123   typedef typename FaceContainer::iterator            KernelFaceIter;
00124   typedef typename FaceContainer::const_iterator      KernelConstFaceIter;
00125 
00126 public:
00127 
00128   ArrayKernelT() : Base()
00129   { }
00130 
00131   virtual ~ArrayKernelT()
00132   { }
00133 
00134 public: // replacements
00135 
00136   void set_halfedge_handle(VertexHandle _vh, HalfedgeHandle _heh) { 
00137     Base::set_halfedge_handle( _vh, _heh );
00138   }
00139 
00140   void set_halfedge_handle(FaceHandle _fh, HalfedgeHandle _heh) { 
00141     Base::set_halfedge_handle( _fh, _heh );
00142     osg_sync( _fh );
00143   }
00144 
00145   void set_next_halfedge_handle(HalfedgeHandle _heh, HalfedgeHandle _nheh) { 
00146     Base::set_next_halfedge_handle( _heh, _nheh );
00147     osg_sync( face_handle( _heh ) ); // ##Changed
00148   }
00149 
00150   void garbage_collection(bool _v=true, bool _e=true, bool _f=true);
00151 
00152 protected:  
00153   
00154   bool osg_sync( FaceHandle _fh )
00155   {    
00156     return _fh.is_valid() 
00157       ? osg_sync( _fh, typename Face::IsTriangle() ) 
00158       : false;
00159   }
00160   
00161 private:
00162 
00163   bool osg_sync( FaceHandle _fh,  GenProg::Bool2Type<true> )
00164   {    
00165     HalfedgeHandle hh( halfedge_handle(_fh) );  
00166     if ( !hh.is_valid() ) return false;
00167     FaceHandle f1( _fh.idx() * 3 );
00168     set_face_indices( f1, to_vertex_handle(hh).idx() );
00169 
00170     hh = next_halfedge_handle(hh);  
00171     if ( !hh.is_valid() ) return false;
00172     FaceHandle f2( f1.idx()+1 );
00173     set_face_indices( f2, to_vertex_handle(hh).idx() );
00174 
00175     hh = next_halfedge_handle(hh);  
00176     if ( !hh.is_valid() ) return false;
00177     FaceHandle f3( f1.idx()+2 );
00178     set_face_indices( f3, to_vertex_handle(hh).idx() );
00179 
00180     set_face_types  ( _fh, GL_TRIANGLES );
00181     set_face_lengths( _fh, 3 );  
00182 
00183     return true;
00184   }
00185 
00186   bool osg_sync( FaceHandle _fh,  GenProg::Bool2Type<false> )
00187   {
00188     return false;
00189   }
00190 
00191 };
00192 
00193 
00194 template <class AttribKernel, class FinalMeshItems>
00195 void
00196 ArrayKernelT<AttribKernel, FinalMeshItems>::
00197 garbage_collection(bool _v, bool _e, bool _f)
00198 {
00199   Base::garbage_collection(_v, _e, _f);
00200   for (size_t fidx=0; fidx < n_faces(); ++fidx)
00201     osg_sync( FaceHandle(fidx) );
00202 }
00203 
00204 //=============================================================================
00205 } // namespace Kernel_OSG
00206 } // namespace OpenMesh
00207 //=============================================================================
00208 #endif // OPENMESH_ARRAY_KERNEL_HH defined
00209 //=============================================================================

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