Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / src / MEDWrapper / V2_2 / MED_V2_2_Wrapper.cxx
1 //  
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : 
27 //  $Header$
28
29 #include "MED_V2_2_Wrapper.hxx"
30 #include "MED_Utilities.hxx"
31
32 extern "C"{
33 #include <med.h>
34 }
35
36 #ifdef _DEBUG_
37 static int MYDEBUG = 0;
38 #else
39 static int MYDEBUG = 0;
40 #endif
41
42
43
44 namespace MED{
45   namespace V2_2{
46
47     //---------------------------------------------------------------
48     class TFile{
49       TFile();
50       TFile(const TFile&);
51       
52     public:
53       TFile(const std::string& theFileName): 
54         myFid(0), 
55         myCount(0),
56         myFileName(theFileName)
57       {}
58       
59       ~TFile(){ 
60         Close();
61       }
62       
63       void Open(EModeAcces theMode, TErr* theErr = NULL){
64         if(myCount++ == 0){
65           char* aFileName = const_cast<char*>(myFileName.c_str());
66           myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
67         }
68         if(theErr)
69           *theErr = TErr(myFid > 0);
70         else if(myFid < 0)
71           EXCEPTION(runtime_error,"TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
72       }
73
74       const TIdt& Id() const { 
75         if(myFid < 0)
76           EXCEPTION(runtime_error,"TFile - GetFid() < 0");
77         return myFid;
78       }
79
80       void Close(){ 
81         if(--myCount == 0)
82           MEDfermer(myFid);
83       }
84
85     protected:
86       std::string myFileName;
87       TInt myCount;
88       TIdt myFid;
89     };
90
91
92     //---------------------------------------------------------------
93     class TFileWrapper{
94       PFile myFile;
95
96     public:
97       TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL): 
98         myFile(theFile)
99       {
100         myFile->Open(theMode,theErr);
101       }
102       
103       ~TFileWrapper(){
104         myFile->Close();
105       }
106     };
107
108
109     //---------------------------------------------------------------
110     TVWrapper::TVWrapper(const std::string& theFileName): 
111       myFile(new TFile(theFileName))
112     {
113     }
114     
115     
116     TInt TVWrapper::GetNbMeshes(TErr* theErr)
117     {
118       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
119       
120       if(theErr && !*theErr)
121         return -1;
122       
123       return MEDnMaa(myFile->Id());
124     }
125     
126     
127     void TVWrapper::GetMeshInfo(TInt theMeshId, 
128                                MED::TMeshInfo& theInfo,
129                                TErr* theErr)
130     {
131       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
132       
133       if(theErr && !*theErr)
134         return;
135       
136       med_maillage& aType = static_cast<med_maillage>(theInfo.myType);
137
138       TErr aRet = MEDmaaInfo(myFile->Id(),
139                              theMeshId,
140                              &theInfo.myName[0],
141                              &theInfo.myDim,
142                              &aType,
143                              &theInfo.myDesc[0]);
144       if(theErr) 
145         *theErr = aRet;
146       else if(aRet < 0)
147         EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
148     }
149     
150     
151     void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo,
152                                EModeAcces theMode,
153                                TErr* theErr)
154     {
155       TFileWrapper aFileWrapper(myFile,theMode,theErr);
156       
157       if(theErr && !*theErr)
158         return;
159       
160       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
161       
162       med_maillage& aType = static_cast<med_maillage>(theInfo.myType);
163
164       TErr aRet = MEDmaaCr(myFile->Id(),
165                            &anInfo.myName[0],
166                            anInfo.myDim,
167                            aType,
168                            &anInfo.myDesc[0]);
169       if(aRet == 0){
170         aRet = MEDunvCr(myFile->Id(),
171                         &anInfo.myName[0]);
172       }
173       
174       INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
175       
176       if(theErr) 
177         *theErr = aRet;
178       else if(aRet < 0)
179         EXCEPTION(runtime_error,"SetMeshInfo - MEDmaaCr(...)");
180     }
181     
182     
183     void TVWrapper::SetMeshInfo(const MED::TMeshInfo& theInfo,
184                                TErr* theErr)
185     {
186       TErr aRet;
187       SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
188       
189       if(aRet < 0)
190         SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
191
192       if(aRet < 0)
193         SetMeshInfo(theInfo,eCREATION,theErr);
194     }
195     
196     
197     TInt TVWrapper::GetNbFamilies(const MED::TMeshInfo& theInfo,
198                                  TErr* theErr)
199     {
200       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
201       
202       if(theErr && !*theErr)
203         return -1;
204       
205       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
206       return MEDnFam(myFile->Id(),
207                      &anInfo.myName[0]);
208     }
209     
210     
211     TInt TVWrapper::GetNbFamAttr(TInt theFamId, 
212                                 const MED::TMeshInfo& theInfo,
213                                 TErr* theErr)
214     {
215       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
216       
217       if(theErr && !*theErr)
218         return -1;
219       
220       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
221       return MEDnAttribut(myFile->Id(),
222                           &anInfo.myName[0],
223                           theFamId);
224     }
225     
226     
227     TInt TVWrapper::GetNbFamGroup(TInt theFamId, 
228                                  const MED::TMeshInfo& theInfo,
229                                  TErr* theErr)
230     {
231       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
232       
233       if(theErr && !*theErr)
234         return -1;
235       
236       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
237       return MEDnGroupe(myFile->Id(),
238                         &anInfo.myName[0],
239                         theFamId);
240     }
241     
242     
243     void TVWrapper::GetFamilyInfo(TInt theFamId, 
244                                  MED::TFamilyInfo& theInfo,
245                                  TErr* theErr)
246     {
247       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
248       
249       if(theErr && !*theErr)
250         return;
251       
252       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
253       
254       TErr aRet = MEDfamInfo(myFile->Id(),
255                              &aMeshInfo.myName[0],
256                              theFamId,
257                              &theInfo.myName[0],
258                              &theInfo.myId,
259                              &theInfo.myAttrId[0],
260                              &theInfo.myAttrVal[0],
261                              &theInfo.myAttrDesc[0],
262                              &theInfo.myNbAttr,
263                              &theInfo.myGroupNames[0],
264                              &theInfo.myNbGroup);
265       
266       if(theErr) 
267         *theErr = aRet;
268       else if(aRet < 0)
269         EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<<
270                   " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
271                   "'; theFamId = "<<theFamId<<
272                   "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
273                   "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
274
275       INITMSG(MYDEBUG,"GetFamilyInfo - MEDfamInfo(...) - "<<
276               " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
277               "'; theFamId = "<<theFamId<<
278               "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
279               "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
280     }
281     
282     
283     void TVWrapper::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
284                                  EModeAcces theMode,
285                                  TErr* theErr)
286     {
287       TFileWrapper aFileWrapper(myFile,theMode,theErr);
288       
289       if(theErr && !*theErr)
290         return;
291       
292       MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
293       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
294       
295       TErr aRet = MEDfamCr(myFile->Id(),
296                            &aMeshInfo.myName[0],
297                            &anInfo.myName[0],
298                            anInfo.myId,
299                            &anInfo.myAttrId[0],
300                            &anInfo.myAttrVal[0],
301                            &anInfo.myAttrDesc[0],
302                            anInfo.myNbAttr,
303                            &anInfo.myGroupNames[0],
304                            anInfo.myNbGroup);
305       
306       INITMSG(MYDEBUG,"TVWrapper::GetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
307       
308       if(theErr) 
309         *theErr = aRet;
310       else if(aRet < 0)
311         EXCEPTION(runtime_error,"SetFamilyInfo - MEDfamCr(...)");
312     }
313     
314     
315     void TVWrapper::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
316                                  TErr* theErr)
317     {
318       TErr aRet;
319       SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
320       
321       if(aRet < 0)
322         SetFamilyInfo(theInfo,eLECTURE_AJOUT,theErr);
323     }
324     
325     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326     void TVWrapper::GetNames(TElemInfo& theInfo,
327                              TInt nb,
328                              EEntiteMaillage theTEntity, 
329                              EGeometrieElement theTGeom,
330                              TErr* theErr)
331     {
332       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
333       
334       if(theErr && !*theErr)
335         return;
336       
337       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
338
339       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
340       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
341
342       TErr aRet = MEDnomLire(myFile->Id(),
343                              &aMeshInfo.myName[0],
344                              &theInfo.myElemNames[0],
345                              nb,
346                              anEntity,
347                              aGeom);
348
349       theInfo.myIsElemNames = (theInfo.myElemNames).empty()? EBooleen(0) : EBooleen(1) ;
350
351       if(theErr) 
352         *theErr = aRet;
353       else if(aRet < 0)
354         EXCEPTION(runtime_error,"GetNames - MEDnomLire(...)");
355     }
356
357     void TVWrapper::GetNumeration(TElemInfo& theInfo,
358                                   TInt nb,
359                                   EEntiteMaillage theTEntity, 
360                                   EGeometrieElement theTGeom,
361                                   TErr* theErr)
362     {
363       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
364       
365       if(theErr && !*theErr)
366         return;
367       
368       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
369       
370       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
371       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
372
373       TErr aRet = MEDnumLire(myFile->Id(),
374                              &aMeshInfo.myName[0],
375                              &theInfo.myElemNum[0],
376                              nb,
377                              anEntity,
378                              aGeom);
379
380       theInfo.myIsElemNum = (theInfo.myElemNum).empty()? EBooleen(0) : EBooleen(1) ;
381
382       if(theErr) 
383         *theErr = aRet;
384       else if(aRet < 0)
385         EXCEPTION(runtime_error,"GetNumeration - MEDnumLire(...)");
386     }
387
388     void TVWrapper::GetFamilies(TElemInfo& theInfo,
389                                 TInt nb,
390                                 EEntiteMaillage theTEntity, 
391                                 EGeometrieElement theTGeom,
392                                 TErr* theErr)
393     {
394       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
395       
396       if(theErr && !*theErr)
397         return;
398       
399       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
400       
401       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
402       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
403
404       TErr aRet = MEDfamLire(myFile->Id(),
405                              &aMeshInfo.myName[0],
406                              &theInfo.myFamNum[0],
407                              nb,
408                              anEntity,
409                              aGeom);
410
411       if(theErr) 
412         *theErr = aRet;
413       else if(aRet < 0)
414         EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)");
415     }
416
417     void TVWrapper::SetNames(const TElemInfo& theInfo,
418                              EEntiteMaillage theTEntity, 
419                              EGeometrieElement theTGeom,
420                              TErr* theErr)
421     { 
422       SetNames(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
423     }
424
425     void TVWrapper::SetNames(const TElemInfo& theInfo,
426                              EModeAcces theMode,
427                              EEntiteMaillage theTEntity, 
428                              EGeometrieElement theTGeom,
429                              TErr* theErr)
430     {
431       TFileWrapper aFileWrapper(myFile,theMode,theErr);
432       
433       if(theErr && !*theErr)
434         return;
435
436       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
437       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
438
439       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
440       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
441       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
442       
443       TErr aRet = 0;
444       if (anIsElemNames){
445         aRet  = MEDnomEcr(myFile->Id(),
446                           &aMeshInfo.myName[0],
447                           &anInfo.myElemNames[0],
448                           anInfo.myElemNames.size(),
449                           anEntity,
450                           aGeom);
451         if(theErr) 
452           *theErr = aRet;
453         else if(aRet < 0)
454           EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)");
455       }
456     }
457
458     void TVWrapper::SetNumeration(const TElemInfo& theInfo,
459                                   EEntiteMaillage theTEntity, 
460                                   EGeometrieElement theTGeom,
461                                   TErr* theErr)
462     { 
463       SetNumeration(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
464     }
465
466     void TVWrapper::SetNumeration(const TElemInfo& theInfo,
467                                   EModeAcces theMode,
468                                   EEntiteMaillage theTEntity, 
469                                   EGeometrieElement theTGeom,
470                                   TErr* theErr)
471     {
472       TFileWrapper aFileWrapper(myFile,theMode,theErr);
473       
474       if(theErr && !*theErr)
475         return;
476
477       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
478       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
479
480       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
481       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
482       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
483       
484       TErr aRet = 0;
485       if (anIsElemNum){
486         aRet  = MEDnumEcr(myFile->Id(),
487                           &aMeshInfo.myName[0],
488                           &anInfo.myElemNum[0],
489                           anInfo.myElemNum.size(),
490                           anEntity,
491                           aGeom);
492         if(theErr) 
493           *theErr = aRet;
494         else if(aRet < 0)
495           EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)");
496       }
497     }
498
499     void TVWrapper::SetFamilies(const TElemInfo& theInfo,
500                                 EEntiteMaillage theTEntity, 
501                                 EGeometrieElement theTGeom,
502                                 TErr* theErr)
503     { 
504       SetFamilies(theInfo,eLECTURE_ECRITURE,theTEntity,theTGeom,theErr);
505     }
506
507     void TVWrapper::SetFamilies(const TElemInfo& theInfo,
508                                 EModeAcces theMode,
509                                 EEntiteMaillage theTEntity, 
510                                 EGeometrieElement theTGeom,
511                                 TErr* theErr)
512     {
513       TFileWrapper aFileWrapper(myFile,theMode,theErr);
514       
515       if(theErr && !*theErr)
516         return;
517
518       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
519       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
520
521       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
522       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theTGeom);
523       
524       TErr aRet = MEDfamEcr(myFile->Id(),
525                             &aMeshInfo.myName[0],
526                             &anInfo.myFamNum[0],
527                             anInfo.myFamNum.size(),
528                             anEntity,
529                             aGeom);
530       
531       if(theErr) 
532         *theErr = aRet;
533       else if(aRet < 0)
534         EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)");
535     }
536     
537     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
538     TInt TVWrapper::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
539                               TErr* theErr)
540     {
541       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
542       
543       if(theErr && !*theErr)
544         return -1;
545       
546       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
547       
548       return MEDnEntMaa(myFile->Id(),
549                         &aMeshInfo.myName[0],
550                         MED_COOR,
551                         MED_NOEUD,
552                         med_geometrie_element(0),
553                         med_connectivite(0));
554     }
555     
556     
557     void TVWrapper::GetNodeInfo(MED::TNodeInfo& theInfo,
558                                TErr* theErr)
559     {
560       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
561       
562       if(theErr && !*theErr)
563         return;
564       
565       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
566
567       med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
568       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
569       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
570
571       TErr aRet = MEDnoeudsLire(myFile->Id(),
572                                 &aMeshInfo.myName[0],
573                                 aMeshInfo.myDim,
574                                 &theInfo.myCoord[0],
575                                 MED_FULL_INTERLACE,
576                                 &aRepere,
577                                 &theInfo.myCoordNames[0],
578                                 &theInfo.myCoordUnits[0],
579                                 &theInfo.myElemNames[0],
580                                 &anIsElemNames,
581                                 &theInfo.myElemNum[0],
582                                 &anIsElemNum,
583                                 &theInfo.myFamNum[0],
584                                 theInfo.myNbElem);
585       if(theErr) 
586         *theErr = aRet;
587       else if(aRet < 0)
588         EXCEPTION(runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
589     }
590     
591     
592     void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo,
593                                EModeAcces theMode,
594                                TErr* theErr)
595     {
596       TFileWrapper aFileWrapper(myFile,theMode,theErr);
597       
598       if(theErr && !*theErr)
599         return;
600       
601       MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
602       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
603       
604       med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
605       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
606       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
607
608       TErr aRet = MEDnoeudsEcr(myFile->Id(),
609                                &aMeshInfo.myName[0],
610                                aMeshInfo.myDim,
611                                &anInfo.myCoord[0],
612                                MED_FULL_INTERLACE,
613                                aRepere,
614                                &anInfo.myCoordNames[0],
615                                &anInfo.myCoordUnits[0],
616                                &anInfo.myElemNames[0],
617                                anIsElemNames,
618                                &anInfo.myElemNum[0],
619                                anIsElemNum,
620                                &anInfo.myFamNum[0],
621                                anInfo.myNbElem);
622       if(theErr) 
623         *theErr = aRet;
624       else if(aRet < 0)
625         EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
626     }
627     
628     
629     void TVWrapper::SetNodeInfo(const MED::TNodeInfo& theInfo,
630                                TErr* theErr)
631     {
632       TErr aRet;
633       SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
634       
635       if(aRet < 0)
636         SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr);
637     }
638     
639     void TVWrapper::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
640                                     TErr* theErr)
641     {
642       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
643
644       if(theErr && !*theErr)
645         return;
646
647       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
648       TInt aNbElem = theInfo.myElemNum.size();
649
650       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
651       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
652       
653       TErr aRet = 0;
654       
655       aRet = MEDpolygoneConnLire(myFile->Id(), 
656                                  &aMeshInfo.myName[0],
657                                  &theInfo.myIndex[0],
658                                  aNbElem+1,
659                                  &theInfo.myConn[0],
660                                  anEntity,
661                                  aConn);
662
663       if(theErr) 
664         *theErr = aRet;
665       else if(aRet < 0)
666         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
667
668
669       GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
670       if(theErr) 
671         *theErr = aRet;
672
673       GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
674       if(theErr) 
675         *theErr = aRet;
676
677       GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYGONE,&aRet);
678       if(theErr) 
679         *theErr = aRet;
680     }
681     
682     void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
683                                     TErr* theErr)
684     {
685       SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
686     }
687     
688     void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
689                                     EModeAcces theMode,
690                                     TErr* theErr)
691     {
692       TFileWrapper aFileWrapper(myFile,theMode,theErr);
693       
694       if(theErr && !*theErr)
695         return;
696
697       MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
698       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
699
700       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
701       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
702       
703       TErr aRet = MEDpolygoneConnEcr(myFile->Id(),
704                                      &aMeshInfo.myName[0],
705                                      &anInfo.myIndex[0],
706                                      anInfo.myNbElem+1,
707                                      &anInfo.myConn[0],
708                                      anEntity,
709                                      aConn);
710       
711       if(theErr) 
712         *theErr = aRet;
713       else if(aRet < 0)
714         EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)");
715       
716       SetNames(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
717       if(theErr) 
718         *theErr = aRet;
719       
720       SetNumeration(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
721       if(theErr) 
722         *theErr = aRet;
723       
724       SetFamilies(anInfo,theInfo.myTEntity,ePOLYGONE,&aRet);
725       if(theErr) 
726         *theErr = aRet;
727     }
728
729     TInt TVWrapper::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, 
730                                    EEntiteMaillage theTEntity, 
731                                    EGeometrieElement theTGeom, 
732                                    EConnectivite theTConn,
733                                    TErr* theErr)
734     {
735       return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr);
736     }
737     
738     TInt TVWrapper::GetNbPolygoneConn(const MED::TMeshInfo& theMeshInfo, 
739                                       EEntiteMaillage theTEntity, 
740                                       EGeometrieElement theTGeom, 
741                                       EConnectivite theTConn,
742                                       TErr* theErr)
743     {
744       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
745
746       if(theErr && !*theErr)
747         return 0;
748
749       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
750       
751       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
752       med_connectivite& aConn = static_cast<med_connectivite>(theTConn);
753
754       med_int taille = 0;
755
756       TErr aRet = MEDpolygoneInfo(myFile->Id(), 
757                                   &aMeshInfo.myName[0], 
758                                   anEntity, 
759                                   aConn,
760                                   &taille);
761       
762       if(theErr) 
763         *theErr = aRet;
764       else if(aRet < 0)
765         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
766
767       return TInt(taille);
768     }
769
770     void TVWrapper::GetPolyedreInfo(TPolyedreInfo& theInfo,
771                                     TErr* theErr)
772     {
773       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
774
775       if(theErr && !*theErr)
776         return;
777
778       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
779       TInt aNbElem = theInfo.myElemNum.size();
780
781       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
782       
783       TErr aRet = 0;
784       
785       aRet = MEDpolyedreConnLire(myFile->Id(), 
786                                  &aMeshInfo.myName[0],
787                                  &theInfo.myIndex[0],
788                                  aNbElem+1,
789                                  &theInfo.myFacesIndex[0],
790                                  theInfo.myNbFacesIndex,
791                                  &theInfo.myConn[0],
792                                  aConn);
793
794       if(theErr) 
795         *theErr = aRet;
796       else if(aRet < 0)
797         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)");
798
799       GetNames(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
800       if(theErr) 
801         *theErr = aRet;
802
803       GetNumeration(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
804       if(theErr) 
805         *theErr = aRet;
806
807       GetFamilies(theInfo,aNbElem,theInfo.myTEntity,ePOLYEDRE,&aRet);
808       if(theErr) 
809         *theErr = aRet;
810     }
811
812     void TVWrapper::SetPolyedreInfo(const TPolyedreInfo& theInfo,
813                                     TErr* theErr)
814     {
815       SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
816     }
817     
818     void TVWrapper::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
819                                     EModeAcces theMode,
820                                     TErr* theErr)
821     {
822       TFileWrapper aFileWrapper(myFile,theMode,theErr);
823       
824       if(theErr && !*theErr)
825         return;
826
827       MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
828       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
829
830       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
831       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
832       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
833       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
834       
835       TErr aRet = MEDpolyedreConnEcr(myFile->Id(),
836                                      &aMeshInfo.myName[0],
837                                      &anInfo.myIndex[0],
838                                      anInfo.myNbElem+1,
839                                      &anInfo.myFacesIndex[0],
840                                      anInfo.myNbFacesIndex,
841                                      &anInfo.myConn[0],
842                                      aConn);
843       
844       if(theErr) 
845         *theErr = aRet;
846       else if(aRet < 0)
847         EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)");
848       
849       if (anIsElemNames){
850         aRet  = MEDnomEcr(myFile->Id(),
851                           &aMeshInfo.myName[0],
852                           &anInfo.myElemNames[0],
853                           anInfo.myElemNames.size(),
854                           anEntity,
855                           MED_POLYEDRE);
856         if(theErr) 
857           *theErr = aRet;
858         else if(aRet < 0)
859           EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)");
860       }
861       
862       if (anIsElemNum){
863         aRet  = MEDnumEcr(myFile->Id(),
864                           &aMeshInfo.myName[0],
865                           &anInfo.myElemNum[0],
866                           anInfo.myElemNum.size(),
867                           anEntity,
868                           MED_POLYEDRE);
869         if(theErr) 
870           *theErr = aRet;
871         else if(aRet < 0)
872           EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)");
873       }
874       
875       
876       aRet = MEDfamEcr(myFile->Id(),
877                        &aMeshInfo.myName[0],
878                        &anInfo.myFamNum[0],
879                        anInfo.myFamNum.size(),
880                        anEntity,
881                        MED_POLYEDRE);
882       
883       if(theErr) 
884         *theErr = aRet;
885       else if(aRet < 0)
886         EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)");
887     }
888
889     TInt TVWrapper::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, 
890                                    EEntiteMaillage theTEntity, 
891                                    EGeometrieElement theTGeom, 
892                                    EConnectivite theTConn,
893                                    TErr* theErr)
894     {
895       return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr);
896     }
897
898     void TVWrapper::GetNbPolyedreConnF(const MED::TMeshInfo& theMeshInfo, 
899                                        EConnectivite theTConn,
900                                        TInt& nf,
901                                        TInt& nc,
902                                        TErr* theErr)
903     {
904       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
905
906       if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)");
907
908       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
909       med_connectivite& aConn = static_cast<med_connectivite>(theTConn);
910       
911       TErr aRet = MEDpolyedreInfo(myFile->Id(), 
912                                   &aMeshInfo.myName[0], 
913                                   aConn,
914                                   &nf,
915                                   &nc);
916
917       if(theErr) 
918         *theErr = aRet;
919       else if(aRet < 0)
920         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)");
921
922     }
923     
924     TEntityInfo TVWrapper::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
925                                         EConnectivite theTConn,
926                                         TErr* theErr)
927     {
928       TEntityInfo anInfo;
929       
930       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
931       
932       if(theErr && *theErr < 0)
933         return anInfo;
934       
935       TInt aNbElem = GetNbNodes(theMeshInfo);
936       if(aNbElem > 0){
937         anInfo[eNOEUD][ePOINT1] = aNbElem;
938         const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
939         TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
940         TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
941         for(; anIter != anIterEnd; anIter++){
942           const EEntiteMaillage& anEntity = anIter->first;
943           const TGeomSet& aGeomSet = anIter->second;
944           TGeomSet::const_iterator anIter2 = aGeomSet.begin();
945           TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
946           for(; anIter2 != anIterEnd2; anIter2++){
947             const EGeometrieElement& aGeom = *anIter2;
948             aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr);
949             if(aNbElem > 0)
950               anInfo[anEntity][aGeom] = aNbElem;
951           }
952         }
953       }
954       return anInfo;
955     }
956     
957     
958     TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo, 
959                               EEntiteMaillage theTEntity, 
960                               EGeometrieElement theTGeom, 
961                               EConnectivite theTConn,
962                               TErr* theErr)
963     {
964       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
965       
966       if(theErr && !*theErr)
967         return -1;
968       
969       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
970       
971       med_entite_maillage anEntity = med_entite_maillage(theTEntity);
972       med_geometrie_element aGeom = med_geometrie_element(theTGeom);
973       med_connectivite aConn = med_connectivite(theTConn);
974
975       return MEDnEntMaa(myFile->Id(),
976                         &aMeshInfo.myName[0],
977                         MED_CONN,
978                         anEntity,
979                         aGeom,
980                         aConn); 
981     }
982     
983     
984     void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo,
985                                 TErr* theErr)
986     {
987       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
988
989       if(theErr && !*theErr)
990         return;
991       
992       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
993       TInt aNbElem = theInfo.myElemNum.size();
994
995       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
996       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
997       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
998       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
999       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
1000
1001       TErr aRet = MEDelementsLire(myFile->Id(),
1002                                   &aMeshInfo.myName[0],
1003                                   aMeshInfo.myDim,
1004                                   &theInfo.myConn[0],
1005                                   MED_FULL_INTERLACE,
1006                                   &theInfo.myElemNames[0],
1007                                   &anIsElemNames,
1008                                   &theInfo.myElemNum[0],
1009                                   &anIsElemNum,
1010                                   &theInfo.myFamNum[0],
1011                                   aNbElem,
1012                                   anEntity,
1013                                   aGeom,
1014                                   aConn);
1015       if(theErr) 
1016         *theErr = aRet;
1017       else if(aRet < 0)
1018         EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)");
1019     }
1020     
1021     
1022     void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo,
1023                                EModeAcces theMode,
1024                                TErr* theErr)
1025     {
1026       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1027       
1028       if(theErr && !*theErr)
1029         return;
1030
1031       MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1032       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1033
1034       med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
1035       med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
1036       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
1037       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
1038       med_connectivite& aConn = static_cast<med_connectivite>(theInfo.myTConn);
1039
1040       TErr aRet = MEDelementsEcr(myFile->Id(),
1041                                  &aMeshInfo.myName[0],
1042                                  aMeshInfo.myDim,
1043                                  &anInfo.myConn[0],
1044                                  MED_FULL_INTERLACE,
1045                                  &anInfo.myElemNames[0],
1046                                  anIsElemNames,
1047                                  &anInfo.myElemNum[0],
1048                                  anIsElemNum,
1049                                  &anInfo.myFamNum[0],
1050                                  anInfo.myNbElem,
1051                                  anEntity,
1052                                  aGeom,
1053                                  aConn);
1054       
1055       if(theErr) 
1056         *theErr = aRet;
1057       else if(aRet < 0)
1058         EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)");
1059     }
1060     
1061
1062     void TVWrapper::SetCellInfo(const MED::TCellInfo& theInfo,
1063                                TErr* theErr)
1064     {
1065       SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1066     }
1067     
1068
1069     TInt TVWrapper::GetNbFields(TErr* theErr)
1070     {
1071       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1072       
1073       if(theErr && !*theErr)
1074         return -1;
1075       
1076       return MEDnChamp(myFile->Id(),0);
1077     }
1078     
1079     
1080     TInt TVWrapper::GetNbComp(TInt theFieldId,
1081                              TErr* theErr)
1082     {
1083       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1084       
1085       if(theErr && !*theErr)
1086         return -1;
1087       
1088       return MEDnChamp(myFile->Id(),theFieldId);
1089     }
1090     
1091     
1092     void TVWrapper::GetFieldInfo(TInt theFieldId, 
1093                                 MED::TFieldInfo& theInfo,
1094                                 TErr* theErr)
1095     {
1096       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1097       
1098       if(theErr && !*theErr)
1099         return;
1100       
1101       med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
1102
1103       TErr aRet = MEDchampInfo(myFile->Id(),
1104                                theFieldId,
1105                                &theInfo.myName[0],
1106                                &aType,
1107                                &theInfo.myCompNames[0],
1108                                &theInfo.myUnitNames[0],
1109                                theInfo.myNbComp);
1110       if(theErr) 
1111         *theErr = aRet;
1112       else if(aRet < 0)
1113         EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)");
1114     }
1115     
1116     
1117     void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo,
1118                                 EModeAcces theMode,
1119                                 TErr* theErr)
1120     {
1121       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1122       
1123       if(theErr && !*theErr)
1124         return;
1125       
1126       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1127       
1128       med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
1129       
1130       TErr aRet = MEDchampCr(myFile->Id(),
1131                              &anInfo.myName[0],
1132                              aType,
1133                              &anInfo.myCompNames[0],
1134                              &anInfo.myUnitNames[0],
1135                              anInfo.myNbComp);
1136       if(theErr) 
1137         *theErr = aRet;
1138       else if(aRet < 0)
1139         EXCEPTION(runtime_error,"SetFieldInfo - MEDchampEcr(...)");
1140     }
1141     
1142     
1143     void TVWrapper::SetFieldInfo(const MED::TFieldInfo& theInfo,
1144                                 TErr* theErr)
1145     {
1146       TErr aRet;
1147       SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1148       
1149       if(aRet < 0)
1150         SetFieldInfo(theInfo,eLECTURE_AJOUT,theErr);
1151     }
1152     
1153     
1154     TInt TVWrapper::GetNbTimeStamps(const MED::TFieldInfo& theInfo, 
1155                                    const MED::TEntityInfo& theEntityInfo,
1156                                    EEntiteMaillage& theEntity,
1157                                    TGeom& theGeom,
1158                                    TErr* theErr)
1159     {
1160       theEntity = EEntiteMaillage(-1);
1161       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1162
1163       if(theErr){
1164         if(theEntityInfo.empty())
1165           *theErr = -1;
1166         if(*theErr < 0)
1167           return -1;
1168       }else if(theEntityInfo.empty()) 
1169         EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1170       
1171       theGeom.clear();
1172       TInt aNbTimeStamps = 0;
1173       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1174       TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1175       for(; anIter != theEntityInfo.end(); anIter++){
1176         const med_entite_maillage& anEntity = static_cast<const med_entite_maillage>(anIter->first);
1177         const TGeom& aTGeom = anIter->second;
1178         TGeom::const_iterator anGeomIter = aTGeom.begin();
1179         for(; anGeomIter != aTGeom.end(); anGeomIter++){
1180           const med_geometrie_element& aGeom = static_cast<const med_geometrie_element>(anGeomIter->first);
1181           TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom);
1182           aNbTimeStamps = max(aTmp,aNbTimeStamps);
1183           if (aNbTimeStamps<1)
1184             continue;
1185           BEGMSG(MYDEBUG,"GetNbTimeStamps aNbTimeStamps="<<aTmp<<"; aGeom="<<aGeom<<"; anEntity="<<anEntity<<"\n");
1186           if(aTmp){
1187             theEntity = EEntiteMaillage(anEntity);
1188             ADDMSG(MYDEBUG,"theEntity="<<theEntity<<"\n");
1189             theGeom[EGeometrieElement(aGeom)] = anGeomIter->second;
1190           }
1191         }
1192         if(!theGeom.empty()) 
1193           break;
1194       }
1195       return aNbTimeStamps;
1196     }
1197     
1198     
1199     void TVWrapper::GetTimeStampInfo(TInt theTimeStampId, 
1200                                     MED::TTimeStampInfo& theInfo,
1201                                     TErr* theErr)
1202     {
1203       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1204       
1205       TGeom& aTGeom = theInfo.myGeom;
1206       
1207       if(theErr){
1208         if(aTGeom.empty())
1209           *theErr = -1;
1210         if(*theErr < 0)
1211           return;
1212       }else if(aTGeom.empty())
1213         EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell");
1214       
1215       MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1216       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1217       
1218       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myEntity);
1219       
1220       TGeom::iterator anIter = aTGeom.begin();
1221       med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1222
1223       med_booleen& anIsLocal = static_cast<med_booleen>(aFieldInfo.myIsLocal);
1224       
1225       TErr aRet = MEDpasdetempsInfo(myFile->Id(),
1226                                     &aFieldInfo.myName[0],
1227                                     anEntity,
1228                                     aGeom,
1229                                     theTimeStampId,
1230                                     &theInfo.myNbGauss,
1231                                     &theInfo.myNumDt,
1232                                     &theInfo.myNumOrd,
1233                                     &theInfo.myUnitDt[0],
1234                                     &theInfo.myDt,
1235                                     &aMeshInfo.myName[0],
1236                                     &anIsLocal,
1237                                     &aFieldInfo.myNbRef);
1238       if(theErr) 
1239         *theErr = aRet;
1240       else if(aRet < 0)
1241         EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1242       
1243       static TInt MAX_NB_GAUSS_POINTS = 32;
1244       if(theInfo.myNbGauss <= 0 || theInfo.myNbGauss > MAX_NB_GAUSS_POINTS) 
1245         theInfo.myNbGauss = 1;
1246     }
1247     
1248
1249     void TVWrapper::GetTimeStampVal(MED::TTimeStampVal& theVal,
1250                                    TErr* theErr)
1251     {
1252       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1253       
1254       if(theErr && !*theErr)
1255         return;
1256       
1257       TIdt anId = myFile->Id();
1258       
1259       MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo;
1260       MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1261       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1262       
1263       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
1264       med_mode_profil& aPflMode = static_cast<med_mode_profil>(theVal.myPflMode);
1265       TGeom& aTGeom = aTimeStampInfo.myGeom;
1266       TGeom::iterator anIter = aTGeom.begin();
1267       for(; anIter != aTGeom.end(); anIter++){
1268         med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1269         TInt aNbVal = MEDnVal(anId,
1270                               &aFieldInfo.myName[0],
1271                               anEntity,
1272                               aGeom,
1273                               aTimeStampInfo.myNumDt,
1274                               aTimeStampInfo.myNumOrd,
1275                               &aMeshInfo.myName[0],
1276                               aPflMode);
1277         if(aNbVal <= 0){
1278           if(theErr){
1279             *theErr = -1;
1280             return;
1281           }
1282           EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1283         }
1284         
1285         TValue& aValue = theVal.myMeshValue[EGeometrieElement(aGeom)];
1286         TInt iEnd = aNbVal*aFieldInfo.myNbComp;
1287         
1288         if(iEnd != aValue.size()){
1289           if(theErr){
1290             *theErr = -1;
1291             return;
1292           }
1293           EXCEPTION(runtime_error,
1294                     "GetTimeStampInfo - iEnd("<<iEnd<<
1295                     ") != aValue.size()("<<aValue.size()<<
1296                     "); aNbVal = "<<aNbVal<<
1297                     "; anEntity = "<<anEntity<<
1298                     "; aGeom = "<<aGeom);
1299         }
1300         
1301         TErr aRet;
1302         switch(aFieldInfo.myType){
1303         case eFLOAT64: {
1304           std::vector<TFloat> anArray(iEnd);
1305           aRet = MEDchampLire(anId,
1306                               &aMeshInfo.myName[0],
1307                               &aFieldInfo.myName[0],
1308                               (unsigned char*)&anArray[0],
1309                               MED_FULL_INTERLACE,
1310                               MED_ALL,
1311                               &aTimeStampInfo.myGaussName[0],
1312                               &theVal.myPflName[0],
1313                               aPflMode,
1314                               anEntity,
1315                               aGeom,
1316                               aTimeStampInfo.myNumDt,
1317                               aTimeStampInfo.myNumOrd);
1318           if(aRet >= 0) 
1319             for(TInt i = 0; i < iEnd; i++)
1320               aValue[i] = anArray[i];
1321           break;
1322         }
1323         default: {
1324           std::vector<TInt> anArray(iEnd);
1325           aRet = MEDchampLire(anId,
1326                               &aMeshInfo.myName[0],
1327                               &aFieldInfo.myName[0],
1328                               (unsigned char*)&anArray[0],
1329                               MED_FULL_INTERLACE,
1330                               MED_ALL,
1331                               &aTimeStampInfo.myGaussName[0],
1332                               &theVal.myPflName[0],
1333                               aPflMode,
1334                               anEntity,
1335                               aGeom,
1336                               aTimeStampInfo.myNumDt,
1337                               aTimeStampInfo.myNumOrd);
1338           if(aRet >= 0) 
1339             for(med_int i = 0; i < iEnd; i++) 
1340               aValue[i] = anArray[i];
1341           break;
1342         }}
1343         if(aRet < 0){
1344           if(theErr){
1345             *theErr = MED_FAUX;
1346             return;
1347           }
1348           EXCEPTION(runtime_error,"GetValTimeStamp - MEDchampLire(...)");
1349         }
1350       }
1351     }
1352     
1353     
1354     void TVWrapper::SetTimeStamp(const MED::TTimeStampVal& theVal,
1355                                  EModeAcces theMode,
1356                                  TErr* theErr)
1357     {
1358       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1359       
1360       if(theErr && !*theErr)
1361         return;
1362       
1363       TErr aRet;
1364       TIdt anId = myFile->Id();
1365       
1366       MED::TTimeStampVal& aVal = const_cast<MED::TTimeStampVal&>(theVal);
1367       MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo;
1368       MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1369       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1370       MED::TMeshValue& aMeshValue = aVal.myMeshValue;
1371       
1372       med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
1373       med_mode_profil& aPflMode = static_cast<med_mode_profil>(theVal.myPflMode);
1374       TMeshValue::iterator anIter = aMeshValue.begin();
1375       for(; anIter != aMeshValue.end(); anIter++){
1376         med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
1377         TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)];
1378         med_int iEnd = aValue.size();
1379         med_int aNbVal = iEnd / aFieldInfo.myNbComp;
1380         
1381         switch(aFieldInfo.myType){
1382         case eFLOAT64: {
1383           std::vector<TFloat>& anArray = aValue;
1384           
1385           aRet = MEDchampEcr(anId,
1386                              &aMeshInfo.myName[0],
1387                              &aFieldInfo.myName[0],
1388                              (unsigned char*)&anArray[0],
1389                              MED_FULL_INTERLACE,
1390                              aNbVal,
1391                              &aTimeStampInfo.myGaussName[0],
1392                              MED_ALL,
1393                              &aVal.myPflName[0],
1394                              aPflMode,
1395                              anEntity,
1396                              aGeom,
1397                              aTimeStampInfo.myNumDt,
1398                              &aTimeStampInfo.myUnitDt[0],
1399                              aTimeStampInfo.myDt,
1400                              aTimeStampInfo.myNumOrd);
1401           break;
1402         }
1403         default: {
1404           vector<TInt> anArray(iEnd);
1405           for(TInt i = 0; i< iEnd; i++) anArray[i] = TInt(aValue[i]);
1406           
1407           aRet = MEDchampEcr(anId,
1408                              &aMeshInfo.myName[0],
1409                              &aFieldInfo.myName[0],
1410                              (unsigned char*)&anArray[0],
1411                              MED_FULL_INTERLACE,
1412                              aNbVal,
1413                              &aTimeStampInfo.myGaussName[0],
1414                              MED_ALL,
1415                              &aVal.myPflName[0],
1416                              aPflMode,
1417                              anEntity,
1418                              aGeom,
1419                              aTimeStampInfo.myNumDt,
1420                              &aTimeStampInfo.myUnitDt[0],
1421                              aTimeStampInfo.myDt,
1422                              aTimeStampInfo.myNumOrd);
1423           break;
1424         }}
1425         
1426         if(aRet < 0){
1427           if(theErr){
1428             *theErr = MED_FAUX;
1429             break;
1430           }
1431           EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)");
1432         }
1433         
1434       }
1435       
1436       INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
1437     }
1438
1439     
1440     void TVWrapper::SetTimeStamp(const MED::TTimeStampVal& theVal,
1441                                 TErr* theErr)
1442     {
1443       TErr aRet;
1444       SetTimeStamp(theVal,eLECTURE_ECRITURE,&aRet);
1445       
1446       if(aRet < 0)
1447         SetTimeStamp(theVal,eLECTURE_AJOUT,theErr);
1448     }
1449     
1450   }
1451 }