Back to index

salome-med  6.5.0
MED_V2_2_Wrapper.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : 
00024 //  Author : 
00025 //  Module : 
00026 //  $Header: /home/server/cvs/MED/MED_SRC/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx,v 1.9.2.4.4.12.2.1 2012-04-13 08:48:46 vsr Exp $
00027 //
00028 #include "MED_V2_2_Wrapper.hxx"
00029 #include "MED_Algorithm.hxx"
00030 #include "MED_Utilities.hxx"
00031 
00032 extern "C"
00033 {
00034 #include <med.h>
00035 #include <med_err.h>
00036 }
00037 
00038 #ifdef _DEBUG_
00039 static int MYDEBUG = 0;
00040 // #else
00041 // static int MYDEBUG = 0;
00042 #endif
00043 
00044 
00045 
00046 namespace MED
00047 {
00048   template<>
00049   TInt
00050   GetDESCLength<eV2_2>()
00051   {
00052     return 200;
00053   }
00054 
00055   template<>
00056   TInt
00057   GetIDENTLength<eV2_2>()
00058   {
00059     return 8;
00060   }
00061 
00062   template<>
00063   TInt
00064   GetNOMLength<eV2_2>()
00065   {
00066     return 64;
00067   }
00068 
00069   template<>
00070   TInt
00071   GetLNOMLength<eV2_2>()
00072   {
00073     return 80;
00074   }
00075 
00076   template<>
00077   TInt
00078   GetPNOMLength<eV2_2>()
00079   {
00080     return 16;
00081   }
00082 
00083   template<>
00084   void
00085   GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
00086   {
00087     majeur=MED_MAJOR_NUM;
00088     mineur=MED_MINOR_NUM;
00089     release=MED_RELEASE_NUM;
00090   }
00091 
00092   template<>
00093   TInt
00094   GetNbConn<eV2_2>(EGeometrieElement typmai,
00095                    EEntiteMaillage typent,
00096                    TInt mdim)
00097   {
00098     return typmai%100;
00099   }
00100 
00101   namespace V2_2
00102   {
00103 
00104     //---------------------------------------------------------------
00105     class TFile{
00106       TFile();
00107       TFile(const TFile&);
00108       
00109     public:
00110       TFile(const std::string& theFileName): 
00111         myCount(0),
00112         myFid(0), 
00113         myFileName(theFileName)
00114       {}
00115       
00116       ~TFile()
00117       { 
00118         Close();
00119       }
00120       
00121       void
00122       Open(EModeAcces theMode, TErr* theErr = NULL)
00123       {
00124         if(myCount++ == 0){
00125           const char* aFileName = myFileName.c_str();
00126           myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
00127         }
00128         if(theErr)
00129           *theErr = TErr(myFid);
00130         else if(myFid < 0)
00131           EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
00132       }
00133 
00134       const TIdt& Id() const 
00135       { 
00136         if(myFid < 0)
00137           EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
00138         return myFid;
00139       }
00140 
00141       void Close()
00142       { 
00143         if(--myCount == 0)
00144           MEDfileClose(myFid);
00145       }
00146 
00147     protected:
00148       TInt myCount;
00149       TIdt myFid;
00150       std::string myFileName;
00151     };
00152 
00153 
00154     //---------------------------------------------------------------
00155     class TFileWrapper
00156     {
00157       PFile myFile;
00158 
00159     public:
00160       TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL): 
00161         myFile(theFile)
00162       {
00163         myFile->Open(theMode,theErr);
00164       }
00165       
00166       ~TFileWrapper()
00167       {
00168         myFile->Close();
00169       }
00170     };
00171 
00172 
00173     //---------------------------------------------------------------
00174     TVWrapper::TVWrapper(const std::string& theFileName): 
00175       myFile(new TFile(theFileName))
00176     {}
00177     
00178     
00179     //----------------------------------------------------------------------------
00180     TInt
00181     TVWrapper
00182     ::GetNbMeshes(TErr* theErr)
00183     {
00184       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00185       
00186       if(theErr && *theErr < 0)
00187         return -1;
00188       
00189       return MEDnMesh(myFile->Id());
00190     }
00191     
00192     
00193     //----------------------------------------------------------------------------
00194     void
00195     TVWrapper
00196     ::GetMeshInfo(TInt theMeshId, 
00197                   MED::TMeshInfo& theInfo,
00198                   TErr* theErr)
00199     {
00200       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00201       
00202       if(theErr && *theErr < 0)
00203         return;
00204       
00205       TValueHolder<TString, char> aMeshName(theInfo.myName);
00206       TValueHolder<TInt, med_int> aDim(theInfo.myDim);
00207       TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
00208       TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
00209       char dtunit[MED_SNAME_SIZE+1];
00210       med_sorting_type sorttype;
00211       med_int nstep;
00212       med_axis_type at;
00213       int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
00214       char *axisname=new char[naxis*MED_SNAME_SIZE+1];
00215       char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
00216       TErr aRet = MEDmeshInfo(myFile->Id(),
00217                               theMeshId,
00218                               &aMeshName,
00219                               &aSpaceDim,
00220                               &aDim,
00221                               &aType,
00222                               &theInfo.myDesc[0],
00223                               dtunit,
00224                               &sorttype,
00225                               &nstep,
00226                               &at,
00227                               axisname,
00228                               axisunit);
00229       delete [] axisname;
00230       delete [] axisunit;
00231       if(aRet < 0)
00232         EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)");
00233     }
00234     
00235     
00236     //----------------------------------------------------------------------------
00237     void
00238     TVWrapper
00239     ::SetMeshInfo(const MED::TMeshInfo& theInfo,
00240                   EModeAcces theMode,
00241                   TErr* theErr)
00242     {
00243       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00244       
00245       if(theErr && *theErr < 0)
00246         return;
00247       
00248       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
00249       
00250       TValueHolder<TString, char> aMeshName(anInfo.myName);
00251       TValueHolder<TInt, med_int> aDim(anInfo.myDim);
00252       TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
00253       TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
00254       TValueHolder<TString, char> aDesc(anInfo.myDesc);
00255 
00256       char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1];
00257       std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0');
00258       char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1];
00259       std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0');
00260       TErr aRet = MEDmeshCr(myFile->Id(),
00261                             &aMeshName,
00262                             aSpaceDim,
00263                             aDim,
00264                             aType,
00265                             &aDesc,
00266                             "",
00267                             MED_SORT_DTIT,
00268                             MED_CARTESIAN,
00269                             nam,
00270                             unit);
00271       delete [] nam;
00272       delete [] unit;
00273       
00274       //if(aRet == 0)
00275       //  aRet = MEDunvCr(myFile->Id(),&aMeshName);
00276       
00277       INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
00278       
00279       if(theErr) 
00280         *theErr = aRet;
00281       else if(aRet < 0)
00282         EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmeshCr(...)");
00283     }
00284     
00285     
00286     //----------------------------------------------------------------------------
00287     void 
00288     TVWrapper
00289     ::SetMeshInfo(const MED::TMeshInfo& theInfo,
00290                   TErr* theErr)
00291     {
00292       TErr aRet;
00293       SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
00294       
00295       if(aRet < 0)
00296         SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
00297 
00298       if(aRet < 0)
00299         SetMeshInfo(theInfo,eCREATION,&aRet);
00300 
00301       if(theErr)
00302         *theErr = aRet;
00303     }
00304     
00305     
00306     //----------------------------------------------------------------------------
00307     TInt
00308     TVWrapper
00309     ::GetNbFamilies(const MED::TMeshInfo& theInfo,
00310                     TErr* theErr)
00311     {
00312       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00313       
00314       if(theErr && *theErr < 0)
00315         return -1;
00316       
00317       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
00318       TValueHolder<TString, char> aName(anInfo.myName);
00319       return MEDnFamily(myFile->Id(),&aName);
00320     }
00321     
00322     
00323     //----------------------------------------------------------------------------
00324     TInt
00325     TVWrapper
00326     ::GetNbFamAttr(TInt theFamId, 
00327                    const MED::TMeshInfo& theInfo,
00328                    TErr* theErr)
00329     {
00330       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00331       
00332       if(theErr && *theErr < 0)
00333         return -1;
00334       
00335       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
00336 
00337       TValueHolder<TString, char> aName(anInfo.myName);
00338 
00339       return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
00340     }
00341     
00342     
00343     //----------------------------------------------------------------------------
00344     TInt
00345     TVWrapper
00346     ::GetNbFamGroup(TInt theFamId, 
00347                     const MED::TMeshInfo& theInfo,
00348                     TErr* theErr)
00349     {
00350       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00351       
00352       if(theErr && *theErr < 0)
00353         return -1;
00354       
00355       MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
00356 
00357       TValueHolder<TString, char> aName(anInfo.myName);
00358 
00359       return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
00360     }
00361     
00362     
00363     //----------------------------------------------------------------------------
00364     void
00365     TVWrapper
00366     ::GetFamilyInfo(TInt theFamId, 
00367                     MED::TFamilyInfo& theInfo,
00368                     TErr* theErr)
00369     {
00370       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00371       
00372       if(theErr && *theErr < 0)
00373         return;
00374       
00375       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00376       
00377       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00378       TValueHolder<TString, char> aFamilyName(theInfo.myName);
00379       TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
00380       TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
00381       TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
00382       TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
00383       TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
00384       
00385       TErr aRet = MEDfamily23Info(myFile->Id(),
00386                                   &aMeshName,
00387                                   theFamId,
00388                                   &aFamilyName,
00389                                   &anAttrId,
00390                                   &anAttrVal,
00391                                   &anAttrDesc,
00392                                   &aFamilyId,
00393                                   &aGroupNames);
00394 
00395       if(theErr) 
00396         *theErr = aRet;
00397       else if(aRet < 0)
00398         EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
00399                   " aMeshInfo.myName = '"<<&aMeshName<<
00400                   "'; theFamId = "<<theFamId<<
00401                   "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
00402                   "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
00403     }
00404     
00405     
00406     //----------------------------------------------------------------------------
00407     void
00408     TVWrapper
00409     ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
00410                     EModeAcces theMode,
00411                     TErr* theErr)
00412     {
00413       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00414       
00415       if(theErr && *theErr < 0)
00416         return;
00417       
00418       MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
00419       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00420       
00421       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00422       TValueHolder<TString, char> aFamilyName(anInfo.myName);
00423       TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
00424       TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
00425       TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
00426       TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
00427       TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
00428       TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
00429       TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
00430 
00431       TErr aRet = MEDfamilyCr(myFile->Id(),
00432                               &aMeshName, 
00433                               &aFamilyName,
00434                               aFamilyId,
00435                               aNbGroup,
00436                               &aGroupNames);                 
00437 
00438       INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
00439       
00440       if(theErr) 
00441         *theErr = aRet;
00442       else if(aRet < 0)
00443         EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
00444     }
00445     
00446     
00447     //----------------------------------------------------------------------------
00448     void
00449     TVWrapper
00450     ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
00451                     TErr* theErr)
00452     {
00453       TErr aRet;
00454       SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
00455       
00456       if(aRet < 0)
00457         SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
00458 
00459       if(theErr)
00460         *theErr = aRet;
00461     }
00462     
00463     //----------------------------------------------------------------------------
00464     void
00465     TVWrapper
00466     ::GetNames(TElemInfo& theInfo,
00467                TInt theNb,
00468                EEntiteMaillage theEntity, 
00469                EGeometrieElement theGeom,
00470                TErr* theErr)
00471     {
00472       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00473       
00474       if(theErr && *theErr < 0)
00475         return;
00476       
00477       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00478 
00479       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00480       TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
00481       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00482       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00483       
00484       TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
00485                                       &aMeshName,
00486                                       MED_NO_DT,
00487                                       MED_NO_IT,
00488                                       anEntity,
00489                                       aGeom,
00490                                       &anElemNames);
00491 
00492       theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
00493 
00494       if(theErr)
00495         *theErr = aRet;
00496     }
00497 
00498     //----------------------------------------------------------------------------
00499     void
00500     TVWrapper
00501     ::GetNumeration(TElemInfo& theInfo,
00502                     TInt theNb,
00503                     EEntiteMaillage theEntity, 
00504                     EGeometrieElement theGeom,
00505                     TErr* theErr)
00506     {
00507       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00508       
00509       if(theErr && *theErr < 0)
00510         return;
00511       
00512       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00513       
00514       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00515       TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
00516       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00517       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00518       
00519       TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
00520                                         &aMeshName,
00521                                         MED_NO_DT,
00522                                         MED_NO_IT,
00523                                         anEntity,
00524                                         aGeom,
00525                                         &anElemNum);
00526 
00527       theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
00528 
00529       if(theErr)
00530         *theErr = aRet;
00531     }
00532 
00533     //----------------------------------------------------------------------------
00534     void
00535     TVWrapper
00536     ::GetFamilies(TElemInfo& theInfo,
00537                   TInt theNb,
00538                   EEntiteMaillage theEntity, 
00539                   EGeometrieElement theGeom,
00540                   TErr* theErr)
00541     {
00542       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00543       
00544       if(theErr && *theErr < 0)
00545         return;
00546       
00547       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00548 
00549       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00550       TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
00551       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00552       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00553       
00554       TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
00555                                               &aMeshName,
00556                                               MED_NO_DT,
00557                                               MED_NO_IT,
00558                                               anEntity,
00559                                               aGeom,
00560                                               &aFamNum);
00561 
00562       if(aRet < 0)
00563       {
00564 //        if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
00565           {
00566             int aSize = (int)theInfo.myFamNum->size();
00567             theInfo.myFamNum->clear();
00568             theInfo.myFamNum->resize(aSize,0);
00569             aRet = 0;
00570           }
00571 //        else
00572 //          EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
00573       }
00574       if(theErr)
00575         *theErr = aRet;
00576     }
00577 
00578 
00579     //----------------------------------------------------------------------------
00580     void
00581     TVWrapper
00582     ::SetNames(const TElemInfo& theInfo,
00583                EEntiteMaillage theEntity, 
00584                EGeometrieElement theGeom,
00585                TErr* theErr)
00586     { 
00587       SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
00588     }
00589 
00590 
00591     //----------------------------------------------------------------------------
00592     void
00593     TVWrapper
00594     ::SetNames(const TElemInfo& theInfo,
00595                EModeAcces theMode,
00596                EEntiteMaillage theEntity, 
00597                EGeometrieElement theGeom,
00598                TErr* theErr)
00599     {
00600       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00601       
00602       if(theErr && *theErr < 0)
00603         return;
00604 
00605       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
00606       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00607 
00608       TErr aRet = 0;
00609       if(theInfo.myIsElemNames){
00610         TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00611         TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
00612         TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00613         TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00614       
00615         aRet  = MEDmeshEntityNameWr(myFile->Id(),
00616                                     &aMeshName,
00617                                     MED_NO_DT,
00618                                     MED_NO_IT,
00619                                     anEntity,
00620                                     aGeom, 
00621                                     (TInt)anInfo.myElemNames->size(),
00622                                     &anElemNames);
00623         if(theErr) 
00624           *theErr = aRet;
00625         else if(aRet < 0)
00626           EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
00627       }
00628     }
00629 
00630 
00631     //----------------------------------------------------------------------------
00632     void
00633     TVWrapper
00634     ::SetNumeration(const TElemInfo& theInfo,
00635                     EEntiteMaillage theEntity, 
00636                     EGeometrieElement theGeom,
00637                     TErr* theErr)
00638     { 
00639       SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
00640     }
00641 
00642 
00643     //----------------------------------------------------------------------------
00644     void 
00645     TVWrapper
00646     ::SetNumeration(const TElemInfo& theInfo,
00647                     EModeAcces theMode,
00648                     EEntiteMaillage theEntity, 
00649                     EGeometrieElement theGeom,
00650                     TErr* theErr)
00651     {
00652       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00653       
00654       if(theErr && *theErr < 0)
00655         return;
00656 
00657       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
00658       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00659 
00660       TErr aRet = 0;
00661       if(theInfo.myIsElemNum){
00662         TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00663         TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
00664         TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00665         TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00666       
00667         aRet  = MEDmeshEntityNumberWr(myFile->Id(),
00668                                       &aMeshName,
00669                                       MED_NO_DT,
00670                                       MED_NO_IT,
00671                                       anEntity,
00672                                       aGeom,
00673                                       (TInt)anInfo.myElemNum->size(),
00674                                       &anElemNum);
00675         if(theErr) 
00676           *theErr = aRet;
00677         else if(aRet < 0)
00678           EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
00679       }
00680     }
00681 
00682     //----------------------------------------------------------------------------
00683     void
00684     TVWrapper
00685     ::SetFamilies(const TElemInfo& theInfo,
00686                   EEntiteMaillage theEntity, 
00687                   EGeometrieElement theGeom,
00688                   TErr* theErr)
00689     { 
00690       SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
00691     }
00692 
00693     //----------------------------------------------------------------------------
00694     void 
00695     TVWrapper
00696     ::SetFamilies(const TElemInfo& theInfo,
00697                   EModeAcces theMode,
00698                   EEntiteMaillage theEntity, 
00699                   EGeometrieElement theGeom,
00700                   TErr* theErr)
00701     {
00702       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00703       
00704       if(theErr && *theErr < 0)
00705         return;
00706 
00707       MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
00708       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00709 
00710       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00711       TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
00712       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theEntity);
00713       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theGeom);
00714       
00715       TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
00716                                               &aMeshName,
00717                                               MED_NO_DT,
00718                                               MED_NO_IT,
00719                                               anEntity,
00720                                               aGeom,
00721                                               (TInt)anInfo.myFamNum->size(),
00722                                               &aFamNum);
00723       
00724       if(theErr) 
00725         *theErr = aRet;
00726       else if(aRet < 0)
00727         EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
00728     }
00729     
00730     //----------------------------------------------------------------------------
00731     TInt
00732     TVWrapper
00733     ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
00734                  ETable theTable,
00735                  TErr* theErr)
00736     {
00737       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00738       
00739       if(theErr && *theErr < 0)
00740         return -1;
00741       
00742       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
00743       
00744       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00745       TValueHolder<ETable, med_data_type > aTable(theTable);
00746       med_bool chgt,trsf;
00747       return MEDmeshnEntity(myFile->Id(),
00748                             &aMeshName,
00749                             MED_NO_DT,
00750                             MED_NO_IT,
00751                             MED_NODE,
00752                             MED_NO_GEOTYPE,
00753                             aTable,
00754                             MED_NO_CMODE,
00755                             &chgt,
00756                             &trsf);
00757     }
00758     
00759     
00760     //----------------------------------------------------------------------------
00761     void
00762     TVWrapper
00763     ::GetNodeInfo(MED::TNodeInfo& theInfo,
00764                   TErr* theErr)
00765     {
00766       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00767       
00768       if(theErr && *theErr < 0)
00769         return;
00770       
00771       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00772 
00773       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00774       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
00775       TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
00776       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
00777       TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
00778       TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
00779       TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
00780       TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
00781       //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
00782       TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
00783       //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
00784       TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
00785       TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
00786 
00787       TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
00788                                           &aMeshName,
00789                                           MED_NO_DT,
00790                                           MED_NO_IT,
00791                                           aModeSwitch,
00792                                           &aCoord);
00793 
00794       TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
00795                                   &aMeshName,
00796                                   MED_NO_DT,
00797                                   MED_NO_IT,
00798                                   MED_NODE,
00799                                   MED_NO_GEOTYPE ,
00800                                   &aFamNum);
00801       if (aRet2  < 0)
00802       {
00803 //        if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
00804           {
00805             int mySize = (int)theInfo.myFamNum->size();
00806             theInfo.myFamNum->clear();
00807             theInfo.myFamNum->resize(mySize,0);
00808           }
00809 //        else
00810 //          EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
00811       }
00812                                   
00813       if ( MEDmeshEntityNameRd(myFile->Id(),
00814                           &aMeshName,
00815                           MED_NO_DT,
00816                           MED_NO_IT,
00817                           MED_NODE,
00818                           MED_NO_GEOTYPE ,
00819                           &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
00820       
00821       if ( MEDmeshEntityNumberRd(myFile->Id(),
00822                             &aMeshName,
00823                             MED_NO_DT,
00824                             MED_NO_IT,
00825                             MED_NODE,
00826                             MED_NO_GEOTYPE ,
00827                             &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
00828       
00829       if(theErr) 
00830         *theErr = aRet;
00831       else if(aRet < 0)
00832         EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
00833     }
00834     
00835     
00836     //----------------------------------------------------------------------------
00837     void
00838     TVWrapper
00839     ::SetNodeInfo(const MED::TNodeInfo& theInfo,
00840                   EModeAcces theMode,
00841                   TErr* theErr)
00842     {
00843       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00844       
00845       if(theErr && *theErr < 0)
00846         return;
00847       
00848       MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
00849       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00850       
00851       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00852       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
00853       TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
00854       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
00855       TValueHolder<ERepere, med_axis_type> aSystem(anInfo.mySystem);
00856       TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
00857       TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
00858       TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
00859       TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
00860       TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
00861       TValueHolder<EBooleen, med_bool> anIsElemNum(anInfo.myIsElemNum);
00862       TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
00863       TValueHolder<TInt, med_int> aNbElem(anInfo.myNbElem);
00864 
00865       TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
00866                                           &aMeshName,
00867                                           MED_NO_DT,
00868                                           MED_NO_IT,
00869                                           MED_NO_DT,
00870                                           aModeSwitch,
00871                                           aNbElem,
00872                                           &aCoord);
00873                                           
00874       MEDmeshEntityFamilyNumberWr(myFile->Id(),
00875                                   &aMeshName,
00876                                   MED_NO_DT,
00877                                   MED_NO_IT,
00878                                   MED_NODE,
00879                                   MED_NO_GEOTYPE,
00880                                   aNbElem,
00881                                   &aFamNum);
00882       if(anIsElemNames)
00883         MEDmeshEntityNameWr(myFile->Id(),
00884                             &aMeshName,
00885                             MED_NO_DT,
00886                             MED_NO_IT,
00887                             MED_NODE,
00888                             MED_NO_GEOTYPE,
00889                             aNbElem,
00890                             &anElemNames);
00891       if(anIsElemNum)
00892         MEDmeshEntityNumberWr(myFile->Id(),
00893                               &aMeshName,
00894                               MED_NO_DT,
00895                               MED_NO_IT,
00896                               MED_NODE,
00897                               MED_NO_GEOTYPE,
00898                               aNbElem,
00899                               &anElemNum);
00900       if(theErr) 
00901         *theErr = aRet;
00902       else if(aRet < 0)
00903         EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
00904     }
00905     
00906     
00907     //----------------------------------------------------------------------------
00908     void
00909     TVWrapper
00910     ::SetNodeInfo(const MED::TNodeInfo& theInfo,
00911                   TErr* theErr)
00912     {
00913       TErr aRet;
00914       SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
00915       
00916       if(aRet < 0)
00917         SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
00918 
00919       if(theErr) 
00920         *theErr = aRet;
00921     }
00922     
00923 
00924     //-----------------------------------------------------------------
00925     void
00926     TVWrapper
00927     ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
00928                       TErr* theErr)
00929     {
00930       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
00931 
00932       if(theErr && *theErr < 0)
00933         return;
00934 
00935       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
00936 
00937       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
00938       TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
00939       TInt aNbElem = (TInt)theInfo.myElemNum->size();
00940       TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
00941       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
00942       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
00943 
00944       TErr aRet;
00945       aRet = MEDmeshPolygonRd(myFile->Id(),
00946                               &aMeshName,
00947                               MED_NO_DT,
00948                               MED_NO_IT,
00949                               anEntity,
00950                               aConnMode,
00951                               &anIndex,
00952                               &aConn);
00953 
00954       if(theErr) 
00955         *theErr = aRet;
00956       else if(aRet < 0)
00957         EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
00958 
00959       if(theInfo.myIsElemNames){
00960         GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
00961         if(theErr) 
00962           *theErr = aRet;
00963       }
00964 
00965       if(theInfo.myIsElemNum){
00966         GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
00967         if(theErr) 
00968           *theErr = aRet;
00969       }
00970 
00971       GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
00972       if(theErr) 
00973         *theErr = aRet;
00974     }
00975     
00976     //----------------------------------------------------------------------------
00977     void
00978     TVWrapper
00979     ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
00980                       TErr* theErr)
00981     {
00982       SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
00983     }
00984     
00985     //----------------------------------------------------------------------------
00986     void 
00987     TVWrapper
00988     ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
00989                       EModeAcces theMode,
00990                       TErr* theErr)
00991     {
00992       TFileWrapper aFileWrapper(myFile,theMode,theErr);
00993       
00994       if(theErr && *theErr < 0)
00995         return;
00996 
00997       MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
00998       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
00999 
01000       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01001       TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
01002       TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
01003       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
01004       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
01005 
01006       TErr aRet = MEDmeshPolygonWr(myFile->Id(),
01007                                    &aMeshName,
01008                                    MED_NO_DT,
01009                                    MED_NO_IT,
01010                                    MED_UNDEF_DT,
01011                                    anEntity,
01012                                    aConnMode,
01013                                    anInfo.myNbElem + 1,
01014                                    &anIndex,
01015                                    &aConn);
01016       
01017       if(theErr) 
01018         *theErr = aRet;
01019       else if(aRet < 0)
01020         EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
01021       
01022       SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
01023       if(theErr) 
01024         *theErr = aRet;
01025       
01026       SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
01027       if(theErr) 
01028         *theErr = aRet;
01029       
01030       SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
01031       if(theErr) 
01032         *theErr = aRet;
01033     }
01034 
01035     //----------------------------------------------------------------------------
01036     TInt 
01037     TVWrapper
01038     ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, 
01039                      EEntiteMaillage theEntity, 
01040                      EGeometrieElement theGeom, 
01041                      EConnectivite theConnMode,
01042                      TErr* theErr)
01043     {
01044       return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
01045     }
01046     
01047     //----------------------------------------------------------------------------
01048     TInt 
01049     TVWrapper
01050     ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo, 
01051                           EEntiteMaillage theEntity, 
01052                           EGeometrieElement theGeom, 
01053                           EConnectivite theConnMode,
01054                           TErr* theErr)
01055     {
01056       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01057 
01058       if(theErr && *theErr < 0)
01059         return 0;
01060 
01061       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
01062       
01063       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01064       med_int aTaille = 0;
01065       med_bool chgt,trsf;
01066       aTaille=MEDmeshnEntity(myFile->Id(),
01067                              &aMeshName,
01068                              MED_NO_DT,
01069                              MED_NO_IT,
01070                              med_entity_type(theEntity),
01071                              MED_POLYGON,
01072                              MED_CONNECTIVITY,
01073                              med_connectivity_mode(theConnMode),
01074                              &chgt,
01075                              &trsf);
01076 
01077       
01078       if(aTaille < 0)
01079         EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
01080 
01081       return TInt(aTaille);
01082     }
01083 
01084     //-----------------------------------------------------------------
01085     void 
01086     TVWrapper
01087     ::GetPolyedreInfo(TPolyedreInfo& theInfo,
01088                       TErr* theErr)
01089     {
01090       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01091 
01092       if(theErr && *theErr < 0)
01093         return;
01094 
01095       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
01096 
01097       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01098       TInt aNbElem = (TInt)theInfo.myElemNum->size();
01099       TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
01100       TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
01101       TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
01102       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
01103 
01104       TErr aRet;
01105       aRet = MEDmeshPolyhedronRd(myFile->Id(),
01106                                  &aMeshName,
01107                                  MED_NO_DT,
01108                                  MED_NO_IT,
01109                                  MED_CELL,
01110                                  aConnMode,
01111                                  &anIndex,
01112                                  &aFaces,
01113                                  &aConn);
01114 
01115       if(theErr) 
01116         *theErr = aRet;
01117       else if(aRet < 0)
01118         EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
01119 
01120       if(theInfo.myIsElemNames){
01121         GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
01122         if(theErr)
01123           *theErr = aRet;
01124       }
01125 
01126       if(theInfo.myIsElemNum){
01127         GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
01128         if(theErr) 
01129           *theErr = aRet;
01130       }
01131 
01132       GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
01133       if(theErr) 
01134         *theErr = aRet;
01135     }
01136 
01137     //----------------------------------------------------------------------------
01138     void
01139     TVWrapper
01140     ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
01141                       TErr* theErr)
01142     {
01143       SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
01144     }
01145     
01146     //----------------------------------------------------------------------------
01147     void 
01148     TVWrapper
01149     ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
01150                       EModeAcces theMode,
01151                       TErr* theErr)
01152     {
01153       TFileWrapper aFileWrapper(myFile,theMode,theErr);
01154       
01155       if(theErr && *theErr < 0)
01156         return;
01157 
01158       MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
01159       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
01160 
01161       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01162       TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
01163       TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
01164       TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
01165       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
01166 
01167       TErr aRet;
01168       aRet = MEDmeshPolyhedronWr(myFile->Id(),
01169                                  &aMeshName,
01170                                  MED_NO_DT,
01171                                  MED_NO_IT,
01172                                  MED_UNDEF_DT,
01173                                  MED_CELL,
01174                                  aConnMode,
01175                                  anInfo.myNbElem+1,
01176                                  &anIndex,
01177                                  (TInt)anInfo.myFaces->size(),
01178                                  &aFaces,
01179                                  &aConn);
01180       
01181       if(theErr) 
01182         *theErr = aRet;
01183       else if(aRet < 0)
01184         EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
01185       
01186       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
01187 
01188       if(theInfo.myIsElemNames){
01189         TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
01190         aRet  = MEDmeshEntityNameWr(myFile->Id(),
01191                                     &aMeshName,
01192                                     MED_NO_DT,
01193                                     MED_NO_IT,
01194                                     anEntity,
01195                                     MED_POLYHEDRON,
01196                                     (TInt)anInfo.myElemNames->size(),
01197                                     &anElemNames);
01198         if(theErr) 
01199           *theErr = aRet;
01200         else if(aRet < 0)
01201           EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
01202       }
01203       
01204       if(theInfo.myIsElemNum){
01205         TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
01206         aRet = MEDmeshEntityNumberWr(myFile->Id(),
01207                                      &aMeshName,
01208                                      MED_NO_DT,
01209                                      MED_NO_IT,
01210                                      anEntity,
01211                                      MED_POLYHEDRON,
01212                                      (TInt)anInfo.myElemNum->size(),
01213                                      &anElemNum);
01214         if(theErr) 
01215           *theErr = aRet;
01216         else if(aRet < 0)
01217           EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
01218       }
01219       
01220       
01221       TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
01222       aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
01223                                          &aMeshName,
01224                                          MED_NO_DT,
01225                                          MED_NO_IT,
01226                                          anEntity,
01227                                          MED_POLYHEDRON,
01228                                          (TInt)anInfo.myFamNum->size(),
01229                                          &aFamNum);
01230       
01231       if(theErr) 
01232         *theErr = aRet;
01233       else if(aRet < 0)
01234         EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
01235     }
01236 
01237     //----------------------------------------------------------------------------
01238     TInt
01239     TVWrapper
01240     ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, 
01241                      EEntiteMaillage theEntity, 
01242                      EGeometrieElement theGeom, 
01243                      EConnectivite theConnMode,
01244                      TErr* theErr)
01245     {
01246       return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
01247     }
01248 
01249     //----------------------------------------------------------------------------
01250     void
01251     TVWrapper    ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
01252                           TInt& theNbFaces,
01253                           TInt& theConnSize,
01254                           EConnectivite theConnMode,
01255                           TErr* theErr)
01256     {
01257       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01258 
01259       if(theErr && *theErr < 0) 
01260         EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
01261 
01262       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
01263       
01264       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01265       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
01266       //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
01267       //TValueHolder<TInt, med_int> aConnSize(theConnSize);
01268 
01269       med_bool chgt,trsf;
01270       theNbFaces = MEDmeshnEntity(myFile->Id(),
01271                                   &aMeshName,
01272                                   MED_NO_DT,
01273                                   MED_NO_IT,
01274                                   MED_CELL,
01275                                   MED_POLYHEDRON,
01276                                   MED_INDEX_NODE,
01277                                   aConnMode,
01278                                   &chgt,
01279                                   &trsf);
01280 
01281       theConnSize = MEDmeshnEntity(myFile->Id(),
01282                                   &aMeshName,
01283                                   MED_NO_DT,
01284                                   MED_NO_IT,
01285                                   MED_CELL,
01286                                   MED_POLYHEDRON,
01287                                   MED_CONNECTIVITY,
01288                                   aConnMode,
01289                                   &chgt,
01290                                   &trsf);
01291 
01292       if(theNbFaces < 0 || theConnSize<0)
01293         EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
01294 
01295     }
01296     
01297     //-----------------------------------------------------------------
01298     TEntityInfo
01299     TVWrapper
01300     ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
01301                     EConnectivite theConnMode,
01302                     TErr* theErr)
01303     {
01304       TEntityInfo anInfo;
01305       
01306       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01307       
01308       if(theErr && *theErr < 0)
01309         return anInfo;
01310 
01311       if(theMeshInfo.GetType() == eNON_STRUCTURE) {
01312         TInt aNbElem = GetNbNodes(theMeshInfo);
01313         if(aNbElem > 0){
01314           anInfo[eNOEUD][ePOINT1] = aNbElem;
01315           const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
01316           TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
01317           TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
01318           for(; anIter != anIterEnd; anIter++){
01319             const EEntiteMaillage& anEntity = anIter->first;
01320             const TGeomSet& aGeomSet = anIter->second;
01321             TGeomSet::const_iterator anIter2 = aGeomSet.begin();
01322             TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
01323             for(; anIter2 != anIterEnd2; anIter2++){
01324               const EGeometrieElement& aGeom = *anIter2;
01325               aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
01326               if(aNbElem > 0)
01327                 anInfo[anEntity][aGeom] = aNbElem;
01328             }
01329           }
01330         }
01331       } else { // eSTRUCTURE
01332         EGrilleType aGrilleType;
01333         TInt aNbNodes = 1;
01334         TInt aNbElem  = 1;
01335         TInt aNbSub   = 0;
01336         TInt aDim = theMeshInfo.GetDim();
01337         EGeometrieElement aGeom, aSubGeom;
01338         EEntiteMaillage aSubEntity = eMAILLE;
01339 
01340         GetGrilleType(theMeshInfo, aGrilleType);
01341 
01342         TIntVector aStruct(aDim);
01343         if(aGrilleType == eGRILLE_STANDARD)
01344         {
01345           GetGrilleStruct(theMeshInfo, aStruct, theErr);
01346         }
01347         else
01348         { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
01349           ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
01350           for(med_int anAxis = 0; anAxis < aDim; anAxis++)
01351             aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
01352         }
01353         for(med_int i = 0; i < aDim; i++){
01354           aNbNodes = aNbNodes * aStruct[i];
01355           aNbElem = aNbElem * (aStruct[i] - 1);
01356         }
01357         switch(aDim){
01358         case 1:
01359           aGeom = eSEG2;
01360           break;
01361         case 2:
01362           aGeom = eQUAD4;
01363           aSubGeom = eSEG2;
01364           aSubEntity = eARETE;
01365           aNbSub =
01366             (aStruct[0]  ) * (aStruct[1]-1) +
01367             (aStruct[0]-1) * (aStruct[1]  );
01368           break;
01369         case 3:
01370           aGeom = eHEXA8;
01371           aSubGeom = eQUAD4;
01372           aSubEntity = eFACE;
01373           aNbSub =
01374             (aStruct[0]  ) * (aStruct[1]-1) * (aStruct[2]-1) +
01375             (aStruct[0]-1) * (aStruct[1]  ) * (aStruct[2]-1) +
01376             (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]  );
01377           break;
01378         }
01379         anInfo[eNOEUD][ePOINT1] = aNbNodes;
01380         anInfo[eMAILLE][aGeom] = aNbElem;
01381         if ( aDim > 1 )
01382           anInfo[aSubEntity][aSubGeom] = aNbSub;
01383       }
01384       return anInfo;
01385     }
01386     
01387     
01388     //-----------------------------------------------------------------
01389     TInt
01390     TVWrapper
01391     ::GetNbCells(const MED::TMeshInfo& theMeshInfo, 
01392                  EEntiteMaillage theEntity, 
01393                  EGeometrieElement theGeom, 
01394                  EConnectivite theConnMode,
01395                  TErr* theErr)
01396     {
01397       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01398       
01399       if(theErr && *theErr < 0)
01400         return -1;
01401       
01402       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
01403       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01404       med_bool chgt,trsf;
01405       if(theGeom!=MED::ePOLYGONE && theGeom!=MED::ePOLYEDRE)
01406         {
01407           return MEDmeshnEntity(myFile->Id(),
01408                                 &aMeshName,
01409                                 MED_NO_DT,
01410                                 MED_NO_IT,
01411                                 med_entity_type(theEntity),
01412                                 med_geometry_type(theGeom),
01413                                 MED_CONNECTIVITY,
01414                                 med_connectivity_mode(theConnMode),
01415                                 &chgt,
01416                                 &trsf);
01417         }
01418       else if(theGeom==MED::ePOLYGONE)
01419         {
01420           return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
01421                                 MED_POLYGON,MED_INDEX_NODE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
01422         }
01423       else
01424         {
01425           return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
01426                                 MED_POLYHEDRON,MED_INDEX_FACE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
01427         }
01428     }
01429     
01430     
01431     //----------------------------------------------------------------------------
01432     void
01433     TVWrapper
01434     ::GetCellInfo(MED::TCellInfo& theInfo,
01435                   TErr* theErr)
01436     {
01437       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01438 
01439       if(theErr && *theErr < 0)
01440         return;
01441       
01442       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
01443 
01444       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01445       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
01446       TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
01447       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
01448       TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
01449       TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
01450       TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
01451       TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
01452       TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
01453       TValueHolder<EBooleen, med_bool> anIsFamNum(theInfo.myIsFamNum);
01454       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
01455       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(theInfo.myGeom);
01456       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
01457 
01458       TErr aRet;
01459       aRet = MEDmeshElementRd(myFile->Id(),
01460                               &aMeshName,
01461                               MED_NO_DT,
01462                               MED_NO_IT,
01463                               anEntity,
01464                               aGeom,
01465                               aConnMode,
01466                               aModeSwitch,
01467                               &aConn,
01468                               &anIsElemNames,
01469                               &anElemNames,
01470                               &anIsElemNum,
01471                               &anElemNum,
01472                               &anIsFamNum,
01473                               &aFamNum);
01474 
01475       if(theErr) 
01476         *theErr = aRet;
01477       else if(aRet < 0)
01478         EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
01479       
01480       if (anIsFamNum == MED_FALSE)
01481         {
01482           int mySize = (int) theInfo.myFamNum->size();
01483           theInfo.myFamNum->clear();
01484           theInfo.myFamNum->resize(mySize, 0);
01485         }
01486       
01487     }
01488     
01489     
01490     //----------------------------------------------------------------------------
01491     void
01492     TVWrapper
01493     ::SetCellInfo(const MED::TCellInfo& theInfo,
01494                   EModeAcces theMode,
01495                   TErr* theErr)
01496     {
01497       TFileWrapper aFileWrapper(myFile,theMode,theErr);
01498       
01499       if(theErr && *theErr < 0)
01500         return;
01501 
01502       MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
01503       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
01504 
01505       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
01506       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
01507       TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
01508       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
01509       TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
01510       TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
01511       TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
01512       TValueHolder<EBooleen, med_bool> anIsElemNum(anInfo.myIsElemNum);
01513       TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
01514       TValueHolder<EBooleen, med_bool> anIsFamNum(anInfo.myIsFamNum);
01515       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
01516       TValueHolder<EGeometrieElement, med_geometry_type> aGeom(anInfo.myGeom);
01517       TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
01518       TValueHolder<TInt, med_int> aNbElem(anInfo.myNbElem);
01519 
01520       TErr aRet;
01521       aRet = MEDmeshElementConnectivityWr(myFile->Id(),
01522                                           &aMeshName,
01523                                           MED_NO_DT,
01524                                           MED_NO_IT,
01525                                           MED_UNDEF_DT,
01526                                           anEntity,
01527                                           aGeom,
01528                                           aConnMode,
01529                                           aModeSwitch,
01530                                           aNbElem,
01531                                           &aConn);
01532 
01533       MEDmeshEntityFamilyNumberWr(myFile->Id(),
01534                                   &aMeshName,
01535                                   MED_NO_DT,
01536                                   MED_NO_IT,
01537                                   anEntity,
01538                                   aGeom,
01539                                   aNbElem,
01540                                   &aFamNum);
01541       if(anIsElemNames)
01542         MEDmeshEntityNameWr(myFile->Id(),
01543                             &aMeshName,
01544                             MED_NO_DT,
01545                             MED_NO_IT,
01546                             anEntity,
01547                             aGeom,
01548                             aNbElem,
01549                             &anElemNames);
01550       if(anIsElemNum)
01551         MEDmeshEntityNumberWr(myFile->Id(),
01552                               &aMeshName,
01553                               MED_NO_DT,
01554                               MED_NO_IT,
01555                               anEntity,
01556                               aGeom,
01557                               aNbElem,
01558                               &anElemNum);
01559       if(theErr) 
01560         *theErr = aRet;
01561       else if(aRet < 0)
01562         EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
01563     }
01564     
01565 
01566     //----------------------------------------------------------------------------
01567     void
01568     TVWrapper
01569     ::SetCellInfo(const MED::TCellInfo& theInfo,
01570                   TErr* theErr)
01571     {
01572       SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
01573     }
01574     
01575 
01576     //-----------------------------------------------------------------
01577     TInt
01578     TVWrapper
01579     ::GetNbFields(TErr* theErr)
01580     {
01581       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01582       
01583       if(theErr && *theErr < 0)
01584         return -1;
01585       
01586       return MEDnField(myFile->Id());
01587     }
01588     
01589     
01590     //----------------------------------------------------------------------------
01591     TInt
01592     TVWrapper
01593     ::GetNbComp(TInt theFieldId,
01594                 TErr* theErr)
01595     {
01596       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01597       
01598       if(theErr && *theErr < 0)
01599         return -1;
01600       
01601       return MEDfieldnComponent(myFile->Id(),theFieldId);
01602     }
01603     
01604     
01605     //----------------------------------------------------------------------------
01606     void
01607     TVWrapper
01608     ::GetFieldInfo(TInt theFieldId, 
01609                    MED::TFieldInfo& theInfo,
01610                    TErr* theErr)
01611     {
01612       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01613       
01614       if(theErr && *theErr < 0)
01615         return;
01616       
01617       TString aFieldName(256); // Protect from memory problems with too long names
01618       TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
01619       TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
01620       TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
01621       MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
01622       
01623       TErr aRet;
01624       med_bool local;
01625       char dtunit[MED_SNAME_SIZE+1];
01626           char local_mesh_name[MED_NAME_SIZE+1]="";
01627       med_int nbofstp;
01628       theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
01629       aRet = MEDfieldInfo(myFile->Id(),
01630                           theFieldId,
01631                           &aFieldName[0],
01632                           local_mesh_name,
01633                           &local,
01634                           &aType,
01635                           &aCompNames,
01636                           &anUnitNames,
01637                           dtunit,
01638                           &nbofstp);
01639 
01640           if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
01641                   if(theErr)
01642                         *theErr = -1;
01643                   return;
01644           }
01645 
01646       theInfo.SetName(aFieldName);
01647 
01648       if(theErr)
01649         *theErr = aRet;
01650       else if(aRet < 0)
01651         EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
01652     }
01653     
01654     
01655     //----------------------------------------------------------------------------
01656     void
01657     TVWrapper
01658     ::SetFieldInfo(const MED::TFieldInfo& theInfo,
01659                    EModeAcces theMode,
01660                    TErr* theErr)
01661     {
01662       TFileWrapper aFileWrapper(myFile,theMode,theErr);
01663       
01664       if(theErr && *theErr < 0)
01665         return;
01666       
01667       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
01668       
01669       TValueHolder<TString, char> aFieldName(anInfo.myName);
01670       TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
01671       TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
01672       TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
01673       MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
01674       TErr aRet;
01675       char dtunit[MED_SNAME_SIZE+1];
01676       std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
01677       aRet = MEDfieldCr(myFile->Id(),
01678                         &aFieldName,
01679                         aType,
01680                         anInfo.myNbComp,
01681                         &aCompNames,
01682                         &anUnitNames,
01683                         dtunit,
01684                         &aMeshInfo.myName[0]);
01685       if(theErr) 
01686         *theErr = aRet;
01687       else if(aRet < 0)
01688         EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
01689     }
01690     
01691     
01692     //----------------------------------------------------------------------------
01693     void
01694     TVWrapper
01695     ::SetFieldInfo(const MED::TFieldInfo& theInfo,
01696                    TErr* theErr)
01697     {
01698       TErr aRet;
01699       SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
01700       
01701       if(aRet < 0)
01702         SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
01703 
01704       if(theErr) 
01705         *theErr = aRet;
01706     }
01707     
01708     
01709     //----------------------------------------------------------------------------
01710     TInt
01711     TVWrapper
01712     ::GetNbGauss(TErr* theErr)
01713     {
01714       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01715       
01716       if(theErr && *theErr < 0)
01717         return -1;
01718       
01719       return MEDnLocalization(myFile->Id());
01720     }
01721 
01722 
01723     //----------------------------------------------------------------------------
01724     TGaussInfo::TInfo
01725     TVWrapper
01726     ::GetGaussPreInfo(TInt theId, 
01727                       TErr* theErr)
01728     {
01729       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01730 
01731       if(theErr && *theErr < 0)
01732         return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
01733       
01734       med_int aNbGaussPoints = med_int();
01735       TVector<char> aName(GetNOMLength<eV2_2>()+1);
01736       med_geometry_type aGeom = MED_NONE;
01737 
01738       TErr aRet;
01739       med_int dim;
01740       char geointerpname[MED_NAME_SIZE+1]="";
01741       char ipointstructmeshname[MED_NAME_SIZE+1]="";
01742       med_int nsectionmeshcell;
01743       med_geometry_type sectiongeotype;
01744       aRet = MEDlocalizationInfo (myFile->Id(),
01745                                   theId,
01746                                   &aName[0],
01747                                   &aGeom,
01748                                   &dim,
01749                                   &aNbGaussPoints,
01750                                   geointerpname,
01751                                   ipointstructmeshname,
01752                                   &nsectionmeshcell,
01753                                   &sectiongeotype);
01754       if(theErr) 
01755         *theErr = aRet;
01756       else if(aRet < 0)
01757         EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
01758       return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
01759                                TInt(aNbGaussPoints));
01760     }
01761 
01762 
01763     //----------------------------------------------------------------------------
01764     void
01765     TVWrapper
01766     ::GetGaussInfo(TInt theId, 
01767                    TGaussInfo& theInfo,
01768                    TErr* theErr)
01769     {
01770       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01771       
01772       if(theErr && *theErr < 0)
01773         return;
01774       
01775       TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
01776       TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
01777       TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
01778       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
01779       TValueHolder<TString, char> aGaussName(theInfo.myName);
01780 
01781       TErr aRet;
01782       aRet = MEDlocalizationRd(myFile->Id(),
01783                                &aGaussName,
01784                                aModeSwitch,
01785                                &aRefCoord,
01786                                &aGaussCoord,
01787                                &aWeight);
01788 
01789       if(theErr) 
01790         *theErr = aRet;
01791       else if(aRet < 0)
01792         EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
01793     }
01794 
01795 
01796     //----------------------------------------------------------------------------
01797     TInt
01798     TVWrapper
01799     ::GetNbProfiles(TErr* theErr)
01800     {
01801       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01802       
01803       if(theErr && *theErr < 0)
01804         return -1;
01805       
01806       return MEDnProfile(myFile->Id());
01807     }
01808 
01809     TProfileInfo::TInfo
01810     TVWrapper
01811     ::GetProfilePreInfo(TInt theId, 
01812                         TErr* theErr)
01813     {
01814       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01815 
01816       if(theErr && *theErr < 0)
01817         return TProfileInfo::TInfo();
01818       
01819       med_int aSize = -1;
01820       TVector<char> aName(GetNOMLength<eV2_2>()+1);
01821 
01822       TErr aRet;
01823       aRet = MEDprofileInfo(myFile->Id(),
01824                             theId,
01825                             &aName[0],
01826                             &aSize);
01827       if(theErr) 
01828         *theErr = aRet;
01829       else if(aRet < 0)
01830         EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
01831       
01832       return TProfileInfo::TInfo(&aName[0],aSize);
01833     }
01834 
01835     void
01836     TVWrapper
01837     ::GetProfileInfo(TInt theId, 
01838                      TProfileInfo& theInfo,
01839                      TErr* theErr)
01840     {
01841       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01842       
01843       if(theErr && *theErr < 0)
01844         return;
01845       
01846       TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
01847       TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
01848       TValueHolder<TString, char>     aProfileName(anInfo.myName);
01849 
01850       TErr aRet;
01851       aRet = MEDprofileRd(myFile->Id(),
01852                           &aProfileName,
01853                           &anElemNum);
01854       if(theErr) 
01855         *theErr = aRet;
01856       else if(aRet < 0)
01857         EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
01858     }
01859 
01860     void
01861     TVWrapper
01862     ::SetProfileInfo(const TProfileInfo& theInfo,
01863                      EModeAcces          theMode,
01864                      TErr*               theErr)
01865     {
01866       TFileWrapper aFileWrapper(myFile,theMode,theErr);
01867       
01868       if(theErr && *theErr < 0)
01869         return;
01870       
01871       TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
01872       TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
01873       TValueHolder<TString, char>     aProfileName(anInfo.myName);
01874 
01875       TErr aRet;
01876       aRet = MEDprofileWr(myFile->Id(),      // descripteur du fichier.
01877                           &aProfileName,        // tableau de valeurs du profil.
01878                           theInfo.GetSize(), // taille du profil.
01879                           &anElemNum);    // nom profil.
01880       if(theErr)
01881         *theErr = aRet;
01882       else if(aRet < 0)
01883         EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
01884     }
01885 
01886     void
01887     TVWrapper
01888     ::SetProfileInfo(const TProfileInfo& theInfo,
01889                      TErr*               theErr)
01890     {
01891       TErr aRet;
01892       SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
01893       
01894       if(aRet < 0)
01895         SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
01896 
01897       if(aRet < 0)
01898         SetProfileInfo(theInfo,eCREATION,&aRet);
01899 
01900       if(theErr)
01901         *theErr = aRet;
01902     }
01903 
01904     //-----------------------------------------------------------------
01905     TInt
01906     TVWrapper
01907     ::GetNbTimeStamps(const MED::TFieldInfo& theInfo, 
01908                       const MED::TEntityInfo& theEntityInfo,
01909                       EEntiteMaillage& theEntity,
01910                       TGeom2Size& theGeom2Size,
01911                       TErr* theErr)
01912     {
01913       theEntity = EEntiteMaillage(-1);
01914       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
01915 
01916       if(theErr){
01917         if(theEntityInfo.empty())
01918           *theErr = -1;
01919         if(*theErr < 0)
01920           return -1;
01921       }else if(theEntityInfo.empty()) 
01922         EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
01923       
01924       bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
01925 
01926       theGeom2Size.clear();
01927       TInt aNbTimeStamps = 0;
01928       TIdt anId = myFile->Id();
01929 
01930       MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
01931       TValueHolder<TString, char> aFieldName(anInfo.myName);
01932       MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
01933 
01934       // workaround for IPAL13676
01935       MED::TEntityInfo localEntityInfo = theEntityInfo;
01936       TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
01937       if(anLocalIter != localEntityInfo.end()){
01938         localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
01939       }
01940         
01941       TEntityInfo::const_iterator anIter = localEntityInfo.begin();
01942       for(; anIter != localEntityInfo.end(); anIter++){
01943         med_entity_type anEntity = med_entity_type(anIter->first);
01944         const TGeom2Size& aGeom2Size = anIter->second;
01945         TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
01946         for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
01947           med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
01948           char aMeshName[MED_NAME_SIZE+1];
01949           med_bool islocal;
01950           med_field_type ft;
01951           char dtunit[MED_SNAME_SIZE+1];
01952           med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
01953           char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
01954           char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
01955           TInt aNbStamps;
01956           MEDfieldInfoByName(anId,
01957                              &aFieldName,
01958                              aMeshName,
01959                              &islocal,
01960                              &ft,
01961                              cname,
01962                              unitname,
01963                              dtunit,
01964                              &aNbStamps);
01965           delete [] cname;
01966           delete [] unitname;
01967           med_int nval = 0;
01968           med_int aNumDt;
01969           med_int aNumOrd;
01970           med_float aDt;
01971           if (aNbStamps > 0)
01972             {
01973               MEDfieldComputingStepInfo(anId,
01974                                         &aFieldName,
01975                                         1,
01976                                         &aNumDt,
01977                                         &aNumOrd,
01978                                         &aDt);
01979               char profilename[MED_NAME_SIZE+1];
01980               char locname[MED_NAME_SIZE+1];
01981               med_int profilsize;
01982               med_int aNbGauss;
01983 
01984               // protection from crash (division by zero)
01985               // inside MEDfieldnValueWithProfile function
01986               // caused by the workaround for IPAL13676 (see above)
01987               if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
01988                 continue;
01989 
01990               nval = MEDfieldnValueWithProfile(anId,
01991                                                &aFieldName,
01992                                                aNumDt,
01993                                                aNumOrd,
01994                                                anEntity,
01995                                                med_geometry_type(aGeom),
01996                                                1,
01997                                                MED_COMPACT_STMODE,
01998                                                profilename,
01999                                                &profilsize,
02000                                                locname,
02001                                                &aNbGauss);
02002             }
02003           bool anIsSatisfied =(nval > 0);
02004           if(anIsSatisfied){
02005             INITMSG(MYDEBUG,
02006                     "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
02007                     "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
02008             if(anIsPerformAdditionalCheck){
02009               anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
02010               if(!anIsSatisfied){
02011                 INITMSG(MYDEBUG,
02012                         "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
02013                         "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
02014               }
02015             }
02016           }
02017           if(anIsSatisfied){
02018             theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
02019             theEntity = EEntiteMaillage(anEntity);
02020             aNbTimeStamps = aNbStamps;
02021           }
02022         }
02023         if(!theGeom2Size.empty()) 
02024           break;
02025       }
02026       return aNbTimeStamps;
02027     }
02028     
02029     
02030     //----------------------------------------------------------------------------
02031     void
02032     TVWrapper
02033     ::GetTimeStampInfo(TInt theTimeStampId, 
02034                        MED::TTimeStampInfo& theInfo,
02035                        TErr* theErr)
02036     {
02037       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
02038       
02039       const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
02040       
02041       if(theErr){
02042         if(aGeom2Size.empty())
02043           *theErr = -1;
02044         if(*theErr < 0)
02045           return;
02046       }else if(aGeom2Size.empty())
02047         EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
02048       
02049       MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
02050       MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
02051       
02052       TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
02053       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
02054       TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
02055       TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
02056       TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
02057       TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
02058       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
02059       TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
02060       TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
02061 
02062       TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
02063 
02064       // just to get a time stamp unit (anUnitDt)
02065       med_field_type aFieldType;
02066       med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
02067       char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
02068       char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
02069       TInt aNbStamps;
02070       MEDfieldInfoByName(myFile->Id(),
02071                          &aFieldName,
02072                          &aMeshName,
02073                          &anIsLocal,
02074                          &aFieldType,
02075                          aCompName,
02076                          aCompUnit,
02077                          &anUnitDt,
02078                          &aNbStamps);
02079       delete [] aCompName;
02080       delete [] aCompUnit;
02081 
02082       TGeom2Size::const_iterator anIter = aGeom2Size.begin();
02083       for(; anIter != aGeom2Size.end(); anIter++){
02084         const EGeometrieElement& aGeom = anIter->first;
02085         med_int aNbGauss = -1;
02086 
02087         TErr aRet;
02088         aRet = MEDfieldComputingStepInfo(myFile->Id(),
02089                                          &aFieldName,
02090                                          theTimeStampId,
02091                                          &aNumDt,  
02092                                          &aNumOrd,
02093                                          &aDt);
02094         char profilename[MED_NAME_SIZE+1];
02095         med_int profilsize;
02096         char locname[MED_NAME_SIZE+1];
02097         MEDfieldnValueWithProfile(myFile->Id(),
02098                                   &aFieldName,
02099                                   aNumDt,
02100                                   aNumOrd,
02101                                   anEntity,
02102                                   med_geometry_type(aGeom),
02103                                   1,
02104                                   MED_COMPACT_STMODE,
02105                                   profilename,
02106                                   &profilsize,
02107                                   locname,
02108                                   &aNbGauss);
02109 
02110         static TInt MAX_NB_GAUSS_POINTS = 32;
02111         if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
02112           aNbGauss = 1;
02113 
02114         aGeom2NbGauss[aGeom] = aNbGauss;
02115 
02116         if(theErr) 
02117           *theErr = aRet;
02118         else if(aRet < 0)
02119           EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
02120       }      
02121     }
02122     
02123 
02124     //----------------------------------------------------------------------------
02125     void 
02126     TVWrapper
02127     ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
02128                         const TMKey2Profile& theMKey2Profile,
02129                         const TKey2Gauss& theKey2Gauss,
02130                         TErr* theErr)
02131     {
02132       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
02133       
02134       if(theErr && *theErr < 0)
02135         return;
02136       
02137       TIdt anId = myFile->Id();
02138       
02139       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
02140       MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
02141 
02142       MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
02143       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
02144       TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
02145       TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
02146 
02147       MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
02148       TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
02149       TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
02150 
02151       MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
02152       TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
02153       
02154       TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
02155       TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
02156 
02157       med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
02158       MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
02159       TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
02160 
02161       TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
02162       TGeom2Size::iterator anIter = aGeom2Size.begin();
02163       for(; anIter != aGeom2Size.end(); anIter++){
02164         EGeometrieElement aGeom = anIter->first;
02165         TInt aNbElem = anIter->second;
02166         med_int profilesize,aNbGauss;
02167 
02168         TInt aNbVal = MEDfieldnValueWithProfile(anId,
02169                                                 &aFieldName,
02170                                                 aNumDt,
02171                                                 aNumOrd,
02172                                                 anEntity,
02173                                                 med_geometry_type(aGeom),
02174                                                 1,
02175                                                 aProfileMode,
02176                                                 &aProfileName[0],
02177                                                 &profilesize,
02178                                                 &aGaussName[0],
02179                                                 &aNbGauss);
02180 
02181         if(aNbVal <= 0){
02182           if(theErr){
02183             *theErr = -1;
02184             return;
02185           }
02186           EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
02187         }
02188         
02189         TInt aNbComp = aFieldInfo->myNbComp;
02190         TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
02191         theTimeStampValue->AllocateValue(aGeom,
02192                                          aNbValue,
02193                                          aNbGauss,
02194                                          aNbComp);
02195         TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
02196 
02197         INITMSG(MYDEBUG,
02198                 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
02199                 "; aNbVal = "<<aNbVal<<
02200                 "; aNbValue = "<<aNbValue<<
02201                 "; aNbGauss = "<<aNbGauss<<
02202                 "; aNbComp = "<<aNbComp<<
02203                 std::endl);
02204         
02205         TErr aRet = MEDfieldValueWithProfileRd(anId,
02206                                                &aFieldName,
02207                                                aNumDt,
02208                                                aNumOrd,
02209                                                anEntity,
02210                                                med_geometry_type(aGeom),
02211                                                aProfileMode,
02212                                                &aProfileName[0],
02213                                                aModeSwitch,
02214                                                MED_ALL_CONSTITUENT,
02215                                                theTimeStampValue->GetValuePtr(aGeom));
02216         if(aRet < 0){
02217           if(theErr){
02218             *theErr = MED_FALSE;
02219             return;
02220           }
02221           EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
02222         }
02223 
02224         MED::PGaussInfo aGaussInfo;
02225         TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
02226         if(strcmp(&aGaussName[0],"") != 0){
02227           MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
02228           if(anIter != theKey2Gauss.end()){
02229             aGaussInfo = anIter->second;
02230             aGeom2Gauss[aGeom] = aGaussInfo;
02231           }
02232         }
02233         
02234         MED::PProfileInfo aProfileInfo;
02235         if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
02236           MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
02237           if(anIter != aKey2Profile.end()){
02238             aProfileInfo = anIter->second;
02239             aGeom2Profile[aGeom] = aProfileInfo;
02240           }
02241         }
02242 
02243         if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
02244           if(theErr){
02245             *theErr = MED_FALSE;
02246             return;
02247           }
02248           EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
02249         }
02250         
02251         if(aProfileInfo && aProfileInfo->IsPresent()){
02252           TInt aNbSubElem = aProfileInfo->GetSize();
02253           TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
02254           if(aProfileSize != aValueSize){
02255             if(theErr){
02256               *theErr = -1;
02257               return;
02258             }
02259             EXCEPTION(std::runtime_error,
02260                       "GetTimeStampValue - aProfileSize("<<aProfileSize<<
02261                       ") != aValueSize("<<aValueSize<<
02262                       "); aNbVal = "<<aNbVal<<
02263                       "; anEntity = "<<anEntity<<
02264                       "; aGeom = "<<aGeom<<
02265                       "; aNbElem = "<<aNbElem<<
02266                       "; aNbSubElem = "<<aNbSubElem<<
02267                       "; aNbComp = "<<aNbComp<<
02268                       "; aNbGauss = "<<aNbGauss<<
02269                       "");
02270           }
02271         }else{
02272           if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
02273             if(theErr){
02274               *theErr = -1;
02275               return;
02276             }
02277             EXCEPTION(std::runtime_error,
02278                       "GetTimeStampValue - aNbElem("<<aNbElem<<
02279                       ") != aNbValue("<<aNbValue<<
02280                       "); aNbVal = "<<aNbVal<<
02281                       "; anEntity = "<<anEntity<<
02282                       "; aGeom = "<<aGeom<<
02283                       "; aNbElem = "<<aNbElem<<
02284                       "; aNbComp = "<<aNbComp<<
02285                       "; aNbGauss = "<<aNbGauss<<
02286                       "");
02287           }
02288         }
02289       }
02290     }
02291     
02292     
02293     //----------------------------------------------------------------------------
02294     void
02295     TVWrapper
02296     ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
02297                         EModeAcces theMode,
02298                         TErr* theErr)
02299     {
02300       TFileWrapper aFileWrapper(myFile,theMode,theErr);
02301       
02302       if(theErr && *theErr < 0)
02303         return;
02304       
02305       TErr aRet;
02306       TIdt anId = myFile->Id();
02307       
02308       TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
02309       MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
02310 
02311       MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
02312       TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
02313       TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
02314       TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
02315       TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
02316       TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
02317       MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
02318 
02319       MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
02320       TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
02321 
02322       MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
02323       TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
02324       
02325       const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
02326       TGeomSet::const_iterator anIter = aGeomSet.begin();
02327       for(; anIter != aGeomSet.end(); anIter++){
02328         EGeometrieElement aGeom = *anIter;
02329 
02330         TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
02331         MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
02332         if(aGaussIter != aGeom2Gauss.end()){
02333           MED::PGaussInfo aGaussInfo = aGaussIter->second;
02334           strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
02335         }
02336 
02337         TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
02338         med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
02339         MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
02340         if(aProfileIter != aGeom2Profile.end()){
02341           MED::PProfileInfo aProfileInfo = aProfileIter->second;
02342           aProfileMode = med_storage_mode(aProfileInfo->myMode);
02343           strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
02344         }
02345 
02346         med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
02347 
02348         aRet = MEDfieldValueWithProfileWr(anId,
02349                                           &aFieldName,
02350                                           aNumDt,
02351                                           aNumOrd,
02352                                           aDt,
02353                                           anEntity,
02354                                           med_geometry_type(aGeom),
02355                                           aProfileMode,
02356                                           &aProfileName[0],
02357                                           &aGaussName[0],
02358                                           aModeSwitch,
02359                                           MED_ALL_CONSTITUENT,
02360                                           aNbVal,
02361                                           theTimeStampValue->GetValuePtr(aGeom));
02362         if(aRet < 0){
02363           if(theErr){
02364             *theErr = MED_FALSE;
02365             break;
02366           }
02367           EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
02368         }
02369         
02370       }
02371       
02372       INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
02373     }
02374 
02375     
02376     //----------------------------------------------------------------------------
02377     void 
02378     TVWrapper
02379     ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
02380                         TErr* theErr)
02381     {
02382       TErr aRet;
02383       SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
02384       
02385       if(aRet < 0)
02386         SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
02387 
02388       if(theErr) 
02389         *theErr = aRet;
02390     }
02391     
02392     //----------------------------------------------------------------------------
02393     void 
02394     TVWrapper
02395     ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
02396                     TErr* theErr)
02397     {
02398       SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
02399     }
02400 
02401     //----------------------------------------------------------------------------
02402     void 
02403     TVWrapper
02404     ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
02405                     EModeAcces theMode,
02406                     TErr* theErr)
02407     {
02408       if(theInfo.myMeshInfo->myType != eSTRUCTURE)
02409         return;
02410       TFileWrapper aFileWrapper(myFile,theMode,theErr);
02411       
02412       if(theErr && *theErr < 0)
02413           return;
02414 
02415       MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
02416 
02417       MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
02418       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
02419       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
02420 
02421       TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
02422 
02423       TErr aRet = 0;
02424       aRet = MEDmeshGridTypeRd(myFile->Id(),
02425                                &aMeshName,
02426                                &aGrilleType);
02427       if(theErr) 
02428         *theErr = aRet;
02429       else if(aRet < 0)
02430         EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
02431       
02432       if(anInfo.myGrilleType == eGRILLE_STANDARD){
02433         TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
02434         TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
02435         TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
02436         TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
02437         med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
02438         //med_axis_type aRepere = MED_CARTESIAN;
02439 
02440         aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
02441                                        &aMeshName,
02442                                        MED_NO_DT,
02443                                        MED_NO_IT,
02444                                        MED_UNDEF_DT,
02445                                        aModeSwitch,
02446                                        aNbNoeuds,
02447                                        &aCoord);
02448 
02449         if(aRet < 0)
02450           EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
02451 
02452         TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
02453         aRet = MEDmeshGridStructWr(myFile->Id(),
02454                                     &aMeshName,
02455                                    MED_NO_DT,
02456                                    MED_NO_IT,
02457                                    MED_UNDEF_DT,
02458                                    &aGrilleStructure);
02459         if(aRet < 0)
02460           EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
02461         
02462       } else {
02463         for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
02464           aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
02465                                               &aMeshName,
02466                                               MED_NO_DT,
02467                                               MED_NO_IT,
02468                                               MED_UNDEF_DT,
02469                                               aAxis+1,
02470                                               anInfo.GetIndexes(aAxis).size(),
02471                                               &anInfo.GetIndexes(aAxis)[0]);
02472 
02473           if(aRet < 0)
02474             EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
02475         }
02476         
02477       }
02478 
02479       return;
02480     }
02481 
02482     //----------------------------------------------------------------------------
02483     void
02484     TVWrapper
02485     ::GetGrilleInfo(TGrilleInfo& theInfo,
02486                     TErr* theErr)
02487     {
02488       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
02489 
02490       if(theErr && *theErr < 0)
02491           return;
02492       
02493       MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
02494       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
02495       TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
02496       EMaillage aMaillageType = aMeshInfo.myType;
02497       
02498       GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
02499       EGrilleType aGrilleType = theInfo.myGrilleType;
02500 
02501       TErr aRet = 0;
02502       if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
02503         GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
02504 
02505         TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
02506         TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
02507         TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
02508         TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
02509         //med_axis_type aRepere;
02510 
02511         aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
02512                                        &aMeshName,
02513                                        MED_NO_DT,
02514                                        MED_NO_IT,
02515                                        aModeSwitch,
02516                                        &aCoord);
02517 
02518         if(theErr) 
02519           *theErr = aRet;
02520         else if(aRet < 0)
02521           EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
02522 
02523         //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
02524         TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
02525         
02526         aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
02527                                            &aMeshName,
02528                                            MED_NO_DT,
02529                                            MED_NO_IT,
02530                                            MED_NODE,
02531                                            MED_NO_GEOTYPE,
02532                                            &aFamNumNode);
02533 
02534         if(aRet < 0)
02535         {
02536 //            if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
02537               {
02538                 int mySize = (int)theInfo.myFamNumNode.size();
02539                 theInfo.myFamNumNode.clear();
02540                 theInfo.myFamNumNode.resize(mySize,0);
02541                 aRet = 0;
02542               }
02543 //            else
02544 //              EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
02545         }
02546         if(theErr) 
02547           *theErr = aRet;
02548 
02549         //============================
02550       }
02551 
02552       if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
02553         ETable aTable;
02554         for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
02555           switch(anAxis){
02556           case 1 :
02557             aTable = eCOOR_IND1;
02558             break;
02559           case 2 :
02560             aTable = eCOOR_IND2;
02561             break;
02562           case 3 :
02563             aTable = eCOOR_IND3;
02564             break;
02565           default :
02566             aRet = -1;
02567           }
02568             
02569           if(theErr) 
02570             *theErr = aRet;
02571           else if(aRet < 0)
02572             EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
02573           
02574           TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
02575           if(aNbIndexes < 0)
02576             EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
02577             
02578           TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
02579           //TValueHolder<ETable, med_data_type > table(aTable);
02580           //char aCompNames[MED_SNAME_SIZE+1];
02581           //char anUnitNames[MED_SNAME_SIZE+1];
02582           aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
02583                                             MED_NO_DT,MED_NO_IT,
02584                                             anAxis,
02585                                             &anIndexes);
02586 
02587           //theInfo.SetCoordName(anAxis-1, aCompNames);
02588           //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
02589           theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
02590 
02591           if(theErr) 
02592             *theErr = aRet;
02593           else if(aRet < 0)
02594             EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
02595         }
02596       }
02597 
02598       EGeometrieElement aGeom = theInfo.GetGeom();
02599       EEntiteMaillage aEntity = theInfo.GetEntity();
02600       TInt aNbCells = theInfo.GetNbCells();
02601       
02602       theInfo.myFamNum.resize(aNbCells);
02603       TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
02604       
02605       aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
02606                                          &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
02607                                          med_geometry_type(aGeom),&aFamNum);
02608 
02609       if ( aMeshInfo.myDim == 3 )
02610       {
02611         aGeom = theInfo.GetSubGeom();
02612         aEntity = theInfo.GetSubEntity();
02613         aNbCells = theInfo.GetNbSubCells();
02614       
02615         theInfo.myFamSubNum.resize(aNbCells,0);
02616         TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
02617       
02618         aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
02619                                     &aMeshName,MED_NO_DT,MED_NO_IT,
02620                                     med_entity_type(aEntity),
02621                                     med_geometry_type(aGeom),&aFamNum);
02622       }
02623       if(aRet < 0)
02624       {
02625 //          if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
02626             {
02627               int mySize = (int)theInfo.myFamNumNode.size();
02628               theInfo.myFamNumNode.clear();
02629               theInfo.myFamNumNode.resize(mySize,0);
02630               aRet = 0;
02631             }
02632 //          else
02633 //            EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
02634       }
02635       if(theErr) 
02636         *theErr = aRet;
02637     }
02638 
02639     void
02640     TVWrapper
02641     ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
02642                     EGrilleType& theGridType,
02643                     TErr* theErr)
02644     {
02645       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
02646 
02647       if(theErr && *theErr < 0)
02648         EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
02649 
02650       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
02651       
02652       if(aMeshInfo.myType == eSTRUCTURE){
02653         TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
02654         TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
02655         TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
02656                                       &aMeshName,
02657                                       &aGridType);
02658 
02659         if(aRet < 0)
02660           EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
02661       }
02662     }    
02663     
02664     void
02665     TVWrapper
02666     ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
02667                       TIntVector& theStruct,
02668                       TErr* theErr)
02669     {
02670       TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
02671       
02672       if(theErr && *theErr < 0)
02673           return;
02674       
02675       TErr aRet;
02676       MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
02677 
02678       TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
02679       TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
02680         
02681       aRet = MEDmeshGridStructRd(myFile->Id(),
02682                                  &aMeshName,
02683                                  MED_NO_DT,
02684                                  MED_NO_IT,
02685                                  &aGridStructure);
02686       if(theErr) 
02687         *theErr = aRet;
02688       else if(aRet < 0)
02689         EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");
02690     }
02691 
02692   }  
02693 }