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_1_Wrapper.hxx"
30 #include "MED_Algorithm.hxx"
31 #include "MED_Utilities.hxx"
34 using namespace med_2_1;
37 static int MYDEBUG = 0;
39 static int MYDEBUG = 0;
49 GetDESCLength<eV2_1>()
56 GetIDENTLength<eV2_1>()
63 GetLNOMLength<eV2_1>()
77 GetPNOMLength<eV2_1>()
84 GetVersionRelease<eV2_1>(TInt& majeur, TInt& mineur, TInt& release)
86 MEDversionDonner(&majeur, &mineur, &release);
91 GetNbConn<eV2_1>(EGeometrieElement typmai,
92 EEntiteMaillage typent,
97 if(typent == eMAILLE){
98 TInt edim = typmai / 100;
99 if(mdim == 2 || mdim == 3)
108 return nsup + typmai%100;
114 //---------------------------------------------------------------
120 TFile(const std::string& theFileName):
123 myFileName(theFileName)
132 Open(EModeAcces theMode, TErr* theErr = NULL)
135 char* aFileName = const_cast<char*>(myFileName.c_str());
136 myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
139 *theErr = TErr(myFid);
140 INITMSG(MYDEBUG && myFid < 0,"TFile::Open - MED_MODE_ACCES = "<<theMode<<"; myFid = "<<myFid<<std::endl);
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);
183 //---------------------------------------------------------------
185 ::TVWrapper(const std::string& theFileName):
186 myFile(new TFile(theFileName))
192 ::GetNbMeshes(TErr* theErr)
194 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
196 if(theErr && *theErr < 0)
199 return MEDnMaa(myFile->Id());
205 ::GetMeshInfo(TInt theMeshId,
209 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
211 if(theErr && *theErr < 0)
214 TValueHolder<TString, char> aMeshName(theInfo.myName);
215 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
217 TErr aRet = MEDmaaInfo(myFile->Id(),
224 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
230 ::SetMeshInfo(const TMeshInfo& theInfo,
234 TFileWrapper aFileWrapper(myFile,theMode,theErr);
236 if(theErr && *theErr < 0)
239 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
240 TValueHolder<TString, char> aMeshName(anInfo.myName);
241 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
243 TErr aRet = MEDmaaCr(myFile->Id(),
250 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmaaCr(...)");
256 ::SetMeshInfo(const TMeshInfo& theInfo,
260 SetMeshInfo(theInfo,eECRI,&aRet);
263 SetMeshInfo(theInfo,eREMP,&aRet);
272 ::GetNbFamilies(const TMeshInfo& theInfo,
275 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
277 if(theErr && *theErr < 0)
280 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
281 TValueHolder<TString, char> aMeshName(anInfo.myName);
283 return MEDnFam(myFile->Id(),
292 ::GetNbFamAttr(TInt theFamId,
293 const TMeshInfo& theInfo,
296 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
298 if(theErr && *theErr < 0)
301 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
302 TValueHolder<TString, char> aMeshName(anInfo.myName);
304 return MEDnFam(myFile->Id(),
313 ::GetNbFamGroup(TInt theFamId,
314 const TMeshInfo& theInfo,
317 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
319 if(theErr && *theErr < 0)
322 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
323 TValueHolder<TString, char> aMeshName(anInfo.myName);
325 return MEDnFam(myFile->Id(),
334 ::GetFamilyInfo(TInt theFamId,
335 TFamilyInfo& theInfo,
338 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
340 if(theErr && *theErr < 0)
343 TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
345 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
346 TValueHolder<TString, char> aFamilyName(theInfo.myName);
347 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
348 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
349 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
350 TValueHolder<TInt, med_int> aNbAttr(theInfo.myNbAttr);
351 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
352 TValueHolder<TInt, med_int> aNbGroup(theInfo.myNbGroup);
353 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
355 TErr aRet = MEDfamInfo(myFile->Id(),
370 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamInfo - "<<
371 "&aMeshInfo.myName[0] = '"<<&aMeshName<<"'; "<<
372 "theFamId = "<<theFamId<<"; "<<
373 "&theInfo.myName[0] = '"<<&aFamilyName<<"'; "<<
374 "theInfo.myId = "<<theInfo.myId);
380 ::SetFamilyInfo(const TFamilyInfo& theInfo,
384 TFileWrapper aFileWrapper(myFile,theMode,theErr);
386 if(theErr && *theErr < 0)
389 TFamilyInfo& anInfo = const_cast<TFamilyInfo&>(theInfo);
390 TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
392 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
393 TValueHolder<TString, char> aFamilyName(anInfo.myName);
394 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
395 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
396 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
397 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
398 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
399 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
400 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
402 TErr aRet = MEDfamCr(myFile->Id(),
413 INITMSG(MYDEBUG && aRet,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
418 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamCr(...)");
424 ::SetFamilyInfo(const TFamilyInfo& theInfo,
428 SetFamilyInfo(theInfo,eECRI,&aRet);
431 SetFamilyInfo(theInfo,eREMP,&aRet);
440 ::GetNbNodes(const TMeshInfo& theMeshInfo,
443 MSG(MYDEBUG,"TVWrapper::GetNbNodes");
444 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
446 if(theErr && *theErr < 0)
449 TMeshInfo& aMeshInfo = const_cast<TMeshInfo&>(theMeshInfo);
450 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
452 TInt aRet = MEDnEntMaa(myFile->Id(),
456 med_geometrie_element(0),
457 med_connectivite(0));
464 ::GetNodeInfo(TNodeInfo& theInfo,
467 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
469 if(theErr && *theErr < 0)
472 TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
474 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
475 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
476 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
477 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
478 TValueHolder<ERepere, med_repere> aSystem(theInfo.mySystem);
479 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
480 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
481 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
482 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
483 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
484 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
485 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
486 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
488 TErr aRet = MEDnoeudsLire(myFile->Id(),
506 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
512 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
516 TFileWrapper aFileWrapper(myFile,theMode,theErr);
518 if(theErr && *theErr < 0)
521 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
522 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
524 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
525 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
526 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
527 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
528 TValueHolder<ERepere, med_repere> aSystem(anInfo.mySystem);
529 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
530 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
531 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
532 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
533 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
534 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
535 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
536 TValueHolder<TInt, med_int> aNbElem(anInfo.myNbElem);
538 TErr aRet = MEDnoeudsEcr(myFile->Id(),
556 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
562 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
566 SetNodeInfo(theInfo,eECRI,&aRet);
569 SetNodeInfo(theInfo,eREMP,&aRet);
578 ::GetEntityInfo(const TMeshInfo& theMeshInfo,
579 EConnectivite theConnMode,
584 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
586 if(theErr && *theErr < 0)
589 TInt aNbElem = GetNbNodes(theMeshInfo);
591 anInfo[eNOEUD][ePOINT1] = aNbElem;
592 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
593 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
594 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
595 for(; anIter != anIterEnd; anIter++){
596 const EEntiteMaillage& anEntity = anIter->first;
597 const TGeomSet& aGeomSet = anIter->second;
598 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
599 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
600 for(; anIter2 != anIterEnd2; anIter2++){
601 const EGeometrieElement& aGeom = *anIter2;
602 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
604 anInfo[anEntity][aGeom] = aNbElem;
614 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
615 EEntiteMaillage theEntity,
616 EGeometrieElement theGeom,
617 EConnectivite theConnMode,
620 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
622 if(theErr && *theErr < 0)
625 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
626 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
628 return MEDnEntMaa(myFile->Id(),
631 med_entite_maillage(theEntity),
632 med_geometrie_element(theGeom),
633 med_connectivite(theConnMode));
639 ::GetCellInfo(MED::TCellInfo& theInfo,
642 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
644 if(theErr && *theErr < 0)
647 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
648 TInt aNbElem = theInfo.myElemNum->size();
650 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
651 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
652 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
653 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
654 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
655 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
656 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
657 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
658 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
659 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
660 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theInfo.myGeom);
661 TValueHolder<EConnectivite, med_connectivite> aConnMode(theInfo.myConnMode);
664 aRet = MEDelementsLire(myFile->Id(),
682 EXCEPTION(std::runtime_error,"GetCellInfo - MEDelementsLire(...)");
688 ::SetCellInfo(const MED::TCellInfo& theInfo,
692 TFileWrapper aFileWrapper(myFile,theMode,theErr);
694 if(theErr && *theErr < 0)
697 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
698 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
700 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
701 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
702 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
703 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
704 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
705 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
706 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
707 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
708 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
709 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(anInfo.myEntity);
710 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(anInfo.myGeom);
711 TValueHolder<EConnectivite, med_connectivite> aConnMode(anInfo.myConnMode);
714 aRet = MEDelementsEcr(myFile->Id(),
733 EXCEPTION(std::runtime_error,"GetCellInfo - MEDelementsLire(...)");
739 ::SetCellInfo(const MED::TCellInfo& theInfo,
743 SetCellInfo(theInfo,eECRI,&aRet);
746 SetCellInfo(theInfo,eREMP,&aRet);
755 ::GetNbFields(TErr* theErr)
757 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
759 if(theErr && *theErr < 0)
762 return MEDnChamp(myFile->Id(),0);
768 ::GetNbComp(TInt theFieldId,
771 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
773 if(theErr && *theErr < 0)
776 return MEDnChamp(myFile->Id(),theFieldId);
782 ::GetFieldInfo(TInt theFieldId,
783 MED::TFieldInfo& theInfo,
786 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
788 if(theErr && *theErr < 0)
791 TString aFieldName(256); // Protect from memory problems with too long names
792 TValueHolder<ETypeChamp, med_type_champ> aType(theInfo.myType);
793 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
794 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
797 aRet = MEDchampInfo(myFile->Id(),
805 theInfo.SetName(aFieldName);
810 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDchampInfo(...)");
816 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
820 TFileWrapper aFileWrapper(myFile,theMode,theErr);
822 if(theErr && *theErr < 0)
825 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
827 TValueHolder<TString, char> aFieldName(anInfo.myName);
828 TValueHolder<ETypeChamp, med_type_champ> aType(anInfo.myType);
829 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
830 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
833 aRet = MEDchampCr(myFile->Id(),
843 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDchampCr(...)");
849 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
855 SetFieldInfo(theInfo,eECRI,&aRet);
858 SetFieldInfo(theInfo,eREMP,&aRet);
863 }catch(const std::exception& theExc){
864 EXCEPTION(std::runtime_error,"SetFieldInfo(...)"<<std::endl<<
871 //-----------------------------------------------------------------
874 ::GetNbProfiles(TErr* theErr)
876 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
878 if(theErr && *theErr < 0)
881 return MEDnProfil(myFile->Id());
887 ::GetProfilePreInfo(TInt theId,
890 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
892 if(theErr && *theErr < 0)
893 return TProfileInfo::TInfo("",-1);
896 TVector<char> aName(GetNOMLength<eV2_1>()+1);
899 aRet = MEDprofilInfo(myFile->Id(),
906 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofilInfo(...)");
908 return TProfileInfo::TInfo(&aName[0],aSize);
914 ::GetProfileInfo(TInt theId,
915 TProfileInfo& theInfo,
918 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
920 if(theErr && *theErr < 0)
923 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
924 TValueHolder<TString, char> aProfileName(theInfo.myName);
927 aRet = MEDprofilLire(myFile->Id(),
933 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofilLire(...)");
938 ::SetProfileInfo(const TProfileInfo& theInfo,
942 TFileWrapper aFileWrapper(myFile,theMode,theErr);
944 if(theErr && *theErr < 0)
947 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
948 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
949 TValueHolder<TString, char> aProfileName(anInfo.myName);
952 aRet = MEDprofilEcr(myFile->Id(), // descripteur du fichier.
953 &anElemNum, // tableau de valeurs du profil.
954 theInfo.GetSize(), // taille du profil.
955 &aProfileName); // nom profil.
959 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofilEcr(...)");
964 ::SetProfileInfo(const TProfileInfo& theInfo,
968 SetProfileInfo(theInfo,eECRI,&aRet);
971 SetProfileInfo(theInfo,eREMP,&aRet);
977 //-----------------------------------------------------------------
980 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
981 const MED::TEntityInfo& theEntityInfo,
982 EEntiteMaillage& theEntity,
983 TGeom2Size& theGeom2Size,
986 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
989 if(theEntityInfo.empty())
993 }else if(theEntityInfo.empty())
994 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
996 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
998 static bool anIsCheckOnlyFirstTimeStamp = false;
1000 static bool anIsCheckOnlyFirstTimeStamp = true;
1003 theGeom2Size.clear();
1004 TInt aNbTimeStamps = 0;
1005 TIdt anId = myFile->Id();
1007 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1008 TValueHolder<TString, char> aFieldName(anInfo.myName);
1009 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1011 TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1012 for(; anIter != theEntityInfo.end(); anIter++){
1013 med_entite_maillage anEntity = med_entite_maillage(anIter->first);
1014 const TGeom2Size& aGeom2Size = anIter->second;
1015 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
1016 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
1017 med_geometrie_element aGeom = med_geometrie_element(anGeomIter->first);
1018 TInt aNbStamps = MEDnPasdetemps(anId,
1022 bool anIsSatisfied = aNbStamps > 0;
1025 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
1026 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
1027 if(anIsPerformAdditionalCheck){
1028 TInt iTimeStampEnd = anIsCheckOnlyFirstTimeStamp? 1: aNbStamps;
1029 for(TInt iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++){
1030 TVector<char> aMeshName(GetNOMLength<eV2_1>()+1);
1031 TVector<char> aDtUnit(GetPNOMLength<eV2_1>()+1);
1036 TErr aRet = MEDpasdetempsInfo(anId,
1048 anIsSatisfied = (aRet == 0 && (!strcmp(&aMeshName[0],&aMeshInfo.myName[0])));
1051 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
1052 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
1059 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
1060 theEntity = EEntiteMaillage(anEntity);
1061 aNbTimeStamps = aNbStamps;
1064 if(!theGeom2Size.empty())
1067 return aNbTimeStamps;
1073 ::GetTimeStampInfo(TInt theTimeStampId,
1074 MED::TTimeStampInfo& theInfo,
1077 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
1079 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
1082 if(aGeom2Size.empty())
1086 }else if(aGeom2Size.empty())
1087 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
1089 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1090 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1092 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
1093 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
1094 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
1095 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
1096 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
1097 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
1098 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1100 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
1102 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
1103 for(; anIter != aGeom2Size.end(); anIter++){
1104 const EGeometrieElement& aGeom = anIter->first;
1105 med_int aNbGauss = -1;
1108 aRet = MEDpasdetempsInfo(myFile->Id(),
1111 med_geometrie_element(aGeom),
1121 static TInt MAX_NB_GAUSS_POINTS = 32;
1122 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
1125 aGeom2NbGauss[aGeom] = aNbGauss;
1130 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1137 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
1138 const TMKey2Profile& theMKey2Profile,
1139 const TKey2Gauss& theKey2Gauss,
1142 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
1144 if(theErr && *theErr < 0)
1147 TIdt anId = myFile->Id();
1149 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
1150 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
1152 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
1153 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
1154 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
1155 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
1157 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
1158 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
1160 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
1161 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
1163 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
1164 TVector<char> aProfileName(GetNOMLength<eV2_1>()+1);
1166 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
1167 TGeom2Size::iterator anIter = aGeom2Size.begin();
1168 for(; anIter != aGeom2Size.end(); anIter++){
1169 EGeometrieElement aGeom = anIter->first;
1170 TInt aNbElem = anIter->second;
1172 TInt aNbVal = MEDnVal(anId,
1175 med_geometrie_element(aGeom),
1183 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1186 TInt aNbGauss = aTimeStampInfo->GetNbGauss(aGeom);
1187 TInt aNbComp = aFieldInfo->myNbComp;
1188 TInt aNbValue = aNbVal / aNbGauss;
1189 theTimeStampValue->AllocateValue(aGeom,
1193 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
1196 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
1197 "; aNbVal = "<<aNbVal<<
1198 "; aNbValue = "<<aNbValue<<
1199 "; aNbGauss = "<<aNbGauss<<
1200 "; aNbComp = "<<aNbComp<<
1203 TErr aRet = MEDchampLire(anId,
1206 theTimeStampValue->GetValuePtr(aGeom),
1211 med_geometrie_element(aGeom),
1219 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDchampLire(...)");
1222 MED::PProfileInfo aProfileInfo;
1223 if(strcmp(&aProfileName[0],"") != 0){
1224 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
1225 if(anIter != aKey2Profile.end()){
1226 aProfileInfo = anIter->second;
1227 aGeom2Profile[aGeom] = aProfileInfo;
1231 if(aProfileInfo && aProfileInfo->IsPresent()){
1232 TInt aNbSubElem = aProfileInfo->GetSize();
1233 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
1234 if(aProfileSize > aValueSize){
1239 EXCEPTION(std::runtime_error,
1240 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
1241 ") != aValueSize("<<aValueSize<<
1242 "); aNbVal = "<<aNbVal<<
1243 "; anEntity = "<<anEntity<<
1244 "; aGeom = "<<aGeom<<
1245 "; aNbElem = "<<aNbElem<<
1246 "; aNbSubElem = "<<aNbSubElem<<
1247 "; aNbComp = "<<aNbComp<<
1248 "; aNbGauss = "<<aNbGauss<<
1251 if(aNbElem != aNbValue){
1256 EXCEPTION(std::runtime_error,
1257 "GetTimeStampValue - aNbElem("<<aNbElem<<
1258 ") != aNbValue("<<aNbValue<<
1259 "); aNbVal = "<<aNbVal<<
1260 "; anEntity = "<<anEntity<<
1261 "; aGeom = "<<aGeom<<
1262 "; aNbElem = "<<aNbElem<<
1263 "; aNbComp = "<<aNbComp<<
1264 "; aNbGauss = "<<aNbGauss<<
1275 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
1279 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1281 if(theErr && *theErr < 0)
1285 TIdt anId = myFile->Id();
1287 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
1288 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
1290 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
1291 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
1292 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
1293 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
1294 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
1295 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
1297 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
1298 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
1300 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
1301 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
1303 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
1304 TGeomSet::const_iterator anIter = aGeomSet.begin();
1305 for(; anIter != aGeomSet.end(); anIter++){
1306 EGeometrieElement aGeom = *anIter;
1308 TVector<char> aProfileName(GetNOMLength<eV2_1>()+1);
1309 MED::TGeom2Profile::iterator aProfileIter = aGeom2Profile.find(aGeom);
1310 if(aProfileIter != aGeom2Profile.end()){
1311 MED::TProfileInfo& aProfileInfo = aProfileIter->second;
1312 aProfileName = aProfileInfo.myName;
1315 med_int aNbGauss = aTimeStampInfo->GetNbGauss(aGeom);
1316 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
1318 aRet = MEDchampEcr(anId,
1321 theTimeStampValue->GetValuePtr(aGeom),
1329 med_geometrie_element(aGeom),
1339 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDchampEcr(...)");
1344 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
1350 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
1354 SetTimeStampValue(theTimeStampValue,eECRI,&aRet);
1357 SetTimeStampValue(theTimeStampValue,eREMP,&aRet);