1 // Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SMDS_VtkCellIterator.hxx"
21 #include "utilities.h"
24 #include <vtkIdList.h>
26 _GetVtkNodes::_GetVtkNodes( vtkIdList* _vtkIdList,
29 SMDSAbs_EntityType aType )
31 vtkUnstructuredGrid* grid = mesh->GetGrid();
32 const std::vector<int>& interlace = SMDS_MeshCell::fromVtkOrder( aType );
33 if ( interlace.empty() )
35 grid->GetCellPoints( vtkCellId, _vtkIdList );
40 grid->GetCellPoints( vtkCellId, npts, pts );
41 _vtkIdList->SetNumberOfIds( npts );
42 for (int i = 0; i < npts; i++)
43 _vtkIdList->SetId(i, pts[interlace[i]]);
47 _GetVtkNodesToUNV::_GetVtkNodesToUNV( vtkIdList* _vtkIdList,
50 SMDSAbs_EntityType aType )
52 vtkIdType * pts, npts;
53 vtkUnstructuredGrid* grid = mesh->GetGrid();
54 grid->GetCellPoints( (vtkIdType)vtkCellId, npts, pts );
58 case SMDSEntity_Quad_Edge:
60 static int id[] = { 0, 2, 1 };
64 case SMDSEntity_Quad_Triangle:
65 case SMDSEntity_BiQuad_Triangle:
67 static int id[] = { 0, 3, 1, 4, 2, 5 };
72 case SMDSEntity_Quad_Quadrangle:
73 case SMDSEntity_BiQuad_Quadrangle:
75 static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
80 case SMDSEntity_Quad_Tetra:
82 static int id[] = { 0, 4, 1, 5, 2, 6, 7, 8, 9, 3 };
86 case SMDSEntity_Quad_Pyramid:
88 static int id[] = { 0, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11, 12, 4 };
92 case SMDSEntity_Penta:
94 static int id[] = { 0, 2, 1, 3, 5, 4 };
98 case SMDSEntity_Quad_Penta:
99 case SMDSEntity_BiQuad_Penta: //TODO: check
101 static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 };
105 case SMDSEntity_Quad_Hexa:
106 case SMDSEntity_TriQuad_Hexa:
108 static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 };
113 case SMDSEntity_Polygon:
114 case SMDSEntity_Quad_Polygon:
115 case SMDSEntity_Polyhedra:
116 case SMDSEntity_Quad_Polyhedra:
118 const std::vector<int>& i = SMDS_MeshCell::interlacedSmdsOrder( aType, npts );
123 _vtkIdList->SetNumberOfIds( npts );
126 for (int i = 0; i < npts; i++)
127 _vtkIdList->SetId(i, pts[ids[i]]);
129 for (int i = 0; i < npts; i++)
130 _vtkIdList->SetId(i, pts[i]);
133 _GetVtkNodesPolyh::_GetVtkNodesPolyh( vtkIdList* _vtkIdList,
136 SMDSAbs_EntityType aType )
138 vtkUnstructuredGrid* grid = mesh->GetGrid();
141 case SMDSEntity_Polyhedra:
143 vtkIdType nFaces = 0;
144 vtkIdType* ptIds = 0;
145 grid->GetFaceStream( vtkCellId, nFaces, ptIds );
146 int id = 0, nbNodesInFaces = 0;
147 for (int i = 0; i < nFaces; i++)
149 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
150 nbNodesInFaces += nodesInFace;
151 id += (nodesInFace + 1);
153 _vtkIdList->SetNumberOfIds( nbNodesInFaces );
156 for (int i = 0; i < nFaces; i++)
158 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
159 for (int k = 1; k <= nodesInFace; k++)
160 _vtkIdList->SetId(n++, ptIds[id + k]);
161 id += (nodesInFace + 1);