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