Salome HOME
CoTech decision: move MEDWrapper from MED to SMESH
[modules/smesh.git] / src / MEDWrapper / Base / MED_Utilities.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 "MED_Utilities.hxx"
24 #include "MED_Common.hxx"
25
26 using namespace std;
27
28 #ifdef _DEBUG_
29 static int MYDEBUG = 0;
30 #else
31 // static int MYDEBUG = 0;
32 #endif
33
34
35 int MED::PrefixPrinter::myCounter = 0;
36
37 MED::PrefixPrinter::PrefixPrinter(bool theIsActive):
38   myIsActive(theIsActive)
39 {
40   if(myIsActive)
41     myCounter++;
42   MSG(MYDEBUG,"MED::PrefixPrinter::PrefixPrinter(...)- "<<myCounter);
43 }
44
45 MED::PrefixPrinter::~PrefixPrinter()
46 {
47   if(myIsActive){
48     myCounter--;
49     if(myCounter < 0)
50       EXCEPTION(runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
51   }
52 }
53
54 string MED::PrefixPrinter::GetPrefix()
55 {
56   if(myCounter){
57     if(myCounter < 0)
58       EXCEPTION(runtime_error,"PrefixPrinter::~PrefixPrinter() - myCounter("<<myCounter<<") < 0");
59     return string(myCounter*2,' ');
60   }
61   return "";
62 }
63
64
65 static MED::TEntity2GeomSet Entity2GeomSet;
66
67 bool InitEntity2GeomSet()
68 {
69   using namespace MED;
70
71   TGeomSet& aGeomARETESet = Entity2GeomSet[eARETE];
72   aGeomARETESet.insert(eSEG2);
73   aGeomARETESet.insert(eSEG3);
74
75   TGeomSet& aGeomFACESet = Entity2GeomSet[eFACE];
76   aGeomFACESet.insert(eTRIA3);
77   aGeomFACESet.insert(eQUAD4);
78   aGeomFACESet.insert(eTRIA6);
79   aGeomFACESet.insert(eTRIA7);
80   aGeomFACESet.insert(eQUAD8);
81   aGeomFACESet.insert(eQUAD9);
82   aGeomFACESet.insert(ePOLYGONE);
83
84   TGeomSet& aGeomMAILLESet = Entity2GeomSet[eMAILLE];
85   aGeomMAILLESet.insert(ePOINT1);
86   aGeomMAILLESet.insert(aGeomARETESet.begin(),aGeomARETESet.end());
87   aGeomMAILLESet.insert(aGeomFACESet.begin(),aGeomFACESet.end());
88   aGeomMAILLESet.insert(eTETRA4);
89   aGeomMAILLESet.insert(ePYRA5);
90   aGeomMAILLESet.insert(ePENTA6);
91   aGeomMAILLESet.insert(eHEXA8);
92   aGeomMAILLESet.insert(eOCTA12);
93   aGeomMAILLESet.insert(eTETRA10);
94   aGeomMAILLESet.insert(ePYRA13);
95   aGeomMAILLESet.insert(ePENTA15);
96   aGeomMAILLESet.insert(eHEXA20);
97   aGeomMAILLESet.insert(eHEXA27);
98   aGeomMAILLESet.insert(ePOLYEDRE);
99
100   /* This combination allows reading nb of models of structure elements */
101   Entity2GeomSet[eSTRUCT_ELEMENT].insert(eAllGeoType); 
102
103   return true;
104 }
105
106 static bool anIsInited = InitEntity2GeomSet();
107
108 const MED::TEntity2GeomSet& MED::GetEntity2GeomSet()
109 {
110   return Entity2GeomSet;
111 }
112
113