1 // Copyright (C) 2010-2019 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( TVtkIdList& vtkIds,
29 SMDSAbs_EntityType type )
31 vtkUnstructuredGrid* grid = mesh->GetGrid();
32 const std::vector<int>& interlace = SMDS_MeshCell::fromVtkOrder( type );
34 grid->GetCellPoints( vtkCellId, npts, pts );
35 vtkIds.resize( npts );
36 if ( interlace.empty() )
38 vtkIds.assign( pts, pts + npts );
42 for (vtkIdType i = 0; i < npts; i++)
43 vtkIds[ i ] = pts[ interlace[i] ];
47 _GetVtkNodesToUNV::_GetVtkNodesToUNV( TVtkIdList& vtkIds,
50 SMDSAbs_EntityType type )
52 vtkUnstructuredGrid* grid = mesh->GetGrid();
54 grid->GetCellPoints( 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( type, npts );
123 vtkIds.resize( npts );
126 for (int i = 0; i < npts; i++)
127 vtkIds[ i ] = pts[ ids[i] ];
129 vtkIds.assign( pts, pts + npts );
132 _GetVtkNodesPolyh::_GetVtkNodesPolyh( TVtkIdList& vtkIds,
135 SMDSAbs_EntityType type )
137 vtkUnstructuredGrid* grid = mesh->GetGrid();
140 case SMDSEntity_Polyhedra:
142 vtkIdType nFaces = 0;
143 vtkIdType* ptIds = 0;
144 grid->GetFaceStream( vtkCellId, nFaces, ptIds );
145 int id = 0, nbNodesInFaces = 0;
146 for ( int i = 0; i < nFaces; i++ )
148 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
149 nbNodesInFaces += nodesInFace;
150 id += (nodesInFace + 1);
152 vtkIds.resize( nbNodesInFaces );
155 for ( int i = 0; i < nFaces; i++ )
157 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
158 for ( int k = 1; k <= nodesInFace; k++ )
159 vtkIds[ n++ ] = ptIds[ id + k ];
160 id += (nodesInFace + 1);