Salome HOME
Merge from V6_main 01/04/2013
[modules/med.git] / src / MEDMEM / MEDMEM_DriversDef.cxx
1 // Copyright (C) 2007-2013  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
23 #include "MEDMEM_DriversDef.hxx"
24
25 using namespace std;
26
27 namespace MED_EN {
28
29 // Returns the (string) name of the geometry of 
30 // an element given by a med_geometrie_element value
31 GEO_NAME::GEO_NAME() : map<int,string>()
32 {
33   map<int,string> &table  = (map<int,string>&)*this ;
34   table[(int)0 ] = "MED_NONE" ;
35   table[(int)MED_POINT1 ] = "MED_POINT1" ;
36   table[(int)MED_SEG2   ] = "MED_SEG2"   ;
37   table[(int)MED_SEG3   ] = "MED_SEG3"   ;
38   table[(int)MED_TRIA3  ] = "MED_TRIA3"  ;
39   table[(int)MED_TRIA6  ] = "MED_TRIA6"  ;
40   table[(int)MED_QUAD4  ] = "MED_QUAD4"  ;
41   table[(int)MED_QUAD8  ] = "MED_QUAD8"  ;
42   table[(int)MED_TETRA4 ] = "MED_TETRA4" ;
43   table[(int)MED_TETRA10] = "MED_TETRA10";
44   table[(int)MED_HEXA8  ] = "MED_HEXA8"  ;
45   table[(int)MED_HEXA20 ] = "MED_HEXA20" ;
46   table[(int)MED_PENTA6 ] = "MED_PENTA6" ;
47   table[(int)MED_PENTA15] = "MED_PENTA15";
48   table[(int)MED_PYRA5  ] = "MED_PYRA5"  ;
49   table[(int)MED_PYRA13 ] = "MED_PYRA13" ;
50   table[(int)MED_POLYGON] = "MED_POLYGON";
51   table[(int)MED_POLYHEDRA] = "MED_POLYHEDRA";
52   assert( table.find( (int)MED_POLYHEDRA ) != table.end() ) ;
53 }
54  
55 GEO_NAME::~GEO_NAME()
56 {
57 //   MESSAGE_MED(" destructor GEO_NAME::~GEO_NAME() "<< size() );
58 //   clear();
59 //   MESSAGE_MED(" end of destructor GEO_NAME::~GEO_NAME() "<< size() );
60 }
61  
62 string & GEO_NAME::operator[]( const MED_EN::medGeometryElement &c ) const
63 {
64   map<int,string> &table = (map<int,string>&)*this ;
65   assert( table.find( (int)c ) != table.end() ) ;
66   return table[ (int)c ] ;
67 }
68
69
70 // Returns the (string) name of the type of 
71 // an entity given by a med_entite_maillage value
72
73 ENT_NAME::ENT_NAME() : map<int,string>()
74 {
75   map<int,string> &table = (map<int,string>&)*this ;
76   table[(int)MED_CELL ] = "MED_MAILLE";
77   table[(int)MED_FACE   ] = "MED_FACE"; 
78   table[(int)MED_EDGE  ] = "MED_ARETE";
79   table[(int)MED_NODE  ] = "MED_NOEUD";
80 }
81
82 ENT_NAME::~ENT_NAME()
83 {
84 //   MESSAGE_MED(" destructor ENT_NAME::~ENT_NAME() "<< size() );
85 //   clear();
86 //   MESSAGE_MED(" end of destructor ENT_NAME::~ENT_NAME() "<< size() );
87 }
88
89 string & ENT_NAME::operator[]( const MED_EN::medEntityMesh &c ) const
90 {
91   map<int,string> &table = (map<int,string>&)*this ;
92   assert( table.find( (int)c ) != table.end() ) ;
93   return table[ (int)c ] ;
94 }
95
96 MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<MED_EN::medGeometryElement> >() 
97 {
98   // Override the const declaration in order to used the find method below
99   //  map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ; unused local variable
100   
101   // Initialize the value associated with the ROUGE_ key ( use the private operator = )
102   {
103     const MED_EN::medGeometryElement T[] =  {
104       MED_POINT1,
105       MED_SEG2,
106       MED_SEG3,
107       MED_TRIA3,
108       MED_QUAD4,
109       MED_TRIA6,
110       MED_QUAD8,
111       MED_TETRA4,
112       MED_PYRA5,
113       MED_PENTA6,
114       MED_HEXA8,
115       MED_TETRA10,
116       MED_PYRA13,
117       MED_PENTA15,
118       MED_HEXA20,
119       MED_POLYGON,
120       MED_POLYHEDRA};
121
122     list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
123     (*this)[MED_CELL] = geomList;
124   }
125   
126   {
127     const MED_EN::medGeometryElement T[] =  {
128       MED_TRIA3,
129       MED_QUAD4,
130       MED_TRIA6,
131       MED_QUAD8,
132       MED_POLYGON};
133
134     list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
135     (*this)[MED_FACE] = geomList; 
136   }
137   
138   {
139     const MED_EN::medGeometryElement T[] =  {
140       MED_SEG2,
141       MED_SEG3 };
142
143     list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
144     (*this)[MED_EDGE] = geomList; 
145   }
146   
147   {
148     //    const med_geometrie_element T[] =  { MED_NONE };
149     const MED_EN::medGeometryElement T[] =  { (MED_EN::medGeometryElement)0 };
150     list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
151     (*this)[MED_NODE] = geomList; 
152   }
153   
154 }
155
156 MESH_ENTITIES::~MESH_ENTITIES()
157 {
158 //   MESSAGE_MED(" destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
159 //   clear();
160 //   MESSAGE_MED(" end of destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
161 }
162
163 const list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c ) const
164 {
165   map<int,const list<MED_EN::medGeometryElement> > &table = (map<int,const list<MED_EN::medGeometryElement> >&)*this ;
166   // Verify the object already exists in the map
167   assert( table.find( (int)c ) != table.end() ) ;
168   return table[ (int)c ] ;
169 }
170
171 // This operator is used to initialize class objects of type  const list<med_geometrie_element>
172 list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c )
173 {
174   return (list<MED_EN::medGeometryElement> &) this->map<int,const list<MED_EN::medGeometryElement> >::operator[]( (int)c) ;
175 }
176
177 } // End Of NampeSpace MED_EN
178