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