1 // Copyright (C) 2007-2012 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.
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
28 #include "MED_V2_1_Wrapper.hxx"
29 #include "MED_Algorithm.hxx"
30 #include "MED_Utilities.hxx"
33 using namespace med_2_1;
36 static int MYDEBUG = 0;
38 // static int MYDEBUG = 0;
48 GetDESCLength<eV2_1>()
55 GetIDENTLength<eV2_1>()
62 GetLNOMLength<eV2_1>()
76 GetPNOMLength<eV2_1>()
83 GetVersionRelease<eV2_1>(TInt& majeur, TInt& mineur, TInt& release)
85 MEDversionDonner(&majeur, &mineur, &release);
90 GetNbConn<eV2_1>(EGeometrieElement typmai,
91 EEntiteMaillage typent,
96 if(typent == eMAILLE){
97 TInt edim = typmai / 100;
98 if(mdim == 2 || mdim == 3)
107 return nsup + typmai%100;
113 //---------------------------------------------------------------
119 TFile(const std::string& theFileName):
122 myFileName(theFileName)
131 Open(EModeAcces theMode, TErr* theErr = NULL)
134 char* aFileName = const_cast<char*>(myFileName.c_str());
135 myFid = MEDouvrir(aFileName,med_mode_acces(theMode));
138 *theErr = TErr(myFid);
139 INITMSG(MYDEBUG && myFid < 0,"TFile::Open - MED_MODE_ACCES = "<<theMode<<"; myFid = "<<myFid<<std::endl);
141 EXCEPTION(std::runtime_error, "TFile - MEDouvrir('"<<myFileName<<"',"<<theMode<<")");
144 const TIdt& Id() const
147 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
158 std::string myFileName;
164 //---------------------------------------------------------------
170 TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
173 myFile->Open(theMode,theErr);
182 //---------------------------------------------------------------
184 ::TVWrapper(const std::string& theFileName):
185 myFile(new TFile(theFileName))
191 ::GetNbMeshes(TErr* theErr)
193 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
195 if(theErr && *theErr < 0)
198 return MEDnMaa(myFile->Id());
204 ::GetMeshInfo(TInt theMeshId,
208 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
210 if(theErr && *theErr < 0)
213 TValueHolder<TString, char> aMeshName(theInfo.myName);
214 TValueHolder<TInt, med_int> aDim(theInfo.mySpaceDim);
216 TErr aRet = MEDmaaInfo(myFile->Id(),
221 if ( theInfo.mySpaceDim < 1 )
222 theInfo.mySpaceDim = MEDdimLire( myFile->Id(), &aMeshName );
224 theInfo.myDim = theInfo.mySpaceDim;
229 EXCEPTION(std::runtime_error,"GetMeshInfo - MEDmaaInfo(...)");
235 ::SetMeshInfo(const TMeshInfo& theInfo,
239 TFileWrapper aFileWrapper(myFile,theMode,theErr);
241 if(theErr && *theErr < 0)
244 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
245 TValueHolder<TString, char> aMeshName(anInfo.myName);
246 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
248 TErr aRet = MEDmaaCr(myFile->Id(),
255 EXCEPTION(std::runtime_error,"SetMeshInfo - MEDmaaCr(...)");
261 ::SetMeshInfo(const TMeshInfo& theInfo,
265 SetMeshInfo(theInfo,eECRI,&aRet);
268 SetMeshInfo(theInfo,eREMP,&aRet);
277 ::GetNbFamilies(const TMeshInfo& theInfo,
280 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
282 if(theErr && *theErr < 0)
285 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
286 TValueHolder<TString, char> aMeshName(anInfo.myName);
288 return MEDnFam(myFile->Id(),
297 ::GetNbFamAttr(TInt theFamId,
298 const TMeshInfo& theInfo,
301 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
303 if(theErr && *theErr < 0)
306 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
307 TValueHolder<TString, char> aMeshName(anInfo.myName);
309 return MEDnFam(myFile->Id(),
318 ::GetNbFamGroup(TInt theFamId,
319 const TMeshInfo& theInfo,
322 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
324 if(theErr && *theErr < 0)
327 TMeshInfo& anInfo = const_cast<TMeshInfo&>(theInfo);
328 TValueHolder<TString, char> aMeshName(anInfo.myName);
330 return MEDnFam(myFile->Id(),
339 ::GetFamilyInfo(TInt theFamId,
340 TFamilyInfo& theInfo,
343 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
345 if(theErr && *theErr < 0)
348 TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
350 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
351 TValueHolder<TString, char> aFamilyName(theInfo.myName);
352 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
353 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
354 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
355 TValueHolder<TInt, med_int> aNbAttr(theInfo.myNbAttr);
356 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
357 TValueHolder<TInt, med_int> aNbGroup(theInfo.myNbGroup);
358 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
360 TErr aRet = MEDfamInfo(myFile->Id(),
375 EXCEPTION(std::runtime_error,"GetFamilyInfo - MEDfamInfo - "<<
376 "&aMeshInfo.myName[0] = '"<<&aMeshName<<"'; "<<
377 "theFamId = "<<theFamId<<"; "<<
378 "&theInfo.myName[0] = '"<<&aFamilyName<<"'; "<<
379 "theInfo.myId = "<<theInfo.myId);
385 ::SetFamilyInfo(const TFamilyInfo& theInfo,
389 TFileWrapper aFileWrapper(myFile,theMode,theErr);
391 if(theErr && *theErr < 0)
394 TFamilyInfo& anInfo = const_cast<TFamilyInfo&>(theInfo);
395 TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
397 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
398 TValueHolder<TString, char> aFamilyName(anInfo.myName);
399 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
400 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
401 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
402 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
403 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
404 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
405 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
407 TErr aRet = MEDfamCr(myFile->Id(),
418 INITMSG(MYDEBUG && aRet,"TVWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
423 EXCEPTION(std::runtime_error,"SetFamilyInfo - MEDfamCr(...)");
429 ::SetFamilyInfo(const TFamilyInfo& theInfo,
433 SetFamilyInfo(theInfo,eECRI,&aRet);
436 SetFamilyInfo(theInfo,eREMP,&aRet);
445 ::GetNbNodes(const TMeshInfo& theMeshInfo,
448 MSG(MYDEBUG,"TVWrapper::GetNbNodes");
449 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
451 if(theErr && *theErr < 0)
454 TMeshInfo& aMeshInfo = const_cast<TMeshInfo&>(theMeshInfo);
455 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
457 TInt aRet = MEDnEntMaa(myFile->Id(),
461 med_geometrie_element(0),
462 med_connectivite(0));
469 ::GetNodeInfo(TNodeInfo& theInfo,
472 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
474 if(theErr && *theErr < 0)
477 TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
479 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
480 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
481 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
482 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
483 TValueHolder<ERepere, med_repere> aSystem(theInfo.mySystem);
484 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
485 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
486 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
487 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
488 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
489 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
490 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
491 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
493 TErr aRet = MEDnoeudsLire(myFile->Id(),
511 EXCEPTION(std::runtime_error,"GetNodeInfo - MEDnoeudsLire(...)");
517 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
521 TFileWrapper aFileWrapper(myFile,theMode,theErr);
523 if(theErr && *theErr < 0)
526 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
527 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
529 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
530 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
531 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
532 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
533 TValueHolder<ERepere, med_repere> aSystem(anInfo.mySystem);
534 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
535 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
536 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
537 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
538 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
539 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
540 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
541 TValueHolder<TInt, med_int> aNbElem(anInfo.myNbElem);
543 TErr aRet = MEDnoeudsEcr(myFile->Id(),
561 EXCEPTION(std::runtime_error,"SetNodeInfo - MEDnoeudsEcr(...)");
567 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
571 SetNodeInfo(theInfo,eECRI,&aRet);
574 SetNodeInfo(theInfo,eREMP,&aRet);
583 ::GetEntityInfo(const TMeshInfo& theMeshInfo,
584 EConnectivite theConnMode,
589 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
591 if(theErr && *theErr < 0)
594 TInt aNbElem = GetNbNodes(theMeshInfo);
596 anInfo[eNOEUD][ePOINT1] = aNbElem;
597 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
598 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
599 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
600 for(; anIter != anIterEnd; anIter++){
601 const EEntiteMaillage& anEntity = anIter->first;
602 const TGeomSet& aGeomSet = anIter->second;
603 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
604 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
605 for(; anIter2 != anIterEnd2; anIter2++){
606 const EGeometrieElement& aGeom = *anIter2;
607 aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theConnMode,theErr);
609 anInfo[anEntity][aGeom] = aNbElem;
619 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
620 EEntiteMaillage theEntity,
621 EGeometrieElement theGeom,
622 EConnectivite theConnMode,
625 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
627 if(theErr && *theErr < 0)
630 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
631 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
633 return MEDnEntMaa(myFile->Id(),
636 med_entite_maillage(theEntity),
637 med_geometrie_element(theGeom),
638 med_connectivite(theConnMode));
644 ::GetCellInfo(MED::TCellInfo& theInfo,
647 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
649 if(theErr && *theErr < 0)
652 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
653 TInt aNbElem = theInfo.myElemNum->size();
655 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
656 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
657 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
658 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theInfo.myModeSwitch);
659 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
660 TValueHolder<EBooleen, med_booleen> anIsElemNames(theInfo.myIsElemNames);
661 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
662 TValueHolder<EBooleen, med_booleen> anIsElemNum(theInfo.myIsElemNum);
663 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
664 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
665 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(theInfo.myGeom);
666 TValueHolder<EConnectivite, med_connectivite> aConnMode(theInfo.myConnMode);
669 aRet = MEDelementsLire(myFile->Id(),
687 EXCEPTION(std::runtime_error,"GetCellInfo - MEDelementsLire(...)");
693 ::SetCellInfo(const MED::TCellInfo& theInfo,
697 TFileWrapper aFileWrapper(myFile,theMode,theErr);
699 if(theErr && *theErr < 0)
702 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
703 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
705 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
706 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
707 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
708 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(anInfo.myModeSwitch);
709 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
710 TValueHolder<EBooleen, med_booleen> anIsElemNames(anInfo.myIsElemNames);
711 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
712 TValueHolder<EBooleen, med_booleen> anIsElemNum(anInfo.myIsElemNum);
713 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
714 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(anInfo.myEntity);
715 TValueHolder<EGeometrieElement, med_geometrie_element> aGeom(anInfo.myGeom);
716 TValueHolder<EConnectivite, med_connectivite> aConnMode(anInfo.myConnMode);
719 aRet = MEDelementsEcr(myFile->Id(),
738 EXCEPTION(std::runtime_error,"GetCellInfo - MEDelementsLire(...)");
744 ::SetCellInfo(const MED::TCellInfo& theInfo,
748 SetCellInfo(theInfo,eECRI,&aRet);
751 SetCellInfo(theInfo,eREMP,&aRet);
760 ::GetNbFields(TErr* theErr)
762 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
764 if(theErr && *theErr < 0)
767 return MEDnChamp(myFile->Id(),0);
773 ::GetNbComp(TInt theFieldId,
776 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
778 if(theErr && *theErr < 0)
781 return MEDnChamp(myFile->Id(),theFieldId);
787 ::GetFieldInfo(TInt theFieldId,
788 MED::TFieldInfo& theInfo,
791 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
793 if(theErr && *theErr < 0)
796 TString aFieldName(256); // Protect from memory problems with too long names
797 TValueHolder<ETypeChamp, med_type_champ> aType(theInfo.myType);
798 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
799 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
802 aRet = MEDchampInfo(myFile->Id(),
810 theInfo.SetName(aFieldName);
815 EXCEPTION(std::runtime_error,"GetFieldInfo - MEDchampInfo(...)");
821 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
825 TFileWrapper aFileWrapper(myFile,theMode,theErr);
827 if(theErr && *theErr < 0)
830 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
832 TValueHolder<TString, char> aFieldName(anInfo.myName);
833 TValueHolder<ETypeChamp, med_type_champ> aType(anInfo.myType);
834 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
835 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
838 aRet = MEDchampCr(myFile->Id(),
848 EXCEPTION(std::runtime_error,"SetFieldInfo - MEDchampCr(...)");
854 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
860 SetFieldInfo(theInfo,eECRI,&aRet);
863 SetFieldInfo(theInfo,eREMP,&aRet);
868 }catch(const std::exception& theExc){
869 EXCEPTION(std::runtime_error,"SetFieldInfo(...)"<<std::endl<<
876 //-----------------------------------------------------------------
879 ::GetNbProfiles(TErr* theErr)
881 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
883 if(theErr && *theErr < 0)
886 return MEDnProfil(myFile->Id());
892 ::GetProfilePreInfo(TInt theId,
895 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
897 if(theErr && *theErr < 0)
898 return TProfileInfo::TInfo("",-1);
901 TVector<char> aName(GetNOMLength<eV2_1>()+1);
904 aRet = MEDprofilInfo(myFile->Id(),
911 EXCEPTION(std::runtime_error,"GetProfilePreInfo - MEDprofilInfo(...)");
913 return TProfileInfo::TInfo(&aName[0],aSize);
919 ::GetProfileInfo(TInt theId,
920 TProfileInfo& theInfo,
923 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
925 if(theErr && *theErr < 0)
928 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
929 TValueHolder<TString, char> aProfileName(theInfo.myName);
932 aRet = MEDprofilLire(myFile->Id(),
938 EXCEPTION(std::runtime_error,"GetProfileInfo - MEDprofilLire(...)");
943 ::SetProfileInfo(const TProfileInfo& theInfo,
947 TFileWrapper aFileWrapper(myFile,theMode,theErr);
949 if(theErr && *theErr < 0)
952 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
953 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
954 TValueHolder<TString, char> aProfileName(anInfo.myName);
957 aRet = MEDprofilEcr(myFile->Id(), // descripteur du fichier.
958 &anElemNum, // tableau de valeurs du profil.
959 theInfo.GetSize(), // taille du profil.
960 &aProfileName); // nom profil.
964 EXCEPTION(std::runtime_error,"SetProfileInfo - MEDprofilEcr(...)");
969 ::SetProfileInfo(const TProfileInfo& theInfo,
973 SetProfileInfo(theInfo,eECRI,&aRet);
976 SetProfileInfo(theInfo,eREMP,&aRet);
982 //-----------------------------------------------------------------
985 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
986 const MED::TEntityInfo& theEntityInfo,
987 EEntiteMaillage& theEntity,
988 TGeom2Size& theGeom2Size,
991 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
994 if(theEntityInfo.empty())
998 }else if(theEntityInfo.empty())
999 EXCEPTION(std::runtime_error,"GetNbTimeStamps - There is no any Entity on the Mesh");
1001 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
1003 static bool anIsCheckOnlyFirstTimeStamp = false;
1005 static bool anIsCheckOnlyFirstTimeStamp = true;
1008 theGeom2Size.clear();
1009 TInt aNbTimeStamps = 0;
1010 TIdt anId = myFile->Id();
1012 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
1013 TValueHolder<TString, char> aFieldName(anInfo.myName);
1014 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
1016 TEntityInfo::const_iterator anIter = theEntityInfo.begin();
1017 for(; anIter != theEntityInfo.end(); anIter++){
1018 med_entite_maillage anEntity = med_entite_maillage(anIter->first);
1019 const TGeom2Size& aGeom2Size = anIter->second;
1020 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
1021 for(; anGeomIter != aGeom2Size.end(); anGeomIter++){
1022 med_geometrie_element aGeom = med_geometrie_element(anGeomIter->first);
1023 TInt aNbStamps = MEDnPasdetemps(anId,
1027 bool anIsSatisfied = aNbStamps > 0;
1030 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
1031 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
1032 if(anIsPerformAdditionalCheck){
1033 TInt iTimeStampEnd = anIsCheckOnlyFirstTimeStamp? 1: aNbStamps;
1034 for(TInt iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++){
1035 TVector<char> aMeshName(GetNOMLength<eV2_1>()+1);
1036 TVector<char> aDtUnit(GetPNOMLength<eV2_1>()+1);
1041 TErr aRet = MEDpasdetempsInfo(anId,
1053 anIsSatisfied = (aRet == 0 && (!strcmp(&aMeshName[0],&aMeshInfo.myName[0])));
1056 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
1057 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
1064 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
1065 theEntity = EEntiteMaillage(anEntity);
1066 aNbTimeStamps = aNbStamps;
1069 if(!theGeom2Size.empty())
1072 return aNbTimeStamps;
1078 ::GetTimeStampInfo(TInt theTimeStampId,
1079 MED::TTimeStampInfo& theInfo,
1082 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
1084 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
1087 if(aGeom2Size.empty())
1091 }else if(aGeom2Size.empty())
1092 EXCEPTION(std::runtime_error,"GetTimeStampInfo - There is no any cell");
1094 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
1095 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
1097 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
1098 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(theInfo.myEntity);
1099 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
1100 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
1101 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
1102 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
1103 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1105 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
1107 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
1108 for(; anIter != aGeom2Size.end(); anIter++){
1109 const EGeometrieElement& aGeom = anIter->first;
1110 med_int aNbGauss = -1;
1113 aRet = MEDpasdetempsInfo(myFile->Id(),
1116 med_geometrie_element(aGeom),
1126 static TInt MAX_NB_GAUSS_POINTS = 32;
1127 if(aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
1130 aGeom2NbGauss[aGeom] = aNbGauss;
1135 EXCEPTION(std::runtime_error,"GetTimeStampInfo - MEDpasdetempsInfo(...)");
1142 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
1143 const TMKey2Profile& theMKey2Profile,
1144 const TKey2Gauss& theKey2Gauss,
1147 TFileWrapper aFileWrapper(myFile,eLECT,theErr);
1149 if(theErr && *theErr < 0)
1152 TIdt anId = myFile->Id();
1154 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
1155 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
1157 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
1158 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
1159 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
1160 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
1162 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
1163 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
1165 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
1166 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
1168 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
1169 TVector<char> aProfileName(GetNOMLength<eV2_1>()+1);
1171 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
1172 TGeom2Size::iterator anIter = aGeom2Size.begin();
1173 for(; anIter != aGeom2Size.end(); anIter++){
1174 EGeometrieElement aGeom = anIter->first;
1175 TInt aNbElem = anIter->second;
1177 TInt aNbVal = MEDnVal(anId,
1180 med_geometrie_element(aGeom),
1188 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDnVal(...) - aNbVal == "<<aNbVal<<" <= 0");
1191 TInt aNbGauss = aTimeStampInfo->GetNbGauss(aGeom);
1192 TInt aNbComp = aFieldInfo->myNbComp;
1193 TInt aNbValue = aNbVal / aNbGauss;
1194 theTimeStampValue->AllocateValue(aGeom,
1198 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
1201 "TVWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
1202 "; aNbVal = "<<aNbVal<<
1203 "; aNbValue = "<<aNbValue<<
1204 "; aNbGauss = "<<aNbGauss<<
1205 "; aNbComp = "<<aNbComp<<
1208 TErr aRet = MEDchampLire(anId,
1211 theTimeStampValue->GetValuePtr(aGeom),
1216 med_geometrie_element(aGeom),
1224 EXCEPTION(std::runtime_error,"GetTimeStampValue - MEDchampLire(...)");
1227 MED::PProfileInfo aProfileInfo;
1228 if(strcmp(&aProfileName[0],"") != 0){
1229 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
1230 if(anIter != aKey2Profile.end()){
1231 aProfileInfo = anIter->second;
1232 aGeom2Profile[aGeom] = aProfileInfo;
1236 if(aProfileInfo && aProfileInfo->IsPresent()){
1237 TInt aNbSubElem = aProfileInfo->GetSize();
1238 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
1239 if(aProfileSize > aValueSize){
1244 EXCEPTION(std::runtime_error,
1245 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
1246 ") != aValueSize("<<aValueSize<<
1247 "); aNbVal = "<<aNbVal<<
1248 "; anEntity = "<<anEntity<<
1249 "; aGeom = "<<aGeom<<
1250 "; aNbElem = "<<aNbElem<<
1251 "; aNbSubElem = "<<aNbSubElem<<
1252 "; aNbComp = "<<aNbComp<<
1253 "; aNbGauss = "<<aNbGauss<<
1256 if(aNbElem != aNbValue){
1261 EXCEPTION(std::runtime_error,
1262 "GetTimeStampValue - aNbElem("<<aNbElem<<
1263 ") != aNbValue("<<aNbValue<<
1264 "); aNbVal = "<<aNbVal<<
1265 "; anEntity = "<<anEntity<<
1266 "; aGeom = "<<aGeom<<
1267 "; aNbElem = "<<aNbElem<<
1268 "; aNbComp = "<<aNbComp<<
1269 "; aNbGauss = "<<aNbGauss<<
1280 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
1284 TFileWrapper aFileWrapper(myFile,theMode,theErr);
1286 if(theErr && *theErr < 0)
1290 TIdt anId = myFile->Id();
1292 TValueHolder<EModeSwitch, med_mode_switch> aModeSwitch(theTimeStampValue->myModeSwitch);
1293 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
1295 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
1296 TValueHolder<EEntiteMaillage, med_entite_maillage> anEntity(aTimeStampInfo->myEntity);
1297 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
1298 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
1299 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
1300 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
1302 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
1303 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
1305 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
1306 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
1308 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
1309 TGeomSet::const_iterator anIter = aGeomSet.begin();
1310 for(; anIter != aGeomSet.end(); anIter++){
1311 EGeometrieElement aGeom = *anIter;
1313 TVector<char> aProfileName(GetNOMLength<eV2_1>()+1);
1314 MED::TGeom2Profile::iterator aProfileIter = aGeom2Profile.find(aGeom);
1315 if(aProfileIter != aGeom2Profile.end()){
1316 MED::TProfileInfo& aProfileInfo = aProfileIter->second;
1317 aProfileName = aProfileInfo.myName;
1320 med_int aNbGauss = aTimeStampInfo->GetNbGauss(aGeom);
1321 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
1323 aRet = MEDchampEcr(anId,
1326 theTimeStampValue->GetValuePtr(aGeom),
1334 med_geometrie_element(aGeom),
1344 EXCEPTION(std::runtime_error,"SetTimeStampValue - MEDchampEcr(...)");
1349 INITMSG(MYDEBUG,"TVWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
1355 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
1359 SetTimeStampValue(theTimeStampValue,eECRI,&aRet);
1362 SetTimeStampValue(theTimeStampValue,eREMP,&aRet);