]> SALOME platform Git repositories - modules/kernel.git/blob - src/MEDWrapper/MEDA_Wrapper.cxx
Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/kernel.git] / src / MEDWrapper / MEDA_Wrapper.cxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : VISU_DatConvertor.cxx
6 //  Author : Alexey PETROV
7 //  Module : VISU
8
9 #include "MEDA_Wrapper.hxx"
10 #include "MED_Wrapper.hxx"
11 #include "MED_Utilities.hxx"
12
13 using namespace std;
14 using namespace MEDA;
15
16 #ifdef _DEBUG_
17 static int MYDEBUG = 0;
18 #else
19 static int MYDEBUG = 0;
20 #endif
21
22
23 //---------------------------------------------------------------
24 TWrapper::TWrapper(const string& theFileName):
25   myWrapper(new MED::TWrapper(theFileName))
26 {}
27
28
29 //---------------------------------------------------------------
30 PMeshInfo TWrapper::CrMeshInfo(med_int theDim,
31                                const string& theValue)
32 {
33   MED::PMeshInfo anInfo(new MED::TMeshInfo(theDim,theValue));
34   return PMeshInfo(new TMeshInfo(anInfo));
35 }
36
37 PMeshInfo TWrapper::CrMeshInfo(const PMeshInfo& theInfo){
38   MED::PMeshInfo anInfo(new MED::TMeshInfo(*theInfo->myInfo));
39   return PMeshInfo(new TMeshInfo(anInfo));
40 }
41
42 med_int TWrapper::GetNbMeshes(){
43   return myWrapper->GetNbMeshes();
44 }
45
46 PMeshInfo TWrapper::GetMeshInfo(med_int theId){
47   PMeshInfo anInfo = CrMeshInfo();
48   myWrapper->GetMeshInfo(theId+1,*anInfo->myInfo);
49   if(MYDEBUG){
50     MESSAGE("GetMeshInfo(...)");
51     MED::PrefixPrinter aPrefixPrinter;
52     BEGMSG("aName = '"<<anInfo->GetName()<<"'; aDim = "<<anInfo->GetDim()<<"\n");
53     ADDMSG("\n");
54   }
55   return anInfo;
56 }
57
58 void TWrapper::SetMeshInfo(const PMeshInfo& theInfo){
59   myWrapper->SetMeshInfo(*theInfo->myInfo);
60 }
61
62
63 //---------------------------------------------------------------
64 PFamilyInfo TWrapper::CrFamilyInfo(const PMeshInfo& theMeshInfo, 
65                                    med_int theNbGroup,
66                                    med_int theNbAttr,
67                                    med_int theId,
68                                    const string& theValue)
69 {
70   const MED::PMeshInfo& aMeshInfo = theMeshInfo->myInfo;
71   MED::PFamilyInfo anInfo(new MED::TFamilyInfo(aMeshInfo,
72                                                theNbGroup,
73                                                theNbAttr,
74                                                theId,
75                                                theValue));
76   return PFamilyInfo(new TFamilyInfo(anInfo));
77 }
78
79 PFamilyInfo TWrapper::CrFamilyInfo(const PMeshInfo& theMeshInfo,
80                                    const string& theValue,
81                                    med_int theId,
82                                    const MED::TStringSet& theGroupNames, 
83                                    const MED::TStringVector& theAttrDescs, 
84                                    const MED::TIntVector& theAttrIds, 
85                                    const MED::TIntVector& theAttrVals)
86 {
87   const MED::PMeshInfo& aMeshInfo = theMeshInfo->myInfo;
88   MED::PFamilyInfo anInfo(new MED::TFamilyInfo(aMeshInfo,
89                                                theValue,
90                                                theId,
91                                                theGroupNames,
92                                                theAttrDescs,
93                                                theAttrIds,
94                                                theAttrVals));
95   return PFamilyInfo(new TFamilyInfo(anInfo));
96 }
97
98 PFamilyInfo TWrapper::CrFamilyInfo(const PMeshInfo& theMeshInfo,
99                                    const PFamilyInfo& theInfo)
100 {
101   MED::PFamilyInfo anInfo(new MED::TFamilyInfo(*theInfo->myInfo));
102   anInfo->myMeshInfo = theMeshInfo->myInfo;
103   return PFamilyInfo(new TFamilyInfo(anInfo));
104 }
105
106 med_int TWrapper::GetNbFamilies(const PMeshInfo& theMeshInfo){
107   return myWrapper->GetNbFamilies(*theMeshInfo->myInfo);
108 }
109
110 PFamilyInfo TWrapper::GetFamilyInfo(const PMeshInfo& theMeshInfo, med_int theId){
111   med_int aNbAttr = myWrapper->GetNbFamAttr(theId+1,*theMeshInfo->myInfo);
112   med_int aNbGroup = myWrapper->GetNbFamGroup(theId+1,*theMeshInfo->myInfo);
113   PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo,aNbGroup,aNbAttr);
114   myWrapper->GetFamilyInfo(theId+1,*anInfo->myInfo);
115   if(MYDEBUG){
116     MESSAGE("GetFamilyInfo(...)");
117     MED::PrefixPrinter aPrefixPrinter;
118     BEGMSG("aName = '"<<anInfo->GetName()<<"'; anId = "<<anInfo->GetId()<<"\n");
119     ADDMSG("\n");
120   }
121   return anInfo;
122 }
123
124 void TWrapper::SetFamilyInfo(const PFamilyInfo& theInfo){
125   myWrapper->SetFamilyInfo(*theInfo->myInfo);
126 }
127
128
129 //---------------------------------------------------------------
130 PNodeInfo TWrapper::CrNodeInfo(const PMeshInfo& theMeshInfo, 
131                                med_int theNbElem,
132                                med_repere theSystem, 
133                                med_booleen theIsElemNum,
134                                med_booleen theIsElemNames)
135 {
136   const MED::PMeshInfo& aMeshInfo = theMeshInfo->myInfo;
137   MED::PNodeInfo anInfo(new MED::TNodeInfo(aMeshInfo,
138                                            theNbElem,
139                                            theSystem,
140                                            theIsElemNum,
141                                            theIsElemNames));
142   return PNodeInfo(new TNodeInfo(anInfo));
143 }
144
145 PNodeInfo TWrapper::CrNodeInfo(const PMeshInfo& theMeshInfo, 
146                                med_repere theSystem, 
147                                const MED::TFloatVector& theNodeCoords,
148                                const MED::TStringVector& theCoordNames,
149                                const MED::TStringVector& theCoordUnits,
150                                const MED::TIntVector& theFamilyNums,
151                                const MED::TIntVector& theElemNums,
152                                const MED::TStringVector& theElemNames)
153 {
154   const MED::PMeshInfo& aMeshInfo = theMeshInfo->myInfo;
155   MED::PNodeInfo anInfo(new MED::TNodeInfo(aMeshInfo,
156                                            theSystem,
157                                            theNodeCoords,
158                                            theCoordNames,
159                                            theCoordUnits,
160                                            theFamilyNums,
161                                            theElemNums,
162                                            theElemNames));
163   return PNodeInfo(new TNodeInfo(anInfo));
164 }
165
166 PNodeInfo TWrapper::CrNodeInfo(const PMeshInfo& theMeshInfo,
167                                const PNodeInfo& theInfo)
168 {
169   MED::PNodeInfo anInfo(new MED::TNodeInfo(*theInfo->myInfo));
170   anInfo->myMeshInfo = theMeshInfo->myInfo;
171   return PNodeInfo(new TNodeInfo(anInfo));
172 }
173
174 PNodeInfo TWrapper::GetNodeInfo(const PMeshInfo& theMeshInfo){
175   med_int aNbElems = myWrapper->GetNbNodes(*theMeshInfo->myInfo);
176   PNodeInfo anInfo = CrNodeInfo(theMeshInfo,aNbElems);
177   myWrapper->GetNodeInfo(*anInfo->myInfo);
178   return anInfo;
179 }
180
181 void TWrapper::SetNodeInfo(const PNodeInfo& theInfo){
182   myWrapper->SetNodeInfo(*theInfo->myInfo);
183 }
184
185
186 //---------------------------------------------------------------
187 MED::TEntityInfo TWrapper::GetEntityInfo(const PMeshInfo& theMeshInfo){
188   return myWrapper->GetEntityInfo(*theMeshInfo->myInfo);
189 }
190
191 PCellInfo TWrapper::CrCellInfo(const PMeshInfo& theMeshInfo, 
192                                med_int theNbElem,
193                                med_entite_maillage theEntity, 
194                                med_geometrie_element theGeom,
195                                med_connectivite theConn,
196                                med_booleen theIsElemNum,
197                                med_booleen theIsElemNames)
198 {
199   MED::PCellInfo anInfo(new MED::TCellInfo(theMeshInfo->myInfo,
200                                            theNbElem,
201                                            theEntity,
202                                            theGeom,
203                                            theConn,
204                                            theIsElemNum,
205                                            theIsElemNames));
206   return PCellInfo(new TCellInfo(anInfo));
207 }
208
209 PCellInfo TWrapper::CrCellInfo(const PMeshInfo& theMeshInfo, 
210                                med_entite_maillage theEntity, 
211                                med_geometrie_element theGeom,
212                                med_connectivite theConn,
213                                const MED::TIntVector& theConnectivities,
214                                const MED::TIntVector& theFamilyNums,
215                                const MED::TIntVector& theElemNums,
216                                const MED::TStringVector& theElemNames)
217 {
218   MED::PCellInfo anInfo(new MED::TCellInfo(theMeshInfo->myInfo,
219                                            theEntity,
220                                            theGeom,
221                                            theConn,
222                                            theConnectivities,
223                                            theFamilyNums,
224                                            theElemNums,
225                                            theElemNames));
226   return PCellInfo(new TCellInfo(anInfo));
227 }
228
229 PCellInfo TWrapper::CrCellInfo(const PMeshInfo& theMeshInfo,
230                                const PCellInfo& theInfo)
231 {
232   MED::PCellInfo anInfo(new MED::TCellInfo(*theInfo->myInfo));
233   anInfo->myMeshInfo = theMeshInfo->myInfo;
234   return PCellInfo(new TCellInfo(anInfo));
235 }
236
237 PCellInfo TWrapper::GetCellInfo(const PMeshInfo& theMeshInfo, 
238                                 med_entite_maillage theEntity, 
239                                 med_geometrie_element theGeom, 
240                                 med_connectivite theConn)
241 {
242   med_int aNbElem = myWrapper->GetNbCells(*theMeshInfo->myInfo,theEntity,theGeom,theConn);
243   PCellInfo anInfo = CrCellInfo(theMeshInfo,aNbElem,theEntity,theGeom,theConn);
244   myWrapper->GetCellInfo(*anInfo->myInfo);
245   return anInfo;
246 }
247
248 void TWrapper::SetCellInfo(const PCellInfo& theInfo){
249   myWrapper->SetCellInfo(*theInfo->myInfo);
250 }
251
252
253 //---------------------------------------------------------------
254 PFieldInfo TWrapper::CrFieldInfo(const PMeshInfo& theMeshInfo, 
255                                  med_int theNbComp,
256                                  med_type_champ theType,
257                                  const string& theValue)
258 {
259   MED::PFieldInfo anInfo(new MED::TFieldInfo(theMeshInfo->myInfo,
260                                              theNbComp,
261                                              theType,
262                                              theValue));
263   return PFieldInfo(new TFieldInfo(anInfo));
264 }
265
266 PFieldInfo TWrapper::CrFieldInfo(const PMeshInfo& theMeshInfo,
267                                  const PFieldInfo& theInfo)
268 {
269   MED::PFieldInfo anInfo(new MED::TFieldInfo(*theInfo->myInfo));
270   anInfo->myMeshInfo = theMeshInfo->myInfo;
271   return PFieldInfo(new TFieldInfo(anInfo));
272 }
273
274 med_int TWrapper::GetNbFields(){
275   return myWrapper->GetNbFields();
276 }
277
278 PFieldInfo TWrapper::GetFieldInfo(const PMeshInfo& theMeshInfo, med_int theId){
279   med_int aNbComp = myWrapper->GetNbComp(theId+1);
280   PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp);
281   myWrapper->GetFieldInfo(theId+1,*anInfo->myInfo);
282   return anInfo;
283 }
284
285 void TWrapper::SetFieldInfo(const PFieldInfo& theInfo){
286   myWrapper->SetFieldInfo(*theInfo->myInfo);
287 }
288
289
290 //---------------------------------------------------------------
291 PTimeStampInfo TWrapper::CrTimeStampInfo(const PFieldInfo& theFieldInfo, 
292                                          med_entite_maillage theEntity,
293                                          const MED::TGeom& theGeom)
294 {
295   MED::PTimeStampInfo anInfo(new MED::TTimeStampInfo(theFieldInfo->myInfo,
296                                                      theEntity,
297                                                      theGeom));
298   return PTimeStampInfo(new TTimeStampInfo(anInfo));
299 }
300
301 PTimeStampInfo TWrapper::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
302                                          const PTimeStampInfo& theInfo)
303 {
304   MED::PTimeStampInfo anInfo(new MED::TTimeStampInfo(*theInfo->myInfo));
305   anInfo->myFieldInfo = theFieldInfo->myInfo;
306   return PTimeStampInfo(new TTimeStampInfo(anInfo));
307 }
308
309 med_int TWrapper::GetNbTimeStamps(const PFieldInfo& theFieldInfo, 
310                                   const MED::TEntityInfo& theEntityInfo,
311                                   med_entite_maillage& theEntity,
312                                   MED::TGeom& theGeom)
313 {
314   return myWrapper->GetNbTimeStamps(*theFieldInfo->myInfo,
315                                     theEntityInfo,
316                                     theEntity,
317                                     theGeom);
318 }
319
320 PTimeStampInfo TWrapper::GetTimeStampInfo(const PFieldInfo& theFieldInfo,
321                                           med_int theId,
322                                           med_entite_maillage theEntity,
323                                           const MED::TGeom& theGeom)
324 {
325   PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo,theEntity,theGeom);
326   myWrapper->GetTimeStampInfo(theId+1,*anInfo->myInfo);
327   return anInfo;
328 }
329
330
331 //---------------------------------------------------------------
332 PTimeStampVal TWrapper::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo)
333 {
334   MED::PTimeStampVal anInfo(new MED::TTimeStampVal(theTimeStampInfo->myInfo));
335   return PTimeStampVal(new TTimeStampVal(anInfo));
336 }
337
338 PTimeStampVal TWrapper::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
339                                        const PTimeStampVal& theInfo)
340 {
341   MED::PTimeStampVal anInfo(new MED::TTimeStampVal(*theInfo->myInfo));
342   anInfo->myTimeStampInfo = theTimeStampInfo->myInfo;
343   return PTimeStampVal(new TTimeStampVal(anInfo));
344 }
345
346 PTimeStampVal TWrapper::GetTimeStampVal(const PTimeStampInfo& theTimeStampInfo)
347 {
348   PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
349   myWrapper->GetTimeStampVal(*anInfo->myInfo);
350   return anInfo;
351 }
352
353 void TWrapper::SetTimeStamp(const PTimeStampVal& theTimeStampVal){
354   myWrapper->SetTimeStamp(*theTimeStampVal->myInfo);
355 }