ColTopology.h

00001 
00002 //***************************************************************************
00003 //                              ColTopology
00004 //***************************************************************************
00005 //  Copyright (C):
00006 //***************************************************************************
00007 //CVSId: "@(#)$Id: ColTopology.h,v 1.5 2004/03/09 13:39:49 ehlgen Exp $"
00008 //***************************************************************************
00009 
00010 
00011 #ifndef ColTopology_H
00012 #define ColTopology_H
00013 #if defined(__sgi) || defined(_WIN32)
00014 #pragma once
00015 #endif
00016 
00017 //---------------------------------------------------------------------------
00018 //  Includes
00019 //---------------------------------------------------------------------------
00020 
00021 #include <vector>
00022 
00023 #include <ColDopTree.h>                 // just needed for constant NumOri
00024 #include <ColUtils.h>                   // just needed for constant NearZero
00025 #include <col_import_export.h>
00026 
00027 
00028 namespace col {
00029 
00030 //---------------------------------------------------------------------------
00031 //  Forward References
00032 //---------------------------------------------------------------------------
00033 
00034 //---------------------------------------------------------------------------
00035 //   Constants
00036 //---------------------------------------------------------------------------
00037 
00038 //***************************************************************************
00039 //  TopoFace
00040 //***************************************************************************
00041 
00042 struct COL_EXPORTIMPORT TopoFace
00043 {
00045     std::vector<unsigned int> v;
00046 
00047     TopoFace( const unsigned int vertex_indices[], unsigned int size );
00048     TopoFace( const std::vector< unsigned int > &v );
00049     TopoFace( const TopoFace &source );
00050     TopoFace( void );
00051     void operator = ( const TopoFace &source );
00052     void set( const unsigned int vertex_indices[], unsigned int size );
00053 
00054     void print( void ) const;
00055 
00056     unsigned int & operator [] ( int index );
00057     unsigned int operator [] ( int index ) const;
00058     unsigned int size( void ) const;
00059     void resize( unsigned int newsize );
00060 
00061 };
00062 
00063 
00064 
00065 //***************************************************************************
00066 //  Topology
00067 //***************************************************************************
00068 
00069 class COL_EXPORTIMPORT Topology
00070 {
00071 
00072 public:
00073 
00074 //---------------------------------------------------------------------------
00075 //  Public Types
00076 //---------------------------------------------------------------------------
00077 
00078     typedef std::vector<unsigned int>       FaceNeighbors;
00079     typedef FaceNeighbors::const_iterator   FaceNeighborIterator;
00080     typedef std::vector<unsigned int>       VertexNeighbors;
00081     typedef VertexNeighbors::const_iterator VertexNeighborIterator;
00082 
00083 //---------------------------------------------------------------------------
00084 //  Public Instance methods
00085 //---------------------------------------------------------------------------
00086 
00087     Topology( );
00088     explicit Topology( const Topology & source );
00089     void operator = ( const Topology & source );
00090 
00091     Topology( const std::vector<TopoFace> &face );
00092     Topology( const unsigned int face_a[][Dop::NumOri],
00093               unsigned int nfaces,
00094               unsigned int face_nv[] );
00095     Topology( const osg::GeometryPtr geom,
00096               bool unify = true, float tolerance = NearZero );
00097     void operator = ( const std::vector<TopoFace> &face );
00098     void createFromGeom( const osg::GeometryPtr geom,
00099                          bool unify = false, float tolerance = NearZero );
00100     void create( const unsigned int face_a[][Dop::NumOri],
00101                  unsigned int nfaces, unsigned int face_nv[] );
00102 
00103     unsigned int v_neighbors    ( unsigned int v_index ) const;
00104     unsigned int v_degree       ( unsigned int v_index ) const;
00105     unsigned int v2f_size       ( unsigned int v_index ) const;
00106     unsigned int f_size         ( unsigned int f_index_in ) const;
00107     const unsigned int *f_index ( unsigned int f_index_in ) const;
00108 
00109     const std::vector<TopoFace> &getFaceVector( void ) const;
00110 
00111     Topology::VertexNeighborIterator
00112         vertexNeighborBegin( unsigned int v_index ) const;
00113     Topology::VertexNeighborIterator
00114         vertexNeighborEnd( unsigned int v_index ) const;
00115     Topology::FaceNeighborIterator
00116         faceNeighborBegin( unsigned int f_index ) const;
00117     Topology::FaceNeighborIterator
00118         faceNeighborEnd( unsigned int f_index ) const;
00119 
00120     void setVertexEqualityEpsilon(OSG::Real32 epsilon);
00121     void setVertexEqualityTest(bool status);
00122 
00123     void print( void ) const;
00124 
00125     virtual ~Topology() throw();
00126 
00127 //---------------------------------------------------------------------------
00128 //  Public Class methods
00129 //---------------------------------------------------------------------------
00130 
00131 //---------------------------------------------------------------------------
00132 //  Instance variables
00133 //---------------------------------------------------------------------------
00134 
00135 protected:
00136 
00140     std::vector< std::vector<unsigned int> >    m_v2f;
00141 
00145     std::vector<VertexNeighbors>                m_v2v;
00146 
00150     std::vector<FaceNeighbors>                  m_f2f;
00151 
00153     std::vector<TopoFace>                       m_f2v;
00154 
00161     std::vector<unsigned int>                   m_vEquivClass;
00162 
00163 //---------------------------------------------------------------------------
00164 //  Private Instance methods
00165 //---------------------------------------------------------------------------
00166 
00167 protected:
00168 
00169     void createRelations( void );
00170 
00171 };
00172 
00173 
00174 
00175 //***************************************************************************
00176 //  VertexIterator
00177 //***************************************************************************
00178 
00179 class COL_EXPORTIMPORT VertexIterator
00180 {
00181 public:
00182 
00183     VertexIterator( const Topology &topo, unsigned int v_index );
00184     VertexIterator( const VertexIterator &source );
00185     void operator = ( const VertexIterator &source );
00186 
00187     void operator ++ ( void );
00188     unsigned int operator * ( ) const;
00189     bool operator == ( const VertexIterator &other ) const;
00190     bool operator != ( const VertexIterator &other ) const;
00191 
00192 protected:
00193 
00195     const Topology * m_topo;
00196 
00198     unsigned int m_v_index;
00199 
00201     unsigned int m_neighbor;
00202 
00203 };
00204 
00205 
00206 } // namespace col
00207 
00208 #endif /* ColTopology_H */
00209 

Generated on Tue Oct 16 18:12:21 2007 for CollDet by  doxygen 1.5.2