1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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
19 // Author : Anthony Geay (CEA/DEN)
20 #ifndef __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
21 #define __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
23 #include "VTKNormalizedUnstructuredMesh.hxx"
25 #include "vtkUnstructuredGrid.h"
26 #include "vtkCellArray.h"
27 #include "vtkPoints.h"
30 VTKNormalizedUnstructuredMesh<MESHDIM>::VTKNormalizedUnstructuredMesh(vtkUnstructuredGrid *mesh):_mesh_in_vtk_mode(mesh),
36 VTKNormalizedUnstructuredMesh<MESHDIM>::~VTKNormalizedUnstructuredMesh()
38 _mesh_in_vtk_mode->Delete();
43 void VTKNormalizedUnstructuredMesh<MESHDIM>::getBoundingBox(double *boundingBox) const
46 _mesh_in_vtk_mode->GetBounds(tmp);
47 for(unsigned i=0;i<3;i++)
49 boundingBox[i]=tmp[2*i];
50 boundingBox[3+i]=tmp[2*i+1];
55 NormalizedCellType VTKNormalizedUnstructuredMesh<MESHDIM>::getTypeOfElement(vtkIdType eltId) const
57 int cellType=_mesh_in_vtk_mode->GetCellType(eltId);
58 int convTab[30]={0,0,0,0,0,(int)NORM_TRI3,0,(int)NORM_POLYGON,0,(int)NORM_QUAD4,(int)NORM_TETRA4,0,(int)NORM_HEXA8
59 0,(int)NORM_PYRA5,0,0,0,(int)NORM_TRI6,(int)NORM_QUAD8,};
63 unsigned long VTKNormalizedUnstructuredMesh<MESHDIM>::getNumberOfElements() const
65 return _mesh_in_vtk_mode->GetNumberOfCells();
69 unsigned long VTKNormalizedUnstructuredMesh<MESHDIM>::getNumberOfNodes() const
71 return _mesh_in_vtk_mode->GetNumberOfPoints();
75 const vtkIdType *VTKNormalizedUnstructuredMesh<MESHDIM>::getConnectivityPtr() const
77 vtkIdType *ret=_mesh_in_vtk_mode->GetCells()->GetPointer();
88 const double *VTKNormalizedUnstructuredMesh<MESHDIM>::getCoordinatesPtr() const
90 return (const double *)_mesh_in_vtk_mode->GetPoints()->GetVoidPointer(0);
94 const vtkIdType *VTKNormalizedUnstructuredMesh<MESHDIM>::getConnectivityIndexPtr() const
97 return _tmp_index_array;
101 return _tmp_index_array;
105 template<int MESHDIM>
106 void VTKNormalizedUnstructuredMesh<MESHDIM>::putinMEDFormat() const
108 long nbOfElem=getNumberOfElements();
109 _tmp_index_array=new vtkIdType[nbOfElem+1];
110 _tmp_index_array[0]=0;
111 vtkIdType *coarseConn=_mesh_in_vtk_mode->GetCells()->GetPointer();
113 vtkIdType *finalConn=coarseConn;
114 for(long i=0;i<nbOfElem;i++)
116 vtkIdType cellLgth=coarseConn[ptInCC];
117 for(vtkIdType j=0;j<cellLgth;j++)
118 *finalConn++=coarseConn[ptInCC+j+1];
119 _tmp_index_array[i+1]=_tmp_index_array[i]+cellLgth;
126 template<int MESHDIM>
127 void VTKNormalizedUnstructuredMesh<MESHDIM>::releaseTempArrays()
129 delete [] _tmp_index_array;