Salome HOME
update after merging trhe branches CEA_V3_0_x, OCC_V3_1_0_a1_x, and the main
[modules/med.git] / src / MEDMEM / MEDMEM_DriversDef.cxx
1 #include "MEDMEM_DriversDef.hxx"
2
3 using namespace std;
4
5 namespace MED_EN {
6
7 // Returns the (string) name of the geometry of 
8 // an element given by a med_geometrie_element value
9 GEO_NAME::GEO_NAME() : map<int,string>()
10 {
11   map<int,string> &table  = (map<int,string>&)*this ;
12   table[(int)0 ] = "MED_NONE" ;
13   table[(int)MED_POINT1 ] = "MED_POINT1" ;
14   table[(int)MED_SEG2   ] = "MED_SEG2"   ;
15   table[(int)MED_SEG3   ] = "MED_SEG3"   ;
16   table[(int)MED_TRIA3  ] = "MED_TRIA3"  ;
17   table[(int)MED_TRIA6  ] = "MED_TRIA6"  ;
18   table[(int)MED_QUAD4  ] = "MED_QUAD4"  ;
19   table[(int)MED_QUAD8  ] = "MED_QUAD8"  ;
20   table[(int)MED_TETRA4 ] = "MED_TETRA4" ;
21   table[(int)MED_TETRA10] = "MED_TETRA10";
22   table[(int)MED_HEXA8  ] = "MED_HEXA8"  ;
23   table[(int)MED_HEXA20 ] = "MED_HEXA20" ;
24   table[(int)MED_PENTA6 ] = "MED_PENTA6" ;
25   table[(int)MED_PENTA15] = "MED_PENTA15";
26   table[(int)MED_PYRA5  ] = "MED_PYRA5"  ;
27   table[(int)MED_PYRA13 ] = "MED_PYRA13" ;
28   assert( table.find( (int)MED_PYRA13 ) != table.end() ) ;
29 }
30  
31 GEO_NAME::~GEO_NAME()
32 {
33 //   MESSAGE(" destructor GEO_NAME::~GEO_NAME() "<< size() );
34 //   clear();
35 //   MESSAGE(" end of destructor GEO_NAME::~GEO_NAME() "<< size() );
36 }
37  
38 string & GEO_NAME::operator[]( const MED_EN::medGeometryElement &c ) const
39 {
40   map<int,string> &table = (map<int,string>&)*this ;
41   assert( table.find( (int)c ) != table.end() ) ;
42   return table[ (int)c ] ;
43 }
44
45
46 // Returns the (string) name of the type of 
47 // an entity given by a med_entite_maillage value
48
49 ENT_NAME::ENT_NAME() : map<int,string>()
50 {
51   map<int,string> &table = (map<int,string>&)*this ;
52   table[(int)MED_CELL ] = "MED_MAILLE";
53   table[(int)MED_FACE   ] = "MED_FACE"; 
54   table[(int)MED_EDGE  ] = "MED_ARETE";
55   table[(int)MED_NODE  ] = "MED_NOEUD";
56 }
57
58 ENT_NAME::~ENT_NAME()
59 {
60 //   MESSAGE(" destructor ENT_NAME::~ENT_NAME() "<< size() );
61 //   clear();
62 //   MESSAGE(" end of destructor ENT_NAME::~ENT_NAME() "<< size() );
63 }
64
65 string & ENT_NAME::operator[]( const MED_EN::medEntityMesh &c ) const
66 {
67   map<int,string> &table = (map<int,string>&)*this ;
68   assert( table.find( (int)c ) != table.end() ) ;
69   return table[ (int)c ] ;
70 }
71
72 MESH_ENTITIES::MESH_ENTITIES () : map<int, const list<MED_EN::medGeometryElement> >() 
73 {
74   // Override the const declaration in order to used the find method below
75   //  map<int, const list<med_geometrie_element> > &table = (map<int, const list<med_geometrie_element> >&)*this ; unused local variable
76   
77   // Initialize the value associated with the ROUGE_ key ( use the private operator = )
78   {
79     const MED_EN::medGeometryElement T[] =  {
80       MED_POINT1,
81       MED_SEG2,
82       MED_SEG3,
83       MED_TRIA3,
84       MED_QUAD4,
85       MED_TRIA6,
86       MED_QUAD8,
87       MED_TETRA4,
88       MED_PYRA5,
89       MED_PENTA6,
90       MED_HEXA8,
91       MED_TETRA10,
92       MED_PYRA13,
93       MED_PENTA15,
94       MED_HEXA20};
95
96     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
97     (*this)[MED_CELL] = geomList;
98   }
99   
100   {
101     const MED_EN::medGeometryElement T[] =  {
102       MED_TRIA3,
103       MED_QUAD4,
104       MED_TRIA6,
105       MED_QUAD8};
106
107     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
108     (*this)[MED_FACE] = geomList; 
109   }
110   
111   {
112     const MED_EN::medGeometryElement T[] =  {
113       MED_SEG2,
114       MED_SEG3 };
115
116     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
117     (*this)[MED_EDGE] = geomList; 
118   }
119   
120   {
121     //    const med_geometrie_element T[] =  { MED_NONE };
122     const MED_EN::medGeometryElement T[] =  { (MED_EN::medGeometryElement)0 };
123     static const list<MED_EN::medGeometryElement> geomList(T,T+sizeof(T)/sizeof(MED_EN::medGeometryElement));   
124     (*this)[MED_NODE] = geomList; 
125   }
126   
127 }
128
129 MESH_ENTITIES::~MESH_ENTITIES()
130 {
131 //   MESSAGE(" destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
132 //   clear();
133 //   MESSAGE(" end of destructor MESH_ENTITIES::~MESH_ENTITIES() "<< size() );
134 }
135
136 const list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c ) const
137 {
138   map<int,const list<MED_EN::medGeometryElement> > &table = (map<int,const list<MED_EN::medGeometryElement> >&)*this ;
139   // Verify the object already exists in the map
140   assert( table.find( (int)c ) != table.end() ) ;
141   return table[ (int)c ] ;
142 }
143
144 // This operator is used to initialize class objects of type  const list<med_geometrie_element>
145 list<MED_EN::medGeometryElement> & MESH_ENTITIES::operator[]( const  MED_EN::medEntityMesh &c )
146 {
147   return (list<MED_EN::medGeometryElement> &) this->map<int,const list<MED_EN::medGeometryElement> >::operator[]( (int)c) ;
148 }
149
150 } // End Of NampeSpace MED_EN
151