1 // Copyright (C) 2007-2013 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.
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 __MEDNORMALIZEDUNSTRUCTUREDMESH_TXX__
20 #define __MEDNORMALIZEDUNSTRUCTUREDMESH_TXX__
22 #include "MEDNormalizedUnstructuredMesh.hxx"
23 #include "InterpKernelException.hxx"
25 #include "MEDMEM_Mesh.hxx"
27 template<int SPACEDIM,int MESHDIM>
28 MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDNormalizedUnstructuredMesh(const MEDMEM::MESH *mesh):_meshInMedMode(mesh),
30 _own_conn_for_interp(false),
31 _conn_index_for_interp(0),
32 _own_conn_index_for_interp(false)
37 template<int SPACEDIM,int MESHDIM>
38 MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::~MEDNormalizedUnstructuredMesh()
43 template<int SPACEDIM,int MESHDIM>
44 void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getBoundingBox(double *boundingBox) const
46 vector< vector<double> > ret=_meshInMedMode->getBoundingBox();
49 for(i=0;i<SPACEDIM;i++)
50 boundingBox[i]=ret[0][i];
51 for(i=0;i<SPACEDIM;i++)
52 boundingBox[i+SPACEDIM]=ret[1][i];
55 template<int SPACEDIM,int MESHDIM>
56 INTERP_KERNEL::NormalizedCellType MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getTypeOfElement(int eltId) const
58 MED_EN::medGeometryElement type=_meshInMedMode->getElementType(MED_EN::MED_CELL,eltId);
59 if(type==MED_EN::MED_POLYGON)
60 return INTERP_KERNEL::NORM_POLYGON;
61 if(type==MED_EN::MED_POLYHEDRA)
62 return INTERP_KERNEL::NORM_POLYHED;
63 return (INTERP_KERNEL::NormalizedCellType)(((unsigned long)type/100-2)*10+((unsigned long)type%100));
66 template<int SPACEDIM,int MESHDIM>
67 unsigned char MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(int eltId) const
69 if(_meshInMedMode->getElementType(MED_EN::MED_CELL,eltId)!=MED_EN::MED_POLYHEDRA)
70 return (unsigned char) (_conn_index_for_interp[eltId]-_conn_index_for_interp[eltId-1]);
73 return (unsigned char)(_conn_index_for_interp[eltId]-_conn_index_for_interp[eltId-1])-
74 std::count(_conn_for_interp+_conn_index_for_interp[eltId-1]-1,_conn_for_interp+_conn_index_for_interp[eltId]-1,-1);
78 template<int SPACEDIM,int MESHDIM>
79 unsigned long MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const
81 return _meshInMedMode->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
84 template<int SPACEDIM,int MESHDIM>
85 unsigned long MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const
87 return _meshInMedMode->getNumberOfNodes();
90 template<int SPACEDIM,int MESHDIM>
91 const int *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityPtr() const
93 return _conn_for_interp;
96 template<int SPACEDIM,int MESHDIM>
97 const double *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getCoordinatesPtr() const
99 return _meshInMedMode->getCoordinates(MED_EN::MED_FULL_INTERLACE);
102 template<int SPACEDIM,int MESHDIM>
103 const int *MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityIndexPtr() const
105 return _conn_index_for_interp;
108 template<int SPACEDIM,int MESHDIM>
109 void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::releaseTempArrays()
111 if(_own_conn_for_interp)
112 delete [] _conn_for_interp;
113 if(_own_conn_index_for_interp)
114 delete [] _conn_index_for_interp;
116 _conn_index_for_interp=0;
117 _own_conn_for_interp=false;
118 _own_conn_index_for_interp=false;
121 template<int SPACEDIM,int MESHDIM>
122 void MEDNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::prepare()
125 _conn_for_interp=(int *)_meshInMedMode->getConnectivity(MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS);
126 _own_conn_for_interp=false;
127 _conn_index_for_interp=(int *)_meshInMedMode->getConnectivityIndex(MED_EN::MED_NODAL, MED_EN::MED_CELL);
128 _own_conn_index_for_interp=false;