1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MED_Wrapper.hxx"
24 #include "MED_TStructures.hxx"
25 #include "MED_Utilities.hxx"
29 #include <med_proto.h>
31 #include <boost/version.hpp>
34 static int MYDEBUG = 0;
35 static int MYVALUEDEBUG = 0;
37 static int MYDEBUG = 0;
38 static int MYVALUEDEBUG = 0;
43 //---------------------------------------------------------------
45 ::TLockProxy(TWrapper* theWrapper):
48 #if BOOST_VERSION >= 103500
49 myWrapper->myMutex.lock();
51 boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
53 INITMSG(MYDEBUG, "TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
59 INITMSG(MYDEBUG, "~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
60 #if BOOST_VERSION >= 103500
61 myWrapper->myMutex.unlock();
63 boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
69 ::operator->() const // never throws
74 //---------------------------------------------------------------
81 TFile(const std::string& theFileName, TInt theMajor=-1, TInt theMinor=-1):
84 myFileName(theFileName),
88 if ((myMajor < 0) || (myMajor > MED_MAJOR_NUM)) myMajor = MED_MAJOR_NUM;
89 if ((myMinor < 0) || (myMajor == MED_MAJOR_NUM && myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
98 Open(EModeAcces theMode,
101 if (myCount++ == 0) {
102 const char* aFileName = myFileName.c_str();
103 myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM);
106 *theErr = TErr(myFid);
108 EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<<myFileName<<"',"<<theMode<<"',"<< MED_MAJOR_NUM<<"',"<< myMinor<<"',"<< MED_RELEASE_NUM<<")");
115 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
129 std::string myFileName;
134 //---------------------------------------------------------------
141 TFileWrapper(const PFile& theFile,
148 if (myMinor < 0) myMinor = MED_MINOR_NUM;
149 myFile->Open(theMode, theErr);
158 //----------------------------------------------------------------------------
159 template<class TimeStampValueType>
161 Print(SharedPtr<TimeStampValueType> theTimeStampValue)
163 INITMSG(MYDEBUG,"Print - TimeStampValue\n");
164 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
165 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
166 for (; anIter != aGeom2Value.end(); anIter++) {
167 const EGeometrieElement& aGeom = anIter->first;
168 const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
169 TInt aNbElem = aMeshValue.myNbElem;
170 TInt aNbGauss = aMeshValue.myNbGauss;
171 TInt aNbComp = aMeshValue.myNbComp;
172 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
173 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
174 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
175 aMeshValue.GetGaussValueSliceArr(iElem);
176 ADDMSG(MYVALUEDEBUG, "{");
177 for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
178 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
179 aValueSliceArr[iGauss];
180 for (TInt iComp = 0; iComp < aNbComp; iComp++) {
181 ADDMSG(MYVALUEDEBUG, aValueSlice[iComp]<<" ");
183 ADDMSG(MYVALUEDEBUG, "| ");
185 ADDMSG(MYVALUEDEBUG, "} ");
187 ADDMSG(MYDEBUG, "\n");
191 //---------------------------------------------------------------
193 ::TWrapper(const std::string& theFileName, bool write, TInt theMajor, TInt theMinor):
194 myFile(new TFile(theFileName, theMajor, theMinor)),
200 myFile->Open(eLECTURE_ECRITURE, &aRet);
203 myFile->Open(eCREATION, &aRet);
207 myFile->Open(eLECTURE, &aRet);
211 //----------------------------------------------------------------------------
217 //----------------------------------------------------------------------------
220 ::GetNbMeshes(TErr* theErr)
222 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
224 if (theErr && *theErr < 0)
227 return MEDnMesh(myFile->Id());
230 //----------------------------------------------------------------------------
233 ::GetMeshInfo(TInt theMeshId,
234 MED::TMeshInfo& theInfo,
237 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
239 if (theErr && *theErr < 0)
242 TValueHolder<TString, char> aMeshName(theInfo.myName);
243 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
244 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
245 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
246 char dtunit[MED_SNAME_SIZE+1];
247 med_sorting_type sorttype;
250 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
251 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
252 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
253 TErr aRet = MEDmeshInfo(myFile->Id(),
269 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
272 //----------------------------------------------------------------------------
275 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
279 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
282 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
285 SetMeshInfo(theInfo, eCREATION, &aRet);
291 //----------------------------------------------------------------------------
294 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
298 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
300 if (theErr && *theErr < 0)
303 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
305 TValueHolder<TString, char> aMeshName(anInfo.myName);
306 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
307 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
308 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
309 TValueHolder<TString, char> aDesc(anInfo.myDesc);
311 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
312 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
313 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
314 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
315 TErr aRet = MEDmeshCr(myFile->Id(),
330 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
332 INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
337 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
340 //----------------------------------------------------------------------------
343 ::CrMeshInfo(TInt theDim,
345 const std::string& theValue,
347 const std::string& theDesc)
349 return PMeshInfo(new TTMeshInfo
357 //----------------------------------------------------------------------------
360 ::CrMeshInfo(const PMeshInfo& theInfo)
362 return PMeshInfo(new TTMeshInfo(theInfo));
365 //----------------------------------------------------------------------------
368 ::GetPMeshInfo(TInt theId,
371 PMeshInfo anInfo = CrMeshInfo();
372 GetMeshInfo(theId, *anInfo, theErr);
376 //----------------------------------------------------------------------------
379 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
382 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
384 if (theErr && *theErr < 0)
387 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
388 TValueHolder<TString, char> aName(anInfo.myName);
389 return MEDnFamily(myFile->Id(), &aName);
392 //----------------------------------------------------------------------------
395 ::GetNbFamAttr(TInt theFamId,
396 const MED::TMeshInfo& theInfo,
399 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
401 if (theErr && *theErr < 0)
404 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
406 TValueHolder<TString, char> aName(anInfo.myName);
408 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
411 //----------------------------------------------------------------------------
414 ::GetNbFamGroup(TInt theFamId,
415 const MED::TMeshInfo& theInfo,
418 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
420 if (theErr && *theErr < 0)
423 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
425 TValueHolder<TString, char> aName(anInfo.myName);
427 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
430 //----------------------------------------------------------------------------
433 ::GetFamilyInfo(TInt theFamId,
434 MED::TFamilyInfo& theInfo,
437 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
439 if (theErr && *theErr < 0)
442 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
444 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
445 TValueHolder<TString, char> aFamilyName(theInfo.myName);
446 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
447 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
448 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
449 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
450 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
452 TErr aRet = MEDfamily23Info(myFile->Id(),
465 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
466 " aMeshInfo.myName = '"<<&aMeshName<<
467 "'; theFamId = "<<theFamId<<
468 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
469 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
472 //----------------------------------------------------------------------------
475 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
479 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
482 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
488 //----------------------------------------------------------------------------
491 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
495 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
497 if (theErr && *theErr < 0)
500 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
501 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
503 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
504 TValueHolder<TString, char> aFamilyName(anInfo.myName);
505 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
506 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
507 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
508 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
509 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
510 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
511 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
513 TErr aRet = MEDfamilyCr(myFile->Id(),
520 INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
525 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
528 //----------------------------------------------------------------------------
531 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
535 const std::string& theValue)
537 return PFamilyInfo(new TTFamilyInfo
545 //----------------------------------------------------------------------------
548 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
549 const std::string& theValue,
551 const MED::TStringSet& theGroupNames,
552 const MED::TStringVector& theAttrDescs,
553 const MED::TIntVector& theAttrIds,
554 const MED::TIntVector& theAttrVals)
556 return PFamilyInfo(new TTFamilyInfo
566 //----------------------------------------------------------------------------
569 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
570 const PFamilyInfo& theInfo)
572 return PFamilyInfo(new TTFamilyInfo
577 //----------------------------------------------------------------------------
580 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
584 // must be reimplemented in connection with mesh type eSTRUCTURE
585 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
586 // return PFamilyInfo();
588 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
589 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
590 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
591 GetFamilyInfo(theId, *anInfo, theErr);
594 std::string aName = anInfo->GetName();
595 INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
596 "'; andId = "<<anInfo->GetId()<<
597 "; aNbAttr = "<<aNbAttr<<
598 "; aNbGroup = "<<aNbGroup<<"\n");
599 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
600 aName = anInfo->GetGroupName(iGroup);
601 INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
608 //----------------------------------------------------------------------------
611 ::GetNames(TElemInfo& theInfo,
613 EEntiteMaillage theEntity,
614 EGeometrieElement theGeom,
617 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
619 if (theErr && *theErr < 0)
622 if (theGeom == eBALL)
623 theGeom = GetBallGeom(theInfo.myMeshInfo);
625 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
627 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
628 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
629 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
630 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
632 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
640 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
646 //----------------------------------------------------------------------------
649 ::SetNames(const TElemInfo& theInfo,
650 EEntiteMaillage theEntity,
651 EGeometrieElement theGeom,
654 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
657 //----------------------------------------------------------------------------
660 ::SetNames(const TElemInfo& theInfo,
662 EEntiteMaillage theEntity,
663 EGeometrieElement theGeom,
666 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
668 if (theErr && *theErr < 0)
671 if (theGeom == eBALL)
672 theGeom = GetBallGeom(theInfo.myMeshInfo);
674 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
675 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
678 if (theInfo.myIsElemNames) {
679 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
680 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
681 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
682 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
684 aRet = MEDmeshEntityNameWr(myFile->Id(),
690 (TInt)anInfo.myElemNames->size(),
695 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
699 //----------------------------------------------------------------------------
702 ::GetNumeration(TElemInfo& theInfo,
704 EEntiteMaillage theEntity,
705 EGeometrieElement theGeom,
708 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
710 if (theErr && *theErr < 0)
713 if (theGeom == eBALL)
714 theGeom = GetBallGeom(theInfo.myMeshInfo);
716 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
718 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
719 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
720 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
721 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
723 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
731 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
737 //----------------------------------------------------------------------------
740 ::SetNumeration(const TElemInfo& theInfo,
741 EEntiteMaillage theEntity,
742 EGeometrieElement theGeom,
745 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
748 //----------------------------------------------------------------------------
751 ::SetNumeration(const TElemInfo& theInfo,
753 EEntiteMaillage theEntity,
754 EGeometrieElement theGeom,
757 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
759 if (theErr && *theErr < 0)
762 if (theGeom == eBALL)
763 theGeom = GetBallGeom(theInfo.myMeshInfo);
765 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
766 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
769 if (theInfo.myIsElemNum) {
770 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
771 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
772 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
773 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
775 aRet = MEDmeshEntityNumberWr(myFile->Id(),
781 (TInt)anInfo.myElemNum->size(),
786 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
790 //----------------------------------------------------------------------------
793 ::GetFamilies(TElemInfo& theInfo,
795 EEntiteMaillage theEntity,
796 EGeometrieElement theGeom,
799 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
801 if (theErr && *theErr < 0)
804 if (theGeom == eBALL)
805 theGeom = GetBallGeom(theInfo.myMeshInfo);
807 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
809 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
810 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
811 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
812 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
814 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
823 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
825 int aSize = (int)theInfo.myFamNum->size();
826 theInfo.myFamNum->clear();
827 theInfo.myFamNum->resize(aSize,0);
831 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
837 //----------------------------------------------------------------------------
840 ::SetFamilies(const TElemInfo& theInfo,
841 EEntiteMaillage theEntity,
842 EGeometrieElement theGeom,
845 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
848 //----------------------------------------------------------------------------
851 ::SetFamilies(const TElemInfo& theInfo,
853 EEntiteMaillage theEntity,
854 EGeometrieElement theGeom,
857 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
859 if (theErr && *theErr < 0)
862 if (theGeom == eBALL)
863 theGeom = GetBallGeom(theInfo.myMeshInfo);
865 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
866 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
868 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
869 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
870 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
871 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
873 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
879 (TInt)anInfo.myFamNum->size(),
885 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
888 //----------------------------------------------------------------------------
891 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
894 return GetNbNodes(theMeshInfo, eCOOR, theErr);
897 //----------------------------------------------------------------------------
900 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
904 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
906 if (theErr && *theErr < 0)
909 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
911 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
912 TValueHolder<ETable, med_data_type > aTable(theTable);
914 return MEDmeshnEntity(myFile->Id(),
926 //----------------------------------------------------------------------------
929 ::GetNodeInfo(MED::TNodeInfo& theInfo,
932 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
934 if (theErr && *theErr < 0)
937 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
939 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
940 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
941 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
942 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
943 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
944 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
945 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
946 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
947 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
948 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
949 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
950 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
951 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
953 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
960 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
968 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
970 int mySize = (int)theInfo.myFamNum->size();
971 theInfo.myFamNum->clear();
972 theInfo.myFamNum->resize(mySize,0);
975 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
978 if (MEDmeshEntityNameRd(myFile->Id(),
984 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
986 if (MEDmeshEntityNumberRd(myFile->Id(),
992 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
997 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
1000 //----------------------------------------------------------------------------
1003 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1007 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
1010 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1016 //----------------------------------------------------------------------------
1019 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1023 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1025 if (theErr && *theErr < 0)
1028 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1029 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1031 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1032 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1033 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1034 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1035 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1036 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1037 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1038 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1039 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1040 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1041 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1042 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1044 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1053 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1062 MEDmeshEntityNameWr(myFile->Id(),
1071 MEDmeshEntityNumberWr(myFile->Id(),
1082 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1085 //----------------------------------------------------------------------------
1088 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1090 EModeSwitch theMode,
1092 EBooleen theIsElemNum,
1093 EBooleen theIsElemNames)
1095 return PNodeInfo(new TTNodeInfo
1104 //----------------------------------------------------------------------------
1107 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1108 const TFloatVector& theNodeCoords,
1109 EModeSwitch theMode,
1111 const TStringVector& theCoordNames,
1112 const TStringVector& theCoordUnits,
1113 const TIntVector& theFamilyNums,
1114 const TIntVector& theElemNums,
1115 const TStringVector& theElemNames)
1117 return PNodeInfo(new TTNodeInfo
1129 //----------------------------------------------------------------------------
1132 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1133 const PNodeInfo& theInfo)
1135 return PNodeInfo(new TTNodeInfo
1140 //----------------------------------------------------------------------------
1143 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1146 TInt aNbElems = GetNbNodes(*theMeshInfo);
1147 if (aNbElems == 0) {
1151 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1152 GetNodeInfo(*anInfo, theErr);
1155 TInt aDim = theMeshInfo->myDim;
1156 TInt aNbElem = anInfo->GetNbElem();
1157 INITMSG(MYDEBUG, "GetPNodeInfo: ");
1159 INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
1160 TNodeCoord& aCoord = anInfo->myCoord;
1161 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1162 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1163 ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
1165 ADDMSG(MYVALUEDEBUG, " ");
1167 ADDMSG(MYDEBUG, std::endl);
1169 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
1170 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1171 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
1173 ADDMSG(MYVALUEDEBUG, std::endl);
1175 if (anInfo->IsElemNum()) {
1176 BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
1177 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1178 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
1180 ADDMSG(MYVALUEDEBUG, std::endl);
1183 ADDMSG(MYDEBUG, std::endl);
1189 //----------------------------------------------------------------------------
1192 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1194 EBooleen theIsElemNum,
1195 EBooleen theIsElemNames)
1197 return PElemInfo(new TTElemInfo
1204 //----------------------------------------------------------------------------
1207 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1209 const TIntVector& theFamNum,
1210 const TIntVector& aElemNum,
1211 const TStringVector& aElemNames)
1213 return PElemInfo(new TTElemInfo
1221 //----------------------------------------------------------------------------
1224 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1225 EEntiteMaillage theEntity,
1226 EGeometrieElement theGeom,
1227 EConnectivite theConnMode,
1230 EMaillage aType = theMeshInfo->GetType();
1231 if (aType == eNON_STRUCTURE) {
1234 if (theEntity == eNOEUD)
1235 return GetPNodeInfo(theMeshInfo, theErr);
1236 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1239 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1242 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1245 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1249 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1252 EBooleen theIsElemNum = eFAUX;
1256 nbElems = aGrille->GetNbNodes();
1257 theIsElemNum = eVRAI;
1262 nbElems = aGrille->GetNbCells();
1269 TIntVector aElemNum;
1270 TStringVector aElemNames;
1272 PElemInfo aElemInfo;
1274 if (theGeom == ePOINT1) {
1275 aElemInfo = CrElemInfo(theMeshInfo,
1278 MED::TElemInfo &aTElemInfo = *aElemInfo;
1280 // must be reimplemente in connection with mesh type eSTRUCTURE
1281 // GetNumeration(aTElemInfo,
1287 GetFamilies(aTElemInfo,
1293 // must be reimplemente in connection with mesh type eSTRUCTURE
1294 // GetNames(aTElemInfo,
1301 aElemInfo = CrElemInfo(theMeshInfo,
1313 //----------------------------------------------------------------------------
1316 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1317 EEntiteMaillage theEntity,
1318 EGeometrieElement theGeom,
1319 EConnectivite theConnMode,
1322 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1325 //----------------------------------------------------------------------------
1328 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1329 EEntiteMaillage theEntity,
1330 EGeometrieElement theGeom,
1331 EConnectivite theConnMode,
1334 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1336 if (theErr && *theErr < 0)
1339 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1341 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1342 med_int aTaille = 0;
1344 aTaille=MEDmeshnEntity(myFile->Id(),
1348 med_entity_type(theEntity),
1349 med_geometry_type(theGeom),
1351 med_connectivity_mode(theConnMode),
1356 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1358 return TInt(aTaille);
1361 //-----------------------------------------------------------------
1364 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1367 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1369 if (theErr && *theErr < 0)
1372 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1374 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1375 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1376 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1377 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1378 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1379 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1380 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1383 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1384 MED_NO_DT, MED_NO_IT,
1386 aConnMode, &anIndex, &aConn);
1391 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1393 if (theInfo.myIsElemNames) {
1394 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1399 if (theInfo.myIsElemNum) {
1400 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1405 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1410 //----------------------------------------------------------------------------
1413 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1416 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1419 //----------------------------------------------------------------------------
1422 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1426 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1428 if (theErr && *theErr < 0)
1431 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1432 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1434 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1435 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1436 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1437 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1438 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1439 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1441 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1442 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1444 aConnMode, anInfo.myNbElem + 1,
1449 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1451 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1455 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1459 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1464 //----------------------------------------------------------------------------
1467 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1468 EEntiteMaillage theEntity,
1469 EGeometrieElement theGeom,
1472 EConnectivite theConnMode,
1473 EBooleen theIsElemNum,
1474 EBooleen theIsElemNames)
1476 return PPolygoneInfo(new TTPolygoneInfo
1487 //----------------------------------------------------------------------------
1490 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1491 EEntiteMaillage theEntity,
1492 EGeometrieElement theGeom,
1493 const TIntVector& theIndexes,
1494 const TIntVector& theConnectivities,
1495 EConnectivite theConnMode,
1496 const TIntVector& theFamilyNums,
1497 const TIntVector& theElemNums,
1498 const TStringVector& theElemNames)
1500 return PPolygoneInfo(new TTPolygoneInfo
1512 //----------------------------------------------------------------------------
1515 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1516 const PPolygoneInfo& theInfo)
1518 return PPolygoneInfo(new TTPolygoneInfo
1523 //----------------------------------------------------------------------------
1526 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1527 EEntiteMaillage theEntity,
1528 EGeometrieElement theGeom,
1529 EConnectivite theConnMode)
1531 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1532 return PPolygoneInfo();
1534 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1535 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1536 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1537 GetPolygoneInfo(anInfo);
1540 INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
1541 " - theGeom = "<<theGeom<<
1542 "; aNbElem = "<<aNbElem<<": ");
1543 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1544 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1545 TInt aConnDim = aConnSlice.size();
1546 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1547 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1549 ADDMSG(MYDEBUG, " ");
1551 ADDMSG(MYDEBUG, std::endl);
1557 //----------------------------------------------------------------------------
1560 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1561 EEntiteMaillage theEntity,
1562 EGeometrieElement theGeom,
1563 EConnectivite theConnMode,
1566 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1569 //----------------------------------------------------------------------------
1572 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1575 EConnectivite theConnMode,
1578 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1580 if (theErr && *theErr < 0)
1581 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1583 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1585 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1586 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1587 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1588 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1590 med_bool chgt, trsf;
1591 theNbFaces = MEDmeshnEntity(myFile->Id(),
1602 theConnSize = MEDmeshnEntity(myFile->Id(),
1613 if (theNbFaces < 0 || theConnSize<0)
1614 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1618 //-----------------------------------------------------------------
1621 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1624 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1626 if (theErr && *theErr < 0)
1629 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1631 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1632 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1633 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1634 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1635 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1636 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1639 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1652 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1654 if (theInfo.myIsElemNames) {
1655 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1660 if (theInfo.myIsElemNum) {
1661 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1666 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1671 //----------------------------------------------------------------------------
1674 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1677 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1680 //----------------------------------------------------------------------------
1683 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1687 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1689 if (theErr && *theErr < 0)
1692 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1693 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1695 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1696 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1697 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1698 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1699 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1702 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1711 (TInt)anInfo.myFaces->size(),
1718 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1720 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1722 if (theInfo.myIsElemNames) {
1723 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1724 aRet = MEDmeshEntityNameWr(myFile->Id(),
1730 (TInt)anInfo.myElemNames->size(),
1735 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1738 if (theInfo.myIsElemNum) {
1739 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1740 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1746 (TInt)anInfo.myElemNum->size(),
1751 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1754 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1755 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1761 (TInt)anInfo.myFamNum->size(),
1767 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1770 //----------------------------------------------------------------------------
1773 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1774 EEntiteMaillage theEntity,
1775 EGeometrieElement theGeom,
1779 EConnectivite theConnMode,
1780 EBooleen theIsElemNum,
1781 EBooleen theIsElemNames)
1783 return PPolyedreInfo(new TTPolyedreInfo
1795 //----------------------------------------------------------------------------
1798 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1799 EEntiteMaillage theEntity,
1800 EGeometrieElement theGeom,
1801 const TIntVector& theIndexes,
1802 const TIntVector& theFaces,
1803 const TIntVector& theConnectivities,
1804 EConnectivite theConnMode,
1805 const TIntVector& theFamilyNums,
1806 const TIntVector& theElemNums,
1807 const TStringVector& theElemNames)
1809 return PPolyedreInfo(new TTPolyedreInfo
1822 //----------------------------------------------------------------------------
1825 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1826 const PPolyedreInfo& theInfo)
1828 return PPolyedreInfo(new TTPolyedreInfo
1833 //----------------------------------------------------------------------------
1836 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1837 EEntiteMaillage theEntity,
1838 EGeometrieElement theGeom,
1839 EConnectivite theConnMode)
1841 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1842 return PPolyedreInfo();
1843 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1844 TInt aNbFaces, aConnSize;
1845 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1846 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1847 GetPolyedreInfo(anInfo);
1850 INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
1851 " - theGeom = "<<theGeom<<
1852 "; aNbElem = "<<aNbElem<<": ");
1853 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1854 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1855 TInt aNbFaces = aConnSliceArr.size();
1856 ADDMSG(MYDEBUG, "{");
1857 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1858 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1859 TInt aNbConn = aConnSlice.size();
1860 ADDMSG(MYDEBUG, "[");
1861 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1862 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1864 ADDMSG(MYDEBUG, "] ");
1866 ADDMSG(MYDEBUG, "} ");
1868 ADDMSG(MYDEBUG, std::endl);
1874 //-----------------------------------------------------------------
1877 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1878 EConnectivite theConnMode,
1883 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1885 if (theErr && *theErr < 0)
1888 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1889 TInt aNbElem = GetNbNodes(theMeshInfo);
1891 anInfo[eNOEUD][ePOINT1] = aNbElem;
1892 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1893 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1894 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1895 for (; anIter != anIterEnd; anIter++) {
1896 const EEntiteMaillage& anEntity = anIter->first;
1897 const TGeomSet& aGeomSet = anIter->second;
1898 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1899 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1900 for (; anIter2 != anIterEnd2; anIter2++) {
1901 const EGeometrieElement& aGeom = *anIter2;
1902 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1904 if (anEntity == eSTRUCT_ELEMENT) {
1905 const TInt nbStructTypes = aNbElem;
1906 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1907 // check type name to keep only "MED_BALL" structured element
1908 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1909 char geotypename[ MED_NAME_SIZE + 1] = "";
1910 med_geometry_type geotype;
1911 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1912 med_entity_type(anEntity), structType+1,
1913 geotypename, &geotype);
1914 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1915 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1916 theConnMode, theErr);
1918 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1923 anInfo[anEntity][aGeom] = aNbElem;
1930 else { // eSTRUCTURE
1931 EGrilleType aGrilleType;
1935 TInt aDim = theMeshInfo.GetDim();
1936 EGeometrieElement aGeom, aSubGeom;
1937 EEntiteMaillage aSubEntity = eMAILLE;
1939 GetGrilleType(theMeshInfo, aGrilleType);
1941 TIntVector aStruct(aDim);
1942 if (aGrilleType == eGRILLE_STANDARD)
1944 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1947 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1948 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1949 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1950 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1952 for (med_int i = 0; i < aDim; i++) {
1953 aNbNodes = aNbNodes * aStruct[i];
1954 aNbElem = aNbElem * (aStruct[i] - 1);
1963 aSubEntity = eARETE;
1965 (aStruct[0]) * (aStruct[1]-1) +
1966 (aStruct[0]-1) * (aStruct[1]);
1973 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1974 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1975 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1978 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1979 anInfo[eMAILLE][aGeom] = aNbElem;
1981 anInfo[aSubEntity][aSubGeom] = aNbSub;
1986 //-----------------------------------------------------------------
1989 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1990 EEntiteMaillage theEntity,
1991 EGeometrieElement theGeom,
1992 EConnectivite theConnMode,
1995 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1997 if (theErr && *theErr < 0)
2000 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2001 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2002 med_bool chgt, trsf;
2005 case MED::ePOLYGONE:
2006 case MED::ePOLYGON2:
2008 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2009 MED_NO_DT, MED_NO_IT,
2010 med_entity_type(theEntity), med_geometry_type(theGeom),
2011 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2014 case MED::ePOLYEDRE:
2016 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2017 MED_NO_DT, MED_NO_IT,
2018 med_entity_type(theEntity), MED_POLYHEDRON,
2019 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2024 return GetNbBalls(theMeshInfo);
2028 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2029 MED_NO_DT, MED_NO_IT,
2030 med_entity_type(theEntity), med_geometry_type(theGeom),
2031 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2038 //----------------------------------------------------------------------------
2041 ::GetCellInfo(MED::TCellInfo& theInfo,
2044 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2046 if (theErr && *theErr < 0)
2049 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2051 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2052 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2053 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2054 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2055 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2056 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2057 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2058 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2059 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2060 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2061 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2062 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2066 aRet = MEDmeshnEntity(myFile->Id(),
2077 // names are present in the file, they will be read in spite of theInfo.myIsElemNames
2078 theInfo.myIsElemNames = eVRAI;
2079 theInfo.myElemNames.reset( new TString( theInfo.myNbElem * GetPNOMLength() + 1 ));
2080 anElemNames.myRepresentation = & ((TString&) theInfo.myElemNames )[0];
2083 aRet = MEDmeshElementRd(myFile->Id(),
2102 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2104 if (anIsFamNum == MED_FALSE)
2106 int mySize = (int) theInfo.myFamNum->size();
2107 theInfo.myFamNum->clear();
2108 theInfo.myFamNum->resize(mySize, 0);
2113 //----------------------------------------------------------------------------
2116 ::SetCellInfo(const MED::TCellInfo& theInfo,
2119 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2122 //----------------------------------------------------------------------------
2125 ::SetCellInfo(const MED::TCellInfo& theInfo,
2129 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2131 if (theErr && *theErr < 0)
2134 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2135 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2137 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2138 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2139 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2140 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2141 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2142 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2143 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2144 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2145 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2146 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2147 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2148 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2149 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2152 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2164 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2173 MEDmeshEntityNameWr(myFile->Id(),
2182 MEDmeshEntityNumberWr(myFile->Id(),
2193 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2196 //----------------------------------------------------------------------------
2199 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2200 EEntiteMaillage theEntity,
2201 EGeometrieElement theGeom,
2203 EConnectivite theConnMode,
2204 EBooleen theIsElemNum,
2205 EBooleen theIsElemNames,
2206 EModeSwitch theMode)
2208 return PCellInfo(new TTCellInfo
2219 //----------------------------------------------------------------------------
2222 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2223 EEntiteMaillage theEntity,
2224 EGeometrieElement theGeom,
2225 const TIntVector& theConnectivities,
2226 EConnectivite theConnMode,
2227 const TIntVector& theFamilyNums,
2228 const TIntVector& theElemNums,
2229 const TStringVector& theElemNames,
2230 EModeSwitch theMode)
2232 return PCellInfo(new TTCellInfo
2244 //----------------------------------------------------------------------------
2247 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2248 const PCellInfo& theInfo)
2250 return PCellInfo(new TTCellInfo
2255 //----------------------------------------------------------------------------
2258 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2259 EEntiteMaillage theEntity,
2260 EGeometrieElement theGeom,
2261 EConnectivite theConnMode,
2264 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2266 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2267 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2268 GetCellInfo(anInfo, theErr);
2271 TInt aConnDim = anInfo->GetConnDim();
2272 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2273 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2274 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2275 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2276 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2277 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2279 ADDMSG(MYVALUEDEBUG, " ");
2281 ADDMSG(MYDEBUG, std::endl);
2283 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2284 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2285 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2287 ADDMSG(MYVALUEDEBUG, std::endl);
2289 if (anInfo->IsElemNum()) {
2290 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2291 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2292 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2294 ADDMSG(MYVALUEDEBUG, std::endl);
2296 ADDMSG(MYDEBUG, std::endl);
2302 //----------------------------------------------------------------------------
2305 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2308 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2310 // read med_geometry_type of "MED_BALL" element
2311 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2312 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2315 //----------------------------------------------------------------------------
2318 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2321 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2323 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2327 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2330 //----------------------------------------------------------------------------
2333 ::GetBallInfo(TBallInfo& theInfo,
2336 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2338 // check geometry of MED_BALL
2339 if (theInfo.myGeom == eBALL)
2341 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2342 if (theInfo.myGeom < 0) {
2344 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2345 *theErr = theInfo.myGeom;
2351 GetCellInfo(theInfo);
2354 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2355 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2356 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2357 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2359 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2360 MED_NO_DT, MED_NO_IT,
2367 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2370 //----------------------------------------------------------------------------
2373 ::SetBallInfo(const TBallInfo& theInfo,
2376 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2379 //----------------------------------------------------------------------------
2382 ::SetBallInfo(const TBallInfo& theInfo,
2386 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2389 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2390 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2393 // no ball model in the file, create support mesh for it
2394 char dummyname [MED_NAME_SIZE*3+1] = "";
2395 if ((ret = MEDsupportMeshCr(myFile->Id(),
2397 theInfo.myMeshInfo->GetSpaceDim(),
2398 theInfo.myMeshInfo->GetDim(),
2399 "Support mesh for a ball model",
2401 /*axisname=*/dummyname,
2402 /*unitname=*/dummyname)) < 0) {
2404 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2408 // write coordinates of 1 node
2409 med_float coord[3] = {0, 0, 0};
2410 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2411 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2412 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2414 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2418 // ball model creation
2419 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2420 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2422 theInfo.myMeshInfo->GetSpaceDim(),
2424 MED_NODE,MED_NONE)) < 0) {
2426 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2430 // create diameter attribute
2431 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2432 geotypename, MED_BALL_DIAMETER,
2433 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2435 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2441 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2442 aBallInfo.myGeom = ballGeom;
2445 SetCellInfo(theInfo, theMode, theErr);
2446 if (theErr && theErr < 0)
2450 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2451 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2452 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2453 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2454 MED_NO_DT, MED_NO_IT,
2455 aGeom, MED_BALL_DIAMETER,
2456 theInfo.myNbElem, &aDiam);
2460 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2463 //----------------------------------------------------------------------------
2466 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2468 EBooleen theIsElemNum)
2470 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2473 //----------------------------------------------------------------------------
2476 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2477 const TIntVector& theNodes,
2478 TFloatVector& theDiameters,
2479 const TIntVector& theFamilyNums,
2480 const TIntVector& theElemNums)
2482 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2483 theFamilyNums, theElemNums));
2486 //----------------------------------------------------------------------------
2489 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2490 const PBallInfo& theInfo)
2492 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2495 //----------------------------------------------------------------------------
2498 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2500 TInt nbBalls = GetNbBalls(theMeshInfo);
2501 if (nbBalls < 1) return PBallInfo();
2503 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2504 GetBallInfo(anInfo);
2509 //-----------------------------------------------------------------
2512 ::GetNbFields(TErr* theErr)
2514 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2516 if (theErr && *theErr < 0)
2519 return MEDnField(myFile->Id());
2522 //----------------------------------------------------------------------------
2525 ::GetNbComp(TInt theFieldId,
2528 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2530 if (theErr && *theErr < 0)
2533 return MEDfieldnComponent(myFile->Id(), theFieldId);
2536 //----------------------------------------------------------------------------
2539 ::GetFieldInfo(TInt theFieldId,
2540 MED::TFieldInfo& theInfo,
2543 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2545 if (theErr && *theErr < 0)
2548 TString aFieldName(256); // Protect from memory problems with too long names
2549 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2550 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2551 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2552 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2556 char dtunit[MED_SNAME_SIZE+1];
2557 char local_mesh_name[MED_NAME_SIZE+1]="";
2559 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2560 aRet = MEDfieldInfo(myFile->Id(),
2571 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2577 theInfo.SetName(aFieldName);
2582 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2585 //----------------------------------------------------------------------------
2588 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2592 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2595 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2601 //----------------------------------------------------------------------------
2604 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2608 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2610 if (theErr && *theErr < 0)
2613 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2615 TValueHolder<TString, char> aFieldName(anInfo.myName);
2616 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2617 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2618 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2619 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2621 char dtunit[MED_SNAME_SIZE+1];
2622 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2623 aRet = MEDfieldCr(myFile->Id(),
2630 &aMeshInfo.myName[0]);
2634 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2637 //----------------------------------------------------------------------------
2640 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2643 const std::string& theValue,
2644 EBooleen theIsLocal,
2647 return PFieldInfo(new TTFieldInfo
2656 //----------------------------------------------------------------------------
2659 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2660 const PFieldInfo& theInfo)
2662 return PFieldInfo(new TTFieldInfo
2667 //----------------------------------------------------------------------------
2670 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2674 TInt aNbComp = GetNbComp(theId);
2675 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2676 GetFieldInfo(theId, *anInfo, theErr);
2681 "- aName = '"<<anInfo->GetName()<<"'"<<
2682 "; aType = "<<anInfo->GetType()<<
2683 "; aNbComp = "<<aNbComp<<
2690 //----------------------------------------------------------------------------
2693 ::GetNbGauss(TErr* theErr)
2695 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2697 if (theErr && *theErr < 0)
2700 return MEDnLocalization(myFile->Id());
2703 //----------------------------------------------------------------------------
2706 ::GetGaussPreInfo(TInt theId,
2709 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2711 if (theErr && *theErr < 0)
2712 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2714 med_int aNbGaussPoints = med_int();
2715 TVector<char> aName(GetNOMLength()+1);
2716 med_geometry_type aGeom = MED_NONE;
2720 char geointerpname[MED_NAME_SIZE+1] = "";
2721 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2722 med_int nsectionmeshcell;
2723 med_geometry_type sectiongeotype;
2724 aRet = MEDlocalizationInfo (myFile->Id(),
2731 ipointstructmeshname,
2737 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2738 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2739 TInt(aNbGaussPoints));
2742 //----------------------------------------------------------------------------
2745 ::GetGaussInfo(TInt theId,
2746 TGaussInfo& theInfo,
2749 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2751 if (theErr && *theErr < 0)
2754 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2755 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2756 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2757 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2758 TValueHolder<TString, char> aGaussName(theInfo.myName);
2761 aRet = MEDlocalizationRd(myFile->Id(),
2771 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2774 //----------------------------------------------------------------------------
2777 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2778 EModeSwitch theMode)
2780 return PGaussInfo(new TTGaussInfo
2785 //-----------------------------------------------------------------
2788 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2789 const MED::TEntityInfo& theEntityInfo,
2790 EEntiteMaillage& theEntity,
2791 TGeom2Size& theGeom2Size,
2794 theEntity = EEntiteMaillage(-1);
2795 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2798 if (theEntityInfo.empty())
2803 else if (theEntityInfo.empty())
2804 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2806 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2808 theGeom2Size.clear();
2809 TInt aNbTimeStamps = 0;
2810 TIdt anId = myFile->Id();
2812 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2813 TValueHolder<TString, char> aFieldName(anInfo.myName);
2814 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2816 // workaround for IPAL13676
2817 MED::TEntityInfo localEntityInfo = theEntityInfo;
2818 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2819 if (anLocalIter != localEntityInfo.end()) {
2820 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2823 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2824 for (; anIter != localEntityInfo.end(); anIter++) {
2825 med_entity_type anEntity = med_entity_type(anIter->first);
2826 const TGeom2Size& aGeom2Size = anIter->second;
2827 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2828 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2829 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2830 char aMeshName[MED_NAME_SIZE+1];
2833 char dtunit[MED_SNAME_SIZE+1];
2834 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2835 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2836 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2838 MEDfieldInfoByName(anId,
2855 MEDfieldComputingStepInfo(anId,
2861 char profilename[MED_NAME_SIZE+1];
2862 char locname[MED_NAME_SIZE+1];
2866 // protection from crash (division by zero)
2867 // inside MEDfieldnValueWithProfile function
2868 // caused by the workaround for IPAL13676 (see above)
2869 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2872 nval = MEDfieldnValueWithProfile(anId,
2877 med_geometry_type(aGeom),
2885 bool anIsSatisfied =(nval > 0);
2886 if (anIsSatisfied) {
2888 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2889 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2890 if (anIsPerformAdditionalCheck) {
2891 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2892 if (!anIsSatisfied) {
2894 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2895 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2899 if (anIsSatisfied) {
2900 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2901 theEntity = EEntiteMaillage(anEntity);
2902 aNbTimeStamps = aNbStamps;
2905 if (!theGeom2Size.empty())
2908 return aNbTimeStamps;
2911 //----------------------------------------------------------------------------
2914 ::GetTimeStampInfo(TInt theTimeStampId,
2915 MED::TTimeStampInfo& theInfo,
2918 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2920 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2923 if (aGeom2Size.empty())
2928 else if (aGeom2Size.empty())
2929 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2931 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2932 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2934 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2935 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2936 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2937 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2938 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2939 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2940 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2941 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2942 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2944 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2946 // just to get a time stamp unit (anUnitDt)
2947 med_field_type aFieldType;
2948 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2949 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2950 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2952 MEDfieldInfoByName(myFile->Id(),
2961 delete [] aCompName;
2962 delete [] aCompUnit;
2964 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2965 for (; anIter != aGeom2Size.end(); anIter++) {
2966 const EGeometrieElement& aGeom = anIter->first;
2967 med_int aNbGauss = -1;
2970 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2976 char profilename[MED_NAME_SIZE+1];
2978 char locname[MED_NAME_SIZE+1];
2979 MEDfieldnValueWithProfile(myFile->Id(),
2984 med_geometry_type(aGeom),
2992 static TInt MAX_NB_GAUSS_POINTS = 32;
2993 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2996 aGeom2NbGauss[aGeom] = aNbGauss;
3001 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
3005 //----------------------------------------------------------------------------
3008 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3009 EEntiteMaillage theEntity,
3010 const TGeom2Size& theGeom2Size,
3011 const TGeom2NbGauss& theGeom2NbGauss,
3015 const std::string& theUnitDt,
3016 const TGeom2Gauss& theGeom2Gauss)
3018 return PTimeStampInfo(new TTTimeStampInfo
3030 //----------------------------------------------------------------------------
3033 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3034 const PTimeStampInfo& theInfo)
3036 return PTimeStampInfo(new TTTimeStampInfo
3041 //----------------------------------------------------------------------------
3044 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3045 EEntiteMaillage theEntity,
3046 const TGeom2Size& theGeom2Size,
3050 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3051 GetTimeStampInfo(theId, *anInfo, theErr);
3054 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3055 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3056 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3057 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3058 const EGeometrieElement& aGeom = anIter->first;
3059 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3066 //----------------------------------------------------------------------------
3069 ::GetNbProfiles(TErr* theErr)
3071 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3073 if (theErr && *theErr < 0)
3076 return MEDnProfile(myFile->Id());
3079 //----------------------------------------------------------------------------
3082 ::GetProfilePreInfo(TInt theId,
3085 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3087 if (theErr && *theErr < 0)
3088 return TProfileInfo::TInfo();
3091 TVector<char> aName(GetNOMLength()+1);
3094 aRet = MEDprofileInfo(myFile->Id(),
3101 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3103 return TProfileInfo::TInfo(&aName[0], aSize);
3106 //----------------------------------------------------------------------------
3109 ::GetProfileInfo(TInt theId,
3110 TProfileInfo& theInfo,
3113 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3115 if (theErr && *theErr < 0)
3118 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3119 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3120 TValueHolder<TString, char> aProfileName(anInfo.myName);
3123 aRet = MEDprofileRd(myFile->Id(),
3129 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3132 //----------------------------------------------------------------------------
3135 ::SetProfileInfo(const TProfileInfo& theInfo,
3139 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3142 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3145 SetProfileInfo(theInfo, eCREATION, &aRet);
3151 //----------------------------------------------------------------------------
3154 ::SetProfileInfo(const TProfileInfo& theInfo,
3158 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3160 if (theErr && *theErr < 0)
3163 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3164 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3165 TValueHolder<TString, char> aProfileName(anInfo.myName);
3168 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3169 &aProfileName, // tableau de valeurs du profil.
3170 theInfo.GetSize(), // taille du profil.
3171 &anElemNum); // nom profil.
3175 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3178 //----------------------------------------------------------------------------
3181 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3182 EModeProfil theMode)
3184 return PProfileInfo(new TTProfileInfo
3189 //----------------------------------------------------------------------------
3192 ::GetPProfileInfo(TInt theId,
3193 EModeProfil theMode,
3196 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3197 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3198 GetProfileInfo(theId, *anInfo, theErr);
3203 //----------------------------------------------------------------------------
3206 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3207 const TMKey2Profile& theMKey2Profile,
3208 const TKey2Gauss& theKey2Gauss,
3211 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3213 if (theErr && *theErr < 0)
3216 TIdt anId = myFile->Id();
3218 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3219 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3221 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3222 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3223 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3224 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3226 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3227 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3228 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3230 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3231 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3233 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3234 TVector<char> aGaussName(GetNOMLength()+1);
3236 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3237 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3238 TVector<char> aProfileName(GetNOMLength()+1);
3240 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3241 TGeom2Size::iterator anIter = aGeom2Size.begin();
3242 for (; anIter != aGeom2Size.end(); anIter++) {
3243 EGeometrieElement aGeom = anIter->first;
3244 TInt aNbElem = anIter->second;
3245 med_int profilesize, aNbGauss;
3247 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3252 med_geometry_type(aGeom),
3265 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3268 TInt aNbComp = aFieldInfo->myNbComp;
3269 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3270 theTimeStampValue->AllocateValue(aGeom,
3274 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3277 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3278 "; aNbVal = "<<aNbVal<<
3279 "; aNbValue = "<<aNbValue<<
3280 "; aNbGauss = "<<aNbGauss<<
3281 "; aNbComp = "<<aNbComp<<
3284 TErr aRet = MEDfieldValueWithProfileRd(anId,
3289 med_geometry_type(aGeom),
3293 MED_ALL_CONSTITUENT,
3294 theTimeStampValue->GetValuePtr(aGeom));
3297 *theErr = MED_FALSE;
3300 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3303 MED::PGaussInfo aGaussInfo;
3304 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3305 if (strcmp(&aGaussName[0], "") != 0) {
3306 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3307 if (anIter != theKey2Gauss.end()) {
3308 aGaussInfo = anIter->second;
3309 aGeom2Gauss[aGeom] = aGaussInfo;
3313 MED::PProfileInfo aProfileInfo;
3314 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3315 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3316 if (anIter != aKey2Profile.end()) {
3317 aProfileInfo = anIter->second;
3318 aGeom2Profile[aGeom] = aProfileInfo;
3322 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3324 *theErr = MED_FALSE;
3327 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3330 if (aProfileInfo && aProfileInfo->IsPresent()) {
3331 TInt aNbSubElem = aProfileInfo->GetSize();
3332 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3333 if (aProfileSize != aValueSize) {
3338 EXCEPTION(std::runtime_error,
3339 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3340 ") != aValueSize("<<aValueSize<<
3341 "); aNbVal = "<<aNbVal<<
3342 "; anEntity = "<<anEntity<<
3343 "; aGeom = "<<aGeom<<
3344 "; aNbElem = "<<aNbElem<<
3345 "; aNbSubElem = "<<aNbSubElem<<
3346 "; aNbComp = "<<aNbComp<<
3347 "; aNbGauss = "<<aNbGauss<<
3352 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3357 EXCEPTION(std::runtime_error,
3358 "GetTimeStampValue - aNbElem("<<aNbElem<<
3359 ") != aNbValue("<<aNbValue<<
3360 "); aNbVal = "<<aNbVal<<
3361 "; anEntity = "<<anEntity<<
3362 "; aGeom = "<<aGeom<<
3363 "; aNbElem = "<<aNbElem<<
3364 "; aNbComp = "<<aNbComp<<
3365 "; aNbGauss = "<<aNbGauss<<
3372 //----------------------------------------------------------------------------
3375 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3379 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3382 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3388 //----------------------------------------------------------------------------
3391 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3395 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3397 if (theErr && *theErr < 0)
3401 TIdt anId = myFile->Id();
3403 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3404 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3406 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3407 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3408 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3409 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3410 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3411 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3412 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3414 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3415 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3417 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3418 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3420 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3421 TGeomSet::const_iterator anIter = aGeomSet.begin();
3422 for (; anIter != aGeomSet.end(); anIter++) {
3423 EGeometrieElement aGeom = *anIter;
3425 TVector<char> aGaussName(GetNOMLength()+1);
3426 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3427 if (aGaussIter != aGeom2Gauss.end()) {
3428 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3429 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3432 TVector<char> aProfileName(GetNOMLength()+1);
3433 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3434 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3435 if (aProfileIter != aGeom2Profile.end()) {
3436 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3437 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3438 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3441 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3443 aRet = MEDfieldValueWithProfileWr(anId,
3449 med_geometry_type(aGeom),
3454 MED_ALL_CONSTITUENT,
3456 theTimeStampValue->GetValuePtr(aGeom));
3459 *theErr = MED_FALSE;
3462 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3467 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3470 //----------------------------------------------------------------------------
3473 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3474 ETypeChamp theTypeChamp,
3475 const TGeom2Profile& theGeom2Profile,
3476 EModeSwitch theMode)
3478 if (theTypeChamp == eFLOAT64)
3479 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3484 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3491 //----------------------------------------------------------------------------
3494 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3495 const TGeom2Profile& theGeom2Profile,
3496 EModeSwitch theMode)
3498 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3499 return CrTimeStampValue(theTimeStampInfo,
3500 aFieldInfo->GetType(),
3505 //----------------------------------------------------------------------------
3508 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3509 const PTimeStampValueBase& theInfo,
3510 ETypeChamp theTypeChamp)
3512 if (theTypeChamp == eFLOAT64)
3513 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3517 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3523 //----------------------------------------------------------------------------
3526 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3527 const PTimeStampValueBase& theInfo)
3529 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3530 return CrTimeStampValue(theTimeStampInfo,
3532 aFieldInfo->GetType());
3535 //----------------------------------------------------------------------------
3538 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3539 const TMKey2Profile& theMKey2Profile,
3540 const TKey2Gauss& theKey2Gauss,
3543 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3544 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3545 aFieldInfo->GetType());
3546 GetTimeStampValue(anInfo,
3551 if (aFieldInfo->GetType() == eFLOAT64)
3552 Print<TFloatTimeStampValue>(anInfo);
3554 Print<TIntTimeStampValue>(anInfo);
3559 //----------------------------------------------------------------------------
3562 ::GetTimeStampVal(const PTimeStampVal& theVal,
3563 const TMKey2Profile& theMKey2Profile,
3564 const TKey2Gauss& theKey2Gauss,
3567 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3568 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3569 if (aFieldInfo->GetType() == eFLOAT64)
3570 GetTimeStampValue(theVal,
3575 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3578 GetTimeStampValue(aVal,
3582 CopyTimeStampValueBase(aVal, theVal);
3586 //----------------------------------------------------------------------------
3589 ::SetTimeStamp(const PTimeStampVal& theVal,
3592 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3593 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3594 if (aFieldInfo->GetType() == eFLOAT64)
3595 SetTimeStampValue(theVal, theErr);
3597 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3599 theVal->GetGeom2Profile(),
3600 theVal->GetModeSwitch());
3601 CopyTimeStampValueBase(theVal, aVal);
3602 SetTimeStampValue(aVal, theErr);
3606 //----------------------------------------------------------------------------
3609 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3610 const TGeom2Profile& theGeom2Profile,
3611 EModeSwitch theMode)
3613 return CrTimeStampValue(theTimeStampInfo,
3619 //----------------------------------------------------------------------------
3622 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3623 const PTimeStampVal& theInfo)
3625 return CrTimeStampValue(theTimeStampInfo,
3630 //----------------------------------------------------------------------------
3633 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3634 const TMKey2Profile& theMKey2Profile,
3635 const TKey2Gauss& theKey2Gauss,
3638 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3639 GetTimeStampVal(anInfo,
3646 //----------------------------------------------------------------------------
3649 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3651 if (theMeshInfo->GetType() != eSTRUCTURE)
3652 return PGrilleInfo();
3655 GetGrilleType(*theMeshInfo, type);
3657 if (type == eGRILLE_STANDARD) {
3658 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3659 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3663 aVec.resize(theMeshInfo->GetDim());
3664 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3665 ETable aATable = eCOOR_IND1;
3668 aATable = eCOOR_IND1;
3671 aATable = eCOOR_IND2;
3674 aATable = eCOOR_IND3;
3677 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3679 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3682 GetGrilleInfo(anInfo);
3683 anInfo->SetGrilleType(type);
3686 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3688 TInt aNbElem = anInfo->GetNbNodes();
3689 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3690 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3691 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3693 TInt aNbCells = anInfo->GetNbCells();
3694 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3695 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3696 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3698 ADDMSG(MYVALUEDEBUG, std::endl);
3699 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3700 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3701 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3703 ADDMSG(MYVALUEDEBUG, std::endl);
3704 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3705 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3706 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3708 ADDMSG(MYVALUEDEBUG, std::endl);
3716 //----------------------------------------------------------------------------
3719 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3720 const PGrilleInfo& theInfo)
3722 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3726 //----------------------------------------------------------------------------
3729 ::GetGrilleInfo(TGrilleInfo& theInfo,
3732 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3734 if (theErr && *theErr < 0)
3737 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3738 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3739 EMaillage aMaillageType = aMeshInfo.myType;
3741 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3742 EGrilleType aGrilleType = theInfo.myGrilleType;
3745 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3746 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3748 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3749 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3750 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3751 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3752 //med_axis_type aRepere;
3754 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3764 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3766 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3767 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3769 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3778 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3780 int mySize = (int)theInfo.myFamNumNode.size();
3781 theInfo.myFamNumNode.clear();
3782 theInfo.myFamNumNode.resize(mySize,0);
3786 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3791 //============================
3794 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3795 ETable aTable = eCOOR_IND1;
3796 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3799 aTable = eCOOR_IND1;
3802 aTable = eCOOR_IND2;
3805 aTable = eCOOR_IND3;
3814 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3816 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3818 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3820 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3821 //TValueHolder<ETable, med_data_type > table(aTable);
3822 //char aCompNames[MED_SNAME_SIZE+1];
3823 //char anUnitNames[MED_SNAME_SIZE+1];
3824 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3826 MED_NO_DT,MED_NO_IT,
3830 //theInfo.SetCoordName(anAxis-1, aCompNames);
3831 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3832 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3837 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3841 EGeometrieElement aGeom = theInfo.GetGeom();
3842 EEntiteMaillage aEntity = theInfo.GetEntity();
3843 TInt aNbCells = theInfo.GetNbCells();
3845 theInfo.myFamNum.resize(aNbCells);
3846 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3848 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3849 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3850 med_geometry_type(aGeom), &aFamNum);
3852 if (aMeshInfo.myDim == 3)
3854 aGeom = theInfo.GetSubGeom();
3855 aEntity = theInfo.GetSubEntity();
3856 aNbCells = theInfo.GetNbSubCells();
3858 theInfo.myFamSubNum.resize(aNbCells, 0);
3859 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3861 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3865 med_entity_type(aEntity),
3866 med_geometry_type(aGeom),
3870 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3872 int mySize = (int)theInfo.myFamNumNode.size();
3873 theInfo.myFamNumNode.clear();
3874 theInfo.myFamNumNode.resize(mySize, 0);
3878 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3884 //----------------------------------------------------------------------------
3887 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3890 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3893 //----------------------------------------------------------------------------
3896 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3900 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3902 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3904 if (theErr && *theErr < 0)
3907 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3909 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3910 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3912 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3915 aRet = MEDmeshGridTypeRd(myFile->Id(),
3921 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3923 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3924 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3925 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3926 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3927 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3928 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3929 //med_axis_type aRepere = MED_CARTESIAN;
3931 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3941 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3943 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3944 aRet = MEDmeshGridStructWr(myFile->Id(),
3951 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3955 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3956 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3962 anInfo.GetIndexes(aAxis).size(),
3963 &anInfo.GetIndexes(aAxis)[0]);
3966 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3974 //----------------------------------------------------------------------------
3977 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3978 const PGrilleInfo& theInfo)
3980 return PGrilleInfo(new TTGrilleInfo
3985 //----------------------------------------------------------------------------
3988 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
3990 return PGrilleInfo(); // not implemented????
3993 //----------------------------------------------------------------------------
3996 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3997 const EGrilleType& type)
3999 return PGrilleInfo(new TTGrilleInfo
4004 //----------------------------------------------------------------------------
4007 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4008 const EGrilleType& type,
4009 const TInt& nbNodes)
4011 return PGrilleInfo(new TTGrilleInfo
4017 //----------------------------------------------------------------------------
4020 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4021 const EGrilleType& type,
4022 const MED::TIntVector& nbNodeVec)
4024 return PGrilleInfo(new TTGrilleInfo
4030 //----------------------------------------------------------------------------
4033 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4034 EGrilleType& theGridType,
4037 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4039 if (theErr && *theErr < 0)
4040 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4042 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4044 if (aMeshInfo.myType == eSTRUCTURE) {
4045 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4046 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4047 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4052 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4056 //----------------------------------------------------------------------------
4059 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4060 TIntVector& theStruct,
4063 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4065 if (theErr && *theErr < 0)
4069 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4071 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4072 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4074 aRet = MEDmeshGridStructRd(myFile->Id(),
4082 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");