Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_DriversDef.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #include "MEDMEM_DriversDef.hxx"
23
24 using namespace std;
25
26 namespace MED_EN {
27
28 // Returns the (string) name of the geometry of 
29 // an element given by a med_geometrie_element value
30 GEO_NAME::GEO_NAME() : map<int,string>()
31 {
32   map<int,string> &table  = (map<int,string>&)*this ;
33   table[(int)0 ] = "MED_NONE" ;
34   table[(int)MED_POINT1 ] = "MED_POINT1" ;
35   table[(int)MED_SEG2   ] = "MED_SEG2"   ;
36   table[(int)MED_SEG3   ] = "MED_SEG3"   ;
37   table[(int)MED_TRIA3  ] = "MED_TRIA3"  ;
38   table[(int)MED_TRIA6  ] = "MED_TRIA6"  ;
39   table[(int)MED_QUAD4  ] = "MED_QUAD4"  ;
40   table[(int)MED_QUAD8  ] = "MED_QUAD8"  ;
41   table[(int)MED_TETRA4 ] = "MED_TETRA4" ;
42   table[(int)MED_TETRA10] = "MED_TETRA10";
43   table[(int)MED_HEXA8  ] = "MED_HEXA8"  ;
44   table[(int)MED_HEXA20 ] = "MED_HEXA20" ;
45   table[(int)MED_PENTA6 ] = "MED_PENTA6" ;
46   table[(int)MED_PENTA15] = "MED_PENTA15";
47   table[(int)MED_PYRA5  ] = "MED_PYRA5"  ;
48   table[(int)MED_PYRA13 ] = "MED_PYRA13" ;
49   table[(int)MED_POLYGON] = "MED_POLYGON";
50   table[(int)MED_POLYHEDRA] = "MED_POLYHEDRA";
51   assert( table.find( (int)MED_POLYHEDRA ) != table.end() ) ;
52 }
53  
54 GEO_NAME::~GEO_NAME()
55 {
56 //   MESSAGE_MED(" destructor GEO_NAME::~GEO_NAME() "<< size() );
57 //   clear();
58 //   MESSAGE_MED(" end of destructor GEO_NAME::~GEO_NAME() "<< size() );
59 }
60  
61 string & GEO_NAME::operator[]( const MED_EN::medGeometryElement &c ) const
62 {
63   map<int,string> &table = (map<int,string>&)*this ;
64   assert( table.find( (int)c ) != table.end() ) ;
65   return table[ (int)c ] ;
66 }
67
68
69 // Returns the (string) name of the type of 
70 // an entity given by a med_entite_maillage value
71
72 ENT_NAME::ENT_NAME() : map<int,string>()
73 {
74   map<int,string> &table = (map<int,string>&)*this ;
75   table[(int)MED_CELL ] = "MED_MAILLE";
76   table[(int)MED_FACE   ] = "MED_FACE"; 
77   table[(int)MED_EDGE  ] = "MED_ARETE";
78   table[(int)MED_NODE  ] = "MED_NOEUD";
79 }
80
81 ENT_NAME::~ENT_NAME()
82 {
83 //   MESSAGE_MED(" destructor ENT_NAME::~ENT_NAME() "<< size() );
84 //   clear();
85 //   MESSAGE_MED(" end of destructor ENT_NAME::~ENT_NAME() "<< size() );
86 }
87
88 string & ENT_NAME::operator[]( const MED_EN::medEntityMesh &c ) const
89 {
90   map<int,string> &table = (map<int,string>&)*this ;
91   assert( table.find( (int)c ) != table.end() ) ;
92   return table[ (int)c ] ;
93 }
94
95 MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<MED_EN::medGeometryElement> >() 
96 {
97   // Override the const declaration in order to used the find method below
98   //  map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ; unused local variable
99   
100   // Initialize the value associated with the ROUGE_ key ( use the private operator = )
101   {
102     const MED_EN::medGeometryElement T[] =  {
103       MED_POINT1,
104       MED_SEG2,
105       MED_SEG3,
106       MED_TRIA3,
107       MED_QUAD4,
108       MED_TRIA6,
109       MED_QUAD8,
110       MED_TETRA4,
111       MED_PYRA5,
112       MED_PENTA6,
113       MED_HEXA8,
114       MED_TETRA10,
115       MED_PYRA13,
116       MED_PENTA15,
117       MED_HEXA20,
118       MED_POLYGON,
119       MED_POLYHEDRA};
120
121     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
122     (*this)[MED_CELL] = geomList;
123   }
124   
125   {
126     const MED_EN::medGeometryElement T[] =  {
127       MED_TRIA3,
128       MED_QUAD4,
129       MED_TRIA6,
130       MED_QUAD8,
131       MED_POLYGON};
132
133     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
134     (*this)[MED_FACE] = geomList; 
135   }
136   
137   {
138     const MED_EN::medGeometryElement T[] =  {
139       MED_SEG2,
140       MED_SEG3 };
141
142     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
143     (*this)[MED_EDGE] = geomList; 
144   }
145   
146   {
147     //    const med_geometrie_element T[] =  { MED_NONE };
148     const MED_EN::medGeometryElement T[] =  { (MED_EN::medGeometryElement)0 };
149     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
150     (*this)[MED_NODE] = geomList; 
151   }
152   
153 }
154
155 MESH_ENTITIES::~MESH_ENTITIES()
156 {
157 //   MESSAGE_MED(" destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
158 //   clear();
159 //   MESSAGE_MED(" end of destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
160 }
161
162 const list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c ) const
163 {
164   map<int,const list<MED_EN::medGeometryElement> > &table = (map<int,const list<MED_EN::medGeometryElement> >&)*this ;
165   // Verify the object already exists in the map
166   assert( table.find( (int)c ) != table.end() ) ;
167   return table[ (int)c ] ;
168 }
169
170 // This operator is used to initialize class objects of type  const list<med_geometrie_element>
171 list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c )
172 {
173   return (list<MED_EN::medGeometryElement> &) this->map<int,const list<MED_EN::medGeometryElement> >::operator[]( (int)c) ;
174 }
175
176 } // End Of NampeSpace MED_EN
177