1 // Copyright (C) 2007-2020 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>
35 #include <boost/version.hpp>
38 static int MYDEBUG = 0;
39 static int MYVALUEDEBUG = 0;
41 static int MYDEBUG = 0;
42 static int MYVALUEDEBUG = 0;
47 //---------------------------------------------------------------
49 ::TLockProxy(TWrapper* theWrapper):
52 #if BOOST_VERSION >= 103500
53 myWrapper->myMutex.lock();
55 boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
57 INITMSG(MYDEBUG, "TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
63 INITMSG(MYDEBUG, "~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
64 #if BOOST_VERSION >= 103500
65 myWrapper->myMutex.unlock();
67 boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
73 ::operator->() const // never throws
78 //---------------------------------------------------------------
85 TFile(const std::string& theFileName, TInt theMajor=-1, TInt theMinor=-1):
88 myFileName(theFileName),
92 if ((myMajor < 0) || (myMajor > MED_MAJOR_NUM)) myMajor = MED_MAJOR_NUM;
93 if ((myMinor < 0) || (myMajor == MED_MAJOR_NUM && myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
102 Open(EModeAcces theMode,
105 if (myCount++ == 0) {
106 const char* aFileName = myFileName.c_str();
108 if (med_access_mode(theMode) == MED_ACC_RDWR) {
109 // Force removing readonly attribute from a file under Windows, because of a bug in the HDF5
110 std::string aReadOlnyRmCmd = "attrib -r \"" + myFileName + "\"> nul 2>&1";
112 const char* to_decode = aReadOlnyRmCmd.c_str();
113 int size_needed = MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), NULL, 0);
114 wchar_t* awReadOlnyRmCmd = new wchar_t[size_needed + 1];
115 MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), awReadOlnyRmCmd, size_needed);
116 awReadOlnyRmCmd[size_needed] = '\0';
117 _wsystem(awReadOlnyRmCmd);
118 delete[] awReadOlnyRmCmd;
120 system(aReadOlnyRmCmd.c_str());
124 myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM);
127 *theErr = TErr(myFid);
129 EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<<myFileName<<"',"<<theMode<<"',"<< myMajor <<"',"<< myMinor<<"',"<< MED_RELEASE_NUM<<")");
136 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
150 std::string myFileName;
155 //---------------------------------------------------------------
162 TFileWrapper(const PFile& theFile,
169 if (myMinor < 0) myMinor = MED_MINOR_NUM;
170 myFile->Open(theMode, theErr);
179 //----------------------------------------------------------------------------
180 template<class TimeStampValueType>
182 Print(SharedPtr<TimeStampValueType> theTimeStampValue)
184 INITMSG(MYDEBUG,"Print - TimeStampValue\n");
185 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
186 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
187 for (; anIter != aGeom2Value.end(); anIter++) {
188 const EGeometrieElement& aGeom = anIter->first;
189 const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
190 TInt aNbElem = aMeshValue.myNbElem;
191 TInt aNbGauss = aMeshValue.myNbGauss;
192 TInt aNbComp = aMeshValue.myNbComp;
193 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
194 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
195 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
196 aMeshValue.GetGaussValueSliceArr(iElem);
197 ADDMSG(MYVALUEDEBUG, "{");
198 for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
199 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
200 aValueSliceArr[iGauss];
201 for (TInt iComp = 0; iComp < aNbComp; iComp++) {
202 ADDMSG(MYVALUEDEBUG, aValueSlice[iComp]<<" ");
204 ADDMSG(MYVALUEDEBUG, "| ");
206 ADDMSG(MYVALUEDEBUG, "} ");
208 ADDMSG(MYDEBUG, "\n");
212 //---------------------------------------------------------------
214 ::TWrapper(const std::string& theFileName, bool write, TInt theMajor, TInt theMinor):
215 myFile(new TFile(theFileName, theMajor, theMinor)),
221 myFile->Open(eLECTURE_ECRITURE, &aRet);
224 myFile->Open(eCREATION, &aRet);
228 myFile->Open(eLECTURE, &aRet);
232 //----------------------------------------------------------------------------
238 //----------------------------------------------------------------------------
241 ::GetNbMeshes(TErr* theErr)
243 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
245 if (theErr && *theErr < 0)
248 return MEDnMesh(myFile->Id());
251 //----------------------------------------------------------------------------
254 ::GetMeshInfo(TInt theMeshId,
255 MED::TMeshInfo& theInfo,
258 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
260 if (theErr && *theErr < 0)
263 TValueHolder<TString, char> aMeshName(theInfo.myName);
264 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
265 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
266 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
267 char dtunit[MED_SNAME_SIZE+1];
268 med_sorting_type sorttype;
271 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
272 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
273 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
274 TErr aRet = MEDmeshInfo(myFile->Id(),
290 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
293 //----------------------------------------------------------------------------
296 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
300 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
303 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
306 SetMeshInfo(theInfo, eCREATION, &aRet);
312 //----------------------------------------------------------------------------
315 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
319 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
321 if (theErr && *theErr < 0)
324 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
326 TValueHolder<TString, char> aMeshName(anInfo.myName);
327 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
328 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
329 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
330 TValueHolder<TString, char> aDesc(anInfo.myDesc);
332 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
333 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
334 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
335 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
336 TErr aRet = MEDmeshCr(myFile->Id(),
351 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
353 INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
358 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
361 //----------------------------------------------------------------------------
364 ::CrMeshInfo(TInt theDim,
366 const std::string& theValue,
368 const std::string& theDesc)
370 return PMeshInfo(new TTMeshInfo
378 //----------------------------------------------------------------------------
381 ::CrMeshInfo(const PMeshInfo& theInfo)
383 return PMeshInfo(new TTMeshInfo(theInfo));
386 //----------------------------------------------------------------------------
389 ::GetPMeshInfo(TInt theId,
392 PMeshInfo anInfo = CrMeshInfo();
393 GetMeshInfo(theId, *anInfo, theErr);
397 //----------------------------------------------------------------------------
400 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
403 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
405 if (theErr && *theErr < 0)
408 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
409 TValueHolder<TString, char> aName(anInfo.myName);
410 return MEDnFamily(myFile->Id(), &aName);
413 //----------------------------------------------------------------------------
416 ::GetNbFamAttr(TInt theFamId,
417 const MED::TMeshInfo& theInfo,
420 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
422 if (theErr && *theErr < 0)
425 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
427 TValueHolder<TString, char> aName(anInfo.myName);
429 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
432 //----------------------------------------------------------------------------
435 ::GetNbFamGroup(TInt theFamId,
436 const MED::TMeshInfo& theInfo,
439 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
441 if (theErr && *theErr < 0)
444 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
446 TValueHolder<TString, char> aName(anInfo.myName);
448 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
451 //----------------------------------------------------------------------------
454 ::GetFamilyInfo(TInt theFamId,
455 MED::TFamilyInfo& theInfo,
458 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
460 if (theErr && *theErr < 0)
463 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
465 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
466 TValueHolder<TString, char> aFamilyName(theInfo.myName);
467 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
468 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
469 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
470 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
471 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
473 TErr aRet = MEDfamily23Info(myFile->Id(),
486 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
487 " aMeshInfo.myName = '"<<&aMeshName<<
488 "'; theFamId = "<<theFamId<<
489 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
490 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
493 //----------------------------------------------------------------------------
496 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
500 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
503 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
509 //----------------------------------------------------------------------------
512 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
516 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
518 if (theErr && *theErr < 0)
521 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
522 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
524 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
525 TValueHolder<TString, char> aFamilyName(anInfo.myName);
526 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
527 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
528 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
529 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
530 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
531 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
532 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
534 TErr aRet = MEDfamilyCr(myFile->Id(),
541 INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
546 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
549 //----------------------------------------------------------------------------
552 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
556 const std::string& theValue)
558 return PFamilyInfo(new TTFamilyInfo
566 //----------------------------------------------------------------------------
569 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
570 const std::string& theValue,
572 const MED::TStringSet& theGroupNames,
573 const MED::TStringVector& theAttrDescs,
574 const MED::TIntVector& theAttrIds,
575 const MED::TIntVector& theAttrVals)
577 return PFamilyInfo(new TTFamilyInfo
587 //----------------------------------------------------------------------------
590 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
591 const PFamilyInfo& theInfo)
593 return PFamilyInfo(new TTFamilyInfo
598 //----------------------------------------------------------------------------
601 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
605 // must be reimplemented in connection with mesh type eSTRUCTURE
606 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
607 // return PFamilyInfo();
609 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
610 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
611 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
612 GetFamilyInfo(theId, *anInfo, theErr);
615 std::string aName = anInfo->GetName();
616 INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
617 "'; andId = "<<anInfo->GetId()<<
618 "; aNbAttr = "<<aNbAttr<<
619 "; aNbGroup = "<<aNbGroup<<"\n");
620 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
621 aName = anInfo->GetGroupName(iGroup);
622 INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
629 //----------------------------------------------------------------------------
632 ::GetNames(TElemInfo& theInfo,
634 EEntiteMaillage theEntity,
635 EGeometrieElement theGeom,
638 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
640 if (theErr && *theErr < 0)
643 if (theGeom == eBALL)
644 theGeom = GetBallGeom(theInfo.myMeshInfo);
646 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
648 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
649 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
650 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
651 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
653 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
661 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
667 //----------------------------------------------------------------------------
670 ::SetNames(const TElemInfo& theInfo,
671 EEntiteMaillage theEntity,
672 EGeometrieElement theGeom,
675 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
678 //----------------------------------------------------------------------------
681 ::SetNames(const TElemInfo& theInfo,
683 EEntiteMaillage theEntity,
684 EGeometrieElement theGeom,
687 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
689 if (theErr && *theErr < 0)
692 if (theGeom == eBALL)
693 theGeom = GetBallGeom(theInfo.myMeshInfo);
695 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
696 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
699 if (theInfo.myIsElemNames) {
700 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
701 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
702 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
703 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
705 aRet = MEDmeshEntityNameWr(myFile->Id(),
711 (TInt)anInfo.myElemNames->size(),
716 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
720 //----------------------------------------------------------------------------
723 ::GetNumeration(TElemInfo& theInfo,
725 EEntiteMaillage theEntity,
726 EGeometrieElement theGeom,
729 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
731 if (theErr && *theErr < 0)
734 if (theGeom == eBALL)
735 theGeom = GetBallGeom(theInfo.myMeshInfo);
737 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
739 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
740 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
741 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
742 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
744 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
752 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
758 //----------------------------------------------------------------------------
761 ::SetNumeration(const TElemInfo& theInfo,
762 EEntiteMaillage theEntity,
763 EGeometrieElement theGeom,
766 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
769 //----------------------------------------------------------------------------
772 ::SetNumeration(const TElemInfo& theInfo,
774 EEntiteMaillage theEntity,
775 EGeometrieElement theGeom,
778 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
780 if (theErr && *theErr < 0)
783 if (theGeom == eBALL)
784 theGeom = GetBallGeom(theInfo.myMeshInfo);
786 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
787 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
790 if (theInfo.myIsElemNum) {
791 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
792 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
793 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
794 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
796 aRet = MEDmeshEntityNumberWr(myFile->Id(),
802 (TInt)anInfo.myElemNum->size(),
807 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
811 //----------------------------------------------------------------------------
814 ::GetFamilies(TElemInfo& theInfo,
816 EEntiteMaillage theEntity,
817 EGeometrieElement theGeom,
820 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
822 if (theErr && *theErr < 0)
825 if (theGeom == eBALL)
826 theGeom = GetBallGeom(theInfo.myMeshInfo);
828 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
830 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
831 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
832 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
833 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
835 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
844 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
846 int aSize = (int)theInfo.myFamNum->size();
847 theInfo.myFamNum->clear();
848 theInfo.myFamNum->resize(aSize,0);
852 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
858 //----------------------------------------------------------------------------
861 ::SetFamilies(const TElemInfo& theInfo,
862 EEntiteMaillage theEntity,
863 EGeometrieElement theGeom,
866 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
869 //----------------------------------------------------------------------------
872 ::SetFamilies(const TElemInfo& theInfo,
874 EEntiteMaillage theEntity,
875 EGeometrieElement theGeom,
878 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
880 if (theErr && *theErr < 0)
883 if (theGeom == eBALL)
884 theGeom = GetBallGeom(theInfo.myMeshInfo);
886 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
887 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
889 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
890 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
891 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
892 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
894 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
900 (TInt)anInfo.myFamNum->size(),
906 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
909 //----------------------------------------------------------------------------
912 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
915 return GetNbNodes(theMeshInfo, eCOOR, theErr);
918 //----------------------------------------------------------------------------
921 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
925 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
927 if (theErr && *theErr < 0)
930 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
932 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
933 TValueHolder<ETable, med_data_type > aTable(theTable);
935 return MEDmeshnEntity(myFile->Id(),
947 //----------------------------------------------------------------------------
950 ::GetNodeInfo(MED::TNodeInfo& theInfo,
953 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
955 if (theErr && *theErr < 0)
958 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
960 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
961 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
962 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
963 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
964 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
965 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
966 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
967 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
968 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
969 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
970 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
971 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
972 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
974 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
981 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
989 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
991 int mySize = (int)theInfo.myFamNum->size();
992 theInfo.myFamNum->clear();
993 theInfo.myFamNum->resize(mySize,0);
996 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
999 if (MEDmeshEntityNameRd(myFile->Id(),
1005 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
1007 if (MEDmeshEntityNumberRd(myFile->Id(),
1013 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
1018 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
1021 //----------------------------------------------------------------------------
1024 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1028 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
1031 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1037 //----------------------------------------------------------------------------
1040 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1044 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1046 if (theErr && *theErr < 0)
1049 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1050 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1052 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1053 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1054 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1055 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1056 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1057 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1058 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1059 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1060 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1061 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1062 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1063 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1065 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1074 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1083 MEDmeshEntityNameWr(myFile->Id(),
1092 MEDmeshEntityNumberWr(myFile->Id(),
1103 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1106 //----------------------------------------------------------------------------
1109 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1111 EModeSwitch theMode,
1113 EBooleen theIsElemNum,
1114 EBooleen theIsElemNames)
1116 return PNodeInfo(new TTNodeInfo
1125 //----------------------------------------------------------------------------
1128 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1129 const TFloatVector& theNodeCoords,
1130 EModeSwitch theMode,
1132 const TStringVector& theCoordNames,
1133 const TStringVector& theCoordUnits,
1134 const TIntVector& theFamilyNums,
1135 const TIntVector& theElemNums,
1136 const TStringVector& theElemNames)
1138 return PNodeInfo(new TTNodeInfo
1150 //----------------------------------------------------------------------------
1153 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1154 const PNodeInfo& theInfo)
1156 return PNodeInfo(new TTNodeInfo
1161 //----------------------------------------------------------------------------
1164 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1167 TInt aNbElems = GetNbNodes(*theMeshInfo);
1168 if (aNbElems == 0) {
1172 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1173 GetNodeInfo(*anInfo, theErr);
1176 TInt aDim = theMeshInfo->myDim;
1177 TInt aNbElem = anInfo->GetNbElem();
1178 INITMSG(MYDEBUG, "GetPNodeInfo: ");
1180 INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
1181 TNodeCoord& aCoord = anInfo->myCoord;
1182 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1183 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1184 ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
1186 ADDMSG(MYVALUEDEBUG, " ");
1188 ADDMSG(MYDEBUG, std::endl);
1190 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
1191 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1192 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
1194 ADDMSG(MYVALUEDEBUG, std::endl);
1196 if (anInfo->IsElemNum()) {
1197 BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
1198 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1199 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
1201 ADDMSG(MYVALUEDEBUG, std::endl);
1204 ADDMSG(MYDEBUG, std::endl);
1210 //----------------------------------------------------------------------------
1213 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1215 EBooleen theIsElemNum,
1216 EBooleen theIsElemNames)
1218 return PElemInfo(new TTElemInfo
1225 //----------------------------------------------------------------------------
1228 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1230 const TIntVector& theFamNum,
1231 const TIntVector& aElemNum,
1232 const TStringVector& aElemNames)
1234 return PElemInfo(new TTElemInfo
1242 //----------------------------------------------------------------------------
1245 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1246 EEntiteMaillage theEntity,
1247 EGeometrieElement theGeom,
1248 EConnectivite theConnMode,
1251 EMaillage aType = theMeshInfo->GetType();
1252 if (aType == eNON_STRUCTURE) {
1255 if (theEntity == eNOEUD)
1256 return GetPNodeInfo(theMeshInfo, theErr);
1257 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1260 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1263 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1266 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1270 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1273 EBooleen theIsElemNum = eFAUX;
1277 nbElems = aGrille->GetNbNodes();
1278 theIsElemNum = eVRAI;
1283 nbElems = aGrille->GetNbCells();
1290 TIntVector aElemNum;
1291 TStringVector aElemNames;
1293 PElemInfo aElemInfo;
1295 if (theGeom == ePOINT1) {
1296 aElemInfo = CrElemInfo(theMeshInfo,
1299 MED::TElemInfo &aTElemInfo = *aElemInfo;
1301 // must be reimplemente in connection with mesh type eSTRUCTURE
1302 // GetNumeration(aTElemInfo,
1308 GetFamilies(aTElemInfo,
1314 // must be reimplemente in connection with mesh type eSTRUCTURE
1315 // GetNames(aTElemInfo,
1322 aElemInfo = CrElemInfo(theMeshInfo,
1334 //----------------------------------------------------------------------------
1337 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1338 EEntiteMaillage theEntity,
1339 EGeometrieElement theGeom,
1340 EConnectivite theConnMode,
1343 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1346 //----------------------------------------------------------------------------
1349 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1350 EEntiteMaillage theEntity,
1351 EGeometrieElement theGeom,
1352 EConnectivite theConnMode,
1355 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1357 if (theErr && *theErr < 0)
1360 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1362 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1363 med_int aTaille = 0;
1365 aTaille=MEDmeshnEntity(myFile->Id(),
1369 med_entity_type(theEntity),
1370 med_geometry_type(theGeom),
1372 med_connectivity_mode(theConnMode),
1377 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1379 return TInt(aTaille);
1382 //-----------------------------------------------------------------
1385 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1388 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1390 if (theErr && *theErr < 0)
1393 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1395 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1396 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1397 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1398 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1399 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1400 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1401 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1404 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1405 MED_NO_DT, MED_NO_IT,
1407 aConnMode, &anIndex, &aConn);
1412 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1414 if (theInfo.myIsElemNames) {
1415 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1420 if (theInfo.myIsElemNum) {
1421 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1426 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1431 //----------------------------------------------------------------------------
1434 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1437 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1440 //----------------------------------------------------------------------------
1443 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1447 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1449 if (theErr && *theErr < 0)
1452 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1453 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1455 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1456 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1457 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1458 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1459 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1460 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1462 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1463 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1465 aConnMode, anInfo.myNbElem + 1,
1470 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1472 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1476 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1480 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1485 //----------------------------------------------------------------------------
1488 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1489 EEntiteMaillage theEntity,
1490 EGeometrieElement theGeom,
1493 EConnectivite theConnMode,
1494 EBooleen theIsElemNum,
1495 EBooleen theIsElemNames)
1497 return PPolygoneInfo(new TTPolygoneInfo
1508 //----------------------------------------------------------------------------
1511 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1512 EEntiteMaillage theEntity,
1513 EGeometrieElement theGeom,
1514 const TIntVector& theIndexes,
1515 const TIntVector& theConnectivities,
1516 EConnectivite theConnMode,
1517 const TIntVector& theFamilyNums,
1518 const TIntVector& theElemNums,
1519 const TStringVector& theElemNames)
1521 return PPolygoneInfo(new TTPolygoneInfo
1533 //----------------------------------------------------------------------------
1536 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1537 const PPolygoneInfo& theInfo)
1539 return PPolygoneInfo(new TTPolygoneInfo
1544 //----------------------------------------------------------------------------
1547 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1548 EEntiteMaillage theEntity,
1549 EGeometrieElement theGeom,
1550 EConnectivite theConnMode)
1552 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1553 return PPolygoneInfo();
1555 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1556 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1557 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1558 GetPolygoneInfo(anInfo);
1561 INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
1562 " - theGeom = "<<theGeom<<
1563 "; aNbElem = "<<aNbElem<<": ");
1564 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1565 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1566 TInt aConnDim = aConnSlice.size();
1567 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1568 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1570 ADDMSG(MYDEBUG, " ");
1572 ADDMSG(MYDEBUG, std::endl);
1578 //----------------------------------------------------------------------------
1581 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1582 EEntiteMaillage theEntity,
1583 EGeometrieElement theGeom,
1584 EConnectivite theConnMode,
1587 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1590 //----------------------------------------------------------------------------
1593 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1596 EConnectivite theConnMode,
1599 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1601 if (theErr && *theErr < 0)
1602 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1604 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1606 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1607 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1608 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1609 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1611 med_bool chgt, trsf;
1612 theNbFaces = MEDmeshnEntity(myFile->Id(),
1623 theConnSize = MEDmeshnEntity(myFile->Id(),
1634 if (theNbFaces < 0 || theConnSize<0)
1635 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1639 //-----------------------------------------------------------------
1642 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1645 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1647 if (theErr && *theErr < 0)
1650 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1652 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1653 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1654 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1655 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1656 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1657 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1660 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1673 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1675 if (theInfo.myIsElemNames) {
1676 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1681 if (theInfo.myIsElemNum) {
1682 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1687 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1692 //----------------------------------------------------------------------------
1695 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1698 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1701 //----------------------------------------------------------------------------
1704 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1708 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1710 if (theErr && *theErr < 0)
1713 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1714 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1716 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1717 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1718 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1719 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1720 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1723 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1732 (TInt)anInfo.myFaces->size(),
1739 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1741 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1743 if (theInfo.myIsElemNames) {
1744 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1745 aRet = MEDmeshEntityNameWr(myFile->Id(),
1751 (TInt)anInfo.myElemNames->size(),
1756 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1759 if (theInfo.myIsElemNum) {
1760 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1761 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1767 (TInt)anInfo.myElemNum->size(),
1772 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1775 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1776 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1782 (TInt)anInfo.myFamNum->size(),
1788 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1791 //----------------------------------------------------------------------------
1794 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1795 EEntiteMaillage theEntity,
1796 EGeometrieElement theGeom,
1800 EConnectivite theConnMode,
1801 EBooleen theIsElemNum,
1802 EBooleen theIsElemNames)
1804 return PPolyedreInfo(new TTPolyedreInfo
1816 //----------------------------------------------------------------------------
1819 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1820 EEntiteMaillage theEntity,
1821 EGeometrieElement theGeom,
1822 const TIntVector& theIndexes,
1823 const TIntVector& theFaces,
1824 const TIntVector& theConnectivities,
1825 EConnectivite theConnMode,
1826 const TIntVector& theFamilyNums,
1827 const TIntVector& theElemNums,
1828 const TStringVector& theElemNames)
1830 return PPolyedreInfo(new TTPolyedreInfo
1843 //----------------------------------------------------------------------------
1846 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1847 const PPolyedreInfo& theInfo)
1849 return PPolyedreInfo(new TTPolyedreInfo
1854 //----------------------------------------------------------------------------
1857 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1858 EEntiteMaillage theEntity,
1859 EGeometrieElement theGeom,
1860 EConnectivite theConnMode)
1862 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1863 return PPolyedreInfo();
1864 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1865 TInt aNbFaces, aConnSize;
1866 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1867 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1868 GetPolyedreInfo(anInfo);
1871 INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
1872 " - theGeom = "<<theGeom<<
1873 "; aNbElem = "<<aNbElem<<": ");
1874 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1875 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1876 TInt aNbFaces = aConnSliceArr.size();
1877 ADDMSG(MYDEBUG, "{");
1878 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1879 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1880 TInt aNbConn = aConnSlice.size();
1881 ADDMSG(MYDEBUG, "[");
1882 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1883 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1885 ADDMSG(MYDEBUG, "] ");
1887 ADDMSG(MYDEBUG, "} ");
1889 ADDMSG(MYDEBUG, std::endl);
1895 //-----------------------------------------------------------------
1898 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1899 EConnectivite theConnMode,
1904 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1906 if (theErr && *theErr < 0)
1909 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1910 TInt aNbElem = GetNbNodes(theMeshInfo);
1912 anInfo[eNOEUD][ePOINT1] = aNbElem;
1913 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1914 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1915 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1916 for (; anIter != anIterEnd; anIter++) {
1917 const EEntiteMaillage& anEntity = anIter->first;
1918 const TGeomSet& aGeomSet = anIter->second;
1919 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1920 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1921 for (; anIter2 != anIterEnd2; anIter2++) {
1922 const EGeometrieElement& aGeom = *anIter2;
1923 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1925 if (anEntity == eSTRUCT_ELEMENT) {
1926 const TInt nbStructTypes = aNbElem;
1927 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1928 // check type name to keep only "MED_BALL" structured element
1929 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1930 char geotypename[ MED_NAME_SIZE + 1] = "";
1931 med_geometry_type geotype;
1932 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1933 med_entity_type(anEntity), structType+1,
1934 geotypename, &geotype);
1935 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1936 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1937 theConnMode, theErr);
1939 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1944 anInfo[anEntity][aGeom] = aNbElem;
1951 else { // eSTRUCTURE
1952 EGrilleType aGrilleType;
1956 TInt aDim = theMeshInfo.GetDim();
1957 EGeometrieElement aGeom, aSubGeom;
1958 EEntiteMaillage aSubEntity = eMAILLE;
1960 GetGrilleType(theMeshInfo, aGrilleType);
1962 TIntVector aStruct(aDim);
1963 if (aGrilleType == eGRILLE_STANDARD)
1965 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1968 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1969 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1970 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1971 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1973 for (med_int i = 0; i < aDim; i++) {
1974 aNbNodes = aNbNodes * aStruct[i];
1975 aNbElem = aNbElem * (aStruct[i] - 1);
1984 aSubEntity = eARETE;
1986 (aStruct[0]) * (aStruct[1]-1) +
1987 (aStruct[0]-1) * (aStruct[1]);
1994 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1995 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1996 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1999 anInfo[eNOEUD][ePOINT1] = aNbNodes;
2000 anInfo[eMAILLE][aGeom] = aNbElem;
2002 anInfo[aSubEntity][aSubGeom] = aNbSub;
2007 //-----------------------------------------------------------------
2010 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
2011 EEntiteMaillage theEntity,
2012 EGeometrieElement theGeom,
2013 EConnectivite theConnMode,
2016 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2018 if (theErr && *theErr < 0)
2021 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2022 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2023 med_bool chgt, trsf;
2026 case MED::ePOLYGONE:
2027 case MED::ePOLYGON2:
2029 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2030 MED_NO_DT, MED_NO_IT,
2031 med_entity_type(theEntity), med_geometry_type(theGeom),
2032 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2035 case MED::ePOLYEDRE:
2037 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2038 MED_NO_DT, MED_NO_IT,
2039 med_entity_type(theEntity), MED_POLYHEDRON,
2040 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2045 return GetNbBalls(theMeshInfo);
2049 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2050 MED_NO_DT, MED_NO_IT,
2051 med_entity_type(theEntity), med_geometry_type(theGeom),
2052 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2059 //----------------------------------------------------------------------------
2062 ::GetCellInfo(MED::TCellInfo& theInfo,
2065 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2067 if (theErr && *theErr < 0)
2070 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2072 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2073 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2074 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2075 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2076 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2077 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2078 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2079 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2080 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2081 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2082 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2083 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2087 aRet = MEDmeshnEntity(myFile->Id(),
2098 // names are present in the file, they will be read in spite of theInfo.myIsElemNames
2099 theInfo.myIsElemNames = eVRAI;
2100 theInfo.myElemNames.reset( new TString( theInfo.myNbElem * GetPNOMLength() + 1 ));
2101 anElemNames.myRepresentation = & ((TString&) theInfo.myElemNames )[0];
2104 aRet = MEDmeshElementRd(myFile->Id(),
2123 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2125 if (anIsFamNum == MED_FALSE)
2127 int mySize = (int) theInfo.myFamNum->size();
2128 theInfo.myFamNum->clear();
2129 theInfo.myFamNum->resize(mySize, 0);
2134 //----------------------------------------------------------------------------
2137 ::SetCellInfo(const MED::TCellInfo& theInfo,
2140 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2143 //----------------------------------------------------------------------------
2146 ::SetCellInfo(const MED::TCellInfo& theInfo,
2150 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2152 if (theErr && *theErr < 0)
2155 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2156 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2158 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2159 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2160 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2161 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2162 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2163 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2164 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2165 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2166 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2167 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2168 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2169 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2170 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2173 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2185 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2194 MEDmeshEntityNameWr(myFile->Id(),
2203 MEDmeshEntityNumberWr(myFile->Id(),
2214 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2217 //----------------------------------------------------------------------------
2220 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2221 EEntiteMaillage theEntity,
2222 EGeometrieElement theGeom,
2224 EConnectivite theConnMode,
2225 EBooleen theIsElemNum,
2226 EBooleen theIsElemNames,
2227 EModeSwitch theMode)
2229 return PCellInfo(new TTCellInfo
2240 //----------------------------------------------------------------------------
2243 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2244 EEntiteMaillage theEntity,
2245 EGeometrieElement theGeom,
2246 const TIntVector& theConnectivities,
2247 EConnectivite theConnMode,
2248 const TIntVector& theFamilyNums,
2249 const TIntVector& theElemNums,
2250 const TStringVector& theElemNames,
2251 EModeSwitch theMode)
2253 return PCellInfo(new TTCellInfo
2265 //----------------------------------------------------------------------------
2268 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2269 const PCellInfo& theInfo)
2271 return PCellInfo(new TTCellInfo
2276 //----------------------------------------------------------------------------
2279 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2280 EEntiteMaillage theEntity,
2281 EGeometrieElement theGeom,
2282 EConnectivite theConnMode,
2285 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2287 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2288 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2289 GetCellInfo(anInfo, theErr);
2292 TInt aConnDim = anInfo->GetConnDim();
2293 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2294 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2295 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2296 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2297 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2298 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2300 ADDMSG(MYVALUEDEBUG, " ");
2302 ADDMSG(MYDEBUG, std::endl);
2304 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2305 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2306 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2308 ADDMSG(MYVALUEDEBUG, std::endl);
2310 if (anInfo->IsElemNum()) {
2311 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2312 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2313 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2315 ADDMSG(MYVALUEDEBUG, std::endl);
2317 ADDMSG(MYDEBUG, std::endl);
2323 //----------------------------------------------------------------------------
2326 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2329 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2331 // read med_geometry_type of "MED_BALL" element
2332 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2333 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2336 //----------------------------------------------------------------------------
2339 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2342 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2344 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2348 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2351 //----------------------------------------------------------------------------
2354 ::GetBallInfo(TBallInfo& theInfo,
2357 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2359 // check geometry of MED_BALL
2360 if (theInfo.myGeom == eBALL)
2362 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2363 if (theInfo.myGeom < 0) {
2365 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2366 *theErr = theInfo.myGeom;
2372 GetCellInfo(theInfo);
2375 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2376 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2377 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2378 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2380 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2381 MED_NO_DT, MED_NO_IT,
2388 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2391 //----------------------------------------------------------------------------
2394 ::SetBallInfo(const TBallInfo& theInfo,
2397 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2400 //----------------------------------------------------------------------------
2403 ::SetBallInfo(const TBallInfo& theInfo,
2407 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2410 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2411 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2414 // no ball model in the file, create support mesh for it
2415 char dummyname [MED_NAME_SIZE*3+1] = "";
2416 if ((ret = MEDsupportMeshCr(myFile->Id(),
2418 theInfo.myMeshInfo->GetSpaceDim(),
2419 theInfo.myMeshInfo->GetDim(),
2420 "Support mesh for a ball model",
2422 /*axisname=*/dummyname,
2423 /*unitname=*/dummyname)) < 0) {
2425 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2429 // write coordinates of 1 node
2430 med_float coord[3] = {0, 0, 0};
2431 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2432 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2433 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2435 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2439 // ball model creation
2440 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2441 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2443 theInfo.myMeshInfo->GetSpaceDim(),
2445 MED_NODE,MED_NONE)) < 0) {
2447 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2451 // create diameter attribute
2452 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2453 geotypename, MED_BALL_DIAMETER,
2454 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2456 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2462 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2463 aBallInfo.myGeom = ballGeom;
2466 SetCellInfo(theInfo, theMode, theErr);
2467 if (theErr && *theErr < 0)
2471 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2472 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2473 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2474 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2475 MED_NO_DT, MED_NO_IT,
2476 aGeom, MED_BALL_DIAMETER,
2477 theInfo.myNbElem, &aDiam);
2481 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2484 //----------------------------------------------------------------------------
2487 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2489 EBooleen theIsElemNum)
2491 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2494 //----------------------------------------------------------------------------
2497 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2498 const TIntVector& theNodes,
2499 TFloatVector& theDiameters,
2500 const TIntVector& theFamilyNums,
2501 const TIntVector& theElemNums)
2503 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2504 theFamilyNums, theElemNums));
2507 //----------------------------------------------------------------------------
2510 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2511 const PBallInfo& theInfo)
2513 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2516 //----------------------------------------------------------------------------
2519 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2521 TInt nbBalls = GetNbBalls(theMeshInfo);
2522 if (nbBalls < 1) return PBallInfo();
2524 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2525 GetBallInfo(anInfo);
2530 //-----------------------------------------------------------------
2533 ::GetNbFields(TErr* theErr)
2535 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2537 if (theErr && *theErr < 0)
2540 return MEDnField(myFile->Id());
2543 //----------------------------------------------------------------------------
2546 ::GetNbComp(TInt theFieldId,
2549 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2551 if (theErr && *theErr < 0)
2554 return MEDfieldnComponent(myFile->Id(), theFieldId);
2557 //----------------------------------------------------------------------------
2560 ::GetFieldInfo(TInt theFieldId,
2561 MED::TFieldInfo& theInfo,
2564 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2566 if (theErr && *theErr < 0)
2569 TString aFieldName(256); // Protect from memory problems with too long names
2570 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2571 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2572 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2573 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2577 char dtunit[MED_SNAME_SIZE+1];
2578 char local_mesh_name[MED_NAME_SIZE+1]="";
2580 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2581 aRet = MEDfieldInfo(myFile->Id(),
2592 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2598 theInfo.SetName(aFieldName);
2603 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2606 //----------------------------------------------------------------------------
2609 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2613 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2616 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2622 //----------------------------------------------------------------------------
2625 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2629 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2631 if (theErr && *theErr < 0)
2634 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2636 TValueHolder<TString, char> aFieldName(anInfo.myName);
2637 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2638 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2639 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2640 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2642 char dtunit[MED_SNAME_SIZE+1];
2643 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2644 aRet = MEDfieldCr(myFile->Id(),
2651 &aMeshInfo.myName[0]);
2655 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2658 //----------------------------------------------------------------------------
2661 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2664 const std::string& theValue,
2665 EBooleen theIsLocal,
2668 return PFieldInfo(new TTFieldInfo
2677 //----------------------------------------------------------------------------
2680 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2681 const PFieldInfo& theInfo)
2683 return PFieldInfo(new TTFieldInfo
2688 //----------------------------------------------------------------------------
2691 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2695 TInt aNbComp = GetNbComp(theId);
2696 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2697 GetFieldInfo(theId, *anInfo, theErr);
2702 "- aName = '"<<anInfo->GetName()<<"'"<<
2703 "; aType = "<<anInfo->GetType()<<
2704 "; aNbComp = "<<aNbComp<<
2711 //----------------------------------------------------------------------------
2714 ::GetNbGauss(TErr* theErr)
2716 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2718 if (theErr && *theErr < 0)
2721 return MEDnLocalization(myFile->Id());
2724 //----------------------------------------------------------------------------
2727 ::GetGaussPreInfo(TInt theId,
2730 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2732 if (theErr && *theErr < 0)
2733 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2735 med_int aNbGaussPoints = med_int();
2736 TVector<char> aName(GetNOMLength()+1);
2737 med_geometry_type aGeom = MED_NONE;
2741 char geointerpname[MED_NAME_SIZE+1] = "";
2742 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2743 med_int nsectionmeshcell;
2744 med_geometry_type sectiongeotype;
2745 aRet = MEDlocalizationInfo (myFile->Id(),
2752 ipointstructmeshname,
2758 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2759 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2760 TInt(aNbGaussPoints));
2763 //----------------------------------------------------------------------------
2766 ::GetGaussInfo(TInt theId,
2767 TGaussInfo& theInfo,
2770 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2772 if (theErr && *theErr < 0)
2775 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2776 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2777 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2778 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2779 TValueHolder<TString, char> aGaussName(theInfo.myName);
2782 aRet = MEDlocalizationRd(myFile->Id(),
2792 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2795 //----------------------------------------------------------------------------
2798 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2799 EModeSwitch theMode)
2801 return PGaussInfo(new TTGaussInfo
2806 //-----------------------------------------------------------------
2809 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2810 const MED::TEntityInfo& theEntityInfo,
2811 EEntiteMaillage& theEntity,
2812 TGeom2Size& theGeom2Size,
2815 theEntity = EEntiteMaillage(-1);
2816 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2819 if (theEntityInfo.empty())
2824 else if (theEntityInfo.empty())
2825 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2827 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2829 theGeom2Size.clear();
2830 TInt aNbTimeStamps = 0;
2831 TIdt anId = myFile->Id();
2833 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2834 TValueHolder<TString, char> aFieldName(anInfo.myName);
2835 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2837 // workaround for IPAL13676
2838 MED::TEntityInfo localEntityInfo = theEntityInfo;
2839 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2840 if (anLocalIter != localEntityInfo.end()) {
2841 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2844 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2845 for (; anIter != localEntityInfo.end(); anIter++) {
2846 med_entity_type anEntity = med_entity_type(anIter->first);
2847 const TGeom2Size& aGeom2Size = anIter->second;
2848 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2849 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2850 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2851 char aMeshName[MED_NAME_SIZE+1];
2854 char dtunit[MED_SNAME_SIZE+1];
2855 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2856 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2857 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2859 MEDfieldInfoByName(anId,
2876 MEDfieldComputingStepInfo(anId,
2882 char profilename[MED_NAME_SIZE+1];
2883 char locname[MED_NAME_SIZE+1];
2887 // protection from crash (division by zero)
2888 // inside MEDfieldnValueWithProfile function
2889 // caused by the workaround for IPAL13676 (see above)
2890 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2893 nval = MEDfieldnValueWithProfile(anId,
2898 med_geometry_type(aGeom),
2906 bool anIsSatisfied =(nval > 0);
2907 if (anIsSatisfied) {
2909 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2910 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2911 if (anIsPerformAdditionalCheck) {
2912 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2913 if (!anIsSatisfied) {
2915 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2916 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2920 if (anIsSatisfied) {
2921 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2922 theEntity = EEntiteMaillage(anEntity);
2923 aNbTimeStamps = aNbStamps;
2926 if (!theGeom2Size.empty())
2929 return aNbTimeStamps;
2932 //----------------------------------------------------------------------------
2935 ::GetTimeStampInfo(TInt theTimeStampId,
2936 MED::TTimeStampInfo& theInfo,
2939 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2941 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2944 if (aGeom2Size.empty())
2949 else if (aGeom2Size.empty())
2950 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2952 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2953 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2955 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2956 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2957 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2958 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2959 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2960 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2961 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2962 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2963 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2965 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2967 // just to get a time stamp unit (anUnitDt)
2968 med_field_type aFieldType;
2969 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2970 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2971 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2973 MEDfieldInfoByName(myFile->Id(),
2982 delete [] aCompName;
2983 delete [] aCompUnit;
2985 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2986 for (; anIter != aGeom2Size.end(); anIter++) {
2987 const EGeometrieElement& aGeom = anIter->first;
2988 med_int aNbGauss = -1;
2991 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2997 char profilename[MED_NAME_SIZE+1];
2999 char locname[MED_NAME_SIZE+1];
3000 MEDfieldnValueWithProfile(myFile->Id(),
3005 med_geometry_type(aGeom),
3013 static TInt MAX_NB_GAUSS_POINTS = 32;
3014 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
3017 aGeom2NbGauss[aGeom] = aNbGauss;
3022 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
3026 //----------------------------------------------------------------------------
3029 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3030 EEntiteMaillage theEntity,
3031 const TGeom2Size& theGeom2Size,
3032 const TGeom2NbGauss& theGeom2NbGauss,
3036 const std::string& theUnitDt,
3037 const TGeom2Gauss& theGeom2Gauss)
3039 return PTimeStampInfo(new TTTimeStampInfo
3051 //----------------------------------------------------------------------------
3054 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3055 const PTimeStampInfo& theInfo)
3057 return PTimeStampInfo(new TTTimeStampInfo
3062 //----------------------------------------------------------------------------
3065 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3066 EEntiteMaillage theEntity,
3067 const TGeom2Size& theGeom2Size,
3071 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3072 GetTimeStampInfo(theId, *anInfo, theErr);
3075 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3076 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3077 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3078 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3079 const EGeometrieElement& aGeom = anIter->first;
3080 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3087 //----------------------------------------------------------------------------
3090 ::GetNbProfiles(TErr* theErr)
3092 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3094 if (theErr && *theErr < 0)
3097 return MEDnProfile(myFile->Id());
3100 //----------------------------------------------------------------------------
3103 ::GetProfilePreInfo(TInt theId,
3106 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3108 if (theErr && *theErr < 0)
3109 return TProfileInfo::TInfo();
3112 TVector<char> aName(GetNOMLength()+1);
3115 aRet = MEDprofileInfo(myFile->Id(),
3122 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3124 return TProfileInfo::TInfo(&aName[0], aSize);
3127 //----------------------------------------------------------------------------
3130 ::GetProfileInfo(TInt theId,
3131 TProfileInfo& theInfo,
3134 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3136 if (theErr && *theErr < 0)
3139 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3140 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3141 TValueHolder<TString, char> aProfileName(anInfo.myName);
3144 aRet = MEDprofileRd(myFile->Id(),
3150 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3153 //----------------------------------------------------------------------------
3156 ::SetProfileInfo(const TProfileInfo& theInfo,
3160 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3163 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3166 SetProfileInfo(theInfo, eCREATION, &aRet);
3172 //----------------------------------------------------------------------------
3175 ::SetProfileInfo(const TProfileInfo& theInfo,
3179 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3181 if (theErr && *theErr < 0)
3184 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3185 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3186 TValueHolder<TString, char> aProfileName(anInfo.myName);
3189 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3190 &aProfileName, // tableau de valeurs du profil.
3191 theInfo.GetSize(), // taille du profil.
3192 &anElemNum); // nom profil.
3196 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3199 //----------------------------------------------------------------------------
3202 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3203 EModeProfil theMode)
3205 return PProfileInfo(new TTProfileInfo
3210 //----------------------------------------------------------------------------
3213 ::GetPProfileInfo(TInt theId,
3214 EModeProfil theMode,
3217 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3218 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3219 GetProfileInfo(theId, *anInfo, theErr);
3224 //----------------------------------------------------------------------------
3227 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3228 const TMKey2Profile& theMKey2Profile,
3229 const TKey2Gauss& theKey2Gauss,
3232 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3234 if (theErr && *theErr < 0)
3237 TIdt anId = myFile->Id();
3239 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3240 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3242 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3243 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3244 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3245 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3247 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3248 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3249 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3251 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3252 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3254 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3255 TVector<char> aGaussName(GetNOMLength()+1);
3257 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3258 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3259 TVector<char> aProfileName(GetNOMLength()+1);
3261 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3262 TGeom2Size::iterator anIter = aGeom2Size.begin();
3263 for (; anIter != aGeom2Size.end(); anIter++) {
3264 EGeometrieElement aGeom = anIter->first;
3265 TInt aNbElem = anIter->second;
3266 med_int profilesize, aNbGauss;
3268 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3273 med_geometry_type(aGeom),
3286 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3289 TInt aNbComp = aFieldInfo->myNbComp;
3290 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3291 theTimeStampValue->AllocateValue(aGeom,
3295 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3298 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3299 "; aNbVal = "<<aNbVal<<
3300 "; aNbValue = "<<aNbValue<<
3301 "; aNbGauss = "<<aNbGauss<<
3302 "; aNbComp = "<<aNbComp<<
3305 TErr aRet = MEDfieldValueWithProfileRd(anId,
3310 med_geometry_type(aGeom),
3314 MED_ALL_CONSTITUENT,
3315 theTimeStampValue->GetValuePtr(aGeom));
3318 *theErr = MED_FALSE;
3321 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3324 MED::PGaussInfo aGaussInfo;
3325 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3326 if (strcmp(&aGaussName[0], "") != 0) {
3327 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3328 if (anIter != theKey2Gauss.end()) {
3329 aGaussInfo = anIter->second;
3330 aGeom2Gauss[aGeom] = aGaussInfo;
3334 MED::PProfileInfo aProfileInfo;
3335 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3336 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3337 if (anIter != aKey2Profile.end()) {
3338 aProfileInfo = anIter->second;
3339 aGeom2Profile[aGeom] = aProfileInfo;
3343 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3345 *theErr = MED_FALSE;
3348 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3351 if (aProfileInfo && aProfileInfo->IsPresent()) {
3352 TInt aNbSubElem = aProfileInfo->GetSize();
3353 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3354 if (aProfileSize != aValueSize) {
3359 EXCEPTION(std::runtime_error,
3360 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3361 ") != aValueSize("<<aValueSize<<
3362 "); aNbVal = "<<aNbVal<<
3363 "; anEntity = "<<anEntity<<
3364 "; aGeom = "<<aGeom<<
3365 "; aNbElem = "<<aNbElem<<
3366 "; aNbSubElem = "<<aNbSubElem<<
3367 "; aNbComp = "<<aNbComp<<
3368 "; aNbGauss = "<<aNbGauss<<
3373 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3378 EXCEPTION(std::runtime_error,
3379 "GetTimeStampValue - aNbElem("<<aNbElem<<
3380 ") != aNbValue("<<aNbValue<<
3381 "); aNbVal = "<<aNbVal<<
3382 "; anEntity = "<<anEntity<<
3383 "; aGeom = "<<aGeom<<
3384 "; aNbElem = "<<aNbElem<<
3385 "; aNbComp = "<<aNbComp<<
3386 "; aNbGauss = "<<aNbGauss<<
3393 //----------------------------------------------------------------------------
3396 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3400 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3403 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3409 //----------------------------------------------------------------------------
3412 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3416 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3418 if (theErr && *theErr < 0)
3422 TIdt anId = myFile->Id();
3424 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3425 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3427 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3428 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3429 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3430 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3431 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3432 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3433 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3435 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3436 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3438 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3439 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3441 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3442 TGeomSet::const_iterator anIter = aGeomSet.begin();
3443 for (; anIter != aGeomSet.end(); anIter++) {
3444 EGeometrieElement aGeom = *anIter;
3446 TVector<char> aGaussName(GetNOMLength()+1);
3447 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3448 if (aGaussIter != aGeom2Gauss.end()) {
3449 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3450 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3453 TVector<char> aProfileName(GetNOMLength()+1);
3454 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3455 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3456 if (aProfileIter != aGeom2Profile.end()) {
3457 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3458 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3459 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3462 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3464 aRet = MEDfieldValueWithProfileWr(anId,
3470 med_geometry_type(aGeom),
3475 MED_ALL_CONSTITUENT,
3477 theTimeStampValue->GetValuePtr(aGeom));
3480 *theErr = MED_FALSE;
3483 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3488 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3491 //----------------------------------------------------------------------------
3494 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3495 ETypeChamp theTypeChamp,
3496 const TGeom2Profile& theGeom2Profile,
3497 EModeSwitch theMode)
3499 if (theTypeChamp == eFLOAT64)
3500 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3505 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3512 //----------------------------------------------------------------------------
3515 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3516 const TGeom2Profile& theGeom2Profile,
3517 EModeSwitch theMode)
3519 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3520 return CrTimeStampValue(theTimeStampInfo,
3521 aFieldInfo->GetType(),
3526 //----------------------------------------------------------------------------
3529 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3530 const PTimeStampValueBase& theInfo,
3531 ETypeChamp theTypeChamp)
3533 if (theTypeChamp == eFLOAT64)
3534 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3538 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3544 //----------------------------------------------------------------------------
3547 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3548 const PTimeStampValueBase& theInfo)
3550 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3551 return CrTimeStampValue(theTimeStampInfo,
3553 aFieldInfo->GetType());
3556 //----------------------------------------------------------------------------
3559 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3560 const TMKey2Profile& theMKey2Profile,
3561 const TKey2Gauss& theKey2Gauss,
3564 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3565 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3566 aFieldInfo->GetType());
3567 GetTimeStampValue(anInfo,
3572 if (aFieldInfo->GetType() == eFLOAT64)
3573 Print<TFloatTimeStampValue>(anInfo);
3575 Print<TIntTimeStampValue>(anInfo);
3580 //----------------------------------------------------------------------------
3583 ::GetTimeStampVal(const PTimeStampVal& theVal,
3584 const TMKey2Profile& theMKey2Profile,
3585 const TKey2Gauss& theKey2Gauss,
3588 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3589 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3590 if (aFieldInfo->GetType() == eFLOAT64)
3591 GetTimeStampValue(theVal,
3596 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3599 GetTimeStampValue(aVal,
3603 CopyTimeStampValueBase(aVal, theVal);
3607 //----------------------------------------------------------------------------
3610 ::SetTimeStamp(const PTimeStampVal& theVal,
3613 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3614 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3615 if (aFieldInfo->GetType() == eFLOAT64)
3616 SetTimeStampValue(theVal, theErr);
3618 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3620 theVal->GetGeom2Profile(),
3621 theVal->GetModeSwitch());
3622 CopyTimeStampValueBase(theVal, aVal);
3623 SetTimeStampValue(aVal, theErr);
3627 //----------------------------------------------------------------------------
3630 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3631 const TGeom2Profile& theGeom2Profile,
3632 EModeSwitch theMode)
3634 return CrTimeStampValue(theTimeStampInfo,
3640 //----------------------------------------------------------------------------
3643 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3644 const PTimeStampVal& theInfo)
3646 return CrTimeStampValue(theTimeStampInfo,
3651 //----------------------------------------------------------------------------
3654 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3655 const TMKey2Profile& theMKey2Profile,
3656 const TKey2Gauss& theKey2Gauss,
3659 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3660 GetTimeStampVal(anInfo,
3667 //----------------------------------------------------------------------------
3670 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3672 if (theMeshInfo->GetType() != eSTRUCTURE)
3673 return PGrilleInfo();
3676 GetGrilleType(*theMeshInfo, type);
3678 if (type == eGRILLE_STANDARD) {
3679 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3680 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3684 aVec.resize(theMeshInfo->GetDim());
3685 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3686 ETable aATable = eCOOR_IND1;
3689 aATable = eCOOR_IND1;
3692 aATable = eCOOR_IND2;
3695 aATable = eCOOR_IND3;
3698 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3700 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3703 GetGrilleInfo(anInfo);
3704 anInfo->SetGrilleType(type);
3707 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3709 TInt aNbElem = anInfo->GetNbNodes();
3710 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3711 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3712 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3714 TInt aNbCells = anInfo->GetNbCells();
3715 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3716 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3717 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3719 ADDMSG(MYVALUEDEBUG, std::endl);
3720 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3721 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3722 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3724 ADDMSG(MYVALUEDEBUG, std::endl);
3725 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3726 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3727 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3729 ADDMSG(MYVALUEDEBUG, std::endl);
3737 //----------------------------------------------------------------------------
3740 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3741 const PGrilleInfo& theInfo)
3743 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3747 //----------------------------------------------------------------------------
3750 ::GetGrilleInfo(TGrilleInfo& theInfo,
3753 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3755 if (theErr && *theErr < 0)
3758 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3759 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3760 EMaillage aMaillageType = aMeshInfo.myType;
3762 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3763 EGrilleType aGrilleType = theInfo.myGrilleType;
3766 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3767 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3769 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3770 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3771 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3772 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3773 //med_axis_type aRepere;
3775 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3785 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3787 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3788 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3790 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3799 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3801 int mySize = (int)theInfo.myFamNumNode.size();
3802 theInfo.myFamNumNode.clear();
3803 theInfo.myFamNumNode.resize(mySize,0);
3807 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3812 //============================
3815 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3816 ETable aTable = eCOOR_IND1;
3817 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3820 aTable = eCOOR_IND1;
3823 aTable = eCOOR_IND2;
3826 aTable = eCOOR_IND3;
3835 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3837 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3839 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3841 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3842 //TValueHolder<ETable, med_data_type > table(aTable);
3843 //char aCompNames[MED_SNAME_SIZE+1];
3844 //char anUnitNames[MED_SNAME_SIZE+1];
3845 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3847 MED_NO_DT,MED_NO_IT,
3851 //theInfo.SetCoordName(anAxis-1, aCompNames);
3852 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3853 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3858 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3862 EGeometrieElement aGeom = theInfo.GetGeom();
3863 EEntiteMaillage aEntity = theInfo.GetEntity();
3864 TInt aNbCells = theInfo.GetNbCells();
3866 theInfo.myFamNum.resize(aNbCells);
3867 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3869 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3870 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3871 med_geometry_type(aGeom), &aFamNum);
3873 if (aMeshInfo.myDim == 3)
3875 aGeom = theInfo.GetSubGeom();
3876 aEntity = theInfo.GetSubEntity();
3877 aNbCells = theInfo.GetNbSubCells();
3879 theInfo.myFamSubNum.resize(aNbCells, 0);
3880 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3882 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3886 med_entity_type(aEntity),
3887 med_geometry_type(aGeom),
3891 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3893 int mySize = (int)theInfo.myFamNumNode.size();
3894 theInfo.myFamNumNode.clear();
3895 theInfo.myFamNumNode.resize(mySize, 0);
3899 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3905 //----------------------------------------------------------------------------
3908 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3911 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3914 //----------------------------------------------------------------------------
3917 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3921 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3923 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3925 if (theErr && *theErr < 0)
3928 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3930 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3931 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3933 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3936 aRet = MEDmeshGridTypeRd(myFile->Id(),
3942 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3944 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3945 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3946 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3947 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3948 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3949 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3950 //med_axis_type aRepere = MED_CARTESIAN;
3952 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3962 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3964 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3965 aRet = MEDmeshGridStructWr(myFile->Id(),
3972 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3976 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3977 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3983 anInfo.GetIndexes(aAxis).size(),
3984 &anInfo.GetIndexes(aAxis)[0]);
3987 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3995 //----------------------------------------------------------------------------
3998 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3999 const PGrilleInfo& theInfo)
4001 return PGrilleInfo(new TTGrilleInfo
4006 //----------------------------------------------------------------------------
4009 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
4011 return PGrilleInfo(); // not implemented????
4014 //----------------------------------------------------------------------------
4017 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4018 const EGrilleType& type)
4020 return PGrilleInfo(new TTGrilleInfo
4025 //----------------------------------------------------------------------------
4028 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4029 const EGrilleType& type,
4030 const TInt& nbNodes)
4032 return PGrilleInfo(new TTGrilleInfo
4038 //----------------------------------------------------------------------------
4041 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4042 const EGrilleType& type,
4043 const MED::TIntVector& nbNodeVec)
4045 return PGrilleInfo(new TTGrilleInfo
4051 //----------------------------------------------------------------------------
4054 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4055 EGrilleType& theGridType,
4058 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4060 if (theErr && *theErr < 0)
4061 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4063 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4065 if (aMeshInfo.myType == eSTRUCTURE) {
4066 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4067 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4068 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4073 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4077 //----------------------------------------------------------------------------
4080 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4081 TIntVector& theStruct,
4084 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4086 if (theErr && *theErr < 0)
4090 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4092 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4093 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4095 aRet = MEDmeshGridStructRd(myFile->Id(),
4103 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");