1 // Copyright (C) 2007-2015 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 TInt aNbElem = (TInt)theInfo.myElemNum->size();
966 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
967 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
968 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
971 aRet = MEDmeshPolygonRd(myFile->Id(),
983 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolygonRd(...)");
985 if(theInfo.myIsElemNames){
986 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
991 if(theInfo.myIsElemNum){
992 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
997 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
1002 //----------------------------------------------------------------------------
1005 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1008 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
1011 //----------------------------------------------------------------------------
1014 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1018 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1020 if(theErr && *theErr < 0)
1023 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1024 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1026 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1027 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1028 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1029 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1030 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1032 TErr aRet = MEDmeshPolygonWr(myFile->Id(),
1039 anInfo.myNbElem + 1,
1046 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDmeshPolygonWr(...)");
1048 SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1052 SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1056 SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
1061 //----------------------------------------------------------------------------
1064 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1065 EEntiteMaillage theEntity,
1066 EGeometrieElement theGeom,
1067 EConnectivite theConnMode,
1070 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1073 //----------------------------------------------------------------------------
1076 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1077 EEntiteMaillage theEntity,
1078 EGeometrieElement theGeom,
1079 EConnectivite theConnMode,
1082 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1084 if(theErr && *theErr < 0)
1087 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1089 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1090 med_int aTaille = 0;
1092 aTaille=MEDmeshnEntity(myFile->Id(),
1096 med_entity_type(theEntity),
1099 med_connectivity_mode(theConnMode),
1105 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1107 return TInt(aTaille);
1110 //-----------------------------------------------------------------
1113 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1116 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1118 if(theErr && *theErr < 0)
1121 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1123 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1124 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1125 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1126 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1127 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1128 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1131 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1144 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1146 if(theInfo.myIsElemNames){
1147 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1152 if(theInfo.myIsElemNum){
1153 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1158 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1163 //----------------------------------------------------------------------------
1166 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1169 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1172 //----------------------------------------------------------------------------
1175 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1179 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1181 if(theErr && *theErr < 0)
1184 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1185 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1187 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1188 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1189 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1190 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1191 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1194 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1203 (TInt)anInfo.myFaces->size(),
1210 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1212 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1214 if(theInfo.myIsElemNames){
1215 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1216 aRet = MEDmeshEntityNameWr(myFile->Id(),
1222 (TInt)anInfo.myElemNames->size(),
1227 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1230 if(theInfo.myIsElemNum){
1231 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1232 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1238 (TInt)anInfo.myElemNum->size(),
1243 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1247 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1248 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1254 (TInt)anInfo.myFamNum->size(),
1260 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1263 //----------------------------------------------------------------------------
1266 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1267 EEntiteMaillage theEntity,
1268 EGeometrieElement theGeom,
1269 EConnectivite theConnMode,
1272 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1275 //----------------------------------------------------------------------------
1277 TVWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1280 EConnectivite theConnMode,
1283 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1285 if(theErr && *theErr < 0)
1286 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1288 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1290 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1291 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1292 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1293 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1296 theNbFaces = MEDmeshnEntity(myFile->Id(),
1307 theConnSize = MEDmeshnEntity(myFile->Id(),
1318 if(theNbFaces < 0 || theConnSize<0)
1319 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDmeshnEntity(...)");
1323 //-----------------------------------------------------------------
1326 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1327 EConnectivite theConnMode,
1332 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1334 if(theErr && *theErr < 0)
1337 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1338 TInt aNbElem = GetNbNodes(theMeshInfo);
1340 anInfo[eNOEUD][ePOINT1] = aNbElem;
1341 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1342 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1343 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1344 for(; anIter != anIterEnd; anIter++){
1345 const EEntiteMaillage& anEntity = anIter->first;
1346 const TGeomSet& aGeomSet = anIter->second;
1347 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1348 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1349 for(; anIter2 != anIterEnd2; anIter2++){
1350 const EGeometrieElement& aGeom = *anIter2;
1351 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1353 if ( anEntity == eSTRUCT_ELEMENT ) {
1354 const TInt nbStructTypes = aNbElem;
1355 for ( TInt structType = 0; structType < nbStructTypes; ++structType ) {
1356 // check type name to keep only "MED_BALL" structured element
1357 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName );
1358 char geotypename[ MED_NAME_SIZE + 1] = "";
1359 med_geometry_type geotype;
1360 MEDmeshEntityInfo( myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1361 med_entity_type(anEntity), structType+1,
1362 geotypename, &geotype);
1363 if ( strcmp( geotypename, MED_BALL_NAME ) == 0 ) {
1364 aNbElem = GetNbCells( theMeshInfo, anEntity, EGeometrieElement(geotype),
1365 theConnMode, theErr);
1367 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1372 anInfo[anEntity][aGeom] = aNbElem;
1378 } else { // eSTRUCTURE
1379 EGrilleType aGrilleType;
1383 TInt aDim = theMeshInfo.GetDim();
1384 EGeometrieElement aGeom, aSubGeom;
1385 EEntiteMaillage aSubEntity = eMAILLE;
1387 GetGrilleType(theMeshInfo, aGrilleType);
1389 TIntVector aStruct(aDim);
1390 if(aGrilleType == eGRILLE_STANDARD)
1392 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1395 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1396 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1397 for(med_int anAxis = 0; anAxis < aDim; anAxis++)
1398 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1400 for(med_int i = 0; i < aDim; i++){
1401 aNbNodes = aNbNodes * aStruct[i];
1402 aNbElem = aNbElem * (aStruct[i] - 1);
1411 aSubEntity = eARETE;
1413 (aStruct[0] ) * (aStruct[1]-1) +
1414 (aStruct[0]-1) * (aStruct[1] );
1421 (aStruct[0] ) * (aStruct[1]-1) * (aStruct[2]-1) +
1422 (aStruct[0]-1) * (aStruct[1] ) * (aStruct[2]-1) +
1423 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2] );
1426 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1427 anInfo[eMAILLE][aGeom] = aNbElem;
1429 anInfo[aSubEntity][aSubGeom] = aNbSub;
1435 //-----------------------------------------------------------------
1438 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1439 EEntiteMaillage theEntity,
1440 EGeometrieElement theGeom,
1441 EConnectivite theConnMode,
1444 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1446 if(theErr && *theErr < 0)
1449 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1450 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1452 if(theGeom!=MED::ePOLYGONE && theGeom!=MED::ePOLYEDRE && theGeom != MED::eBALL)
1454 return MEDmeshnEntity(myFile->Id(),
1458 med_entity_type(theEntity),
1459 med_geometry_type(theGeom),
1461 med_connectivity_mode(theConnMode),
1465 else if(theGeom==MED::ePOLYGONE)
1467 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1468 MED_POLYGON,MED_INDEX_NODE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1470 else if ( theGeom==MED::ePOLYEDRE )
1472 return MEDmeshnEntity(myFile->Id(),&aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(theEntity),
1473 MED_POLYHEDRON,MED_INDEX_FACE,med_connectivity_mode(theConnMode),&chgt,&trsf)-1;
1475 else if ( theGeom==MED::eBALL )
1477 return GetNbBalls( theMeshInfo );
1483 //----------------------------------------------------------------------------
1486 ::GetCellInfo(MED::TCellInfo& theInfo,
1489 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1491 if(theErr && *theErr < 0)
1494 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1496 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1497 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
1498 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
1499 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
1500 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
1501 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
1502 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
1503 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
1504 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
1505 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
1506 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1507 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
1510 aRet = MEDmeshElementRd(myFile->Id(),
1529 EXCEPTION(std::runtime_error,"GetCellInfo - MEDmeshElementRd(...)");
1531 if (anIsFamNum == MED_FALSE)
1533 int mySize = (int) theInfo.myFamNum->size();
1534 theInfo.myFamNum->clear();
1535 theInfo.myFamNum->resize(mySize, 0);
1541 //----------------------------------------------------------------------------
1544 ::SetCellInfo(const MED::TCellInfo& theInfo,
1548 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1550 if(theErr && *theErr < 0)
1553 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1554 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1556 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1557 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
1558 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1559 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1560 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1561 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1562 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1563 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1564 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
1565 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
1566 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1567 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
1568 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1571 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
1583 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1592 MEDmeshEntityNameWr(myFile->Id(),
1601 MEDmeshEntityNumberWr(myFile->Id(),
1612 EXCEPTION(std::runtime_error,"SetCellInfo - MEDmeshElementWr(...)");
1616 //----------------------------------------------------------------------------
1619 ::SetCellInfo(const MED::TCellInfo& theInfo,
1622 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1625 //----------------------------------------------------------------------------
1626 //! Read geom type of MED_BALL structural element
1627 EGeometrieElement TVWrapper::GetBallGeom(const TMeshInfo& theMeshInfo)
1629 TFileWrapper aFileWrapper(myFile,eLECTURE);
1631 // read med_geometry_type of "MED_BALL" element
1632 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1633 return EGeometrieElement( MEDstructElementGeotype( myFile->Id(), geotypename ) );
1636 //----------------------------------------------------------------------------
1637 //! Read number of balls in the Mesh
1638 TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
1640 TFileWrapper aFileWrapper(myFile,eLECTURE);
1642 EGeometrieElement ballType = GetBallGeom( theMeshInfo );
1646 return GetNbCells( theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD );
1649 //----------------------------------------------------------------------------
1650 //! Read a MEDWrapped representation of MED_BALL from the MED file
1651 void TVWrapper::GetBallInfo(TBallInfo& theInfo, TErr* theErr)
1653 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1655 // check geometry of MED_BALL
1656 if ( theInfo.myGeom == eBALL )
1658 theInfo.myGeom = GetBallGeom( *theInfo.myMeshInfo );
1659 if ( theInfo.myGeom < 0 ) {
1661 EXCEPTION(std::runtime_error,"GetBallInfo - no balls in the mesh");
1662 *theErr = theInfo.myGeom;
1668 GetCellInfo( theInfo );
1671 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
1672 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1673 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
1674 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
1676 TErr aRet = MEDmeshStructElementVarAttRd( myFile->Id(), &aMeshName,
1677 MED_NO_DT, MED_NO_IT,
1683 else if ( aRet < 0 )
1684 EXCEPTION(std::runtime_error,"GetBallInfo - pb at reading diameters");
1688 //----------------------------------------------------------------------------
1689 //! Write a MEDWrapped representation of MED_BALL to the MED file
1690 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr)
1692 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1695 char ballsupportname[MED_NAME_SIZE+1]="BALL_SUPPORT_MESH";
1696 EGeometrieElement ballGeom = GetBallGeom( *theInfo.myMeshInfo );
1699 // no ball model in the file, create support mesh for it
1700 char dummyname [MED_NAME_SIZE*3+1]="";
1701 if (( ret = MEDsupportMeshCr( myFile->Id(),
1703 theInfo.myMeshInfo->GetSpaceDim(),
1704 theInfo.myMeshInfo->GetDim(),
1705 "Support mesh for a ball model",
1707 /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) {
1709 EXCEPTION(std::runtime_error,"SetBallInfo - MEDsupportMeshCr");
1713 // write coordinates of 1 node
1714 med_float coord[3] = {0,0,0};
1715 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
1716 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
1717 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
1719 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshNodeCoordinateWr");
1723 // ball model creation
1724 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
1725 if (( ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
1727 theInfo.myMeshInfo->GetSpaceDim(),
1729 MED_NODE,MED_NONE)) < 0 ) {
1731 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementCr");
1735 // create diameter attribute
1736 if (( ret = MEDstructElementVarAttCr(myFile->Id(),
1737 geotypename, MED_BALL_DIAMETER,
1738 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
1740 EXCEPTION(std::runtime_error,"SetBallInfo - MEDstructElementVarAttCr");
1746 TBallInfo& aBallInfo = ((TBallInfo&) theInfo );
1747 aBallInfo.myGeom = ballGeom;
1750 SetCellInfo(theInfo,theMode,theErr);
1751 if ( theErr && theErr < 0 )
1755 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
1756 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
1757 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
1758 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
1759 MED_NO_DT, MED_NO_IT,
1760 aGeom, MED_BALL_DIAMETER,
1761 theInfo.myNbElem, &aDiam);
1765 EXCEPTION(std::runtime_error,"SetBallInfo - MEDmeshStructElementVarAttWr");
1768 //----------------------------------------------------------------------------
1769 //! Write a MEDWrapped representation of MED_BALL to the MED file
1770 void TVWrapper::SetBallInfo(const TBallInfo& theInfo, TErr* theErr)
1772 SetBallInfo( theInfo, eLECTURE_ECRITURE, theErr );
1775 //-----------------------------------------------------------------
1778 ::GetNbFields(TErr* theErr)
1780 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1782 if(theErr && *theErr < 0)
1785 return MEDnField(myFile->Id());
1789 //----------------------------------------------------------------------------
1792 ::GetNbComp(TInt theFieldId,
1795 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1797 if(theErr && *theErr < 0)
1800 return MEDfieldnComponent(myFile->Id(),theFieldId);
1804 //----------------------------------------------------------------------------
1807 ::GetFieldInfo(TInt theFieldId,
1808 MED::TFieldInfo& theInfo,
1811 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1813 if(theErr && *theErr < 0)
1816 TString aFieldName(256); // Protect from memory problems with too long names
1817 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
1818 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1819 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1820 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
1824 char dtunit[MED_SNAME_SIZE+1];
1825 char local_mesh_name[MED_NAME_SIZE+1]="";
1827 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(),theFieldId);
1828 aRet = MEDfieldInfo(myFile->Id(),
1839 if(strcmp(&aMeshInfo.myName[0],local_mesh_name) != 0 ) {
1845 theInfo.SetName(aFieldName);
1850 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDfieldInfo(...)");
1854 //----------------------------------------------------------------------------
1857 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1861 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1863 if(theErr && *theErr < 0)
1866 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1868 TValueHolder<TString, char> aFieldName(anInfo.myName);
1869 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
1870 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1871 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1872 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1874 char dtunit[MED_SNAME_SIZE+1];
1875 std::fill(dtunit,dtunit+MED_SNAME_SIZE+1,'\0');
1876 aRet = MEDfieldCr(myFile->Id(),
1883 &aMeshInfo.myName[0]);
1887 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDfieldCr(...)");
1891 //----------------------------------------------------------------------------
1894 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1898 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1901 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1908 //----------------------------------------------------------------------------
1911 ::GetNbGauss(TErr* theErr)
1913 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1915 if(theErr && *theErr < 0)
1918 return MEDnLocalization(myFile->Id());
1922 //----------------------------------------------------------------------------
1925 ::GetGaussPreInfo(TInt theId,
1928 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1930 if(theErr && *theErr < 0)
1931 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1933 med_int aNbGaussPoints = med_int();
1934 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1935 med_geometry_type aGeom = MED_NONE;
1939 char geointerpname[MED_NAME_SIZE+1]="";
1940 char ipointstructmeshname[MED_NAME_SIZE+1]="";
1941 med_int nsectionmeshcell;
1942 med_geometry_type sectiongeotype;
1943 aRet = MEDlocalizationInfo (myFile->Id(),
1950 ipointstructmeshname,
1956 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDlocalizationInfo(...)");
1957 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1958 TInt(aNbGaussPoints));
1962 //----------------------------------------------------------------------------
1965 ::GetGaussInfo(TInt theId,
1966 TGaussInfo& theInfo,
1969 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1971 if(theErr && *theErr < 0)
1974 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1975 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1976 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1977 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
1978 TValueHolder<TString, char> aGaussName(theInfo.myName);
1981 aRet = MEDlocalizationRd(myFile->Id(),
1991 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDlocalizationRd(...)");
1995 //----------------------------------------------------------------------------
1998 ::GetNbProfiles(TErr* theErr)
2000 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2002 if(theErr && *theErr < 0)
2005 return MEDnProfile(myFile->Id());
2010 ::GetProfilePreInfo(TInt theId,
2013 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2015 if(theErr && *theErr < 0)
2016 return TProfileInfo::TInfo();
2019 TVector<char> aName(GetNOMLength<eV2_2>()+1);
2022 aRet = MEDprofileInfo(myFile->Id(),
2029 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofileInfo(...)");
2031 return TProfileInfo::TInfo(&aName[0],aSize);
2036 ::GetProfileInfo(TInt theId,
2037 TProfileInfo& theInfo,
2040 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2042 if(theErr && *theErr < 0)
2045 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2046 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2047 TValueHolder<TString, char> aProfileName(anInfo.myName);
2050 aRet = MEDprofileRd(myFile->Id(),
2056 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofileRd(...)");
2061 ::SetProfileInfo(const TProfileInfo& theInfo,
2065 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2067 if(theErr && *theErr < 0)
2070 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
2071 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
2072 TValueHolder<TString, char> aProfileName(anInfo.myName);
2075 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
2076 &aProfileName, // tableau de valeurs du profil.
2077 theInfo.GetSize(), // taille du profil.
2078 &anElemNum); // nom profil.
2082 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofileWr(...)");
2087 ::SetProfileInfo(const TProfileInfo& theInfo,
2091 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
2094 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
2097 SetProfileInfo(theInfo,eCREATION,&aRet);
2103 //-----------------------------------------------------------------
2106 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2107 const MED::TEntityInfo& theEntityInfo,
2108 EEntiteMaillage& theEntity,
2109 TGeom2Size& theGeom2Size,
2112 theEntity = EEntiteMaillage(-1);
2113 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2116 if(theEntityInfo.empty())
2120 }else if(theEntityInfo.empty())
2121 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
2123 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2125 theGeom2Size.clear();
2126 TInt aNbTimeStamps = 0;
2127 TIdt anId = myFile->Id();
2129 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2130 TValueHolder<TString, char> aFieldName(anInfo.myName);
2131 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2133 // workaround for IPAL13676
2134 MED::TEntityInfo localEntityInfo = theEntityInfo;
2135 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2136 if(anLocalIter != localEntityInfo.end()){
2137 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2140 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2141 for(; anIter != localEntityInfo.end(); anIter++){
2142 med_entity_type anEntity = med_entity_type(anIter->first);
2143 const TGeom2Size& aGeom2Size = anIter->second;
2144 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2145 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
2146 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2147 char aMeshName[MED_NAME_SIZE+1];
2150 char dtunit[MED_SNAME_SIZE+1];
2151 med_int myNbComp = MEDfieldnComponentByName(anId,&aFieldName);
2152 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2153 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2155 MEDfieldInfoByName(anId,
2172 MEDfieldComputingStepInfo(anId,
2178 char profilename[MED_NAME_SIZE+1];
2179 char locname[MED_NAME_SIZE+1];
2183 // protection from crash (division by zero)
2184 // inside MEDfieldnValueWithProfile function
2185 // caused by the workaround for IPAL13676 (see above)
2186 if( anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0 )
2189 nval = MEDfieldnValueWithProfile(anId,
2194 med_geometry_type(aGeom),
2202 bool anIsSatisfied =(nval > 0);
2205 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2206 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2207 if(anIsPerformAdditionalCheck){
2208 anIsSatisfied = !strcmp(&aMeshName[0],&aMeshInfo.myName[0]);
2211 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2212 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2217 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2218 theEntity = EEntiteMaillage(anEntity);
2219 aNbTimeStamps = aNbStamps;
2222 if(!theGeom2Size.empty())
2225 return aNbTimeStamps;
2229 //----------------------------------------------------------------------------
2232 ::GetTimeStampInfo(TInt theTimeStampId,
2233 MED::TTimeStampInfo& theInfo,
2236 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2238 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2241 if(aGeom2Size.empty())
2245 }else if(aGeom2Size.empty())
2246 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
2248 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2249 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2251 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2252 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2253 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2254 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2255 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2256 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2257 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2258 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2259 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2261 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2263 // just to get a time stamp unit (anUnitDt)
2264 med_field_type aFieldType;
2265 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2266 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2267 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2269 MEDfieldInfoByName(myFile->Id(),
2278 delete [] aCompName;
2279 delete [] aCompUnit;
2281 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2282 for(; anIter != aGeom2Size.end(); anIter++){
2283 const EGeometrieElement& aGeom = anIter->first;
2284 med_int aNbGauss = -1;
2287 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2293 char profilename[MED_NAME_SIZE+1];
2295 char locname[MED_NAME_SIZE+1];
2296 MEDfieldnValueWithProfile(myFile->Id(),
2301 med_geometry_type(aGeom),
2309 static TInt MAX_NB_GAUSS_POINTS = 32;
2310 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2313 aGeom2NbGauss[aGeom] = aNbGauss;
2318 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2323 //----------------------------------------------------------------------------
2326 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2327 const TMKey2Profile& theMKey2Profile,
2328 const TKey2Gauss& theKey2Gauss,
2331 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2333 if(theErr && *theErr < 0)
2336 TIdt anId = myFile->Id();
2338 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2339 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2341 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2342 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2343 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2344 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2346 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2347 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2348 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
2350 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2351 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2353 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2354 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2356 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
2357 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
2358 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2360 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
2361 TGeom2Size::iterator anIter = aGeom2Size.begin();
2362 for(; anIter != aGeom2Size.end(); anIter++){
2363 EGeometrieElement aGeom = anIter->first;
2364 TInt aNbElem = anIter->second;
2365 med_int profilesize,aNbGauss;
2367 TInt aNbVal = MEDfieldnValueWithProfile(anId,
2372 med_geometry_type(aGeom),
2385 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
2388 TInt aNbComp = aFieldInfo->myNbComp;
2389 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
2390 theTimeStampValue->AllocateValue(aGeom,
2394 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
2397 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
2398 "; aNbVal = "<<aNbVal<<
2399 "; aNbValue = "<<aNbValue<<
2400 "; aNbGauss = "<<aNbGauss<<
2401 "; aNbComp = "<<aNbComp<<
2404 TErr aRet = MEDfieldValueWithProfileRd(anId,
2409 med_geometry_type(aGeom),
2413 MED_ALL_CONSTITUENT,
2414 theTimeStampValue->GetValuePtr(aGeom));
2417 *theErr = MED_FALSE;
2420 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
2423 MED::PGaussInfo aGaussInfo;
2424 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2425 if(strcmp(&aGaussName[0],"") != 0){
2426 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2427 if(anIter != theKey2Gauss.end()){
2428 aGaussInfo = anIter->second;
2429 aGeom2Gauss[aGeom] = aGaussInfo;
2433 MED::PProfileInfo aProfileInfo;
2434 if(strcmp(&aProfileName[0],MED_NO_PROFILE) != 0){
2435 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2436 if(anIter != aKey2Profile.end()){
2437 aProfileInfo = anIter->second;
2438 aGeom2Profile[aGeom] = aProfileInfo;
2442 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2444 *theErr = MED_FALSE;
2447 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2450 if(aProfileInfo && aProfileInfo->IsPresent()){
2451 TInt aNbSubElem = aProfileInfo->GetSize();
2452 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2453 if(aProfileSize != aValueSize){
2458 EXCEPTION(std::runtime_error,
2459 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2460 ") != aValueSize("<<aValueSize<<
2461 "); aNbVal = "<<aNbVal<<
2462 "; anEntity = "<<anEntity<<
2463 "; aGeom = "<<aGeom<<
2464 "; aNbElem = "<<aNbElem<<
2465 "; aNbSubElem = "<<aNbSubElem<<
2466 "; aNbComp = "<<aNbComp<<
2467 "; aNbGauss = "<<aNbGauss<<
2471 if((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)){
2476 EXCEPTION(std::runtime_error,
2477 "GetTimeStampValue - aNbElem("<<aNbElem<<
2478 ") != aNbValue("<<aNbValue<<
2479 "); aNbVal = "<<aNbVal<<
2480 "; anEntity = "<<anEntity<<
2481 "; aGeom = "<<aGeom<<
2482 "; aNbElem = "<<aNbElem<<
2483 "; aNbComp = "<<aNbComp<<
2484 "; aNbGauss = "<<aNbGauss<<
2492 //----------------------------------------------------------------------------
2495 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2499 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2501 if(theErr && *theErr < 0)
2505 TIdt anId = myFile->Id();
2507 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
2508 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2510 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2511 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
2512 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2513 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2514 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2515 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2516 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2518 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2519 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2521 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2522 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2524 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2525 TGeomSet::const_iterator anIter = aGeomSet.begin();
2526 for(; anIter != aGeomSet.end(); anIter++){
2527 EGeometrieElement aGeom = *anIter;
2529 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2530 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2531 if(aGaussIter != aGeom2Gauss.end()){
2532 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2533 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2536 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2537 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
2538 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2539 if(aProfileIter != aGeom2Profile.end()){
2540 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2541 aProfileMode = med_storage_mode(aProfileInfo->myMode);
2542 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2545 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2547 aRet = MEDfieldValueWithProfileWr(anId,
2553 med_geometry_type(aGeom),
2558 MED_ALL_CONSTITUENT,
2560 theTimeStampValue->GetValuePtr(aGeom));
2563 *theErr = MED_FALSE;
2566 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
2571 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2575 //----------------------------------------------------------------------------
2578 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2582 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2585 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2591 //----------------------------------------------------------------------------
2594 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2597 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2600 //----------------------------------------------------------------------------
2603 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2607 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2609 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2611 if(theErr && *theErr < 0)
2614 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2616 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2617 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2619 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
2622 aRet = MEDmeshGridTypeRd(myFile->Id(),
2628 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridTypeRd(...)");
2630 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2631 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2632 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
2633 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2634 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2635 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2636 //med_axis_type aRepere = MED_CARTESIAN;
2638 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
2648 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
2650 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2651 aRet = MEDmeshGridStructWr(myFile->Id(),
2658 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridStructWr(...)");
2661 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2662 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
2668 anInfo.GetIndexes(aAxis).size(),
2669 &anInfo.GetIndexes(aAxis)[0]);
2672 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
2680 //----------------------------------------------------------------------------
2683 ::GetGrilleInfo(TGrilleInfo& theInfo,
2686 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2688 if(theErr && *theErr < 0)
2691 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2692 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2693 EMaillage aMaillageType = aMeshInfo.myType;
2695 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2696 EGrilleType aGrilleType = theInfo.myGrilleType;
2699 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
2700 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2702 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2703 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2704 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2705 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2706 //med_axis_type aRepere;
2708 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
2718 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
2720 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2721 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2723 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2733 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2735 int mySize = (int)theInfo.myFamNumNode.size();
2736 theInfo.myFamNumNode.clear();
2737 theInfo.myFamNumNode.resize(mySize,0);
2741 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2746 //============================
2749 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2751 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2754 aTable = eCOOR_IND1;
2757 aTable = eCOOR_IND2;
2760 aTable = eCOOR_IND3;
2769 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2771 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2773 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2775 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2776 //TValueHolder<ETable, med_data_type > table(aTable);
2777 //char aCompNames[MED_SNAME_SIZE+1];
2778 //char anUnitNames[MED_SNAME_SIZE+1];
2779 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),&aMeshName,
2780 MED_NO_DT,MED_NO_IT,
2784 //theInfo.SetCoordName(anAxis-1, aCompNames);
2785 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2786 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
2791 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2795 EGeometrieElement aGeom = theInfo.GetGeom();
2796 EEntiteMaillage aEntity = theInfo.GetEntity();
2797 TInt aNbCells = theInfo.GetNbCells();
2799 theInfo.myFamNum.resize(aNbCells);
2800 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2802 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2803 &aMeshName,MED_NO_DT,MED_NO_IT,med_entity_type(aEntity),
2804 med_geometry_type(aGeom),&aFamNum);
2806 if ( aMeshInfo.myDim == 3 )
2808 aGeom = theInfo.GetSubGeom();
2809 aEntity = theInfo.GetSubEntity();
2810 aNbCells = theInfo.GetNbSubCells();
2812 theInfo.myFamSubNum.resize(aNbCells,0);
2813 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
2815 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
2816 &aMeshName,MED_NO_DT,MED_NO_IT,
2817 med_entity_type(aEntity),
2818 med_geometry_type(aGeom),&aFamNum);
2822 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
2824 int mySize = (int)theInfo.myFamNumNode.size();
2825 theInfo.myFamNumNode.clear();
2826 theInfo.myFamNumNode.resize(mySize,0);
2830 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
2838 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2839 EGrilleType& theGridType,
2842 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2844 if(theErr && *theErr < 0)
2845 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2847 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2849 if(aMeshInfo.myType == eSTRUCTURE){
2850 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2851 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
2852 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
2857 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridTypeRd(...)");
2863 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2864 TIntVector& theStruct,
2867 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2869 if(theErr && *theErr < 0)
2873 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2875 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2876 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
2878 aRet = MEDmeshGridStructRd(myFile->Id(),
2886 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshGridStructRd(...)");