1 #include "SMDS_VtkCellIterator.hxx"
4 SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
5 _mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
7 //MESSAGE("SMDS_VtkCellIterator " << _type);
8 _vtkIdList = vtkIdList::New();
9 vtkUnstructuredGrid* grid = _mesh->getGrid();
10 grid->GetCellPoints(_cellId, _vtkIdList);
11 _nbNodes = _vtkIdList->GetNumberOfIds();
14 case SMDSEntity_Tetra:
19 case SMDSEntity_Pyramid:
24 case SMDSEntity_Penta:
26 //this->exchange(1, 2);
27 //this->exchange(4, 5);
36 case SMDSEntity_Quad_Tetra:
43 case SMDSEntity_Quad_Pyramid:
48 this->exchange(10, 12);
51 case SMDSEntity_Quad_Penta:
53 //this->exchange(1, 2);
54 //this->exchange(4, 5);
55 //this->exchange(6, 8);
56 //this->exchange(9, 11);
57 //this->exchange(13, 14);
60 case SMDSEntity_Quad_Hexa:
62 MESSAGE("SMDS_VtkCellIterator Quad_Hexa");
65 this->exchange(8, 11);
66 this->exchange(9, 10);
67 this->exchange(12, 15);
68 this->exchange(13, 14);
69 this->exchange(17, 19);
72 case SMDSEntity_Polyhedra:
73 MESSAGE("SMDS_VtkCellIterator Polyhedra (iterate on actual nodes)");
80 SMDS_VtkCellIterator::~SMDS_VtkCellIterator()
85 bool SMDS_VtkCellIterator::more()
87 return (_index < _nbNodes);
90 const SMDS_MeshElement* SMDS_VtkCellIterator::next()
92 vtkIdType id = _vtkIdList->GetId(_index++);
93 return _mesh->FindNodeVtk(id);
96 SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
97 SMDS_VtkCellIterator()
103 //MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type);
105 _vtkIdList = vtkIdList::New();
107 vtkUnstructuredGrid* grid = _mesh->getGrid();
108 grid->GetCellPoints((vtkIdType)_cellId, (vtkIdType&)_nbNodes, pts);
109 _vtkIdList->SetNumberOfIds(_nbNodes);
113 case SMDSEntity_Quad_Edge:
115 static int id[] = { 0, 2, 1 };
119 case SMDSEntity_Quad_Triangle:
121 static int id[] = { 0, 3, 1, 4, 2, 5 };
125 case SMDSEntity_Quad_Quadrangle:
127 static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
131 case SMDSEntity_Quad_Tetra:
133 static int id[] = { 0, 4, 1, 5, 2, 6, 7, 8, 9, 3 };
137 case SMDSEntity_Quad_Pyramid:
139 static int id[] = { 0, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11, 12, 4 };
143 case SMDSEntity_Penta:
145 static int id[] = { 0, 2, 1, 3, 5, 4 };
149 case SMDSEntity_Quad_Penta:
151 static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 };
155 case SMDSEntity_Quad_Hexa:
157 static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 };
161 case SMDSEntity_Polygon:
162 case SMDSEntity_Quad_Polygon:
163 case SMDSEntity_Polyhedra:
164 case SMDSEntity_Quad_Polyhedra:
167 static int id[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
168 25, 26, 27, 28, 29 };
173 //MESSAGE("_nbNodes " << _nbNodes);
174 for (int i = 0; i < _nbNodes; i++)
175 _vtkIdList->SetId(i, pts[ids[i]]);
178 SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV()
182 SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
183 SMDS_VtkCellIterator()
189 //MESSAGE("SMDS_VtkCellIteratorPolyH " << _type);
190 _vtkIdList = vtkIdList::New();
191 vtkUnstructuredGrid* grid = _mesh->getGrid();
192 grid->GetCellPoints(_cellId, _vtkIdList);
193 _nbNodes = _vtkIdList->GetNumberOfIds();
196 case SMDSEntity_Polyhedra:
198 //MESSAGE("SMDS_VtkCellIterator Polyhedra");
199 vtkIdType nFaces = 0;
200 vtkIdType* ptIds = 0;
201 grid->GetFaceStream(_cellId, nFaces, ptIds);
204 for (int i = 0; i < nFaces; i++)
206 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
207 _nbNodesInFaces += nodesInFace;
208 id += (nodesInFace + 1);
210 _vtkIdList->SetNumberOfIds(_nbNodesInFaces);
213 for (int i = 0; i < nFaces; i++)
215 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
216 for (int k = 1; k <= nodesInFace; k++)
217 _vtkIdList->SetId(n++, ptIds[id + k]);
218 id += (nodesInFace + 1);
227 SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH()
231 bool SMDS_VtkCellIteratorPolyH::more()
233 return (_index < _nbNodesInFaces);