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