1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MED_V2_2_Wrapper.hxx"
24 #include "MED_Algorithm.hxx"
25 #include "MED_Utilities.hxx"
31 static int MYDEBUG = 0;
33 // static int MYDEBUG = 0;
42 GetDESCLength<eV2_2>()
49 GetIDENTLength<eV2_2>()
63 GetLNOMLength<eV2_2>()
70 GetPNOMLength<eV2_2>()
77 GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
81 release=MED_RELEASE_NUM;
86 GetNbConn<eV2_2>(EGeometrieElement typmai,
87 EEntiteMaillage typent,
96 //---------------------------------------------------------------
102 TFile(const std::string& theFileName):
105 myFileName(theFileName)
114 Open(EModeAcces theMode, TErr* theErr = NULL)
117 const char* aFileName = myFileName.c_str();
118 myFid = MEDfileOpen(aFileName,med_access_mode(theMode));
121 *theErr = TErr(myFid);
123 EXCEPTION(std::runtime_error,"TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
126 const TIdt& Id() const
129 EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
142 std::string myFileName;
146 //---------------------------------------------------------------
152 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
155 myFile->Open(theMode,theErr);
165 //---------------------------------------------------------------
166 TVWrapper::TVWrapper(const std::string& theFileName):
167 myFile(new TFile(theFileName))
170 myFile->Open( eLECTURE_ECRITURE, &aRet );
173 // myFile->Open( eLECTURE_AJOUT, &aRet );
177 myFile->Open( eLECTURE, &aRet );
181 myFile->Open( eCREATION, &aRet );
186 //----------------------------------------------------------------------------
189 ::GetNbMeshes(TErr* theErr)
191 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
193 if(theErr && *theErr < 0)
196 return MEDnMesh(myFile->Id());
200 //----------------------------------------------------------------------------
203 ::GetMeshInfo(TInt theMeshId,
204 MED::TMeshInfo& theInfo,
207 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
209 if(theErr && *theErr < 0)
212 TValueHolder<TString, char> aMeshName(theInfo.myName);
213 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
214 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
215 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
216 char dtunit[MED_SNAME_SIZE+1];
217 med_sorting_type sorttype;
220 int naxis=MEDmeshnAxis(myFile->Id(),theMeshId);
221 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
222 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
223 TErr aRet = MEDmeshInfo(myFile->Id(),
239 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmeshInfo(...)");
243 //----------------------------------------------------------------------------
246 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
250 TFileWrapper aFileWrapper(myFile,theMode,theErr);
252 if(theErr && *theErr < 0)
255 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
257 TValueHolder<TString, char> aMeshName(anInfo.myName);
258 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
259 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
260 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
261 TValueHolder<TString, char> aDesc(anInfo.myDesc);
263 char *nam=new char[aSpaceDim*MED_SNAME_SIZE+1];
264 std::fill(nam,nam+aSpaceDim*MED_SNAME_SIZE+1,'\0');
265 char *unit=new char[aSpaceDim*MED_SNAME_SIZE+1];
266 std::fill(unit,unit+aSpaceDim*MED_SNAME_SIZE+1,'\0');
267 TErr aRet = MEDmeshCr(myFile->Id(),
282 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
284 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
289 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmeshCr(...)");
293 //----------------------------------------------------------------------------
296 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
300 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
303 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
306 SetMeshInfo(theInfo,eCREATION,&aRet);
313 //----------------------------------------------------------------------------
316 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
319 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
321 if(theErr && *theErr < 0)
324 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
325 TValueHolder<TString, char> aName(anInfo.myName);
326 return MEDnFamily(myFile->Id(),&aName);
330 //----------------------------------------------------------------------------
333 ::GetNbFamAttr(TInt theFamId,
334 const MED::TMeshInfo& theInfo,
337 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
339 if(theErr && *theErr < 0)
342 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
344 TValueHolder<TString, char> aName(anInfo.myName);
346 return MEDnFamily23Attribute(myFile->Id(),&aName,theFamId);
350 //----------------------------------------------------------------------------
353 ::GetNbFamGroup(TInt theFamId,
354 const MED::TMeshInfo& theInfo,
357 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
359 if(theErr && *theErr < 0)
362 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
364 TValueHolder<TString, char> aName(anInfo.myName);
366 return MEDnFamilyGroup(myFile->Id(),&aName,theFamId);
370 //----------------------------------------------------------------------------
373 ::GetFamilyInfo(TInt theFamId,
374 MED::TFamilyInfo& theInfo,
377 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
379 if(theErr && *theErr < 0)
382 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
384 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
385 TValueHolder<TString, char> aFamilyName(theInfo.myName);
386 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
387 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
388 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
389 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
390 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
392 TErr aRet = MEDfamily23Info(myFile->Id(),
405 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamily23Info(...) - "<<
406 " aMeshInfo.myName = '"<<&aMeshName<<
407 "'; theFamId = "<<theFamId<<
408 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
409 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
413 //----------------------------------------------------------------------------
416 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
420 TFileWrapper aFileWrapper(myFile,theMode,theErr);
422 if(theErr && *theErr < 0)
425 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
426 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
428 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
429 TValueHolder<TString, char> aFamilyName(anInfo.myName);
430 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
431 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
432 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
433 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
434 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
435 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
436 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
438 TErr aRet = MEDfamilyCr(myFile->Id(),
445 INITMSG(MYDEBUG,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
450 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamilyCr(...)");
454 //----------------------------------------------------------------------------
457 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
461 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
464 SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
470 //----------------------------------------------------------------------------
473 ::GetNames(TElemInfo& theInfo,
475 EEntiteMaillage theEntity,
476 EGeometrieElement theGeom,
479 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
481 if(theErr && *theErr < 0)
484 if ( theGeom == eBALL )
485 theGeom = GetBallGeom( theInfo.myMeshInfo );
487 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
489 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
490 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
491 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
492 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
494 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
502 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
508 //----------------------------------------------------------------------------
511 ::GetNumeration(TElemInfo& theInfo,
513 EEntiteMaillage theEntity,
514 EGeometrieElement theGeom,
517 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
519 if(theErr && *theErr < 0)
522 if ( theGeom == eBALL )
523 theGeom = GetBallGeom( theInfo.myMeshInfo );
525 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
527 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
528 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
529 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
530 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
532 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
540 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
546 //----------------------------------------------------------------------------
549 ::GetFamilies(TElemInfo& theInfo,
551 EEntiteMaillage theEntity,
552 EGeometrieElement theGeom,
555 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
557 if(theErr && *theErr < 0)
560 if ( theGeom == eBALL )
561 theGeom = GetBallGeom( theInfo.myMeshInfo );
563 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
565 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
566 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
567 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
568 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
570 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
580 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
582 int aSize = (int)theInfo.myFamNum->size();
583 theInfo.myFamNum->clear();
584 theInfo.myFamNum->resize(aSize,0);
588 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
595 //----------------------------------------------------------------------------
598 ::SetNames(const TElemInfo& theInfo,
599 EEntiteMaillage theEntity,
600 EGeometrieElement theGeom,
603 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
607 //----------------------------------------------------------------------------
610 ::SetNames(const TElemInfo& theInfo,
612 EEntiteMaillage theEntity,
613 EGeometrieElement theGeom,
616 TFileWrapper aFileWrapper(myFile,theMode,theErr);
618 if(theErr && *theErr < 0)
621 if ( theGeom == eBALL )
622 theGeom = GetBallGeom( theInfo.myMeshInfo );
624 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
625 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
628 if(theInfo.myIsElemNames)
630 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
631 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
632 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
633 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
635 aRet = MEDmeshEntityNameWr(myFile->Id(),
641 (TInt)anInfo.myElemNames->size(),
646 EXCEPTION(std::runtime_error,"SetNames - MEDmeshEntityNameWr(...)");
651 //----------------------------------------------------------------------------
654 ::SetNumeration(const TElemInfo& theInfo,
655 EEntiteMaillage theEntity,
656 EGeometrieElement theGeom,
659 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
663 //----------------------------------------------------------------------------
666 ::SetNumeration(const TElemInfo& theInfo,
668 EEntiteMaillage theEntity,
669 EGeometrieElement theGeom,
672 TFileWrapper aFileWrapper(myFile,theMode,theErr);
674 if(theErr && *theErr < 0)
677 if ( theGeom == eBALL )
678 theGeom = GetBallGeom( theInfo.myMeshInfo );
680 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
681 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
684 if(theInfo.myIsElemNum)
686 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
687 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
688 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
689 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
691 aRet = MEDmeshEntityNumberWr(myFile->Id(),
697 (TInt)anInfo.myElemNum->size(),
702 EXCEPTION(std::runtime_error,"SetNumeration - MEDmeshEntityNumberWr(...)");
706 //----------------------------------------------------------------------------
709 ::SetFamilies(const TElemInfo& theInfo,
710 EEntiteMaillage theEntity,
711 EGeometrieElement theGeom,
714 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
717 //----------------------------------------------------------------------------
720 ::SetFamilies(const TElemInfo& theInfo,
722 EEntiteMaillage theEntity,
723 EGeometrieElement theGeom,
726 TFileWrapper aFileWrapper(myFile,theMode,theErr);
728 if(theErr && *theErr < 0)
731 if ( theGeom == eBALL )
732 theGeom = GetBallGeom( theInfo.myMeshInfo );
734 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
735 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
737 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
738 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
739 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
740 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
742 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
748 (TInt)anInfo.myFamNum->size(),
754 EXCEPTION(std::runtime_error,"SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
757 //----------------------------------------------------------------------------
760 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
764 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
766 if(theErr && *theErr < 0)
769 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
771 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
772 TValueHolder<ETable, med_data_type > aTable(theTable);
774 return MEDmeshnEntity(myFile->Id(),
787 //----------------------------------------------------------------------------
790 ::GetNodeInfo(MED::TNodeInfo& theInfo,
793 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
795 if(theErr && *theErr < 0)
798 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
800 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
801 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
802 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
803 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
804 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
805 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
806 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
807 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
808 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
809 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
810 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
811 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
812 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
814 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
821 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
830 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
832 int mySize = (int)theInfo.myFamNum->size();
833 theInfo.myFamNum->clear();
834 theInfo.myFamNum->resize(mySize,0);
837 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
840 if ( MEDmeshEntityNameRd(myFile->Id(),
846 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
848 if ( MEDmeshEntityNumberRd(myFile->Id(),
854 &anElemNum) < 0 ) theInfo.myIsElemNum=eFAUX;
859 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
863 //----------------------------------------------------------------------------
866 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
870 TFileWrapper aFileWrapper(myFile,theMode,theErr);
872 if(theErr && *theErr < 0)
875 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
876 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
878 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
879 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
880 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
881 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
882 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
883 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
884 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
885 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
886 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
887 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
888 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
889 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
891 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
900 MEDmeshEntityFamilyNumberWr(myFile->Id(),
909 MEDmeshEntityNameWr(myFile->Id(),
918 MEDmeshEntityNumberWr(myFile->Id(),
929 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
933 //----------------------------------------------------------------------------
936 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
940 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
943 SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
950 //-----------------------------------------------------------------
953 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
956 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
958 if(theErr && *theErr < 0)
961 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
963 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
964 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
965 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
966 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
967 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
968 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
969 TInt aNbElem = (TInt)theInfo.myElemNum->size();
972 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
973 MED_NO_DT, MED_NO_IT,
975 aConnMode, &anIndex, &aConn);
980 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
982 if(theInfo.myIsElemNames){
983 GetNames(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
988 if(theInfo.myIsElemNum){
989 GetNumeration(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
994 GetFamilies(theInfo,aNbElem,theInfo.myEntity,theInfo.myGeom,&aRet);
999 //----------------------------------------------------------------------------
1002 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1005 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
1008 //----------------------------------------------------------------------------
1011 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1015 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1017 if(theErr && *theErr < 0)
1020 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1021 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1023 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1024 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1025 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1026 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1027 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1028 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1030 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1031 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1033 aConnMode, anInfo.myNbElem + 1,
1038 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
1040 SetNames(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1044 SetNumeration(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1048 SetFamilies(anInfo,theInfo.myEntity,anInfo.myGeom,&aRet);
1053 //----------------------------------------------------------------------------
1056 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1057 EEntiteMaillage theEntity,
1058 EGeometrieElement theGeom,
1059 EConnectivite theConnMode,
1062 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1065 //----------------------------------------------------------------------------
1068 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1069 EEntiteMaillage theEntity,
1070 EGeometrieElement theGeom,
1071 EConnectivite theConnMode,
1074 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1076 if(theErr && *theErr < 0)
1079 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1081 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1082 med_int aTaille = 0;
1084 aTaille=MEDmeshnEntity(myFile->Id(),
1088 med_entity_type(theEntity),
1089 med_geometry_type(theGeom),
1091 med_connectivity_mode(theConnMode),
1097 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1099 return TInt(aTaille);
1102 //-----------------------------------------------------------------
1105 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1108 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1110 if(theErr && *theErr < 0)
1113 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1115 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1116 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1117 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1118 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1119 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1120 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1123 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1136 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1138 if(theInfo.myIsElemNames){
1139 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1144 if(theInfo.myIsElemNum){
1145 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1150 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1155 //----------------------------------------------------------------------------
1158 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1161 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1164 //----------------------------------------------------------------------------
1167 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1171 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1173 if(theErr && *theErr < 0)
1176 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1177 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1179 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1180 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1181 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1182 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1183 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1186 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1195 (TInt)anInfo.myFaces->size(),
1202 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1204 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1206 if(theInfo.myIsElemNames){
1207 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1208 aRet = MEDmeshEntityNameWr(myFile->Id(),
1214 (TInt)anInfo.myElemNames->size(),
1219 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1222 if(theInfo.myIsElemNum){
1223 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1224 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1230 (TInt)anInfo.myElemNum->size(),
1235 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1239 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1240 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1246 (TInt)anInfo.myFamNum->size(),
1252 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1255 //----------------------------------------------------------------------------
1258 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1259 EEntiteMaillage theEntity,
1260 EGeometrieElement theGeom,
1261 EConnectivite theConnMode,
1264 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1267 //----------------------------------------------------------------------------
1269 TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1272 EConnectivite theConnMode,
1275 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1277 if(theErr && *theErr < 0)
1278 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1280 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1282 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1283 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1284 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1285 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1288 theNbFaces = MEDmeshnEntity(myFile->Id(),
1299 theConnSize = MEDmeshnEntity(myFile->Id(),
1310 if(theNbFaces < 0 || theConnSize<0)
1311 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1315 //-----------------------------------------------------------------
1318 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1319 EConnectivite theConnMode,
1324 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1326 if(theErr && *theErr < 0)
1329 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1330 TInt aNbElem = GetNbNodes(theMeshInfo);
1332 anInfo[eNOEUD][ePOINT1] = aNbElem;
1333 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1334 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1335 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1336 for(; anIter != anIterEnd; anIter++){
1337 const EEntiteMaillage& anEntity = anIter->first;
1338 const TGeomSet& aGeomSet = anIter->second;
1339 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1340 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1341 for(; anIter2 != anIterEnd2; anIter2++){
1342 const EGeometrieElement& aGeom = *anIter2;
1343 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1345 if ( anEntity == eSTRUCT_ELEMENT ) {
1346 const TInt nbStructTypes = aNbElem;
1347 for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
1348 // check type name to keep only "MED_BALL" structured element
1349 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
1350 char geotypename[ MED_NAME_SIZE + 1] = "";
1351 med_geometry_type geotype;
1352 MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1353 med_entity_type(anEntity), structType+1,
1354 geotypename, &geotype);
1355 if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
1356 aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
1357 theConnMode, theErr);
1359 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1364 anInfo[anEntity][aGeom] = aNbElem;
1370 } else { // eSTRUCTURE
1371 EGrilleType aGrilleType;
1375 TInt aDim = theMeshInfo.GetDim();
1376 EGeometrieElement aGeom, aSubGeom;
1377 EEntiteMaillage aSubEntity = eMAILLE;
1379 GetGrilleType(theMeshInfo, aGrilleType);
1381 TIntVector aStruct(aDim);
1382 if(aGrilleType == eGRILLE_STANDARD)
1384 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1387 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1388 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1389 for(med_int anAxis = 0; anAxis < aDim; anAxis++)
1390 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1392 for(med_int i = 0; i < aDim; i++){
1393 aNbNodes = aNbNodes * aStruct[i];
1394 aNbElem = aNbElem * (aStruct[i] - 1);
1403 aSubEntity = eARETE;
1405 (aStruct[0] ) * (aStruct[1]-1) +
1406 (aStruct[0]-1) * (aStruct[1] );
1413 (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
1414 (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
1415 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
1418 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1419 anInfo[eMAILLE][aGeom] = aNbElem;
1421 anInfo[aSubEntity][aSubGeom] = aNbSub;
1427 //-----------------------------------------------------------------
1428 TInt TVWrapper::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1429 EEntiteMaillage theEntity,
1430 EGeometrieElement theGeom,
1431 EConnectivite theConnMode,
1434 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1436 if(theErr && *theErr < 0)
1439 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1440 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1444 case MED::ePOLYGONE:
1445 case MED::ePOLYGON2:
1447 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1448 MED_NO_DT,MED_NO_IT,
1449 med_entity_type(theEntity),med_geometry_type(theGeom),
1450 MED_INDEX_NODE,med_connectivity_mode(theConnMode),
1453 case MED::ePOLYEDRE:
1455 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1456 MED_NO_DT,MED_NO_IT,
1457 med_entity_type(theEntity),MED_POLYHEDRON,
1458 MED_INDEX_FACE,med_connectivity_mode(theConnMode),
1463 return GetNbBalls( theMeshInfo );
1467 return MEDmeshnEntity(myFile->Id(),&aMeshName,
1468 MED_NO_DT,MED_NO_IT,
1469 med_entity_type(theEntity),med_geometry_type(theGeom),
1470 MED_CONNECTIVITY,med_connectivity_mode(theConnMode),
1478 //----------------------------------------------------------------------------
1479 void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, TErr* theErr)
1481 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1483 if(theErr && *theErr < 0)
1486 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1488 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1489 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
1490 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
1491 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
1492 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
1493 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
1494 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
1495 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
1496 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
1497 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
1498 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1499 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
1502 aRet = MEDmeshElementRd(myFile->Id(),
1521 EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
1523 if (anIsFamNum == MED_FALSE)
1525 int mySize = (int) theInfo.myFamNum->size();
1526 theInfo.myFamNum->clear();
1527 theInfo.myFamNum->resize(mySize, 0);
1533 //----------------------------------------------------------------------------
1536 ::SetCellInfo(const MED::TCellInfo& theInfo,
1540 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1542 if(theErr && *theErr < 0)
1545 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1546 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1548 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1549 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
1550 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1551 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1552 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1553 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1554 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1555 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1556 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
1557 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
1558 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1559 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
1560 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1563 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
1575 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1584 MEDmeshEntityNameWr(myFile->Id(),
1593 MEDmeshEntityNumberWr(myFile->Id(),
1604 EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
1608 //----------------------------------------------------------------------------
1611 ::SetCellInfo(const MED::TCellInfo& theInfo,
1614 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1617 //----------------------------------------------------------------------------
1618 //! Read geom type of MED_BALL structural element
1619 EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
1621 TFileWrapper aFileWrapper(myFile,eLECTURE);
1623 // read med_geometry_type of "MED_BALL" element
1624 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1625 return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
1628 //----------------------------------------------------------------------------
1629 //! Read number of balls in the Mesh
1630 TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
1632 TFileWrapper aFileWrapper(myFile,eLECTURE);
1634 EGeometrieElement ballType = GetBallGeom( theMeshInfo );
1638 return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
1641 //----------------------------------------------------------------------------
1642 //! Read a MEDWrapped representation of MED_BALL from the MED file
1643 void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
1645 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1647 // check geometry of MED_BALL
1648 if ( theInfo.myGeom == eBALL )
1650 theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
1651 if ( theInfo.myGeom < 0 ) {
1653 EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
1654 *theErr = theInfo.myGeom;
1660 GetCellInfo( theInfo );
1663 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
1664 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1665 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
1666 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
1668 TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
1669 MED_NO_DT, MED_NO_IT,
1675 else if ( aRet < 0 )
1676 EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
1680 //----------------------------------------------------------------------------
1681 //! Write a MEDWrapped representation of MED_BALL to the MED file
1682 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
1684 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1687 char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
1688 EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
1691 // no ball model in the file, create support mesh for it
1692 char dummyname [MED_NAME_SIZE*3+1]="";
1693 if (( ret = MEDsupportMeshCr( myFile->Id(),
1695 theInfo.myMeshInfo->GetSpaceDim(),
1696 theInfo.myMeshInfo->GetDim(),
1697 "Support mesh for a ball model",
1699 /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
1701 EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
1705 // write coordinates of 1 node
1706 med_float coord[3] = {0,0,0};
1707 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
1708 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
1709 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
1711 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
1715 // ball model creation
1716 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1717 if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
1719 theInfo.myMeshInfo->GetSpaceDim(),
1721 MED_NODE,MED_NONE)) < 0 ) {
1723 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
1727 // create diameter attribute
1728 if (( ret = MEDstructElementVarAttCr(myFile->Id(),
1729 geotypename, MED_BALL_DIAMETER,
1730 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
1732 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
1738 TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
1739 aBallInfo.myGeom = ballGeom;
1742 SetCellInfo(theInfo,theMode,theErr);
1743 if ( theErr && theErr < 0 )
1747 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
1748 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
1749 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
1750 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
1751 MED_NO_DT, MED_NO_IT,
1752 aGeom, MED_BALL_DIAMETER,
1753 theInfo.myNbElem, &aDiam);
1757 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
1760 //----------------------------------------------------------------------------
1761 //! Write a MEDWrapped representation of MED_BALL to the MED file
1762 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
1764 SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
1767 //-----------------------------------------------------------------
1770 ::GetNbFields(TErr* theErr)
1772 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1774 if(theErr && *theErr < 0)
1777 return MEDnField(myFile->Id());
1781 //----------------------------------------------------------------------------
1784 ::GetNbComp(TInt theFieldId,
1787 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1789 if(theErr && *theErr < 0)
1792 return MEDfieldnComponent(myFile->Id(),theFieldId);
1796 //----------------------------------------------------------------------------
1799 ::GetFieldInfo(TInt theFieldId,
1800 MED::TFieldInfo& theInfo,
1803 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1805 if(theErr && *theErr < 0)
1808 TString aFieldName(256); // Protect from memory problems with too long names
1809 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
1810 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1811 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1812 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
1816 char dtunit[MED_SNAME_SIZE+1];
1817 char local_mesh_name[MED_NAME_SIZE+1]="";
1819 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
1820 aRet = MEDfieldInfo(myFile->Id(),
1831 if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
1837 theInfo.SetName(aFieldName);
1842 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
1846 //----------------------------------------------------------------------------
1849 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1853 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1855 if(theErr && *theErr < 0)
1858 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1860 TValueHolder<TString, char> aFieldName(anInfo.myName);
1861 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
1862 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1863 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1864 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1866 char dtunit[MED_SNAME_SIZE+1];
1867 std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
1868 aRet = MEDfieldCr(myFile->Id(),
1875 &aMeshInfo.myName[0]);
1879 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
1883 //----------------------------------------------------------------------------
1886 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1890 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1893 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1900 //----------------------------------------------------------------------------
1903 ::GetNbGauss(TErr* theErr)
1905 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1907 if(theErr && *theErr < 0)
1910 return MEDnLocalization(myFile->Id());
1914 //----------------------------------------------------------------------------
1917 ::GetGaussPreInfo(TInt theId,
1920 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1922 if(theErr && *theErr < 0)
1923 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1925 med_int aNbGaussPoints = med_int();
1926 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1927 med_geometry_type aGeom = MED_NONE;
1931 char geointerpname[MED_NAME_SIZE+1]="";
1932 char ipointstructmeshname[MED_NAME_SIZE+1]="";
1933 med_int nsectionmeshcell;
1934 med_geometry_type sectiongeotype;
1935 aRet = MEDlocalizationInfo (myFile->Id(),
1942 ipointstructmeshname,
1948 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
1949 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1950 TInt(aNbGaussPoints));
1954 //----------------------------------------------------------------------------
1957 ::GetGaussInfo(TInt theId,
1958 TGaussInfo& theInfo,
1961 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1963 if(theErr && *theErr < 0)
1966 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1967 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1968 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1969 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
1970 TValueHolder<TString, char> aGaussName(theInfo.myName);
1973 aRet = MEDlocalizationRd(myFile->Id(),
1983 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
1987 //----------------------------------------------------------------------------
1990 ::GetNbProfiles(TErr* theErr)
1992 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1994 if(theErr && *theErr < 0)
1997 return MEDnProfile(myFile->Id());
2002 ::GetProfilePreInfo(TInt theId,
2005 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2007 if(theErr && *theErr < 0)
2008 return TProfileInfo::TInfo();
2011 TVector<char> aName(GetNOMLength<eV2_2>()+1);
2014 aRet = MEDprofileInfo(myFile->Id(),
2021 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
2023 return TProfileInfo::TInfo(&aName[0],aSize);
2028 ::GetProfileInfo(TInt theId,
2029 TProfileInfo& theInfo,
2032 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2034 if(theErr && *theErr < 0)
2037 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2038 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2039 TValueHolder<TString, char> aProfileName(anInfo.myName);
2042 aRet = MEDprofileRd(myFile->Id(),
2048 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
2053 ::SetProfileInfo(const TProfileInfo& theInfo,
2057 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2059 if(theErr && *theErr < 0)
2062 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2063 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2064 TValueHolder<TString, char> aProfileName(anInfo.myName);
2067 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
2068 &aProfileName, // tableau de valeurs du profil.
2069 theInfo.GetSize(), // taille du profil.
2070 &anElemNum); // nom profil.
2074 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
2079 ::SetProfileInfo(const TProfileInfo& theInfo,
2083 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
2086 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
2089 SetProfileInfo(theInfo,eCREATION,&aRet);
2095 //-----------------------------------------------------------------
2098 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2099 const MED::TEntityInfo& theEntityInfo,
2100 EEntiteMaillage& theEntity,
2101 TGeom2Size& theGeom2Size,
2104 theEntity = EEntiteMaillage(-1);
2105 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2108 if(theEntityInfo.empty())
2112 }else if(theEntityInfo.empty())
2113 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
2115 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2117 theGeom2Size.clear();
2118 TInt aNbTimeStamps = 0;
2119 TIdt anId = myFile->Id();
2121 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2122 TValueHolder<TString, char> aFieldName(anInfo.myName);
2123 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2125 // workaround for IPAL13676
2126 MED::TEntityInfo localEntityInfo = theEntityInfo;
2127 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2128 if(anLocalIter != localEntityInfo.end()){
2129 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2132 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2133 for(; anIter != localEntityInfo.end(); anIter++){
2134 med_entity_type anEntity = med_entity_type(anIter->first);
2135 const TGeom2Size& aGeom2Size = anIter->second;
2136 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2137 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
2138 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2139 char aMeshName[MED_NAME_SIZE+1];
2142 char dtunit[MED_SNAME_SIZE+1];
2143 med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
2144 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2145 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2147 MEDfieldInfoByName(anId,
2164 MEDfieldComputingStepInfo(anId,
2170 char profilename[MED_NAME_SIZE+1];
2171 char locname[MED_NAME_SIZE+1];
2175 // protection from crash (division by zero)
2176 // inside MEDfieldnValueWithProfile function
2177 // caused by the workaround for IPAL13676 (see above)
2178 if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
2181 nval = MEDfieldnValueWithProfile(anId,
2186 med_geometry_type(aGeom),
2194 bool anIsSatisfied =(nval > 0);
2197 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2198 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2199 if(anIsPerformAdditionalCheck){
2200 anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
2203 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2204 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2209 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2210 theEntity = EEntiteMaillage(anEntity);
2211 aNbTimeStamps = aNbStamps;
2214 if(!theGeom2Size.empty())
2217 return aNbTimeStamps;
2221 //----------------------------------------------------------------------------
2224 ::GetTimeStampInfo(TInt theTimeStampId,
2225 MED::TTimeStampInfo& theInfo,
2228 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2230 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2233 if(aGeom2Size.empty())
2237 }else if(aGeom2Size.empty())
2238 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
2240 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2241 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2243 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2244 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2245 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2246 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2247 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2248 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2249 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2250 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2251 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2253 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2255 // just to get a time stamp unit (anUnitDt)
2256 med_field_type aFieldType;
2257 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2258 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2259 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2261 MEDfieldInfoByName(myFile->Id(),
2270 delete [] aCompName;
2271 delete [] aCompUnit;
2273 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2274 for(; anIter != aGeom2Size.end(); anIter++){
2275 const EGeometrieElement& aGeom = anIter->first;
2276 med_int aNbGauss = -1;
2279 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2285 char profilename[MED_NAME_SIZE+1];
2287 char locname[MED_NAME_SIZE+1];
2288 MEDfieldnValueWithProfile(myFile->Id(),
2293 med_geometry_type(aGeom),
2301 static TInt MAX_NB_GAUSS_POINTS = 32;
2302 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2305 aGeom2NbGauss[aGeom] = aNbGauss;
2310 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2315 //----------------------------------------------------------------------------
2318 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2319 const TMKey2Profile& theMKey2Profile,
2320 const TKey2Gauss& theKey2Gauss,
2323 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2325 if(theErr && *theErr < 0)
2328 TIdt anId = myFile->Id();
2330 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2331 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2333 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2334 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2335 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2336 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2338 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2339 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2340 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
2342 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2343 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2345 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2346 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2348 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
2349 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
2350 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2352 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
2353 TGeom2Size::iterator anIter = aGeom2Size.begin();
2354 for(; anIter != aGeom2Size.end(); anIter++){
2355 EGeometrieElement aGeom = anIter->first;
2356 TInt aNbElem = anIter->second;
2357 med_int profilesize,aNbGauss;
2359 TInt aNbVal = MEDfieldnValueWithProfile(anId,
2364 med_geometry_type(aGeom),
2377 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
2380 TInt aNbComp = aFieldInfo->myNbComp;
2381 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
2382 theTimeStampValue->AllocateValue(aGeom,
2386 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
2389 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
2390 "; aNbVal = "<<aNbVal<<
2391 "; aNbValue = "<<aNbValue<<
2392 "; aNbGauss = "<<aNbGauss<<
2393 "; aNbComp = "<<aNbComp<<
2396 TErr aRet = MEDfieldValueWithProfileRd(anId,
2401 med_geometry_type(aGeom),
2405 MED_ALL_CONSTITUENT,
2406 theTimeStampValue->GetValuePtr(aGeom));
2409 *theErr = MED_FALSE;
2412 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
2415 MED::PGaussInfo aGaussInfo;
2416 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2417 if(strcmp(&aGaussName[0],"") != 0){
2418 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2419 if(anIter != theKey2Gauss.end()){
2420 aGaussInfo = anIter->second;
2421 aGeom2Gauss[aGeom] = aGaussInfo;
2425 MED::PProfileInfo aProfileInfo;
2426 if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
2427 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2428 if(anIter != aKey2Profile.end()){
2429 aProfileInfo = anIter->second;
2430 aGeom2Profile[aGeom] = aProfileInfo;
2434 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2436 *theErr = MED_FALSE;
2439 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2442 if(aProfileInfo && aProfileInfo->IsPresent()){
2443 TInt aNbSubElem = aProfileInfo->GetSize();
2444 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2445 if(aProfileSize != aValueSize){
2450 EXCEPTION(std::runtime_error,
2451 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2452 ") != aValueSize("<<aValueSize<<
2453 "); aNbVal = "<<aNbVal<<
2454 "; anEntity = "<<anEntity<<
2455 "; aGeom = "<<aGeom<<
2456 "; aNbElem = "<<aNbElem<<
2457 "; aNbSubElem = "<<aNbSubElem<<
2458 "; aNbComp = "<<aNbComp<<
2459 "; aNbGauss = "<<aNbGauss<<
2463 if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
2468 EXCEPTION(std::runtime_error,
2469 "GetTimeStampValue - aNbElem("<<aNbElem<<
2470 ") != aNbValue("<<aNbValue<<
2471 "); aNbVal = "<<aNbVal<<
2472 "; anEntity = "<<anEntity<<
2473 "; aGeom = "<<aGeom<<
2474 "; aNbElem = "<<aNbElem<<
2475 "; aNbComp = "<<aNbComp<<
2476 "; aNbGauss = "<<aNbGauss<<
2484 //----------------------------------------------------------------------------
2487 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2491 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2493 if(theErr && *theErr < 0)
2497 TIdt anId = myFile->Id();
2499 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2500 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2502 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2503 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2504 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2505 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2506 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2507 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2508 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2510 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2511 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2513 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2514 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2516 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2517 TGeomSet::const_iterator anIter = aGeomSet.begin();
2518 for(; anIter != aGeomSet.end(); anIter++){
2519 EGeometrieElement aGeom = *anIter;
2521 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2522 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2523 if(aGaussIter != aGeom2Gauss.end()){
2524 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2525 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2528 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2529 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
2530 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2531 if(aProfileIter != aGeom2Profile.end()){
2532 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2533 aProfileMode = med_storage_mode(aProfileInfo->myMode);
2534 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2537 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2539 aRet = MEDfieldValueWithProfileWr(anId,
2545 med_geometry_type(aGeom),
2550 MED_ALL_CONSTITUENT,
2552 theTimeStampValue->GetValuePtr(aGeom));
2555 *theErr = MED_FALSE;
2558 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
2563 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2567 //----------------------------------------------------------------------------
2570 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2574 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2577 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2583 //----------------------------------------------------------------------------
2586 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2589 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2592 //----------------------------------------------------------------------------
2595 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2599 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2601 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2603 if(theErr && *theErr < 0)
2606 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2608 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2609 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2611 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
2614 aRet = MEDmeshGridTypeRd(myFile->Id(),
2620 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
2622 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2623 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2624 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
2625 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2626 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2627 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2628 //med_axis_type aRepere = MED_CARTESIAN;
2630 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
2640 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
2642 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2643 aRet = MEDmeshGridStructWr(myFile->Id(),
2650 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
2653 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2654 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
2660 anInfo.GetIndexes(aAxis).size(),
2661 &anInfo.GetIndexes(aAxis)[0]);
2664 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
2672 //----------------------------------------------------------------------------
2675 ::GetGrilleInfo(TGrilleInfo& theInfo,
2678 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2680 if(theErr && *theErr < 0)
2683 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2684 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2685 EMaillage aMaillageType = aMeshInfo.myType;
2687 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2688 EGrilleType aGrilleType = theInfo.myGrilleType;
2691 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
2692 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2694 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2695 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2696 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2697 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2698 //med_axis_type aRepere;
2700 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
2710 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
2712 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2713 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2715 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2725 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2727 int mySize = (int)theInfo.myFamNumNode.size();
2728 theInfo.myFamNumNode.clear();
2729 theInfo.myFamNumNode.resize(mySize,0);
2733 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2738 //============================
2741 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2742 ETable aTable = eCOOR_IND1;
2743 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2746 aTable = eCOOR_IND1;
2749 aTable = eCOOR_IND2;
2752 aTable = eCOOR_IND3;
2761 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2763 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2765 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2767 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2768 //TValueHolder<ETable, med_data_type > table(aTable);
2769 //char aCompNames[MED_SNAME_SIZE+1];
2770 //char anUnitNames[MED_SNAME_SIZE+1];
2771 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
2772 MED_NO_DT,MED_NO_IT,
2776 //theInfo.SetCoordName(anAxis-1, aCompNames);
2777 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2778 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
2783 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2787 EGeometrieElement aGeom = theInfo.GetGeom();
2788 EEntiteMaillage aEntity = theInfo.GetEntity();
2789 TInt aNbCells = theInfo.GetNbCells();
2791 theInfo.myFamNum.resize(aNbCells);
2792 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2794 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2795 &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
2796 med_geometry_type(aGeom),&aFamNum);
2798 if ( aMeshInfo.myDim == 3 )
2800 aGeom = theInfo.GetSubGeom();
2801 aEntity = theInfo.GetSubEntity();
2802 aNbCells = theInfo.GetNbSubCells();
2804 theInfo.myFamSubNum.resize(aNbCells,0);
2805 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
2807 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2808 &aMeshName,MED_NO_DT,MED_NO_IT,
2809 med_entity_type(aEntity),
2810 med_geometry_type(aGeom),&aFamNum);
2814 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2816 int mySize = (int)theInfo.myFamNumNode.size();
2817 theInfo.myFamNumNode.clear();
2818 theInfo.myFamNumNode.resize(mySize,0);
2822 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2830 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2831 EGrilleType& theGridType,
2834 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2836 if(theErr && *theErr < 0)
2837 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2839 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2841 if(aMeshInfo.myType == eSTRUCTURE){
2842 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2843 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
2844 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
2849 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
2855 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2856 TIntVector& theStruct,
2859 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2861 if(theErr && *theErr < 0)
2865 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2867 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2868 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
2870 aRet = MEDmeshGridStructRd(myFile->Id(),
2878 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");