Salome HOME
merge V5_1_4
[modules/smesh.git] / src / SMDS / SMDS_VtkCellIterator.cxx
1 #include "SMDS_VtkCellIterator.hxx"
2
3 SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId,
4                                            SMDSAbs_EntityType aType) :
5   _mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
6 {
7   vtkUnstructuredGrid* grid = _mesh->getGrid();
8   _vtkIdList = vtkIdList::New();
9   grid->GetCellPoints(_cellId, _vtkIdList);
10   _nbNodes = _vtkIdList->GetNumberOfIds();
11   vtkIdType tempid;
12   switch (_type)
13   {
14     case SMDSEntity_Tetra:
15       {
16         this->exchange(1, 2);
17         break;
18       }
19     case SMDSEntity_Pyramid:
20       {
21         this->exchange(1, 3);
22         break;
23       }
24     case SMDSEntity_Penta:
25       {
26         //this->exchange(1, 2);
27         //this->exchange(4, 5);
28         break;
29       }
30     case SMDSEntity_Hexa:
31       {
32         this->exchange(1, 3);
33         this->exchange(5, 7);
34         break;
35       }
36     case SMDSEntity_Quad_Tetra:
37       {
38         this->exchange(1, 2);
39         this->exchange(4, 6);
40         this->exchange(8, 9);
41         break;
42       }
43     case SMDSEntity_Quad_Pyramid:
44       {
45         this->exchange(1, 3);
46         this->exchange(5, 8);
47         this->exchange(6, 7);
48         this->exchange(10, 12);
49         break;
50       }
51     case SMDSEntity_Quad_Penta:
52       {
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);
58         break;
59       }
60     case SMDSEntity_Quad_Hexa:
61       {
62         this->exchange(1, 3);
63         this->exchange(5, 7);
64         this->exchange(8, 11);
65         this->exchange(9, 10);
66         this->exchange(12, 15);
67         this->exchange(13, 14);
68         this->exchange(17, 19);
69         break;
70       }
71     default:
72       break;
73   }
74 }
75
76 SMDS_VtkCellIterator::~SMDS_VtkCellIterator()
77 {
78   _vtkIdList->Delete();
79 }
80
81 bool SMDS_VtkCellIterator::more()
82 {
83   return (_index < _nbNodes);
84 }
85
86 const SMDS_MeshElement* SMDS_VtkCellIterator::next()
87 {
88   vtkIdType id = _vtkIdList->GetId(_index++);
89   return _mesh->FindNode(id);
90 }