1 // Copyright (C) 2010-2022 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 vtkIdType const *pts(nullptr);
35 grid->GetCellPoints( vtkCellId, npts, pts );
36 vtkIds.resize( npts );
37 if ( interlace.empty() )
39 vtkIds.assign( pts, pts + npts );
43 for (vtkIdType i = 0; i < npts; i++)
44 vtkIds[ i ] = pts[ interlace[i] ];
48 _GetVtkNodesToUNV::_GetVtkNodesToUNV( TVtkIdList& vtkIds,
51 SMDSAbs_EntityType type )
53 vtkUnstructuredGrid* grid = mesh->GetGrid();
55 vtkIdType const *pts(nullptr);
56 grid->GetCellPoints( vtkCellId, npts, pts );
60 case SMDSEntity_Quad_Edge:
62 static int id[] = { 0, 2, 1 };
66 case SMDSEntity_Quad_Triangle:
67 case SMDSEntity_BiQuad_Triangle:
69 static int id[] = { 0, 3, 1, 4, 2, 5 };
74 case SMDSEntity_Quad_Quadrangle:
75 case SMDSEntity_BiQuad_Quadrangle:
77 static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 };
82 case SMDSEntity_Quad_Tetra:
84 static int id[] = { 0, 4, 1, 5, 2, 6, 7, 8, 9, 3 };
88 case SMDSEntity_Quad_Pyramid:
90 static int id[] = { 0, 5, 1, 6, 2, 7, 3, 8, 9, 10, 11, 12, 4 };
94 case SMDSEntity_Penta:
96 static int id[] = { 0, 2, 1, 3, 5, 4 };
100 case SMDSEntity_Quad_Penta:
101 case SMDSEntity_BiQuad_Penta: //TODO: check
103 static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 };
107 case SMDSEntity_Quad_Hexa:
108 case SMDSEntity_TriQuad_Hexa:
110 static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 };
115 case SMDSEntity_Polygon:
116 case SMDSEntity_Quad_Polygon:
117 case SMDSEntity_Polyhedra:
118 case SMDSEntity_Quad_Polyhedra:
120 const std::vector<int>& i = SMDS_MeshCell::interlacedSmdsOrder( type, npts );
125 vtkIds.resize( npts );
128 for (int i = 0; i < npts; i++)
129 vtkIds[ i ] = pts[ ids[i] ];
131 vtkIds.assign( pts, pts + npts );
134 _GetVtkNodesPolyh::_GetVtkNodesPolyh( TVtkIdList& vtkIds,
137 SMDSAbs_EntityType type )
139 vtkUnstructuredGrid* grid = mesh->GetGrid();
142 case SMDSEntity_Polyhedra:
144 vtkIdType nFaces = 0;
145 vtkIdType const *ptIds(nullptr);
146 grid->GetFaceStream( vtkCellId, nFaces, ptIds );
147 int id = 0, nbNodesInFaces = 0;
148 for ( int i = 0; i < nFaces; i++ )
150 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
151 nbNodesInFaces += nodesInFace;
152 id += (nodesInFace + 1);
154 vtkIds.resize( nbNodesInFaces );
157 for ( int i = 0; i < nFaces; i++ )
159 int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
160 for ( int k = 1; k <= nodesInFace; k++ )
161 vtkIds[ n++ ] = ptIds[ id + k ];
162 id += (nodesInFace + 1);