]> SALOME platform Git repositories - modules/med.git/blob - src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx
Salome HOME
Join modifications from branch CEAFor_V3_2_0
[modules/med.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_Algorithm.hxx"
31 #include "MED_Utilities.hxx"
32
33 extern "C"
34 {
35 #include <med.h>
36
37 med_err
38 MEDgaussInfo(med_idt fid, int indice, char * locname, med_geometrie_element * type_geo,
39              med_int * ngauss );
40 }
41
42 #ifdef _DEBUG_
43 static int MYDEBUG = 0;
44 #else
45 static int MYDEBUG = 0;
46 #endif
47
48
49
50 namespace MED
51 {
52   template<>
53   TInt
54   GetDESCLength<eV2_2>()
55   {
56     return 200;
57   }
58
59   template<>
60   TInt
61   GetIDENTLength<eV2_2>()
62   {
63     return 8;
64   }
65
66   template<>
67   TInt
68   GetNOMLength<eV2_2>()
69   {
70     return 32;
71   }
72
73   template<>
74   TInt
75   GetLNOMLength<eV2_2>()
76   {
77     return 80;
78   }
79
80   template<>
81   TInt
82   GetPNOMLength<eV2_2>()
83   {
84     return 16;
85   }
86
87   template<>
88   TInt
89   GetNbConn<eV2_2>(EGeometrieElement typmai,
90                    EEntiteMaillage typent,
91                    TInt mdim)
92   {
93     return typmai%100;
94   }
95
96   namespace V2_2
97   {
98
99     //---------------------------------------------------------------
100     class TFile{
101       TFile();
102       TFile(const TFile&);
103       
104     public:
105       TFile(const std::string& theFileName): 
106         myFid(0), 
107         myCount(0),
108         myFileName(theFileName)
109       {}
110       
111       ~TFile(){ 
112         Close();
113       }
114       
115       void Open(EModeAcces theMode, TErr* theErr = NULL){
116         if(myCount++ == 0){
117           char* aFileName = const_cast<char*>(myFileName.c_str());
118           myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
119         }
120         if(theErr)
121           *theErr = TErr(myFid > 0);
122         else if(myFid < 0)
123           EXCEPTION(runtime_error,"TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
124       }
125
126       const TIdt& Id() const { 
127         if(myFid < 0)
128           EXCEPTION(runtime_error,"TFile - GetFid() < 0");
129         return myFid;
130       }
131
132       void Close(){ 
133         if(--myCount == 0)
134           MEDfermer(myFid);
135       }
136
137     protected:
138       std::string myFileName;
139       TInt myCount;
140       TIdt myFid;
141     };
142
143
144     //---------------------------------------------------------------
145     class TFileWrapper{
146       PFile myFile;
147
148     public:
149       TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL): 
150         myFile(theFile)
151       {
152         myFile->Open(theMode,theErr);
153       }
154       
155       ~TFileWrapper(){
156         myFile->Close();
157       }
158     };
159
160
161     //---------------------------------------------------------------
162     TVWrapper::TVWrapper(const std::string& theFileName): 
163       myFile(new TFile(theFileName))
164     {
165     }
166     
167     
168     TInt
169     TVWrapper
170     ::GetNbMeshes(TErr* theErr)
171     {
172       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
173       
174       if(theErr && !*theErr)
175         return -1;
176       
177       return MEDnMaa(myFile->Id());
178     }
179     
180     
181     void
182     TVWrapper
183     ::GetMeshInfo(TInt theMeshId, 
184                   MED::TMeshInfo& theInfo,
185                   TErr* theErr)
186     {
187       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
188       
189       if(theErr && !*theErr)
190         return;
191       
192       TErr aRet = MEDmaaInfo(myFile->Id(),
193                              theMeshId,
194                              &theInfo.myName[0],
195                              (med_int*)&theInfo.myDim,
196                              (med_maillage*)&theInfo.myType,
197                              &theInfo.myDesc[0]);
198       if(theErr) 
199         *theErr = aRet;
200       else if(aRet < 0)
201         EXCEPTION(runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
202     }
203     
204     
205     void
206     TVWrapper
207     ::SetMeshInfo(const MED::TMeshInfo& theInfo,
208                   EModeAcces theMode,
209                   TErr* theErr)
210     {
211       TFileWrapper aFileWrapper(myFile,theMode,theErr);
212       
213       if(theErr && !*theErr)
214         return;
215       
216       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
217       
218       TErr aRet = MEDmaaCr(myFile->Id(),
219                            &anInfo.myName[0],
220                            med_int(anInfo.myDim),
221                            med_maillage(theInfo.myType),
222                            &anInfo.myDesc[0]);
223       if(aRet == 0){
224         aRet = MEDunvCr(myFile->Id(),
225                         &anInfo.myName[0]);
226       }
227       
228       INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
229       
230       if(theErr) 
231         *theErr = aRet;
232       else if(aRet < 0)
233         EXCEPTION(runtime_error,"SetMeshInfo - MEDmaaCr(...)");
234     }
235     
236     
237     void 
238     TVWrapper
239     ::SetMeshInfo(const MED::TMeshInfo& theInfo,
240                   TErr* theErr)
241     {
242       TErr aRet;
243       SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
244       
245       if(aRet < 0)
246         SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
247
248       if(aRet < 0)
249         SetMeshInfo(theInfo,eCREATION,theErr);
250     }
251     
252     
253     TInt
254     TVWrapper
255     ::GetNbFamilies(const MED::TMeshInfo& theInfo,
256                     TErr* theErr)
257     {
258       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
259       
260       if(theErr && !*theErr)
261         return -1;
262       
263       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
264       return MEDnFam(myFile->Id(),
265                      &anInfo.myName[0]);
266     }
267     
268     
269     TInt
270     TVWrapper
271     ::GetNbFamAttr(TInt theFamId, 
272                    const MED::TMeshInfo& theInfo,
273                    TErr* theErr)
274     {
275       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
276       
277       if(theErr && !*theErr)
278         return -1;
279       
280       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
281       return MEDnAttribut(myFile->Id(),
282                           &anInfo.myName[0],
283                           theFamId);
284     }
285     
286     
287     TInt
288     TVWrapper
289     ::GetNbFamGroup(TInt theFamId, 
290                     const MED::TMeshInfo& theInfo,
291                     TErr* theErr)
292     {
293       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
294       
295       if(theErr && !*theErr)
296         return -1;
297       
298       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
299       return MEDnGroupe(myFile->Id(),
300                         &anInfo.myName[0],
301                         theFamId);
302     }
303     
304     
305     void
306     TVWrapper
307     ::GetFamilyInfo(TInt theFamId, 
308                     MED::TFamilyInfo& theInfo,
309                     TErr* theErr)
310     {
311       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
312       
313       if(theErr && !*theErr)
314         return;
315       
316       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
317       
318       med_int* anAttrId = theInfo.myNbAttr > 0? (med_int*)&theInfo.myAttrId[0]: NULL;
319       med_int* anAttrVal = theInfo.myNbAttr > 0? (med_int*)&theInfo.myAttrVal[0]: NULL;
320       char* anAttrDesc = theInfo.myNbAttr > 0? &theInfo.myAttrDesc[0]: NULL;
321       char* aGroupNames = theInfo.myNbGroup > 0? &theInfo.myGroupNames[0]: NULL;
322
323       TErr aRet = MEDfamInfo(myFile->Id(),
324                              &aMeshInfo.myName[0],
325                              theFamId,
326                              &theInfo.myName[0],
327                              (med_int*)&theInfo.myId,
328                              anAttrId,
329                              anAttrVal,
330                              anAttrDesc,
331                              (med_int*)&theInfo.myNbAttr,
332                              aGroupNames,
333                              (med_int*)&theInfo.myNbGroup);
334       
335       if(theErr) 
336         *theErr = aRet;
337       else if(aRet < 0)
338         EXCEPTION(runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<<
339                   " aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<
340                   "'; theFamId = "<<theFamId<<
341                   "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
342                   "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
343     }
344     
345     
346     void
347     TVWrapper
348     ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
349                     EModeAcces theMode,
350                     TErr* theErr)
351     {
352       TFileWrapper aFileWrapper(myFile,theMode,theErr);
353       
354       if(theErr && !*theErr)
355         return;
356       
357       MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
358       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
359       
360       med_int* anAttrId = anInfo.myNbAttr > 0? (med_int*)&anInfo.myAttrId[0]: NULL;
361       med_int* anAttrVal = anInfo.myNbAttr > 0? (med_int*)&anInfo.myAttrVal[0]: NULL;
362       char* anAttrDesc = anInfo.myNbAttr > 0? &anInfo.myAttrDesc[0]: NULL;
363       char* aGroupNames = anInfo.myNbGroup > 0? &anInfo.myGroupNames[0]: NULL;
364
365       TErr aRet = MEDfamCr(myFile->Id(),
366                            &aMeshInfo.myName[0],
367                            &anInfo.myName[0],
368                            anInfo.myId,
369                            anAttrId,
370                            anAttrVal,
371                            anAttrDesc,
372                            anInfo.myNbAttr,
373                            aGroupNames,
374                            anInfo.myNbGroup);
375       
376       INITMSG(MYDEBUG,"TVWrapper::GetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
377       
378       if(theErr) 
379         *theErr = aRet;
380       else if(aRet < 0)
381         EXCEPTION(runtime_error,"SetFamilyInfo - MEDfamCr(...)");
382     }
383     
384     
385     void
386     TVWrapper
387     ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
388                     TErr* theErr)
389     {
390       TErr aRet;
391       SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
392       
393       if(aRet < 0)
394         SetFamilyInfo(theInfo,eLECTURE_AJOUT,theErr);
395     }
396     
397     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398     void
399     TVWrapper
400     ::GetNames(TElemInfo& theInfo,
401                TInt theNb,
402                EEntiteMaillage theEntity, 
403                EGeometrieElement theGeom,
404                TErr* theErr)
405     {
406       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
407       
408       if(theErr && !*theErr)
409         return;
410       
411       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
412
413       TErr aRet = MEDnomLire(myFile->Id(),
414                              &aMeshInfo.myName[0],
415                              &theInfo.myElemNames[0],
416                              theNb,
417                              med_entite_maillage(theEntity),
418                              med_geometrie_element(theGeom));
419
420       theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
421     }
422
423     void
424     TVWrapper
425     ::GetNumeration(TElemInfo& theInfo,
426                     TInt theNb,
427                     EEntiteMaillage theEntity, 
428                     EGeometrieElement theGeom,
429                     TErr* theErr)
430     {
431       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
432       
433       if(theErr && !*theErr)
434         return;
435       
436       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
437       
438       med_entite_maillage& anEntity = (med_entite_maillage&)(theEntity);
439       med_geometrie_element& aGeom = (med_geometrie_element&)(theGeom);
440
441       TErr aRet = MEDnumLire(myFile->Id(),
442                              &aMeshInfo.myName[0],
443                              (med_int*)&theInfo.myElemNum[0],
444                              theNb,
445                              anEntity,
446                              aGeom);
447
448       theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
449     }
450
451     void
452     TVWrapper
453     ::GetFamilies(TElemInfo& theInfo,
454                   TInt theNb,
455                   EEntiteMaillage theEntity, 
456                   EGeometrieElement theGeom,
457                   TErr* theErr)
458     {
459       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
460       
461       if(theErr && !*theErr)
462         return;
463       
464       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
465       
466       TErr aRet = MEDfamLire(myFile->Id(),
467                              &aMeshInfo.myName[0],
468                              (med_int*)&theInfo.myFamNum[0],
469                              theNb,
470                              med_entite_maillage(theEntity),
471                              med_geometrie_element(theGeom));
472
473       if(theErr) 
474         *theErr = aRet;
475       else if(aRet < 0)
476         EXCEPTION(runtime_error,"GetFamilies - MEDfamLire(...)");
477     }
478
479     void
480     TVWrapper
481     ::SetNames(const TElemInfo& theInfo,
482                EEntiteMaillage theEntity, 
483                EGeometrieElement theGeom,
484                TErr* theErr)
485     { 
486       SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
487     }
488
489     void
490     TVWrapper
491     ::SetNames(const TElemInfo& theInfo,
492                EModeAcces theMode,
493                EEntiteMaillage theEntity, 
494                EGeometrieElement theGeom,
495                TErr* theErr)
496     {
497       TFileWrapper aFileWrapper(myFile,theMode,theErr);
498       
499       if(theErr && !*theErr)
500         return;
501
502       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
503       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
504
505       TErr aRet = 0;
506       if(theInfo.myIsElemNames){
507         aRet  = MEDnomEcr(myFile->Id(),
508                           &aMeshInfo.myName[0],
509                           &anInfo.myElemNames[0],
510                           anInfo.myElemNames.size(),
511                           med_entite_maillage(theEntity),
512                           med_geometrie_element(theGeom));
513         if(theErr) 
514           *theErr = aRet;
515         else if(aRet < 0)
516           EXCEPTION(runtime_error,"SetNames - MEDnomEcr(...)");
517       }
518     }
519
520     void
521     TVWrapper
522     ::SetNumeration(const TElemInfo& theInfo,
523                     EEntiteMaillage theEntity, 
524                     EGeometrieElement theGeom,
525                     TErr* theErr)
526     { 
527       SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
528     }
529
530     void 
531     TVWrapper
532     ::SetNumeration(const TElemInfo& theInfo,
533                     EModeAcces theMode,
534                     EEntiteMaillage theEntity, 
535                     EGeometrieElement theGeom,
536                     TErr* theErr)
537     {
538       TFileWrapper aFileWrapper(myFile,theMode,theErr);
539       
540       if(theErr && !*theErr)
541         return;
542
543       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
544       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
545
546       TErr aRet = 0;
547       if(theInfo.myIsElemNum){
548         aRet  = MEDnumEcr(myFile->Id(),
549                           &aMeshInfo.myName[0],
550                           (med_int*)&anInfo.myElemNum[0],
551                           anInfo.myElemNum.size(),
552                           med_entite_maillage(theEntity),
553                           med_geometrie_element(theGeom));
554         if(theErr) 
555           *theErr = aRet;
556         else if(aRet < 0)
557           EXCEPTION(runtime_error,"SetNumeration - MEDnumEcr(...)");
558       }
559     }
560
561     void
562     TVWrapper
563     ::SetFamilies(const TElemInfo& theInfo,
564                   EEntiteMaillage theEntity, 
565                   EGeometrieElement theGeom,
566                   TErr* theErr)
567     { 
568       SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
569     }
570
571     void 
572     TVWrapper
573     ::SetFamilies(const TElemInfo& theInfo,
574                   EModeAcces theMode,
575                   EEntiteMaillage theEntity, 
576                   EGeometrieElement theGeom,
577                   TErr* theErr)
578     {
579       TFileWrapper aFileWrapper(myFile,theMode,theErr);
580       
581       if(theErr && !*theErr)
582         return;
583
584       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
585       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
586
587       TErr aRet = MEDfamEcr(myFile->Id(),
588                             &aMeshInfo.myName[0],
589                             (med_int*)&anInfo.myFamNum[0],
590                             anInfo.myFamNum.size(),
591                             med_entite_maillage(theEntity),
592                             med_geometrie_element(theGeom));
593       
594       if(theErr) 
595         *theErr = aRet;
596       else if(aRet < 0)
597         EXCEPTION(runtime_error,"SetFamilies - MEDfamEcr(...)");
598     }
599     
600     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601     TInt
602     TVWrapper
603     ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
604                  ETable theTable,
605                  TErr* theErr)
606     {
607       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
608       
609       if(theErr && !*theErr)
610         return -1;
611       
612       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
613       
614       return MEDnEntMaa(myFile->Id(),
615                         &aMeshInfo.myName[0],
616                         (med_table)theTable,
617                         MED_NOEUD,
618                         med_geometrie_element(0),
619                         med_connectivite(0));
620     }
621     
622     
623     void
624     TVWrapper
625     ::GetNodeInfo(MED::TNodeInfo& theInfo,
626                   TErr* theErr)
627     {
628       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
629       
630       if(theErr && !*theErr)
631         return;
632       
633       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
634
635       char* anElemNames = theInfo.myIsElemNames? &theInfo.myElemNames[0]: NULL;
636       med_int* anElemNum = theInfo.myIsElemNum? &theInfo.myElemNum[0]: NULL;
637
638       TErr aRet = MEDnoeudsLire(myFile->Id(),
639                                 &aMeshInfo.myName[0],
640                                 aMeshInfo.myDim,
641                                 &theInfo.myCoord[0],
642                                 med_mode_switch(theInfo.myModeSwitch),
643                                 (med_repere*)&theInfo.mySystem,
644                                 &theInfo.myCoordNames[0],
645                                 &theInfo.myCoordUnits[0],
646                                 anElemNames,
647                                 (med_booleen*)&theInfo.myIsElemNames,
648                                 anElemNum,
649                                 (med_booleen*)&theInfo.myIsElemNum,
650                                 (med_int*)&theInfo.myFamNum[0],
651                                 theInfo.myNbElem);
652       if(theErr) 
653         *theErr = aRet;
654       else if(aRet < 0)
655         EXCEPTION(runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
656     }
657     
658     
659     void
660     TVWrapper
661     ::SetNodeInfo(const MED::TNodeInfo& theInfo,
662                   EModeAcces theMode,
663                   TErr* theErr)
664     {
665       TFileWrapper aFileWrapper(myFile,theMode,theErr);
666       
667       if(theErr && !*theErr)
668         return;
669       
670       MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
671       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
672       
673       char* anElemNames = theInfo.myIsElemNames? &anInfo.myElemNames[0]: NULL;
674       med_int* anElemNum = theInfo.myIsElemNum? &anInfo.myElemNum[0]: NULL;
675
676       TErr aRet = MEDnoeudsEcr(myFile->Id(),
677                                &aMeshInfo.myName[0],
678                                aMeshInfo.myDim,
679                                &anInfo.myCoord[0],
680                                med_mode_switch(theInfo.myModeSwitch),
681                                med_repere(theInfo.mySystem),
682                                &anInfo.myCoordNames[0],
683                                &anInfo.myCoordUnits[0],
684                                anElemNames,
685                                med_booleen(theInfo.myIsElemNames),
686                                anElemNum,
687                                med_booleen(theInfo.myIsElemNum),
688                                (med_int*)&anInfo.myFamNum[0],
689                                anInfo.myNbElem);
690       if(theErr) 
691         *theErr = aRet;
692       else if(aRet < 0)
693         EXCEPTION(runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
694     }
695     
696     
697     void
698     TVWrapper
699     ::SetNodeInfo(const MED::TNodeInfo& theInfo,
700                   TErr* theErr)
701     {
702       TErr aRet;
703       SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
704       
705       if(aRet < 0)
706         SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr);
707     }
708     
709
710     //-----------------------------------------------------------------
711     void
712     TVWrapper
713     ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
714                       TErr* theErr)
715     {
716       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
717
718       if(theErr && !*theErr)
719         return;
720
721       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
722       TInt aNbElem = theInfo.myElemNum.size();
723
724       TErr aRet;
725       aRet = MEDpolygoneConnLire(myFile->Id(), 
726                                  &aMeshInfo.myName[0],
727                                  (med_int*)&theInfo.myIndex[0],
728                                  aNbElem+1,
729                                  (med_int*)&theInfo.myConn[0],
730                                  med_entite_maillage(theInfo.myEntity),
731                                  med_connectivite(theInfo.myConnMode));
732
733       if(theErr) 
734         *theErr = aRet;
735       else if(aRet < 0)
736         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
737
738       if(theInfo.myIsElemNames){
739         GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
740         if(theErr) 
741           *theErr = aRet;
742       }
743
744       if(theInfo.myIsElemNum){
745         GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
746         if(theErr) 
747           *theErr = aRet;
748       }
749
750       GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
751       if(theErr) 
752         *theErr = aRet;
753     }
754     
755     void
756     TVWrapper
757     ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
758                       TErr* theErr)
759     {
760       SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
761     }
762     
763     void 
764     TVWrapper
765     ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
766                       EModeAcces theMode,
767                       TErr* theErr)
768     {
769       TFileWrapper aFileWrapper(myFile,theMode,theErr);
770       
771       if(theErr && !*theErr)
772         return;
773
774       MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
775       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
776
777       TErr aRet = MEDpolygoneConnEcr(myFile->Id(),
778                                      &aMeshInfo.myName[0],
779                                      (med_int*)&anInfo.myIndex[0],
780                                      anInfo.myNbElem+1,
781                                      (med_int*)&anInfo.myConn[0],
782                                      med_entite_maillage(theInfo.myEntity),
783                                      med_connectivite(theInfo.myConnMode));
784       
785       if(theErr) 
786         *theErr = aRet;
787       else if(aRet < 0)
788         EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)");
789       
790       SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
791       if(theErr) 
792         *theErr = aRet;
793       
794       SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
795       if(theErr) 
796         *theErr = aRet;
797       
798       SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
799       if(theErr) 
800         *theErr = aRet;
801     }
802
803     TInt 
804     TVWrapper
805     ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, 
806                      EEntiteMaillage theEntity, 
807                      EGeometrieElement theGeom, 
808                      EConnectivite theConnMode,
809                      TErr* theErr)
810     {
811       return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
812     }
813     
814     TInt 
815     TVWrapper
816     ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo, 
817                           EEntiteMaillage theEntity, 
818                           EGeometrieElement theGeom, 
819                           EConnectivite theConnMode,
820                           TErr* theErr)
821     {
822       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
823
824       if(theErr && !*theErr)
825         return 0;
826
827       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
828       
829       med_int taille = 0;
830
831       TErr aRet;
832       aRet = MEDpolygoneInfo(myFile->Id(), 
833                              &aMeshInfo.myName[0], 
834                              med_entite_maillage(theEntity), 
835                              med_connectivite(theConnMode),
836                              &taille);
837       
838       if(theErr) 
839         *theErr = aRet;
840       else if(aRet < 0)
841         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
842
843       return TInt(taille);
844     }
845
846     //-----------------------------------------------------------------
847     void 
848     TVWrapper
849     ::GetPolyedreInfo(TPolyedreInfo& theInfo,
850                       TErr* theErr)
851     {
852       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
853
854       if(theErr && !*theErr)
855         return;
856
857       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
858       TInt aNbElem = theInfo.myElemNum.size();
859
860       TErr aRet;
861       aRet = MEDpolyedreConnLire(myFile->Id(), 
862                                  &aMeshInfo.myName[0],
863                                  (med_int*)&theInfo.myIndex[0],
864                                  aNbElem + 1,
865                                  (med_int*)&theInfo.myFaces[0],
866                                  theInfo.myFaces.size(),
867                                  (med_int*)&theInfo.myConn[0],
868                                  med_connectivite(theInfo.myConnMode));
869
870       if(theErr) 
871         *theErr = aRet;
872       else if(aRet < 0)
873         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)");
874
875       if(theInfo.myIsElemNames){
876         GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
877         if(theErr)
878           *theErr = aRet;
879       }
880
881       if(theInfo.myIsElemNum){
882         GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
883         if(theErr) 
884           *theErr = aRet;
885       }
886
887       GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
888       if(theErr) 
889         *theErr = aRet;
890     }
891
892     void
893     TVWrapper
894     ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
895                       TErr* theErr)
896     {
897       SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
898     }
899     
900     void 
901     TVWrapper
902     ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
903                       EModeAcces theMode,
904                       TErr* theErr)
905     {
906       TFileWrapper aFileWrapper(myFile,theMode,theErr);
907       
908       if(theErr && !*theErr)
909         return;
910
911       MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
912       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
913
914       TErr aRet;
915       aRet = MEDpolyedreConnEcr(myFile->Id(),
916                                 &aMeshInfo.myName[0],
917                                 (med_int*)&anInfo.myIndex[0],
918                                 anInfo.myNbElem+1,
919                                 (med_int*)&anInfo.myFaces[0],
920                                 anInfo.myFaces.size(),
921                                 (med_int*)&anInfo.myConn[0],
922                                 med_connectivite(theInfo.myConnMode));
923       
924       if(theErr) 
925         *theErr = aRet;
926       else if(aRet < 0)
927         EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)");
928       
929       if(theInfo.myIsElemNames){
930         aRet  = MEDnomEcr(myFile->Id(),
931                           &aMeshInfo.myName[0],
932                           &anInfo.myElemNames[0],
933                           anInfo.myElemNames.size(),
934                           med_entite_maillage(theInfo.myEntity),
935                           MED_POLYEDRE);
936         if(theErr) 
937           *theErr = aRet;
938         else if(aRet < 0)
939           EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)");
940       }
941       
942       if(theInfo.myIsElemNum){
943         aRet  = MEDnumEcr(myFile->Id(),
944                           &aMeshInfo.myName[0],
945                           (med_int*)&anInfo.myElemNum[0],
946                           anInfo.myElemNum.size(),
947                           med_entite_maillage(theInfo.myEntity),
948                           MED_POLYEDRE);
949         if(theErr) 
950           *theErr = aRet;
951         else if(aRet < 0)
952           EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)");
953       }
954       
955       
956       aRet = MEDfamEcr(myFile->Id(),
957                        &aMeshInfo.myName[0],
958                        (med_int*)&anInfo.myFamNum[0],
959                        anInfo.myFamNum.size(),
960                        med_entite_maillage(theInfo.myEntity),
961                        MED_POLYEDRE);
962       
963       if(theErr) 
964         *theErr = aRet;
965       else if(aRet < 0)
966         EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)");
967     }
968
969     TInt
970     TVWrapper
971     ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, 
972                      EEntiteMaillage theEntity, 
973                      EGeometrieElement theGeom, 
974                      EConnectivite theConnMode,
975                      TErr* theErr)
976     {
977       return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
978     }
979
980     void
981     TVWrapper
982     ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
983                           TInt& theNbFaces,
984                           TInt& theConnSize,
985                           EConnectivite theConnMode,
986                           TErr* theErr)
987     {
988       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
989
990       if(theErr && !*theErr) 
991         EXCEPTION(runtime_error,"GetPolyedreInfo - (...)");
992
993       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
994       
995       TErr aRet = MEDpolyedreInfo(myFile->Id(), 
996                                   &aMeshInfo.myName[0], 
997                                   med_connectivite(theConnMode),
998                                   (med_int*)&theNbFaces,
999                                   (med_int*)&theConnSize);
1000
1001       if(theErr) 
1002         *theErr = aRet;
1003       else if(aRet < 0)
1004         EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)");
1005
1006     }
1007     
1008     //-----------------------------------------------------------------
1009     TEntityInfo
1010     TVWrapper
1011     ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1012                     EConnectivite theConnMode,
1013                     TErr* theErr)
1014     {
1015       TEntityInfo anInfo;
1016       
1017       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1018       
1019       if(theErr && *theErr < 0)
1020         return anInfo;
1021
1022       if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1023
1024       TInt aNbElem = GetNbNodes(theMeshInfo);
1025       if(aNbElem > 0){
1026         anInfo[eNOEUD][ePOINT1] = aNbElem;
1027         const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1028         TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1029         TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1030         for(; anIter != anIterEnd; anIter++){
1031           const EEntiteMaillage& anEntity = anIter->first;
1032           const TGeomSet& aGeomSet = anIter->second;
1033           TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1034           TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1035           for(; anIter2 != anIterEnd2; anIter2++){
1036             const EGeometrieElement& aGeom = *anIter2;
1037             aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1038             if(aNbElem > 0)
1039               anInfo[anEntity][aGeom] = aNbElem;
1040           }
1041         }
1042       }
1043       } else { // eSTRUCTURE
1044         EGrilleType aGrilleType;
1045         TInt aNbNodes = 1;
1046         TInt aNbElem  = 1;
1047         TInt aDim = theMeshInfo.GetDim();
1048         EGeometrieElement aGeom;
1049         EEntiteMaillage anEntity = eMAILLE;
1050         switch(aDim){
1051         case 1:
1052           aGeom = eSEG2;
1053           break;
1054         case 2:
1055           aGeom = eQUAD4;
1056           break;
1057         case 3:
1058           aGeom = eHEXA8;
1059           break;
1060         }
1061
1062         GetGrilleType(theMeshInfo,aGrilleType);
1063
1064         if (aGrilleType == eGRILLE_STANDARD){
1065           TIntVector theStruct;
1066           theStruct.resize(aDim);
1067           GetGrilleStruct(theMeshInfo,theStruct,theErr);
1068           for(med_int i=0;i<aDim;i++){
1069             aNbNodes = aNbNodes * theStruct[i];
1070             aNbElem =  aNbElem * (theStruct[i]-1);
1071           }
1072           anInfo[eNOEUD][ePOINT1] = aNbNodes;
1073           anInfo[anEntity][aGeom] = aNbElem;
1074           
1075         } else { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1076           med_table quoi;
1077           for(int aAxe=1;aAxe<=aDim;aAxe++)
1078           {
1079             switch(aAxe) {
1080             case 1 :
1081               quoi = MED_COOR_IND1;
1082               break;
1083             case 2 :
1084               quoi = MED_COOR_IND2;
1085               break;
1086             case 3 :
1087               quoi = MED_COOR_IND3;
1088               break;
1089             }
1090             TInt nbn = GetNbNodes(theMeshInfo,(ETable)quoi);
1091             aNbNodes = aNbNodes * nbn;
1092             aNbElem =  aNbElem * (nbn-1);
1093           }
1094           anInfo[eNOEUD][ePOINT1] = aNbNodes;
1095           anInfo[anEntity][aGeom] = aNbElem;
1096         }
1097       }
1098       return anInfo;
1099     }
1100     
1101     
1102     //-----------------------------------------------------------------
1103     TInt
1104     TVWrapper
1105     ::GetNbCells(const MED::TMeshInfo& theMeshInfo, 
1106                  EEntiteMaillage theEntity, 
1107                  EGeometrieElement theGeom, 
1108                  EConnectivite theConnMode,
1109                  TErr* theErr)
1110     {
1111       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1112       
1113       if(theErr && !*theErr)
1114         return -1;
1115       
1116       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1117       
1118       return MEDnEntMaa(myFile->Id(),
1119                         &aMeshInfo.myName[0],
1120                         MED_CONN,
1121                         med_entite_maillage(theEntity),
1122                         med_geometrie_element(theGeom),
1123                         med_connectivite(theConnMode)); 
1124     }
1125     
1126     
1127     void
1128     TVWrapper
1129     ::GetCellInfo(MED::TCellInfo& theInfo,
1130                   TErr* theErr)
1131     {
1132       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1133
1134       if(theErr && !*theErr)
1135         return;
1136       
1137       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1138       TInt aNbElem = theInfo.myElemNum.size();
1139
1140       char* anElemNames = theInfo.myIsElemNames? &theInfo.myElemNames[0]: NULL;
1141       med_int* anElemNum = theInfo.myIsElemNum? &theInfo.myElemNum[0]: NULL;
1142
1143       TErr aRet;
1144       aRet = MEDelementsLire(myFile->Id(),
1145                              &aMeshInfo.myName[0],
1146                              aMeshInfo.myDim,
1147                              (med_int*)&theInfo.myConn[0],
1148                              med_mode_switch(theInfo.myModeSwitch),
1149                              anElemNames,
1150                              (med_booleen*)&theInfo.myIsElemNames,
1151                              anElemNum,
1152                              (med_booleen*)&theInfo.myIsElemNum,
1153                              (med_int*)&theInfo.myFamNum[0],
1154                              aNbElem,
1155                              med_entite_maillage(theInfo.myEntity),
1156                              med_geometrie_element(theInfo.myGeom),
1157                              med_connectivite(theInfo.myConnMode));
1158       if(theErr) 
1159         *theErr = aRet;
1160       else if(aRet < 0)
1161         EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)");
1162     }
1163     
1164     
1165     void
1166     TVWrapper
1167     ::SetCellInfo(const MED::TCellInfo& theInfo,
1168                   EModeAcces theMode,
1169                   TErr* theErr)
1170     {
1171       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1172       
1173       if(theErr && !*theErr)
1174         return;
1175
1176       MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1177       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1178
1179       char* anElemNames = theInfo.myIsElemNames? &anInfo.myElemNames[0]: NULL;
1180       med_int* anElemNum = theInfo.myIsElemNum? &anInfo.myElemNum[0]: NULL;
1181
1182       TErr aRet;
1183       aRet = MEDelementsEcr(myFile->Id(),
1184                             &aMeshInfo.myName[0],
1185                             aMeshInfo.myDim,
1186                             (med_int*)&anInfo.myConn[0],
1187                             med_mode_switch(theInfo.myModeSwitch),
1188                             anElemNames,
1189                             med_booleen(theInfo.myIsElemNames),
1190                             anElemNum,
1191                             med_booleen(theInfo.myIsElemNum),
1192                             (med_int*)&anInfo.myFamNum[0],
1193                             anInfo.myNbElem,
1194                             med_entite_maillage(theInfo.myEntity),
1195                             med_geometrie_element(theInfo.myGeom),
1196                             med_connectivite(theInfo.myConnMode));
1197       
1198       if(theErr) 
1199         *theErr = aRet;
1200       else if(aRet < 0)
1201         EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)");
1202     }
1203     
1204
1205     void
1206     TVWrapper
1207     ::SetCellInfo(const MED::TCellInfo& theInfo,
1208                   TErr* theErr)
1209     {
1210       SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1211     }
1212     
1213
1214     //-----------------------------------------------------------------
1215     TInt
1216     TVWrapper
1217     ::GetNbFields(TErr* theErr)
1218     {
1219       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1220       
1221       if(theErr && !*theErr)
1222         return -1;
1223       
1224       return MEDnChamp(myFile->Id(),0);
1225     }
1226     
1227     
1228     TInt
1229     TVWrapper
1230     ::GetNbComp(TInt theFieldId,
1231                 TErr* theErr)
1232     {
1233       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1234       
1235       if(theErr && !*theErr)
1236         return -1;
1237       
1238       return MEDnChamp(myFile->Id(),theFieldId);
1239     }
1240     
1241     
1242     void
1243     TVWrapper
1244     ::GetFieldInfo(TInt theFieldId, 
1245                    MED::TFieldInfo& theInfo,
1246                                 TErr* theErr)
1247     {
1248       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1249       
1250       if(theErr && !*theErr)
1251         return;
1252       
1253       TErr aRet;
1254       aRet = MEDchampInfo(myFile->Id(),
1255                           theFieldId,
1256                           &theInfo.myName[0],
1257                           (med_type_champ*)&theInfo.myType,
1258                           &theInfo.myCompNames[0],
1259                           &theInfo.myUnitNames[0],
1260                           theInfo.myNbComp);
1261       if(theErr) 
1262         *theErr = aRet;
1263       else if(aRet < 0)
1264         EXCEPTION(runtime_error,"GetFieldInfo - MEDchampInfo(...)");
1265     }
1266     
1267     
1268     void
1269     TVWrapper
1270     ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1271                    EModeAcces theMode,
1272                    TErr* theErr)
1273     {
1274       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1275       
1276       if(theErr && !*theErr)
1277         return;
1278       
1279       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1280       
1281       TErr aRet;
1282       aRet = MEDchampCr(myFile->Id(),
1283                         &anInfo.myName[0],
1284                         med_type_champ(theInfo.myType),
1285                         &anInfo.myCompNames[0],
1286                         &anInfo.myUnitNames[0],
1287                         anInfo.myNbComp);
1288       if(theErr) 
1289         *theErr = aRet;
1290       else if(aRet < 0)
1291         EXCEPTION(runtime_error,"SetFieldInfo - MEDchampEcr(...)");
1292     }
1293     
1294     
1295     void
1296     TVWrapper
1297     ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1298                    TErr* theErr)
1299     {
1300       TErr aRet;
1301       SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1302       
1303       if(aRet < 0)
1304         SetFieldInfo(theInfo,eLECTURE_AJOUT,theErr);
1305     }
1306     
1307     
1308     //-----------------------------------------------------------------
1309     TInt
1310     TVWrapper
1311     ::GetNbGauss(TErr* theErr)
1312     {
1313       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1314       
1315       if(theErr && *theErr < 0)
1316         return -1;
1317       
1318       return MEDnGauss(myFile->Id());
1319     }
1320
1321
1322     TGaussInfo::TInfo
1323     TVWrapper
1324     ::GetGaussPreInfo(TInt theId, 
1325                       TErr* theErr)
1326     {
1327       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1328
1329       if(theErr && *theErr < 0)
1330         return TGaussInfo::TInfo();
1331       
1332       med_int aNbGaussPoints = med_int();
1333       TVector<char> aName(GetNOMLength<eV2_2>()+1);
1334       med_geometrie_element aGeom = MED_NONE;
1335
1336       TErr aRet;
1337       aRet = MEDgaussInfo(myFile->Id(),
1338                           theId,
1339                           &aName[0],
1340                           &aGeom,
1341                           &aNbGaussPoints);
1342       if(theErr) 
1343         *theErr = aRet;
1344       else if(aRet < 0)
1345         EXCEPTION(runtime_error,"GetGaussPreInfo - MEDgaussInfo(...)");
1346       
1347       return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1348                                TInt(aNbGaussPoints));
1349     }
1350
1351
1352     void
1353     TVWrapper
1354     ::GetGaussInfo(TInt theId, 
1355                    TGaussInfo& theInfo,
1356                    TErr* theErr)
1357     {
1358       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1359       
1360       if(theErr && *theErr < 0)
1361         return;
1362       
1363       TErr aRet;
1364       aRet = MEDgaussLire(myFile->Id(),
1365                           &theInfo.myRefCoord[0],
1366                           &theInfo.myGaussCoord[0],
1367                           &theInfo.myWeight[0],
1368                           med_mode_switch(theInfo.myModeSwitch),
1369                           &theInfo.myName[0]);
1370
1371       if(theErr) 
1372         *theErr = aRet;
1373       else if(aRet < 0)
1374         EXCEPTION(runtime_error,"GetGaussInfo - MEDgaussLire(...)");
1375     }
1376
1377
1378     //-----------------------------------------------------------------
1379     TInt
1380     TVWrapper
1381     ::GetNbProfiles(TErr* theErr)
1382     {
1383       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1384       
1385       if(theErr && *theErr < 0)
1386         return -1;
1387       
1388       return MEDnProfil(myFile->Id());
1389     }
1390
1391
1392     TProfileInfo::TInfo
1393     TVWrapper
1394     ::GetProfilePreInfo(TInt theId, 
1395                         TErr* theErr)
1396     {
1397       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1398
1399       if(theErr && *theErr < 0)
1400         return TProfileInfo::TInfo();
1401       
1402       TInt aSize = -1;
1403       TVector<char> aName(GetNOMLength<eV2_2>()+1);
1404
1405       TErr aRet;
1406       aRet = MEDprofilInfo(myFile->Id(),
1407                            theId,
1408                            &aName[0],
1409                            &aSize);
1410       if(theErr) 
1411         *theErr = aRet;
1412       else if(aRet < 0)
1413         EXCEPTION(runtime_error,"GetProfilePreInfo - MEDprofilInfo(...)");
1414       
1415       return TProfileInfo::TInfo(&aName[0],aSize);
1416     }
1417
1418
1419     void
1420     TVWrapper
1421     ::GetProfileInfo(TInt theId, 
1422                      TProfileInfo& theInfo,
1423                      TErr* theErr)
1424     {
1425       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1426       
1427       if(theErr && *theErr < 0)
1428         return;
1429       
1430       TErr aRet;
1431       aRet = MEDprofilLire(myFile->Id(),
1432                            &theInfo.myElemNum[0],
1433                            &theInfo.myName[0]);
1434       if(theErr) 
1435         *theErr = aRet;
1436       else if(aRet < 0)
1437         EXCEPTION(runtime_error,"GetProfileInfo - MEDprofilLire(...)");
1438     }
1439
1440
1441     //-----------------------------------------------------------------
1442     TInt
1443     TVWrapper
1444     ::GetNbTimeStamps(const MED::TFieldInfo& theInfo, 
1445                       const MED::TEntityInfo& theEntityInfo,
1446                       EEntiteMaillage& theEntity,
1447                       TGeom2Size& theGeom2Size,
1448                       TErr* theErr)
1449     {
1450       theEntity = EEntiteMaillage(-1);
1451       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1452
1453       if(theErr){
1454         if(theEntityInfo.empty())
1455           *theErr = -1;
1456         if(*theErr < 0)
1457           return -1;
1458       }else if(theEntityInfo.empty()) 
1459         EXCEPTION(runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1460       
1461       bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
1462 #ifdef _DEBUG_
1463       static bool anIsCheckOnlyFirstTimeStamp = false;
1464 #else
1465       static bool anIsCheckOnlyFirstTimeStamp = true;
1466 #endif
1467
1468       theGeom2Size.clear();
1469       TInt aNbTimeStamps = 0;
1470       TIdt anId = myFile->Id();
1471
1472       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1473       MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1474
1475       TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1476       for(; anIter != theEntityInfo.end(); anIter++){
1477         med_entite_maillage anEntity = med_entite_maillage(anIter->first);
1478         const TGeom2Size& aGeom2Size = anIter->second;
1479         TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
1480         for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
1481           med_geometrie_element aGeom = med_geometrie_element(anGeomIter->first);
1482           TInt aNbStamps = MEDnPasdetemps(anId,
1483                                           &anInfo.myName[0],
1484                                           anEntity,
1485                                           aGeom);
1486           bool anIsSatisfied = aNbStamps > 0;
1487           if(anIsSatisfied){
1488             INITMSG(MYDEBUG,
1489                     "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
1490                     "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
1491             if(anIsPerformAdditionalCheck){
1492               TInt iTimeStampEnd = anIsCheckOnlyFirstTimeStamp? 1: aNbStamps;
1493               for(TInt iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++){
1494                 TVector<char> aMeshName(GetNOMLength<eV2_2>()+1);
1495                 TVector<char> aDtUnit(GetPNOMLength<eV2_2>()+1);
1496                 med_int aNbGauss;
1497                 med_int aNumDt;
1498                 med_int aNumOrd;
1499                 med_float aDt;
1500                 med_booleen anIsLocal;
1501                 med_int aNbRef;
1502                 TErr aRet = MEDpasdetempsInfo(anId,
1503                                               &anInfo.myName[0],
1504                                               anEntity,
1505                                               aGeom,
1506                                               iTimeStamp, 
1507                                               &aNbGauss,
1508                                               &aNumDt,  
1509                                               &aNumOrd,
1510                                               &aDtUnit[0],
1511                                               &aDt, 
1512                                               &aMeshName[0],
1513                                               &anIsLocal,
1514                                               &aNbRef);
1515
1516                 anIsSatisfied = (aRet == 0 && (!strcmp(&aMeshName[0],&aMeshInfo.myName[0])));
1517                 if(!anIsSatisfied){
1518                   INITMSG(MYDEBUG,
1519                           "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
1520                           "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
1521                   break;
1522                 }
1523               }
1524             }
1525           }
1526           if(anIsSatisfied){
1527             theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
1528             theEntity = EEntiteMaillage(anEntity);
1529             aNbTimeStamps = aNbStamps;
1530           }
1531         }
1532         if(!theGeom2Size.empty()) 
1533           break;
1534       }
1535       return aNbTimeStamps;
1536     }
1537     
1538     
1539     void
1540     TVWrapper
1541     ::GetTimeStampInfo(TInt theTimeStampId, 
1542                        MED::TTimeStampInfo& theInfo,
1543                        TErr* theErr)
1544     {
1545       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1546       
1547       const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
1548       
1549       if(theErr){
1550         if(aGeom2Size.empty())
1551           *theErr = -1;
1552         if(*theErr < 0)
1553           return;
1554       }else if(aGeom2Size.empty())
1555         EXCEPTION(runtime_error,"GetTimeStampInfo - There is no any cell");
1556       
1557       MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1558       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1559       
1560       TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
1561
1562       TGeom2Size::const_iterator anIter = aGeom2Size.begin();
1563       for(; anIter != aGeom2Size.end(); anIter++){
1564         const EGeometrieElement& aGeom = anIter->first;
1565         med_int aNbGauss = -1;
1566
1567         TErr aRet;
1568         aRet = MEDpasdetempsInfo(myFile->Id(),
1569                                  &aFieldInfo.myName[0],
1570                                  med_entite_maillage(theInfo.myEntity),
1571                                  med_geometrie_element(aGeom),
1572                                  theTimeStampId,
1573                                  &aNbGauss,
1574                                  (med_int*)&theInfo.myNumDt,
1575                                  (med_int*)&theInfo.myNumOrd,
1576                                  &theInfo.myUnitDt[0],
1577                                  &theInfo.myDt,
1578                                  &aMeshInfo.myName[0],
1579                                  (med_booleen*)&aFieldInfo.myIsLocal,
1580                                  (med_int*)&aFieldInfo.myNbRef);
1581
1582         static TInt MAX_NB_GAUSS_POINTS = 32;
1583         if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
1584           aNbGauss = 1;
1585
1586         aGeom2NbGauss[aGeom] = aNbGauss;
1587
1588         if(theErr) 
1589           *theErr = aRet;
1590         else if(aRet < 0)
1591           EXCEPTION(runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1592       }      
1593     }
1594     
1595
1596     void 
1597     TVWrapper
1598     ::GetTimeStampVal(TTimeStampVal& theVal,
1599                       const TMKey2Profile& theMKey2Profile,
1600                       const TKey2Gauss& theKey2Gauss,
1601                       TErr* theErr)
1602     {
1603       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1604       
1605       if(theErr && !*theErr)
1606         return;
1607       
1608       TIdt anId = myFile->Id();
1609       
1610       MED::TTimeStampInfo& aTimeStampInfo = *theVal.myTimeStampInfo;
1611       MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1612       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1613       
1614       TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.myGeom2Gauss;
1615       TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
1616
1617       med_mode_profil aProfileMode = med_mode_profil(boost::get<0>(theMKey2Profile));
1618       MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
1619       MED::TGeom2Profile& aGeom2Profile = theVal.myGeom2Profile;
1620       TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
1621
1622       TGeom2Size& aGeom2Size = aTimeStampInfo.myGeom2Size;
1623       TGeom2Size::iterator anIter = aGeom2Size.begin();
1624       for(; anIter != aGeom2Size.end(); anIter++){
1625         EGeometrieElement aGeom = anIter->first;
1626         TInt aNbCells = anIter->second;
1627
1628         TInt aNbMeshRef = MEDnChampRef(anId,
1629                                        &aFieldInfo.myName[0],
1630                                        med_entite_maillage(aTimeStampInfo.myEntity),
1631                                        med_geometrie_element(aGeom),
1632                                        aTimeStampInfo.myNumDt,
1633                                        aTimeStampInfo.myNumOrd);
1634         if(aNbMeshRef < 1){
1635           if(theErr){
1636             *theErr = MED_FAUX;
1637             return;
1638           }
1639           EXCEPTION(runtime_error,"GetTimeStampVal - MEDnChampRef(...) < 1");
1640         }
1641         
1642         TErr aRet;
1643         med_int aNbGauss = -1;
1644         aRet = MEDchampRefInfo(anId,
1645                                &aFieldInfo.myName[0],
1646                                med_entite_maillage(aTimeStampInfo.myEntity),
1647                                med_geometrie_element(aGeom),
1648                                aNbMeshRef,
1649                                aTimeStampInfo.myNumDt,
1650                                aTimeStampInfo.myNumOrd, 
1651                                &aMeshInfo.myName[0],
1652                                (med_booleen*)&aFieldInfo.myIsLocal,
1653                                &aNbGauss);
1654
1655         if(aRet < 0){
1656           if(theErr){
1657             *theErr = MED_FAUX;
1658             return;
1659           }
1660           EXCEPTION(runtime_error,"GetTimeStampVal - MEDchampRefInfo(...)");
1661         }
1662  
1663         TInt aNbVal = MEDnVal(anId,
1664                               &aFieldInfo.myName[0],
1665                               med_entite_maillage(aTimeStampInfo.myEntity),
1666                               med_geometrie_element(aGeom),
1667                               aTimeStampInfo.myNumDt,
1668                               aTimeStampInfo.myNumOrd,
1669                               &aMeshInfo.myName[0],
1670                               aProfileMode);
1671         if(aNbVal <= 0){
1672           if(theErr){
1673             *theErr = -1;
1674             return;
1675           }
1676           EXCEPTION(runtime_error,"GetTimeStampInfo - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1677         }
1678         
1679         TMeshValue& aMeshValue = theVal.GetMeshValue(aGeom);
1680         TInt aNbElem = aNbVal / aNbGauss;
1681         aMeshValue.Init(aNbElem,
1682                         aNbGauss,
1683                         aFieldInfo.myNbComp);
1684         TValue& aValue = aMeshValue.myValue;
1685         TInt anEnd = aValue.size();
1686
1687         switch(aFieldInfo.myType){
1688         case eFLOAT64: {
1689           TVector<TFloat> anArray(anEnd);
1690           aRet = MEDchampLire(anId,
1691                               &aMeshInfo.myName[0],
1692                               &aFieldInfo.myName[0],
1693                               (unsigned char*)&anArray[0],
1694                               med_mode_switch(theVal.myModeSwitch),
1695                               MED_ALL,
1696                               &aGaussName[0],
1697                               &aProfileName[0],
1698                               aProfileMode,
1699                               med_entite_maillage(aTimeStampInfo.myEntity),
1700                               med_geometrie_element(aGeom),
1701                               aTimeStampInfo.myNumDt,
1702                               aTimeStampInfo.myNumOrd);
1703           if(aRet >= 0) 
1704             for(TInt anId = 0; anId < anEnd; anId++)
1705               aValue[anId] = anArray[anId];
1706           break;
1707         }
1708         default: {
1709           TVector<TInt> anArray(anEnd);
1710           aRet = MEDchampLire(anId,
1711                               &aMeshInfo.myName[0],
1712                               &aFieldInfo.myName[0],
1713                               (unsigned char*)&anArray[0],
1714                               med_mode_switch(theVal.myModeSwitch),
1715                               MED_ALL,
1716                               &aGaussName[0],
1717                               &aProfileName[0],
1718                               aProfileMode,
1719                               med_entite_maillage(aTimeStampInfo.myEntity),
1720                               med_geometrie_element(aGeom),
1721                               aTimeStampInfo.myNumDt,
1722                               aTimeStampInfo.myNumOrd);
1723           if(aRet >= 0) 
1724             for(TInt anId = 0; anId < anEnd; anId++)
1725               aValue[anId] = anArray[anId];
1726           break;
1727         }}
1728
1729         if(aRet < 0){
1730           if(theErr){
1731             *theErr = MED_FAUX;
1732             return;
1733           }
1734           EXCEPTION(runtime_error,"GetValTimeStamp - MEDchampLire(...)");
1735         }
1736
1737         MED::PGaussInfo aGaussInfo;
1738         TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
1739         if(strcmp(&aGaussName[0],"") != 0){
1740           MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
1741           if(anIter != theKey2Gauss.end()){
1742             aGaussInfo = anIter->second;
1743             aGeom2Gauss[aGeom] = aGaussInfo;
1744           }
1745         }
1746         
1747         MED::PProfileInfo aProfileInfo;
1748         if(strcmp(&aProfileName[0],"") != 0){
1749           MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
1750           if(anIter != aKey2Profile.end()){
1751             aProfileInfo = anIter->second;
1752             aGeom2Profile[aGeom] = aProfileInfo;
1753           }
1754         }
1755
1756         if(aNbGauss > 1 && !aGaussInfo){
1757           if(theErr){
1758             *theErr = MED_FAUX;
1759             return;
1760           }
1761           EXCEPTION(runtime_error,"GetValTimeStamp "<<
1762                     "- aNbGauss("<<aNbGauss<<") > 1 && !aGaussInfo"<<
1763                     "; aGaussName = '"<<&aGaussName[0]<<"'"<<
1764                     "; aGeom = "<<aGeom<<
1765                     "");
1766         }
1767           
1768         if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
1769           if(theErr){
1770             *theErr = MED_FAUX;
1771             return;
1772           }
1773           EXCEPTION(runtime_error,"GetValTimeStamp - aNbGauss != aGaussInfo->GetNbGauss()");
1774         }
1775         
1776         if(aProfileInfo && aProfileInfo->IsPresent()){
1777           TInt aNbSubCells = aProfileInfo->GetSize();
1778
1779           TInt aSize = aNbSubCells*aFieldInfo.myNbComp*aNbGauss;
1780           if(aSize != aValue.size()){
1781             if(theErr){
1782               *theErr = -1;
1783               return;
1784             }
1785             EXCEPTION(runtime_error,
1786                       "GetTimeStampInfo - aSize("<<aSize<<
1787                       ") != aValue.size()("<<aValue.size()<<
1788                       "); aNbVal = "<<aNbVal<<
1789                       "; anEntity = "<<aTimeStampInfo.myEntity<<
1790                       "; aGeom = "<<aGeom<<
1791                       "; aNbCells = "<<aNbCells<<
1792                       "; aNbSubCells = "<<aNbSubCells<<
1793                       "; aNbComp = "<<aFieldInfo.myNbComp<<
1794                       "; aNbGauss = "<<aNbGauss<<
1795                       "");
1796           }
1797         }else{
1798           if(anEnd != aValue.size()){
1799             if(theErr){
1800               *theErr = -1;
1801               return;
1802             }
1803             EXCEPTION(runtime_error,
1804                       "GetTimeStampInfo - anEnd("<<anEnd<<
1805                       ") != aValue.size()("<<aValue.size()<<
1806                       "); aNbVal = "<<aNbVal<<
1807                       "; anEntity = "<<aTimeStampInfo.myEntity<<
1808                       "; aGeom = "<<aGeom<<
1809                       "; aNbCells = "<<aNbCells<<
1810                       "; aNbComp = "<<aFieldInfo.myNbComp<<
1811                       "; aNbGauss = "<<aNbGauss<<
1812                       "");
1813           }
1814         }
1815       }
1816     }
1817     
1818     
1819     void
1820     TVWrapper
1821     ::SetTimeStamp(const MED::TTimeStampVal& theVal,
1822                    EModeAcces theMode,
1823                    TErr* theErr)
1824     {
1825       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1826       
1827       if(theErr && !*theErr)
1828         return;
1829       
1830       TErr aRet;
1831       TIdt anId = myFile->Id();
1832       
1833       MED::TTimeStampVal& aVal = const_cast<MED::TTimeStampVal&>(theVal);
1834
1835       MED::TTimeStampInfo& aTimeStampInfo = *aVal.myTimeStampInfo;
1836       MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
1837       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1838       MED::TGeom2Value& aGeom2Value = aVal.myGeom2Value;
1839       
1840       MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.myGeom2Gauss;
1841       MED::TGeom2Profile& aGeom2Profile = aVal.myGeom2Profile;
1842
1843       TGeom2Value::iterator anIter = aGeom2Value.begin();
1844       for(; anIter != aGeom2Value.end(); anIter++){
1845         EGeometrieElement aGeom = anIter->first;
1846         TMeshValue& aMeshValue = anIter->second;
1847
1848         TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
1849         MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
1850         if(aGaussIter != aGeom2Gauss.end()){
1851           MED::PGaussInfo aGaussInfo = aGaussIter->second;
1852           strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
1853         }
1854
1855         TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
1856         med_mode_profil aProfileMode = med_mode_profil(eNO_PFLMOD);
1857         MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
1858         if(aProfileIter != aGeom2Profile.end()){
1859           MED::PProfileInfo aProfileInfo = aProfileIter->second;
1860           aProfileMode = med_mode_profil(aProfileInfo->myMode);
1861           strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
1862         }
1863
1864         med_int aNbVal = aMeshValue.myNbElem / aFieldInfo.myNbComp;
1865         TValue& aValue = aMeshValue.myValue;
1866         TInt anEnd = aValue.size();
1867         
1868         switch(aFieldInfo.myType){
1869         case eFLOAT64: {
1870           TVector<TFloat>& anArray = aValue;
1871           
1872           aRet = MEDchampEcr(anId,
1873                              &aMeshInfo.myName[0],
1874                              &aFieldInfo.myName[0],
1875                              (unsigned char*)&anArray[0],
1876                              med_mode_switch(theVal.myModeSwitch),
1877                              aNbVal,
1878                              &aGaussName[0],
1879                              MED_ALL,
1880                              &aProfileName[0],
1881                              aProfileMode,
1882                              med_entite_maillage(aTimeStampInfo.myEntity),
1883                              med_geometrie_element(aGeom),
1884                              aTimeStampInfo.myNumDt,
1885                              &aTimeStampInfo.myUnitDt[0],
1886                              aTimeStampInfo.myDt,
1887                              aTimeStampInfo.myNumOrd);
1888           break;
1889         }
1890         default: {
1891           vector<TInt> anArray(anEnd);
1892           for(TInt anID = 0; anID < anEnd; anID++)
1893             anArray[anID] = TInt(aValue[anID]);
1894           
1895           aRet = MEDchampEcr(anId,
1896                              &aMeshInfo.myName[0],
1897                              &aFieldInfo.myName[0],
1898                              (unsigned char*)&anArray[0],
1899                              med_mode_switch(theVal.myModeSwitch),
1900                              aNbVal,
1901                              &aGaussName[0],
1902                              MED_ALL,
1903                              &aProfileName[0],
1904                              aProfileMode,
1905                              med_entite_maillage(aTimeStampInfo.myEntity),
1906                              med_geometrie_element(aGeom),
1907                              aTimeStampInfo.myNumDt,
1908                              &aTimeStampInfo.myUnitDt[0],
1909                              aTimeStampInfo.myDt,
1910                              aTimeStampInfo.myNumOrd);
1911           break;
1912         }}
1913         
1914         if(aRet < 0){
1915           if(theErr){
1916             *theErr = MED_FAUX;
1917             break;
1918           }
1919           EXCEPTION(runtime_error,"SetTimeStamp - MEDchampEcr(...)");
1920         }
1921         
1922       }
1923       
1924       INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<endl);
1925     }
1926
1927     
1928     void 
1929     TVWrapper
1930     ::SetTimeStamp(const MED::TTimeStampVal& theVal,
1931                    TErr* theErr)
1932     {
1933       TErr aRet;
1934       SetTimeStamp(theVal,eLECTURE_ECRITURE,&aRet);
1935       
1936       if(aRet < 0)
1937         SetTimeStamp(theVal,eLECTURE_AJOUT,theErr);
1938     }
1939     
1940     void 
1941     TVWrapper
1942     ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
1943                     TErr* theErr)
1944     {
1945       SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
1946     }
1947
1948     void 
1949     TVWrapper
1950     ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
1951                     EModeAcces theMode,
1952                     TErr* theErr)
1953     {
1954       if(theInfo.myMeshInfo->myType != eSTRUCTURE)
1955         return;
1956       TFileWrapper aFileWrapper(myFile,theMode,theErr);
1957       
1958       if(theErr)
1959         if(!*theErr)
1960           return;
1961
1962       MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
1963       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1964
1965       TErr aRet = 0;
1966       aRet = MEDnatureGrilleEcr(myFile->Id(),
1967                                 &aMeshInfo.myName[0],
1968                                 (med_type_grille)anInfo.myGrilleType);
1969       if(theErr) 
1970         *theErr = aRet;
1971       else if(aRet < 0)
1972         EXCEPTION(runtime_error,"SetGrilleInfo - MEDnatureGrilleEcr(...)");
1973       
1974       if(anInfo.myGrilleType == eGRILLE_STANDARD){
1975         med_int nnoeuds = (med_int)(anInfo.myCoord.size()/aMeshInfo.myDim);
1976         aRet = MEDcoordEcr(myFile->Id(),
1977                            &aMeshInfo.myName[0],
1978                            aMeshInfo.myDim,
1979                            &anInfo.myCoord[0],
1980                            med_mode_switch(anInfo.myModeSwitch),
1981                            nnoeuds,
1982                            (med_repere)theInfo.myGrilleType,
1983                            &anInfo.myCoordNames[0],
1984                            &anInfo.myCoordUnits[0]);
1985
1986         if(aRet < 0)
1987           EXCEPTION(runtime_error,"SetGrilleInfo - MEDcoordEcr(...)");
1988
1989         aRet = MEDstructureCoordEcr(myFile->Id(),
1990                                     &aMeshInfo.myName[0],
1991                                     aMeshInfo.myDim,
1992                                     &anInfo.myGrilleStructure[0]);
1993         if(aRet < 0)
1994           EXCEPTION(runtime_error,"SetGrilleInfo - MEDstructureCoordEcr(...)");
1995         
1996       } else {
1997         for(int aAxe=0;aAxe<aMeshInfo.myDim;aAxe++){
1998           aRet = MEDindicesCoordEcr(myFile->Id(),
1999                                     &aMeshInfo.myName[0],
2000                                     aMeshInfo.myDim,
2001                                     &anInfo.GetIndexes(aAxe)[0],
2002                                     anInfo.GetIndexes(aAxe).size(),
2003                                     aAxe+1,
2004                                     &anInfo.GetCoordName(aAxe)[0],
2005                                     &anInfo.GetCoordUnit(aAxe)[0]);
2006           if(aRet < 0)
2007             EXCEPTION(runtime_error,"SetGrilleInfo - MEDindicesCoordEcr(...)");
2008         }
2009         
2010       }
2011
2012       return;
2013     }
2014
2015     void
2016     TVWrapper
2017     ::GetGrilleInfo(TGrilleInfo& theInfo,
2018                     TErr* theErr)
2019     {
2020       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2021
2022       if(theErr)
2023         if(!*theErr)
2024           return;
2025       
2026       MED::TMeshInfo& aMeshInfo      = *theInfo.myMeshInfo;
2027       
2028       EMaillage type_maillage   = aMeshInfo.myType;
2029       
2030       GetGrilleType(aMeshInfo,theInfo.myGrilleType,theErr);
2031       EGrilleType       type = theInfo.myGrilleType;
2032
2033       TErr aRet;
2034       if(type_maillage == eSTRUCTURE && type == eGRILLE_STANDARD){
2035         
2036         GetGrilleStruct(aMeshInfo,theInfo.myGrilleStructure,theErr);
2037         
2038         aRet = MEDcoordLire(myFile->Id(),
2039                             &aMeshInfo.myName[0],
2040                             aMeshInfo.myDim,
2041                             &theInfo.myCoord[0],
2042                             med_mode_switch(theInfo.myModeSwitch),
2043                             MED_ALL, // all coordinates must be return
2044                             NULL,
2045                             0,
2046                             (med_repere*)&theInfo.myGrilleType,
2047                             &theInfo.myCoordNames[0],
2048                             &theInfo.myCoordUnits[0]);
2049
2050         if(theErr) 
2051           *theErr = aRet;
2052         else if(aRet < 0)
2053           EXCEPTION(runtime_error,"GetGrilleInfo - MEDcoordLire(...)");
2054         //============================
2055       }
2056
2057       if(type_maillage == eSTRUCTURE && type != eGRILLE_STANDARD){
2058         med_table quoi;
2059         for(int aAxe=1;aAxe<=aMeshInfo.myDim;aAxe++)
2060           {
2061             switch(aAxe) {
2062             case 1 :
2063               quoi = MED_COOR_IND1;
2064               break;
2065             case 2 :
2066               quoi = MED_COOR_IND2;
2067               break;
2068             case 3 :
2069               quoi = MED_COOR_IND3;
2070               break;
2071
2072             default :
2073               aRet = -1;
2074             }
2075             
2076             if(theErr) 
2077               *theErr = aRet;
2078             else if(aRet < 0)
2079               EXCEPTION(runtime_error,"GetGrilleInfo - Axe number out of range(...)");
2080
2081             TInt nind = GetNbNodes(aMeshInfo,(ETable)quoi);
2082             if(nind < 0)
2083               EXCEPTION(runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2084             
2085             med_float* indices = (med_float*)&theInfo.myIndixes[aAxe-1][0];
2086             
2087             char comp[MED_TAILLE_PNOM+1];
2088             char unit[MED_TAILLE_PNOM+1];
2089             
2090             aRet = MEDindicesCoordLire(myFile->Id(),
2091                                        &aMeshInfo.myName[0],
2092                                        aMeshInfo.myDim,
2093                                        indices,
2094                                        (med_int)nind,
2095                                        (med_int)aAxe,
2096                                        comp,
2097                                        unit);
2098             theInfo.SetCoordName(aAxe-1,comp);
2099             theInfo.SetCoordUnit(aAxe-1,unit);
2100             if(theErr) 
2101               *theErr = aRet;
2102             else if(aRet < 0)
2103               EXCEPTION(runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2104           }
2105       }
2106     }
2107
2108     void
2109     TVWrapper
2110     ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2111                     EGrilleType& type,
2112                     TErr* theErr)
2113     {
2114       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2115
2116       if(theErr)
2117         if(!*theErr)
2118         EXCEPTION(runtime_error," GetGrilleType - aFileWrapper (...)");
2119
2120       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2121       
2122       EMaillage type_maillage   = aMeshInfo.myType;
2123       
2124       TErr aRet;
2125       if(type_maillage == eSTRUCTURE){
2126         med_type_grille Mtype;
2127         aRet = MEDnatureGrilleLire(myFile->Id(),
2128                                    &aMeshInfo.myName[0],
2129                                    &Mtype);
2130         if(aRet < 0)
2131           EXCEPTION(runtime_error,"GetGrilleInfo - MEDnatureGrilleLire(...)");
2132
2133         type = (EGrilleType)Mtype;
2134
2135       }
2136     }    
2137     
2138     void
2139     TVWrapper
2140     ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2141                       TIntVector& theStruct,
2142                       TErr* theErr)
2143     {
2144       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2145       
2146       if(theErr) 
2147         if(!*theErr)
2148           return;
2149       
2150       TErr aRet;
2151       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2152
2153       med_int* anGrilleStruct = aMeshInfo.myDim > 0? (med_int*)&theStruct[0]: NULL;
2154         
2155       aRet = MEDstructureCoordLire(myFile->Id(),
2156                                    &aMeshInfo.myName[0],
2157                                    aMeshInfo.myDim,
2158                                    anGrilleStruct);
2159       if(theErr) 
2160         *theErr = aRet;
2161       else if(aRet < 0)
2162         EXCEPTION(runtime_error,"GetGrilleInfo - MEDstructureCoordLire(...)");
2163     }
2164
2165   }
2166 }