3 // Copyright (C) 2003 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.
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
29 #include "MED_V2_2_Wrapper.hxx"
30 #include "MED_Algorithm.hxx"
31 #include "MED_Utilities.hxx"
36 //using namespace med_2_2;
43 MEDgaussInfo(med_idt fid, int indice, char * locname, med_geometrie_element * type_geo,
52 static int MYDEBUG = 0;
54 static int MYDEBUG = 0;
63 GetDESCLength<eV2_2>()
70 GetIDENTLength<eV2_2>()
84 GetLNOMLength<eV2_2>()
91 GetPNOMLength<eV2_2>()
98 GetVersionRelease<eV2_2>(TInt& majeur, TInt& mineur, TInt& release)
100 MEDversionDonner(&majeur, &mineur, &release);
105 GetNbConn<eV2_2>(EGeometrieElement typmai,
106 EEntiteMaillage typent,
115 //---------------------------------------------------------------
121 TFile(const std::string& theFileName):
124 myFileName(theFileName)
133 Open(EModeAcces theMode, TErr* theErr = NULL)
136 char* aFileName = const_cast<char*>(myFileName.c_str());
137 myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
140 *theErr = TErr(myFid);
142 EXCEPTION(std::runtime_error,"TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
145 const TIdt& Id() const
148 EXCEPTION(std::runtime_error,"TFile - GetFid() < 0");
159 std::string myFileName;
165 //---------------------------------------------------------------
171 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
174 myFile->Open(theMode,theErr);
184 //---------------------------------------------------------------
185 TVWrapper::TVWrapper(const std::string& theFileName):
186 myFile(new TFile(theFileName))
190 //----------------------------------------------------------------------------
193 ::GetNbMeshes(TErr* theErr)
195 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
197 if(theErr && *theErr < 0)
200 return MEDnMaa(myFile->Id());
204 //----------------------------------------------------------------------------
207 ::GetMeshInfo(TInt theMeshId,
208 MED::TMeshInfo& theInfo,
211 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
213 if(theErr && *theErr < 0)
216 TValueHolder<TString, char> aMeshName(theInfo.myName);
217 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
218 TValueHolder<EMaillage, med_maillage> aType(theInfo.myType);
220 TErr aRet = MEDmaaInfo(myFile->Id(),
229 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
233 //----------------------------------------------------------------------------
236 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
240 TFileWrapper aFileWrapper(myFile,theMode,theErr);
242 if(theErr && *theErr < 0)
245 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
247 TValueHolder<TString, char> aMeshName(anInfo.myName);
248 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
249 TValueHolder<EMaillage, med_maillage> aType(anInfo.myType);
250 TValueHolder<TString, char> aDesc(anInfo.myDesc);
252 TErr aRet = MEDmaaCr(myFile->Id(),
258 aRet = MEDunvCr(myFile->Id(),
262 INITMSG(MYDEBUG,"TVWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
267 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmaaCr(...)");
271 //----------------------------------------------------------------------------
274 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
278 SetMeshInfo(theInfo,eLECTURE_ECRITURE,&aRet);
281 SetMeshInfo(theInfo,eLECTURE_AJOUT,&aRet);
284 SetMeshInfo(theInfo,eCREATION,&aRet);
291 //----------------------------------------------------------------------------
294 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
297 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
299 if(theErr && *theErr < 0)
302 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
303 TValueHolder<TString, char> aName(anInfo.myName);
304 return MEDnFam(myFile->Id(),
309 //----------------------------------------------------------------------------
312 ::GetNbFamAttr(TInt theFamId,
313 const MED::TMeshInfo& theInfo,
316 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
318 if(theErr && *theErr < 0)
321 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
323 TValueHolder<TString, char> aName(anInfo.myName);
325 return MEDnAttribut(myFile->Id(),
331 //----------------------------------------------------------------------------
334 ::GetNbFamGroup(TInt theFamId,
335 const MED::TMeshInfo& theInfo,
338 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
340 if(theErr && *theErr < 0)
343 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
345 TValueHolder<TString, char> aName(anInfo.myName);
347 return MEDnGroupe(myFile->Id(),
353 //----------------------------------------------------------------------------
356 ::GetFamilyInfo(TInt theFamId,
357 MED::TFamilyInfo& theInfo,
360 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
362 if(theErr && *theErr < 0)
365 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
367 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
368 TValueHolder<TString, char> aFamilyName(theInfo.myName);
369 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
370 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
371 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
372 TValueHolder<TInt, med_int> aNbAttr(theInfo.myNbAttr);
373 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
374 TValueHolder<TInt, med_int> aNbGroup(theInfo.myNbGroup);
375 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
377 TErr aRet = MEDfamInfo(myFile->Id(),
392 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamInfo(...) - "<<
393 " aMeshInfo.myName = '"<<&aMeshName<<
394 "'; theFamId = "<<theFamId<<
395 "; theInfo.myNbGroup = "<<aNbGroup()<<
396 "; theInfo.myNbAttr = "<<aNbAttr());
400 //----------------------------------------------------------------------------
403 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
407 TFileWrapper aFileWrapper(myFile,theMode,theErr);
409 if(theErr && *theErr < 0)
412 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
413 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
415 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
416 TValueHolder<TString, char> aFamilyName(anInfo.myName);
417 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
418 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
419 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
420 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
421 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
422 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
423 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
425 TErr aRet = MEDfamCr(myFile->Id(),
436 INITMSG(MYDEBUG,"TVWrapper::GetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
441 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamCr(...)");
445 //----------------------------------------------------------------------------
448 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
452 SetFamilyInfo(theInfo,eLECTURE_ECRITURE,&aRet);
455 SetFamilyInfo(theInfo,eLECTURE_AJOUT,&aRet);
461 //----------------------------------------------------------------------------
464 ::GetNames(TElemInfo& theInfo,
466 EEntiteMaillage theEntity,
467 EGeometrieElement theGeom,
470 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
472 if(theErr && *theErr < 0)
475 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
477 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
478 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
479 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
480 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
482 TErr aRet = MEDnomLire(myFile->Id(),
489 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
495 //----------------------------------------------------------------------------
498 ::GetNumeration(TElemInfo& theInfo,
500 EEntiteMaillage theEntity,
501 EGeometrieElement theGeom,
504 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
506 if(theErr && *theErr < 0)
509 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
511 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
512 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
513 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
514 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
516 TErr aRet = MEDnumLire(myFile->Id(),
523 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
529 //----------------------------------------------------------------------------
532 ::GetFamilies(TElemInfo& theInfo,
534 EEntiteMaillage theEntity,
535 EGeometrieElement theGeom,
538 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
540 if(theErr && *theErr < 0)
543 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
545 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
546 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
547 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
548 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
550 TErr aRet = MEDfamLire(myFile->Id(),
560 EXCEPTION(std::runtime_error,"GetFamilies - MEDfamLire(...)");
564 //----------------------------------------------------------------------------
567 ::SetNames(const TElemInfo& theInfo,
568 EEntiteMaillage theEntity,
569 EGeometrieElement theGeom,
572 SetNames(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
576 //----------------------------------------------------------------------------
579 ::SetNames(const TElemInfo& theInfo,
581 EEntiteMaillage theEntity,
582 EGeometrieElement theGeom,
585 TFileWrapper aFileWrapper(myFile,theMode,theErr);
587 if(theErr && *theErr < 0)
590 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
591 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
594 if(theInfo.myIsElemNames){
595 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
596 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
597 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
598 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
600 aRet = MEDnomEcr(myFile->Id(),
603 (TInt)anInfo.myElemNames->size(),
609 EXCEPTION(std::runtime_error,"SetNames - MEDnomEcr(...)");
614 //----------------------------------------------------------------------------
617 ::SetNumeration(const TElemInfo& theInfo,
618 EEntiteMaillage theEntity,
619 EGeometrieElement theGeom,
622 SetNumeration(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
626 //----------------------------------------------------------------------------
629 ::SetNumeration(const TElemInfo& theInfo,
631 EEntiteMaillage theEntity,
632 EGeometrieElement theGeom,
635 TFileWrapper aFileWrapper(myFile,theMode,theErr);
637 if(theErr && *theErr < 0)
640 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
641 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
644 if(theInfo.myIsElemNum){
645 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
646 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
647 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
648 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
650 aRet = MEDnumEcr(myFile->Id(),
653 (TInt)anInfo.myElemNum->size(),
659 EXCEPTION(std::runtime_error,"SetNumeration - MEDnumEcr(...)");
663 //----------------------------------------------------------------------------
666 ::SetFamilies(const TElemInfo& theInfo,
667 EEntiteMaillage theEntity,
668 EGeometrieElement theGeom,
671 SetFamilies(theInfo,eLECTURE_ECRITURE,theEntity,theGeom,theErr);
674 //----------------------------------------------------------------------------
677 ::SetFamilies(const TElemInfo& theInfo,
679 EEntiteMaillage theEntity,
680 EGeometrieElement theGeom,
683 TFileWrapper aFileWrapper(myFile,theMode,theErr);
685 if(theErr && *theErr < 0)
688 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
689 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
691 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
692 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
693 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theEntity);
694 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theGeom);
696 TErr aRet = MEDfamEcr(myFile->Id(),
699 (TInt)anInfo.myFamNum->size(),
706 EXCEPTION(std::runtime_error,"SetFamilies - MEDfamEcr(...)");
709 //----------------------------------------------------------------------------
712 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
716 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
718 if(theErr && *theErr < 0)
721 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
723 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
724 TValueHolder<ETable, med_table> aTable(theTable);
726 return MEDnEntMaa(myFile->Id(),
730 med_geometrie_element(0),
731 med_connectivite(0));
735 //----------------------------------------------------------------------------
738 ::GetNodeInfo(MED::TNodeInfo& theInfo,
741 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
743 if(theErr && *theErr < 0)
746 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
748 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
749 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
750 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
751 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
752 TValueHolder<ERepere, med_repere> aSystem(theInfo.mySystem);
753 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
754 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
755 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
756 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
757 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
758 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
759 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
760 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
762 TErr aRet = MEDnoeudsLire(myFile->Id(),
779 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
783 //----------------------------------------------------------------------------
786 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
790 TFileWrapper aFileWrapper(myFile,theMode,theErr);
792 if(theErr && *theErr < 0)
795 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
796 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
798 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
799 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
800 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
801 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
802 TValueHolder<ERepere, med_repere> aSystem(anInfo.mySystem);
803 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
804 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
805 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
806 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
807 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
808 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
809 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
810 TValueHolder<TInt, med_int> aNbElem(anInfo.myNbElem);
812 TErr aRet = MEDnoeudsEcr(myFile->Id(),
829 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
833 //----------------------------------------------------------------------------
836 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
840 SetNodeInfo(theInfo,eLECTURE_ECRITURE,&aRet);
843 SetNodeInfo(theInfo,eLECTURE_AJOUT,&aRet);
850 //-----------------------------------------------------------------
853 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
856 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
858 if(theErr && *theErr < 0)
861 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
863 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
864 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
865 TInt aNbElem = (TInt)theInfo.myElemNum->size();
866 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
867 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
868 TValueHolder<EConnectivite, med_connectivite> aConnMode(theInfo.myConnMode);
871 aRet = MEDpolygoneConnLire(myFile->Id(),
882 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
884 if(theInfo.myIsElemNames){
885 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
890 if(theInfo.myIsElemNum){
891 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
896 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYGONE,&aRet);
901 //----------------------------------------------------------------------------
904 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
907 SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr);
910 //----------------------------------------------------------------------------
913 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
917 TFileWrapper aFileWrapper(myFile,theMode,theErr);
919 if(theErr && *theErr < 0)
922 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
923 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
925 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
926 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
927 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
928 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(anInfo.myEntity);
929 TValueHolder<EConnectivite, med_connectivite> aConnMode(anInfo.myConnMode);
931 TErr aRet = MEDpolygoneConnEcr(myFile->Id(),
942 EXCEPTION(std::runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)");
944 SetNames(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
948 SetNumeration(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
952 SetFamilies(anInfo,theInfo.myEntity,ePOLYGONE,&aRet);
957 //----------------------------------------------------------------------------
960 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
961 EEntiteMaillage theEntity,
962 EGeometrieElement theGeom,
963 EConnectivite theConnMode,
966 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
969 //----------------------------------------------------------------------------
972 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
973 EEntiteMaillage theEntity,
974 EGeometrieElement theGeom,
975 EConnectivite theConnMode,
978 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
980 if(theErr && *theErr < 0)
983 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
985 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
989 aRet = MEDpolygoneInfo(myFile->Id(),
991 med_entite_maillage(theEntity),
992 med_connectivite(theConnMode),
998 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)");
1000 return TInt(aTaille);
1003 //-----------------------------------------------------------------
1006 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1009 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1011 if(theErr && *theErr < 0)
1014 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1016 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1017 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1018 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1019 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1020 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1021 TValueHolder<EConnectivite, med_connectivite> aConnMode(theInfo.myConnMode);
1024 aRet = MEDpolyedreConnLire(myFile->Id(),
1029 (TInt)theInfo.myFaces->size(),
1036 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)");
1038 if(theInfo.myIsElemNames){
1039 GetNames(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1044 if(theInfo.myIsElemNum){
1045 GetNumeration(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1050 GetFamilies(theInfo,aNbElem,theInfo.myEntity,ePOLYEDRE,&aRet);
1055 //----------------------------------------------------------------------------
1058 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1061 SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr);
1064 //----------------------------------------------------------------------------
1067 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1071 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1073 if(theErr && *theErr < 0)
1076 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1077 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1079 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1080 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1081 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1082 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1083 TValueHolder<EConnectivite, med_connectivite> aConnMode(anInfo.myConnMode);
1086 aRet = MEDpolyedreConnEcr(myFile->Id(),
1089 anInfo.myNbElem + 1,
1091 (TInt)anInfo.myFaces->size(),
1098 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)");
1100 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(anInfo.myEntity);
1102 if(theInfo.myIsElemNames){
1103 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1104 aRet = MEDnomEcr(myFile->Id(),
1107 (TInt)anInfo.myElemNames->size(),
1113 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDnomEcr(...)");
1116 if(theInfo.myIsElemNum){
1117 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1118 aRet = MEDnumEcr(myFile->Id(),
1121 (TInt)anInfo.myElemNum->size(),
1127 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDnumEcr(...)");
1131 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1132 aRet = MEDfamEcr(myFile->Id(),
1135 (TInt)anInfo.myFamNum->size(),
1142 EXCEPTION(std::runtime_error,"SetPolyedreInfo - MEDfamEcr(...)");
1145 //----------------------------------------------------------------------------
1148 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1149 EEntiteMaillage theEntity,
1150 EGeometrieElement theGeom,
1151 EConnectivite theConnMode,
1154 return GetNbCells(theMeshInfo,theEntity,theGeom,theConnMode,theErr);
1157 //----------------------------------------------------------------------------
1160 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1163 EConnectivite theConnMode,
1166 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1168 if(theErr && *theErr < 0)
1169 EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
1171 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1173 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1174 TValueHolder<EConnectivite, med_connectivite> aConnMode(theConnMode);
1175 TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1176 TValueHolder<TInt, med_int> aConnSize(theConnSize);
1178 TErr aRet = MEDpolyedreInfo(myFile->Id(),
1187 EXCEPTION(std::runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)");
1191 //-----------------------------------------------------------------
1194 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1195 EConnectivite theConnMode,
1200 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1202 if(theErr && *theErr < 0)
1205 if(theMeshInfo.GetType() == eNON_STRUCTURE) {
1206 TInt aNbElem = GetNbNodes(theMeshInfo);
1208 anInfo[eNOEUD][ePOINT1] = aNbElem;
1209 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1210 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1211 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1212 for(; anIter != anIterEnd; anIter++){
1213 const EEntiteMaillage& anEntity = anIter->first;
1214 const TGeomSet& aGeomSet = anIter->second;
1215 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1216 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1217 for(; anIter2 != anIterEnd2; anIter2++){
1218 const EGeometrieElement& aGeom = *anIter2;
1219 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
1221 anInfo[anEntity][aGeom] = aNbElem;
1225 } else { // eSTRUCTURE
1226 EGrilleType aGrilleType;
1229 TInt aDim = theMeshInfo.GetDim();
1230 EGeometrieElement aGeom;
1231 EEntiteMaillage anEntity = eMAILLE;
1244 GetGrilleType(theMeshInfo, aGrilleType);
1246 if(aGrilleType == eGRILLE_STANDARD){
1247 TIntVector aStruct(aDim);
1248 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1249 for(med_int i = 0; i < aDim; i++){
1250 aNbNodes = aNbNodes * aStruct[i];
1251 aNbElem = aNbElem * (aStruct[i] - 1);
1253 }else{ // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1255 for(med_int anAxis = 1; anAxis <= aDim; anAxis++){
1258 aTable = eCOOR_IND1;
1261 aTable = eCOOR_IND2;
1264 aTable = eCOOR_IND3;
1267 TInt aNbNodes = GetNbNodes(theMeshInfo, aTable);
1268 aNbNodes = aNbNodes * aNbNodes;
1269 aNbElem = aNbElem * (aNbNodes - 1);
1272 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1273 anInfo[anEntity][aGeom] = aNbElem;
1279 //-----------------------------------------------------------------
1282 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1283 EEntiteMaillage theEntity,
1284 EGeometrieElement theGeom,
1285 EConnectivite theConnMode,
1288 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1290 if(theErr && *theErr < 0)
1293 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1294 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1296 return MEDnEntMaa(myFile->Id(),
1299 med_entite_maillage(theEntity),
1300 med_geometrie_element(theGeom),
1301 med_connectivite(theConnMode));
1305 //----------------------------------------------------------------------------
1308 ::GetCellInfo(MED::TCellInfo& theInfo,
1311 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1313 if(theErr && *theErr < 0)
1316 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1317 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1319 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1320 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
1321 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1322 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
1323 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
1324 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
1325 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
1326 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
1327 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
1328 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
1329 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theInfo.myGeom);
1330 TValueHolder<EConnectivite, med_connectivite> aConnMode(theInfo.myConnMode);
1333 aRet = MEDelementsLire(myFile->Id(),
1350 EXCEPTION(std::runtime_error,"GetCellInfo - MEDelementsLire(...)");
1354 //----------------------------------------------------------------------------
1357 ::SetCellInfo(const MED::TCellInfo& theInfo,
1361 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1363 if(theErr && *theErr < 0)
1366 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
1367 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1369 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1370 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
1371 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1372 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
1373 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1374 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
1375 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1376 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
1377 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1378 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(anInfo.myEntity);
1379 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(anInfo.myGeom);
1380 TValueHolder<EConnectivite, med_connectivite> aConnMode(anInfo.myConnMode);
1383 aRet = MEDelementsEcr(myFile->Id(),
1401 EXCEPTION(std::runtime_error,"SetCellInfo - MEDelementsLire(...)");
1405 //----------------------------------------------------------------------------
1408 ::SetCellInfo(const MED::TCellInfo& theInfo,
1411 SetCellInfo(theInfo,eLECTURE_ECRITURE,theErr);
1415 //-----------------------------------------------------------------
1418 ::GetNbFields(TErr* theErr)
1420 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1422 if(theErr && *theErr < 0)
1425 return MEDnChamp(myFile->Id(),0);
1429 //----------------------------------------------------------------------------
1432 ::GetNbComp(TInt theFieldId,
1435 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1437 if(theErr && *theErr < 0)
1440 return MEDnChamp(myFile->Id(),theFieldId);
1444 //----------------------------------------------------------------------------
1447 ::GetFieldInfo(TInt theFieldId,
1448 MED::TFieldInfo& theInfo,
1451 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1453 if(theErr && *theErr < 0)
1456 TString aFieldName(256); // Protect from memory problems with too long names
1457 TValueHolder<ETypeChamp, med_type_champ> aType(theInfo.myType);
1458 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
1459 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
1462 aRet = MEDchampInfo(myFile->Id(),
1470 theInfo.SetName(aFieldName);
1475 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDchampInfo(...)");
1479 //----------------------------------------------------------------------------
1482 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1486 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1488 if(theErr && *theErr < 0)
1491 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1493 TValueHolder<TString, char> aFieldName(anInfo.myName);
1494 TValueHolder<ETypeChamp, med_type_champ> aType(anInfo.myType);
1495 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
1496 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
1499 aRet = MEDchampCr(myFile->Id(),
1508 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDchampEcr(...)");
1512 //----------------------------------------------------------------------------
1515 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
1519 SetFieldInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1522 SetFieldInfo(theInfo,eLECTURE_AJOUT,&aRet);
1529 //----------------------------------------------------------------------------
1532 ::GetNbGauss(TErr* theErr)
1534 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1536 if(theErr && *theErr < 0)
1539 return MEDnGauss(myFile->Id());
1543 //----------------------------------------------------------------------------
1546 ::GetGaussPreInfo(TInt theId,
1549 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1551 if(theErr && *theErr < 0)
1552 return TGaussInfo::TInfo( TGaussInfo::TKey(ePOINT1,""),0 );
1554 med_int aNbGaussPoints = med_int();
1555 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1556 med_geometrie_element aGeom = MED_NONE;
1559 aRet = MEDgaussInfo(myFile->Id(),
1567 EXCEPTION(std::runtime_error,"GetGaussPreInfo - MEDgaussInfo(...)");
1569 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom),&aName[0]),
1570 TInt(aNbGaussPoints));
1574 //----------------------------------------------------------------------------
1577 ::GetGaussInfo(TInt theId,
1578 TGaussInfo& theInfo,
1581 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1583 if(theErr && *theErr < 0)
1586 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
1587 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
1588 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
1589 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
1590 TValueHolder<TString, char> aGaussName(theInfo.myName);
1593 aRet = MEDgaussLire(myFile->Id(),
1603 EXCEPTION(std::runtime_error,"GetGaussInfo - MEDgaussLire(...)");
1607 //----------------------------------------------------------------------------
1610 ::GetNbProfiles(TErr* theErr)
1612 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1614 if(theErr && *theErr < 0)
1617 return MEDnProfil(myFile->Id());
1622 ::GetProfilePreInfo(TInt theId,
1625 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1627 if(theErr && *theErr < 0)
1628 return TProfileInfo::TInfo();
1631 TVector<char> aName(GetNOMLength<eV2_2>()+1);
1634 aRet = MEDprofilInfo(myFile->Id(),
1641 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofilInfo(...)");
1643 return TProfileInfo::TInfo(&aName[0],aSize);
1648 ::GetProfileInfo(TInt theId,
1649 TProfileInfo& theInfo,
1652 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1654 if(theErr && *theErr < 0)
1657 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
1658 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1659 TValueHolder<TString, char> aProfileName(anInfo.myName);
1662 aRet = MEDprofilLire(myFile->Id(),
1668 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofilLire(...)");
1673 ::SetProfileInfo(const TProfileInfo& theInfo,
1677 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1679 if(theErr && *theErr < 0)
1682 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
1683 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1684 TValueHolder<TString, char> aProfileName(anInfo.myName);
1687 aRet = MEDprofilEcr(myFile->Id(), // descripteur du fichier.
1688 &anElemNum, // tableau de valeurs du profil.
1689 theInfo.GetSize(), // taille du profil.
1690 &aProfileName); // nom profil.
1694 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofilEcr(...)");
1699 ::SetProfileInfo(const TProfileInfo& theInfo,
1703 SetProfileInfo(theInfo,eLECTURE_ECRITURE,&aRet);
1706 SetProfileInfo(theInfo,eLECTURE_AJOUT,&aRet);
1709 SetProfileInfo(theInfo,eCREATION,&aRet);
1715 //-----------------------------------------------------------------
1718 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
1719 const MED::TEntityInfo& theEntityInfo,
1720 EEntiteMaillage& theEntity,
1721 TGeom2Size& theGeom2Size,
1724 theEntity = EEntiteMaillage(-1);
1725 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1728 if(theEntityInfo.empty())
1732 }else if(theEntityInfo.empty())
1733 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1735 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
1737 theGeom2Size.clear();
1738 TInt aNbTimeStamps = 0;
1739 TIdt anId = myFile->Id();
1741 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1742 TValueHolder<TString, char> aFieldName(anInfo.myName);
1743 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1745 TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1746 for(; anIter != theEntityInfo.end(); anIter++){
1747 med_entite_maillage anEntity = med_entite_maillage(anIter->first);
1748 const TGeom2Size& aGeom2Size = anIter->second;
1749 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
1750 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
1751 med_geometrie_element aGeom = med_geometrie_element(anGeomIter->first);
1752 TInt aNbStamps = MEDnPasdetemps(anId,
1756 bool anIsSatisfied = aNbStamps > 0;
1759 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
1760 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
1761 if(anIsPerformAdditionalCheck){
1762 TInt iTimeStampEnd = aNbStamps;
1763 for(TInt iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++){
1764 TVector<char> aMeshName(GetNOMLength<eV2_2>()+1);
1765 TVector<char> aDtUnit(GetPNOMLength<eV2_2>()+1);
1770 med_booleen anIsLocal;
1772 TErr aRet = MEDpasdetempsInfo(anId,
1786 anIsSatisfied = (aRet == 0 && (!strcmp(&aMeshName[0],&aMeshInfo.myName[0])));
1789 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
1790 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
1797 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
1798 theEntity = EEntiteMaillage(anEntity);
1799 aNbTimeStamps = aNbStamps;
1802 if(!theGeom2Size.empty())
1805 return aNbTimeStamps;
1809 //----------------------------------------------------------------------------
1812 ::GetTimeStampInfo(TInt theTimeStampId,
1813 MED::TTimeStampInfo& theInfo,
1816 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1818 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
1821 if(aGeom2Size.empty())
1825 }else if(aGeom2Size.empty())
1826 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
1828 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1829 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1831 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
1832 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
1833 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
1834 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
1835 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
1836 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
1837 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1838 TValueHolder<EBooleen, med_booleen> anIsLocal(aFieldInfo.myIsLocal);
1839 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
1841 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
1843 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
1844 for(; anIter != aGeom2Size.end(); anIter++){
1845 const EGeometrieElement& aGeom = anIter->first;
1846 med_int aNbGauss = -1;
1849 aRet = MEDpasdetempsInfo(myFile->Id(),
1852 med_geometrie_element(aGeom),
1863 static TInt MAX_NB_GAUSS_POINTS = 32;
1864 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
1867 aGeom2NbGauss[aGeom] = aNbGauss;
1872 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1877 //----------------------------------------------------------------------------
1880 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
1881 const TMKey2Profile& theMKey2Profile,
1882 const TKey2Gauss& theKey2Gauss,
1885 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
1887 if(theErr && *theErr < 0)
1890 TIdt anId = myFile->Id();
1892 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
1893 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
1895 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
1896 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
1897 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
1898 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
1900 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
1901 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
1902 TValueHolder<EBooleen, med_booleen> anIsLocal(aFieldInfo->myIsLocal);
1904 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
1905 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
1907 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
1908 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
1910 med_mode_profil aProfileMode = med_mode_profil(boost::get<0>(theMKey2Profile));
1911 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
1912 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
1914 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
1915 TGeom2Size::iterator anIter = aGeom2Size.begin();
1916 for(; anIter != aGeom2Size.end(); anIter++){
1917 EGeometrieElement aGeom = anIter->first;
1918 TInt aNbElem = anIter->second;
1920 TInt aNbMeshRef = MEDnChampRef(anId,
1923 med_geometrie_element(aGeom),
1931 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDnChampRef(...) < 1");
1935 med_int aNbGauss = -1;
1936 aRet = MEDchampRefInfo(anId,
1939 med_geometrie_element(aGeom),
1952 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDchampRefInfo(...)");
1955 TInt aNbVal = MEDnVal(anId,
1958 med_geometrie_element(aGeom),
1968 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1971 TInt aNbComp = aFieldInfo->myNbComp;
1972 TInt aNbValue = aNbVal / aNbGauss;
1973 theTimeStampValue->AllocateValue(aGeom,
1977 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
1980 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
1981 "; aNbVal = "<<aNbVal<<
1982 "; aNbValue = "<<aNbValue<<
1983 "; aNbGauss = "<<aNbGauss<<
1984 "; aNbComp = "<<aNbComp<<
1987 aRet = MEDchampLire(anId,
1990 theTimeStampValue->GetValuePtr(aGeom),
1997 med_geometrie_element(aGeom),
2005 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDchampLire(...)");
2008 MED::PGaussInfo aGaussInfo;
2009 TGaussInfo::TKey aKey(aGeom,&aGaussName[0]);
2010 if(strcmp(&aGaussName[0],"") != 0){
2011 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
2012 if(anIter != theKey2Gauss.end()){
2013 aGaussInfo = anIter->second;
2014 aGeom2Gauss[aGeom] = aGaussInfo;
2018 MED::PProfileInfo aProfileInfo;
2019 if(strcmp(&aProfileName[0],"") != 0){
2020 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
2021 if(anIter != aKey2Profile.end()){
2022 aProfileInfo = anIter->second;
2023 aGeom2Profile[aGeom] = aProfileInfo;
2027 if(aNbGauss > 1 && !aGaussInfo){
2032 EXCEPTION(std::runtime_error,"GetTimeStampValue "<<
2033 "- aNbGauss("<<aNbGauss<<") > 1 && !aGaussInfo"<<
2034 "; aGaussName = '"<<&aGaussName[0]<<"'"<<
2035 "; aGeom = "<<aGeom<<
2039 if(aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()){
2044 EXCEPTION(std::runtime_error,"GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
2047 if(aProfileInfo && aProfileInfo->IsPresent()){
2048 TInt aNbSubElem = aProfileInfo->GetSize();
2049 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
2050 if(aProfileSize != aValueSize){
2055 EXCEPTION(std::runtime_error,
2056 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
2057 ") != aValueSize("<<aValueSize<<
2058 "); aNbVal = "<<aNbVal<<
2059 "; anEntity = "<<anEntity<<
2060 "; aGeom = "<<aGeom<<
2061 "; aNbElem = "<<aNbElem<<
2062 "; aNbSubElem = "<<aNbSubElem<<
2063 "; aNbComp = "<<aNbComp<<
2064 "; aNbGauss = "<<aNbGauss<<
2068 if(aNbElem != aNbValue){
2073 EXCEPTION(std::runtime_error,
2074 "GetTimeStampValue - aNbElem("<<aNbElem<<
2075 ") != aNbValue("<<aNbValue<<
2076 "); aNbVal = "<<aNbVal<<
2077 "; anEntity = "<<anEntity<<
2078 "; aGeom = "<<aGeom<<
2079 "; aNbElem = "<<aNbElem<<
2080 "; aNbComp = "<<aNbComp<<
2081 "; aNbGauss = "<<aNbGauss<<
2089 //----------------------------------------------------------------------------
2092 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
2096 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2098 if(theErr && *theErr < 0)
2102 TIdt anId = myFile->Id();
2104 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
2105 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
2107 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
2108 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
2109 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
2110 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
2111 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
2112 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
2113 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
2115 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
2116 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
2118 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
2119 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
2121 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
2122 TGeomSet::const_iterator anIter = aGeomSet.begin();
2123 for(; anIter != aGeomSet.end(); anIter++){
2124 EGeometrieElement aGeom = *anIter;
2126 TVector<char> aGaussName(GetNOMLength<eV2_2>()+1);
2127 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
2128 if(aGaussIter != aGeom2Gauss.end()){
2129 MED::PGaussInfo aGaussInfo = aGaussIter->second;
2130 strcpy(&aGaussName[0],&aGaussInfo->myName[0]);
2133 TVector<char> aProfileName(GetNOMLength<eV2_2>()+1);
2134 med_mode_profil aProfileMode = med_mode_profil(eNO_PFLMOD);
2135 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
2136 if(aProfileIter != aGeom2Profile.end()){
2137 MED::PProfileInfo aProfileInfo = aProfileIter->second;
2138 aProfileMode = med_mode_profil(aProfileInfo->myMode);
2139 strcpy(&aProfileName[0],&aProfileInfo->myName[0]);
2142 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
2144 aRet = MEDchampEcr(anId,
2147 theTimeStampValue->GetValuePtr(aGeom),
2155 med_geometrie_element(aGeom),
2165 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDchampEcr(...)");
2170 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
2174 //----------------------------------------------------------------------------
2177 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
2181 SetTimeStampValue(theTimeStampValue,eLECTURE_ECRITURE,&aRet);
2184 SetTimeStampValue(theTimeStampValue,eLECTURE_AJOUT,&aRet);
2190 //----------------------------------------------------------------------------
2193 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2196 SetGrilleInfo(theInfo,eLECTURE_ECRITURE,theErr);
2199 //----------------------------------------------------------------------------
2202 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
2206 if(theInfo.myMeshInfo->myType != eSTRUCTURE)
2208 TFileWrapper aFileWrapper(myFile,theMode,theErr);
2210 if(theErr && *theErr < 0)
2213 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
2215 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2216 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2217 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
2219 TValueHolder<EGrilleType, med_type_grille> aGrilleType(anInfo.myGrilleType);
2222 aRet = MEDnatureGrilleEcr(myFile->Id(),
2228 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDnatureGrilleEcr(...)");
2230 if(anInfo.myGrilleType == eGRILLE_STANDARD){
2231 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
2232 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
2233 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
2234 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
2235 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
2236 med_repere aRepere = MED_CART;
2238 aRet = MEDcoordEcr(myFile->Id(),
2249 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDcoordEcr(...)");
2251 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
2252 aRet = MEDstructureCoordEcr(myFile->Id(),
2257 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDstructureCoordEcr(...)");
2260 for(med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++){
2261 aRet = MEDindicesCoordEcr(myFile->Id(),
2264 &anInfo.GetIndexes(aAxis)[0],
2265 anInfo.GetIndexes(aAxis).size(),
2267 &anInfo.GetCoordName(aAxis)[0],
2268 &anInfo.GetCoordUnit(aAxis)[0]);
2270 EXCEPTION(std::runtime_error,"SetGrilleInfo - MEDindicesCoordEcr(...)");
2278 //----------------------------------------------------------------------------
2281 ::GetGrilleInfo(TGrilleInfo& theInfo,
2284 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2286 if(theErr && *theErr < 0)
2289 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2290 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2291 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
2292 EMaillage aMaillageType = aMeshInfo.myType;
2294 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
2295 EGrilleType aGrilleType = theInfo.myGrilleType;
2298 if(aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD){
2299 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
2301 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
2302 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
2303 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
2304 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
2307 aRet = MEDcoordLire(myFile->Id(),
2312 MED_ALL, // all coordinates must be return
2322 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDcoordLire(...)");
2324 TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
2325 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
2327 aRet = MEDfamLire(myFile->Id(),
2331 med_entite_maillage(eNOEUD),
2332 med_geometrie_element(ePOINT1));
2337 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDfamLire(...) of NODES");
2339 //============================
2342 if(aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD){
2344 for(med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++){
2347 aTable = eCOOR_IND1;
2350 aTable = eCOOR_IND2;
2353 aTable = eCOOR_IND3;
2362 EXCEPTION(std::runtime_error,"GetGrilleInfo - anAxis number out of range(...)");
2364 TInt aNbIndexes = GetNbNodes(aMeshInfo,aTable);
2366 EXCEPTION(std::runtime_error,"GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
2368 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
2369 char aCompNames[MED_TAILLE_PNOM+1];
2370 char anUnitNames[MED_TAILLE_PNOM+1];
2372 aRet = MEDindicesCoordLire(myFile->Id(),
2381 theInfo.SetCoordName(anAxis-1, aCompNames);
2382 theInfo.SetCoordUnit(anAxis-1, anUnitNames);
2387 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDindicesCoordLire(...)");
2391 EGeometrieElement aGeom = theInfo.GetGeom();
2392 EEntiteMaillage aEntity = theInfo.GetEntity();
2393 TInt aNbCells = theInfo.GetNbCells();
2395 theInfo.myFamNum.resize(aNbCells);
2396 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
2398 aRet = MEDfamLire(myFile->Id(),
2402 med_entite_maillage(aEntity),
2403 med_geometrie_element(aGeom));
2408 //EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDfamLire(...) of CELLS");
2410 theInfo.myFamNum.resize(0);
2417 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
2418 EGrilleType& theGrilleType,
2421 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2423 if(theErr && *theErr < 0)
2424 EXCEPTION(std::runtime_error," GetGrilleType - aFileWrapper (...)");
2426 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2428 if(aMeshInfo.myType == eSTRUCTURE){
2429 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2430 TValueHolder<EGrilleType, med_type_grille> aGrilleType(theGrilleType);
2432 TErr aRet = MEDnatureGrilleLire(myFile->Id(),
2436 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDnatureGrilleLire(...)");
2442 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
2443 TIntVector& theStruct,
2446 TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
2448 if(theErr && *theErr < 0)
2452 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2454 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2455 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
2456 TValueHolder<TIntVector, med_int> aGrilleStructure(theStruct);
2458 aRet = MEDstructureCoordLire(myFile->Id(),
2465 EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDstructureCoordLire(...)");