00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MBHEXAHEDRONCELLSSET_H
00024 #define _MBHEXAHEDRONCELLSSET_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/MbHexahedronCell.h>
00035 #include <MbError.h>
00036
00037 #include <Inventor/STL/algorithm>
00038
00044 class MbHexahedronCellsSet : virtual public MiVolumeTopologyExplicitI, public MbTopologyI
00045 {
00046 public:
00047
00051 MbHexahedronCellsSet();
00052
00057 template <typename _NodeIdIter>
00058 void assign(_NodeIdIter beginId, _NodeIdIter endId);
00059
00063 virtual const MbHexahedronCell* getCell(size_t cellId) const;
00064
00068 virtual size_t getNumCells() const;
00069
00073 virtual size_t getBeginNodeId() const
00074 {
00075 return m_beginNodeId;
00076 }
00077
00081 virtual size_t getEndNodeId() const
00082 {
00083 return m_endNodeId;
00084 }
00085
00086 private:
00087 std::vector<MbHexahedronCell> m_cells;
00088 size_t m_beginNodeId;
00089 size_t m_endNodeId;
00090 };
00091
00092
00093
00094 inline
00095 MbHexahedronCellsSet::MbHexahedronCellsSet()
00096 : m_beginNodeId(0), m_endNodeId(0)
00097 {
00098 }
00099
00100
00101
00102 inline const MbHexahedronCell*
00103 MbHexahedronCellsSet::getCell(size_t cellId) const
00104 {
00105 #ifndef MBMESH_DONT_USE_ASSERT
00106 if (hasDeadCells() && isDead(cellId))
00107 throw MbError("accessing dead cells");
00108 #endif
00109 return &(m_cells[cellId]);
00110 }
00111
00112
00113 inline size_t
00114 MbHexahedronCellsSet::getNumCells() const
00115 {
00116 return m_cells.size();
00117 }
00118
00119
00120 template <typename _NodeIdIter>
00121 inline void
00122 MbHexahedronCellsSet::assign(_NodeIdIter beginId, _NodeIdIter endId)
00123 {
00124 size_t numIds = std::distance(beginId,endId);
00125 size_t numCells = (numIds - numIds%8)/8;
00126 m_beginNodeId = std::numeric_limits<size_t>::max();
00127
00128 m_cells.clear();
00129 m_cells.reserve(numCells);
00130 _NodeIdIter it = beginId;
00131 size_t i, node[8];
00132 for (i=0; i<numCells; ++i)
00133 {
00134 for(size_t n=0; n<8; n++){
00135 node[n] = *it++;
00136 if(node[n]+1 > m_endNodeId) m_endNodeId = node[n]+1;
00137 if(node[n] < m_beginNodeId) m_beginNodeId = node[n];
00138 }
00139 m_cells.push_back(MbHexahedronCell(node[0],node[1],node[2],node[3],node[4],node[5],node[6],node[7]));
00140 }
00141 m_timeStamp = MxTimeStamp::getTimeStamp();
00142 }
00143
00144 #ifdef _WIN32
00145 #pragma warning(pop)
00146 #endif
00147
00148 #endif
00149
00150