00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MBPOLYGONCELLSSET_H
00024 #define _MBPOLYGONCELLSSET_H
00025
00026 #ifdef _WIN32
00027 #pragma warning(push)
00028 #pragma warning(disable:4250)
00029 #pragma warning(disable:4251)
00030 #endif
00031
00032 #include <MeshVizXLM/mesh/topology/MiSurfaceTopologyExplicitI.h>
00033 #include <topology/MbTopologyI.h>
00034 #include <cell/MbPolygonCell.h>
00035 #include <MbError.h>
00036
00037 #include <Inventor/STL/algorithm>
00038
00039
00045 class MbPolygonCellsSet : virtual public MiSurfaceTopologyExplicitI, public MbTopologyI
00046 {
00047 public:
00048
00052 MbPolygonCellsSet();
00053
00057 virtual const MbPolygonCell* getCell(size_t cellId) const;
00058
00062 virtual size_t getNumCells() const;
00063
00067 virtual size_t getBeginNodeId() const
00068 {
00069 return m_beginNodeId;
00070 }
00071
00075 virtual size_t getEndNodeId() const
00076 {
00077 return m_maxNodeId;
00078 }
00079
00085 template <typename _NodeIdIter, typename _numNodeIter>
00086 void assign(_NodeIdIter beginId, _NodeIdIter endId,_numNodeIter beginNum, _numNodeIter endNum);
00087
00088 private:
00089 std::vector<MbPolygonCell> m_cells;
00090 size_t m_beginNodeId;
00091 size_t m_maxNodeId;
00092
00093 };
00094
00095
00096
00097 inline
00098 MbPolygonCellsSet::MbPolygonCellsSet()
00099 : m_beginNodeId(0), m_maxNodeId(0)
00100 {
00101 }
00102
00103
00104 inline const MbPolygonCell*
00105 MbPolygonCellsSet::getCell(size_t cellId) const
00106 {
00107 #ifndef MBMESH_DONT_USE_ASSERT
00108 if (hasDeadCells() && isDead(cellId))
00109 throw MbError("accessing dead cells");
00110 #endif
00111 return &(m_cells[cellId]);
00112 }
00113
00114
00115 inline size_t
00116 MbPolygonCellsSet::getNumCells() const
00117 {
00118 return m_cells.size();
00119 }
00120
00121
00122 template <typename _NodeIdIter, typename _numNodeIter>
00123 inline void
00124 MbPolygonCellsSet::assign(_NodeIdIter beginId, _NodeIdIter endId,
00125 _numNodeIter beginNum, _numNodeIter endNum)
00126 {
00127 size_t numCells = std::distance(beginNum,endNum);
00128 m_beginNodeId = std::numeric_limits<size_t>::max();
00129 m_cells.reserve(numCells);
00130 _NodeIdIter itBeginPolyg = beginId;
00131 _NodeIdIter itEndPolyg;
00132 _numNodeIter it = beginNum;
00133 for(size_t i=0; i<numCells; i++)
00134 {
00135 itEndPolyg = (itBeginPolyg + *it);
00136 m_cells.push_back(MbPolygonCell(itBeginPolyg,itEndPolyg));
00137 for(size_t j=0; j<*it; j++)
00138 {
00139 if(*itBeginPolyg+1>m_maxNodeId) m_maxNodeId = *itBeginPolyg+1;
00140 if(*itBeginPolyg < m_beginNodeId) m_beginNodeId = *itBeginPolyg;
00141 itBeginPolyg++;
00142 }
00143 it++;
00144
00145 }
00146 m_timeStamp = MxTimeStamp::getTimeStamp();
00147 }
00148
00149 #ifdef _WIN32
00150 #pragma warning(pop)
00151 #endif
00152
00153 #endif
00154
00155