1 // Copyright (C) 2007-2012 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.
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 #ifndef __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
20 #define __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
22 #include "VTKNormalizedUnstructuredMesh.hxx"
24 #include "vtkUnstructuredGrid.h"
25 #include "vtkCellArray.h"
26 #include "vtkPoints.h"
29 VTKNormalizedUnstructuredMesh<MESHDIM>::VTKNormalizedUnstructuredMesh(vtkUnstructuredGrid *mesh):_mesh_in_vtk_mode(mesh),
35 VTKNormalizedUnstructuredMesh<MESHDIM>::~VTKNormalizedUnstructuredMesh()
37 _mesh_in_vtk_mode->Delete();
42 void VTKNormalizedUnstructuredMesh<MESHDIM>::getBoundingBox(double *boundingBox) const
45 _mesh_in_vtk_mode->GetBounds(tmp);
46 for(unsigned i=0;i<3;i++)
48 boundingBox[i]=tmp[2*i];
49 boundingBox[3+i]=tmp[2*i+1];
54 NormalizedCellType VTKNormalizedUnstructuredMesh<MESHDIM>::getTypeOfElement(vtkIdType eltId) const
56 int cellType=_mesh_in_vtk_mode->GetCellType(eltId);
57 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
58 0,(int)NORM_PYRA5,0,0,0,(int)NORM_TRI6,(int)NORM_QUAD8,};
62 unsigned long VTKNormalizedUnstructuredMesh<MESHDIM>::getNumberOfElements() const
64 return _mesh_in_vtk_mode->GetNumberOfCells();
68 unsigned long VTKNormalizedUnstructuredMesh<MESHDIM>::getNumberOfNodes() const
70 return _mesh_in_vtk_mode->GetNumberOfPoints();
74 const vtkIdType *VTKNormalizedUnstructuredMesh<MESHDIM>::getConnectivityPtr() const
76 vtkIdType *ret=_mesh_in_vtk_mode->GetCells()->GetPointer();
87 const double *VTKNormalizedUnstructuredMesh<MESHDIM>::getCoordinatesPtr() const
89 return (const double *)_mesh_in_vtk_mode->GetPoints()->GetVoidPointer(0);
93 const vtkIdType *VTKNormalizedUnstructuredMesh<MESHDIM>::getConnectivityIndexPtr() const
96 return _tmp_index_array;
100 return _tmp_index_array;
104 template<int MESHDIM>
105 void VTKNormalizedUnstructuredMesh<MESHDIM>::putinMEDFormat() const
107 long nbOfElem=getNumberOfElements();
108 _tmp_index_array=new vtkIdType[nbOfElem+1];
109 _tmp_index_array[0]=0;
110 vtkIdType *coarseConn=_mesh_in_vtk_mode->GetCells()->GetPointer();
112 vtkIdType *finalConn=coarseConn;
113 for(long i=0;i<nbOfElem;i++)
115 vtkIdType cellLgth=coarseConn[ptInCC];
116 for(vtkIdType j=0;j<cellLgth;j++)
117 *finalConn++=coarseConn[ptInCC+j+1];
118 _tmp_index_array[i+1]=_tmp_index_array[i]+cellLgth;
125 template<int MESHDIM>
126 void VTKNormalizedUnstructuredMesh<MESHDIM>::releaseTempArrays()
128 delete [] _tmp_index_array;