00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MBTETRAHEDRONCELLSSET_H
00024 #define _MBTETRAHEDRONCELLSSET_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/MiVolumeTopologyExplicitI.h>
00033 #include <topology/MbTopologyI.h>
00034 #include <cell/MbTetrahedronCell.h>
00035 #include <MbError.h>
00036
00037 #include <Inventor/STL/algorithm>
00038
00039
00045 class MbTetrahedronCellsSet : virtual public MiVolumeTopologyExplicitI, public MbTopologyI
00046 {
00047 public:
00048
00052 MbTetrahedronCellsSet();
00053
00058 template <typename _NodeIdIter>
00059 void assign(_NodeIdIter beginId, _NodeIdIter endId);
00060
00064 virtual const MbTetrahedronCell* getCell(size_t id) const;
00065
00066
00070 virtual size_t getNumCells() const;
00071
00075 virtual size_t getBeginNodeId() const
00076 {
00077 return m_beginNodeId;
00078 }
00079
00083 virtual size_t getEndNodeId() const
00084 {
00085 return m_endNodeId;
00086 }
00087
00088 private:
00089 std::vector<MbTetrahedronCell> m_cells;
00090 size_t m_endNodeId;
00091 size_t m_beginNodeId;
00092 };
00093
00094
00095
00096 inline
00097 MbTetrahedronCellsSet::MbTetrahedronCellsSet()
00098 : m_endNodeId(0),m_beginNodeId(0)
00099 {
00100 }
00101
00102
00103
00104 inline const MbTetrahedronCell*
00105 MbTetrahedronCellsSet::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 MbTetrahedronCellsSet::getNumCells() const
00117 {
00118 return m_cells.size();
00119 }
00120
00121
00122 template <typename _NodeIdIter>
00123 inline void
00124 MbTetrahedronCellsSet::assign(_NodeIdIter beginId, _NodeIdIter endId)
00125 {
00126 size_t numIds = std::distance(beginId,endId);
00127 size_t numCells = (numIds - numIds%4)/4;
00128
00129 m_beginNodeId = std::numeric_limits<size_t>::max();
00130 m_cells.clear();
00131 m_cells.reserve(numCells);
00132 _NodeIdIter it = beginId;
00133 size_t i, node[4];
00134 for (i=0; i<numCells; ++i)
00135 {
00136 for (size_t j = 0; j < 4; ++j,++it)
00137 {
00138 node[j] = *it;
00139 if (*it+1 > m_endNodeId) m_endNodeId = *it+1;
00140 if (*it < m_beginNodeId) m_beginNodeId = *it;
00141 }
00142 m_cells.push_back(MbTetrahedronCell(node[0],node[1],node[2],node[3]));
00143 }
00144 m_timeStamp = MxTimeStamp::getTimeStamp();
00145 }
00146
00147 #ifdef _WIN32
00148 #pragma warning(pop)
00149 #endif
00150
00151 #endif
00152
00153