1 // Copyright (C) 2007-2016 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 theMinor=-1):
84 myFileName(theFileName),
87 if ((myMinor < 0) || (myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
96 Open(EModeAcces theMode,
100 const char* aFileName = myFileName.c_str();
101 myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), MED_MAJOR_NUM, myMinor, MED_RELEASE_NUM);
104 *theErr = TErr(myFid);
106 EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<<myFileName<<"',"<<theMode<<"',"<< MED_MAJOR_NUM<<"',"<< myMinor<<"',"<< MED_RELEASE_NUM<<")");
113 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
127 std::string myFileName;
131 //---------------------------------------------------------------
138 TFileWrapper(const PFile& theFile,
145 if (myMinor < 0) myMinor = MED_MINOR_NUM;
146 myFile->Open(theMode, theErr);
155 //----------------------------------------------------------------------------
156 template<class TimeStampValueType>
158 Print(SharedPtr<TimeStampValueType> theTimeStampValue)
160 INITMSG(MYDEBUG,"Print - TimeStampValue\n");
161 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
162 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
163 for (; anIter != aGeom2Value.end(); anIter++) {
164 const EGeometrieElement& aGeom = anIter->first;
165 const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
166 TInt aNbElem = aMeshValue.myNbElem;
167 TInt aNbGauss = aMeshValue.myNbGauss;
168 TInt aNbComp = aMeshValue.myNbComp;
169 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
170 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
171 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
172 aMeshValue.GetGaussValueSliceArr(iElem);
173 ADDMSG(MYVALUEDEBUG, "{");
174 for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
175 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
176 aValueSliceArr[iGauss];
177 for (TInt iComp = 0; iComp < aNbComp; iComp++) {
178 ADDMSG(MYVALUEDEBUG, aValueSlice[iComp]<<" ");
180 ADDMSG(MYVALUEDEBUG, "| ");
182 ADDMSG(MYVALUEDEBUG, "} ");
184 ADDMSG(MYDEBUG, "\n");
188 //---------------------------------------------------------------
190 ::TWrapper(const std::string& theFileName, TInt theMinor):
192 myFile(new TFile(theFileName, theMinor))
195 myFile->Open(eLECTURE_ECRITURE, &aRet);
198 // myFile->Open(eLECTURE_AJOUT, &aRet);
202 myFile->Open(eLECTURE, &aRet);
206 myFile->Open(eCREATION, &aRet);
210 //----------------------------------------------------------------------------
216 //----------------------------------------------------------------------------
219 ::GetNbMeshes(TErr* theErr)
221 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
223 if (theErr && *theErr < 0)
226 return MEDnMesh(myFile->Id());
229 //----------------------------------------------------------------------------
232 ::GetMeshInfo(TInt theMeshId,
233 MED::TMeshInfo& theInfo,
236 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
238 if (theErr && *theErr < 0)
241 TValueHolder<TString, char> aMeshName(theInfo.myName);
242 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
243 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
244 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
245 char dtunit[MED_SNAME_SIZE+1];
246 med_sorting_type sorttype;
249 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
250 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
251 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
252 TErr aRet = MEDmeshInfo(myFile->Id(),
268 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
271 //----------------------------------------------------------------------------
274 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
278 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
281 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
284 SetMeshInfo(theInfo, eCREATION, &aRet);
290 //----------------------------------------------------------------------------
293 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
297 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
299 if (theErr && *theErr < 0)
302 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
304 TValueHolder<TString, char> aMeshName(anInfo.myName);
305 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
306 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
307 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
308 TValueHolder<TString, char> aDesc(anInfo.myDesc);
310 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
311 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
312 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
313 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
314 TErr aRet = MEDmeshCr(myFile->Id(),
329 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
331 INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
336 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
339 //----------------------------------------------------------------------------
342 ::CrMeshInfo(TInt theDim,
344 const std::string& theValue,
346 const std::string& theDesc)
348 return PMeshInfo(new TTMeshInfo
356 //----------------------------------------------------------------------------
359 ::CrMeshInfo(const PMeshInfo& theInfo)
361 return PMeshInfo(new TTMeshInfo(theInfo));
364 //----------------------------------------------------------------------------
367 ::GetPMeshInfo(TInt theId,
370 PMeshInfo anInfo = CrMeshInfo();
371 GetMeshInfo(theId, *anInfo, theErr);
375 //----------------------------------------------------------------------------
378 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
381 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
383 if (theErr && *theErr < 0)
386 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
387 TValueHolder<TString, char> aName(anInfo.myName);
388 return MEDnFamily(myFile->Id(), &aName);
391 //----------------------------------------------------------------------------
394 ::GetNbFamAttr(TInt theFamId,
395 const MED::TMeshInfo& theInfo,
398 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
400 if (theErr && *theErr < 0)
403 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
405 TValueHolder<TString, char> aName(anInfo.myName);
407 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
410 //----------------------------------------------------------------------------
413 ::GetNbFamGroup(TInt theFamId,
414 const MED::TMeshInfo& theInfo,
417 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
419 if (theErr && *theErr < 0)
422 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
424 TValueHolder<TString, char> aName(anInfo.myName);
426 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
429 //----------------------------------------------------------------------------
432 ::GetFamilyInfo(TInt theFamId,
433 MED::TFamilyInfo& theInfo,
436 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
438 if (theErr && *theErr < 0)
441 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
443 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
444 TValueHolder<TString, char> aFamilyName(theInfo.myName);
445 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
446 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
447 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
448 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
449 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
451 TErr aRet = MEDfamily23Info(myFile->Id(),
464 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
465 " aMeshInfo.myName = '"<<&aMeshName<<
466 "'; theFamId = "<<theFamId<<
467 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
468 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
471 //----------------------------------------------------------------------------
474 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
478 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
481 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
487 //----------------------------------------------------------------------------
490 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
494 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
496 if (theErr && *theErr < 0)
499 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
500 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
502 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
503 TValueHolder<TString, char> aFamilyName(anInfo.myName);
504 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
505 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
506 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
507 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
508 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
509 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
510 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
512 TErr aRet = MEDfamilyCr(myFile->Id(),
519 INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
524 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
527 //----------------------------------------------------------------------------
530 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
534 const std::string& theValue)
536 return PFamilyInfo(new TTFamilyInfo
544 //----------------------------------------------------------------------------
547 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
548 const std::string& theValue,
550 const MED::TStringSet& theGroupNames,
551 const MED::TStringVector& theAttrDescs,
552 const MED::TIntVector& theAttrIds,
553 const MED::TIntVector& theAttrVals)
555 return PFamilyInfo(new TTFamilyInfo
565 //----------------------------------------------------------------------------
568 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
569 const PFamilyInfo& theInfo)
571 return PFamilyInfo(new TTFamilyInfo
576 //----------------------------------------------------------------------------
579 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
583 // must be reimplemented in connection with mesh type eSTRUCTURE
584 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
585 // return PFamilyInfo();
587 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
588 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
589 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
590 GetFamilyInfo(theId, *anInfo, theErr);
593 std::string aName = anInfo->GetName();
594 INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
595 "'; andId = "<<anInfo->GetId()<<
596 "; aNbAttr = "<<aNbAttr<<
597 "; aNbGroup = "<<aNbGroup<<"\n");
598 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
599 aName = anInfo->GetGroupName(iGroup);
600 INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
607 //----------------------------------------------------------------------------
610 ::GetNames(TElemInfo& theInfo,
612 EEntiteMaillage theEntity,
613 EGeometrieElement theGeom,
616 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
618 if (theErr && *theErr < 0)
621 if (theGeom == eBALL)
622 theGeom = GetBallGeom(theInfo.myMeshInfo);
624 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
626 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
627 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
628 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
629 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
631 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
639 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
645 //----------------------------------------------------------------------------
648 ::SetNames(const TElemInfo& theInfo,
649 EEntiteMaillage theEntity,
650 EGeometrieElement theGeom,
653 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
656 //----------------------------------------------------------------------------
659 ::SetNames(const TElemInfo& theInfo,
661 EEntiteMaillage theEntity,
662 EGeometrieElement theGeom,
665 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
667 if (theErr && *theErr < 0)
670 if (theGeom == eBALL)
671 theGeom = GetBallGeom(theInfo.myMeshInfo);
673 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
674 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
677 if (theInfo.myIsElemNames) {
678 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
679 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
680 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
681 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
683 aRet = MEDmeshEntityNameWr(myFile->Id(),
689 (TInt)anInfo.myElemNames->size(),
694 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
698 //----------------------------------------------------------------------------
701 ::GetNumeration(TElemInfo& theInfo,
703 EEntiteMaillage theEntity,
704 EGeometrieElement theGeom,
707 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
709 if (theErr && *theErr < 0)
712 if (theGeom == eBALL)
713 theGeom = GetBallGeom(theInfo.myMeshInfo);
715 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
717 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
718 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
719 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
720 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
722 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
730 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
736 //----------------------------------------------------------------------------
739 ::SetNumeration(const TElemInfo& theInfo,
740 EEntiteMaillage theEntity,
741 EGeometrieElement theGeom,
744 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
747 //----------------------------------------------------------------------------
750 ::SetNumeration(const TElemInfo& theInfo,
752 EEntiteMaillage theEntity,
753 EGeometrieElement theGeom,
756 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
758 if (theErr && *theErr < 0)
761 if (theGeom == eBALL)
762 theGeom = GetBallGeom(theInfo.myMeshInfo);
764 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
765 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
768 if (theInfo.myIsElemNum) {
769 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
770 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
771 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
772 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
774 aRet = MEDmeshEntityNumberWr(myFile->Id(),
780 (TInt)anInfo.myElemNum->size(),
785 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
789 //----------------------------------------------------------------------------
792 ::GetFamilies(TElemInfo& theInfo,
794 EEntiteMaillage theEntity,
795 EGeometrieElement theGeom,
798 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
800 if (theErr && *theErr < 0)
803 if (theGeom == eBALL)
804 theGeom = GetBallGeom(theInfo.myMeshInfo);
806 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
808 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
809 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
810 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
811 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
813 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
822 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
824 int aSize = (int)theInfo.myFamNum->size();
825 theInfo.myFamNum->clear();
826 theInfo.myFamNum->resize(aSize,0);
830 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
836 //----------------------------------------------------------------------------
839 ::SetFamilies(const TElemInfo& theInfo,
840 EEntiteMaillage theEntity,
841 EGeometrieElement theGeom,
844 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
847 //----------------------------------------------------------------------------
850 ::SetFamilies(const TElemInfo& theInfo,
852 EEntiteMaillage theEntity,
853 EGeometrieElement theGeom,
856 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
858 if (theErr && *theErr < 0)
861 if (theGeom == eBALL)
862 theGeom = GetBallGeom(theInfo.myMeshInfo);
864 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
865 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
867 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
868 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
869 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
870 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
872 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
878 (TInt)anInfo.myFamNum->size(),
884 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
887 //----------------------------------------------------------------------------
890 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
893 return GetNbNodes(theMeshInfo, eCOOR, theErr);
896 //----------------------------------------------------------------------------
899 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
903 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
905 if (theErr && *theErr < 0)
908 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
910 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
911 TValueHolder<ETable, med_data_type > aTable(theTable);
913 return MEDmeshnEntity(myFile->Id(),
925 //----------------------------------------------------------------------------
928 ::GetNodeInfo(MED::TNodeInfo& theInfo,
931 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
933 if (theErr && *theErr < 0)
936 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
938 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
939 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
940 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
941 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
942 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
943 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
944 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
945 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
946 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
947 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
948 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
949 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
950 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
952 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
959 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
967 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
969 int mySize = (int)theInfo.myFamNum->size();
970 theInfo.myFamNum->clear();
971 theInfo.myFamNum->resize(mySize,0);
974 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
977 if (MEDmeshEntityNameRd(myFile->Id(),
983 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
985 if (MEDmeshEntityNumberRd(myFile->Id(),
991 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
996 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
999 //----------------------------------------------------------------------------
1002 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1006 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
1009 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1015 //----------------------------------------------------------------------------
1018 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1022 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1024 if (theErr && *theErr < 0)
1027 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1028 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1030 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1031 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1032 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1033 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1034 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1035 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1036 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1037 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1038 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1039 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1040 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1041 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1043 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1052 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1061 MEDmeshEntityNameWr(myFile->Id(),
1070 MEDmeshEntityNumberWr(myFile->Id(),
1081 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1084 //----------------------------------------------------------------------------
1087 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1089 EModeSwitch theMode,
1091 EBooleen theIsElemNum,
1092 EBooleen theIsElemNames)
1094 return PNodeInfo(new TTNodeInfo
1103 //----------------------------------------------------------------------------
1106 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1107 const TFloatVector& theNodeCoords,
1108 EModeSwitch theMode,
1110 const TStringVector& theCoordNames,
1111 const TStringVector& theCoordUnits,
1112 const TIntVector& theFamilyNums,
1113 const TIntVector& theElemNums,
1114 const TStringVector& theElemNames)
1116 return PNodeInfo(new TTNodeInfo
1128 //----------------------------------------------------------------------------
1131 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1132 const PNodeInfo& theInfo)
1134 return PNodeInfo(new TTNodeInfo
1139 //----------------------------------------------------------------------------
1142 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1145 TInt aNbElems = GetNbNodes(*theMeshInfo);
1146 if (aNbElems == 0) {
1150 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1151 GetNodeInfo(*anInfo, theErr);
1154 TInt aDim = theMeshInfo->myDim;
1155 TInt aNbElem = anInfo->GetNbElem();
1156 INITMSG(MYDEBUG, "GetPNodeInfo: ");
1158 INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
1159 TNodeCoord& aCoord = anInfo->myCoord;
1160 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1161 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1162 ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
1164 ADDMSG(MYVALUEDEBUG, " ");
1166 ADDMSG(MYDEBUG, std::endl);
1168 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
1169 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1170 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
1172 ADDMSG(MYVALUEDEBUG, std::endl);
1174 if (anInfo->IsElemNum()) {
1175 BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
1176 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1177 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
1179 ADDMSG(MYVALUEDEBUG, std::endl);
1182 ADDMSG(MYDEBUG, std::endl);
1188 //----------------------------------------------------------------------------
1191 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1193 EBooleen theIsElemNum,
1194 EBooleen theIsElemNames)
1196 return PElemInfo(new TTElemInfo
1203 //----------------------------------------------------------------------------
1206 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1208 const TIntVector& theFamNum,
1209 const TIntVector& aElemNum,
1210 const TStringVector& aElemNames)
1212 return PElemInfo(new TTElemInfo
1220 //----------------------------------------------------------------------------
1223 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1224 EEntiteMaillage theEntity,
1225 EGeometrieElement theGeom,
1226 EConnectivite theConnMode,
1229 EMaillage aType = theMeshInfo->GetType();
1230 if (aType == eNON_STRUCTURE) {
1233 if (theEntity == eNOEUD)
1234 return GetPNodeInfo(theMeshInfo, theErr);
1235 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1238 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1241 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1244 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1248 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1251 EBooleen theIsElemNum = eFAUX;
1255 nbElems = aGrille->GetNbNodes();
1256 theIsElemNum = eVRAI;
1261 nbElems = aGrille->GetNbCells();
1268 TIntVector aElemNum;
1269 TStringVector aElemNames;
1271 PElemInfo aElemInfo;
1273 if (theGeom == ePOINT1) {
1274 aElemInfo = CrElemInfo(theMeshInfo,
1277 MED::TElemInfo &aTElemInfo = *aElemInfo;
1279 // must be reimplemente in connection with mesh type eSTRUCTURE
1280 // GetNumeration(aTElemInfo,
1286 GetFamilies(aTElemInfo,
1292 // must be reimplemente in connection with mesh type eSTRUCTURE
1293 // GetNames(aTElemInfo,
1300 aElemInfo = CrElemInfo(theMeshInfo,
1312 //----------------------------------------------------------------------------
1315 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1316 EEntiteMaillage theEntity,
1317 EGeometrieElement theGeom,
1318 EConnectivite theConnMode,
1321 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1324 //----------------------------------------------------------------------------
1327 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1328 EEntiteMaillage theEntity,
1329 EGeometrieElement theGeom,
1330 EConnectivite theConnMode,
1333 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1335 if (theErr && *theErr < 0)
1338 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1340 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1341 med_int aTaille = 0;
1343 aTaille=MEDmeshnEntity(myFile->Id(),
1347 med_entity_type(theEntity),
1348 med_geometry_type(theGeom),
1350 med_connectivity_mode(theConnMode),
1355 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1357 return TInt(aTaille);
1360 //-----------------------------------------------------------------
1363 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1366 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1368 if (theErr && *theErr < 0)
1371 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1373 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1374 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1375 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1376 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1377 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1378 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1379 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1382 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1383 MED_NO_DT, MED_NO_IT,
1385 aConnMode, &anIndex, &aConn);
1390 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1392 if (theInfo.myIsElemNames) {
1393 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1398 if (theInfo.myIsElemNum) {
1399 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1404 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1409 //----------------------------------------------------------------------------
1412 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1415 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1418 //----------------------------------------------------------------------------
1421 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1425 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1427 if (theErr && *theErr < 0)
1430 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1431 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1433 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1434 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1435 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1436 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1437 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1438 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1440 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1441 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1443 aConnMode, anInfo.myNbElem + 1,
1448 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1450 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1454 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1458 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1463 //----------------------------------------------------------------------------
1466 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1467 EEntiteMaillage theEntity,
1468 EGeometrieElement theGeom,
1471 EConnectivite theConnMode,
1472 EBooleen theIsElemNum,
1473 EBooleen theIsElemNames)
1475 return PPolygoneInfo(new TTPolygoneInfo
1486 //----------------------------------------------------------------------------
1489 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1490 EEntiteMaillage theEntity,
1491 EGeometrieElement theGeom,
1492 const TIntVector& theIndexes,
1493 const TIntVector& theConnectivities,
1494 EConnectivite theConnMode,
1495 const TIntVector& theFamilyNums,
1496 const TIntVector& theElemNums,
1497 const TStringVector& theElemNames)
1499 return PPolygoneInfo(new TTPolygoneInfo
1511 //----------------------------------------------------------------------------
1514 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1515 const PPolygoneInfo& theInfo)
1517 return PPolygoneInfo(new TTPolygoneInfo
1522 //----------------------------------------------------------------------------
1525 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1526 EEntiteMaillage theEntity,
1527 EGeometrieElement theGeom,
1528 EConnectivite theConnMode)
1530 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1531 return PPolygoneInfo();
1533 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1534 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1535 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1536 GetPolygoneInfo(anInfo);
1539 INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
1540 " - theGeom = "<<theGeom<<
1541 "; aNbElem = "<<aNbElem<<": ");
1542 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1543 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1544 TInt aConnDim = aConnSlice.size();
1545 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1546 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1548 ADDMSG(MYDEBUG, " ");
1550 ADDMSG(MYDEBUG, std::endl);
1556 //----------------------------------------------------------------------------
1559 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1560 EEntiteMaillage theEntity,
1561 EGeometrieElement theGeom,
1562 EConnectivite theConnMode,
1565 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1568 //----------------------------------------------------------------------------
1571 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1574 EConnectivite theConnMode,
1577 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1579 if (theErr && *theErr < 0)
1580 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1582 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1584 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1585 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1586 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1587 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1589 med_bool chgt, trsf;
1590 theNbFaces = MEDmeshnEntity(myFile->Id(),
1601 theConnSize = MEDmeshnEntity(myFile->Id(),
1612 if (theNbFaces < 0 || theConnSize<0)
1613 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1617 //-----------------------------------------------------------------
1620 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1623 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1625 if (theErr && *theErr < 0)
1628 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1630 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1631 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1632 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1633 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1634 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1635 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1638 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1651 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1653 if (theInfo.myIsElemNames) {
1654 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1659 if (theInfo.myIsElemNum) {
1660 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1665 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1670 //----------------------------------------------------------------------------
1673 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1676 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1679 //----------------------------------------------------------------------------
1682 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1686 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1688 if (theErr && *theErr < 0)
1691 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1692 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1694 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1695 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1696 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1697 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1698 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1701 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1710 (TInt)anInfo.myFaces->size(),
1717 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1719 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1721 if (theInfo.myIsElemNames) {
1722 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1723 aRet = MEDmeshEntityNameWr(myFile->Id(),
1729 (TInt)anInfo.myElemNames->size(),
1734 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1737 if (theInfo.myIsElemNum) {
1738 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1739 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1745 (TInt)anInfo.myElemNum->size(),
1750 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1753 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1754 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1760 (TInt)anInfo.myFamNum->size(),
1766 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1769 //----------------------------------------------------------------------------
1772 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1773 EEntiteMaillage theEntity,
1774 EGeometrieElement theGeom,
1778 EConnectivite theConnMode,
1779 EBooleen theIsElemNum,
1780 EBooleen theIsElemNames)
1782 return PPolyedreInfo(new TTPolyedreInfo
1794 //----------------------------------------------------------------------------
1797 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1798 EEntiteMaillage theEntity,
1799 EGeometrieElement theGeom,
1800 const TIntVector& theIndexes,
1801 const TIntVector& theFaces,
1802 const TIntVector& theConnectivities,
1803 EConnectivite theConnMode,
1804 const TIntVector& theFamilyNums,
1805 const TIntVector& theElemNums,
1806 const TStringVector& theElemNames)
1808 return PPolyedreInfo(new TTPolyedreInfo
1821 //----------------------------------------------------------------------------
1824 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1825 const PPolyedreInfo& theInfo)
1827 return PPolyedreInfo(new TTPolyedreInfo
1832 //----------------------------------------------------------------------------
1835 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1836 EEntiteMaillage theEntity,
1837 EGeometrieElement theGeom,
1838 EConnectivite theConnMode)
1840 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1841 return PPolyedreInfo();
1842 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1843 TInt aNbFaces, aConnSize;
1844 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1845 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1846 GetPolyedreInfo(anInfo);
1849 INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
1850 " - theGeom = "<<theGeom<<
1851 "; aNbElem = "<<aNbElem<<": ");
1852 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1853 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1854 TInt aNbFaces = aConnSliceArr.size();
1855 ADDMSG(MYDEBUG, "{");
1856 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1857 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1858 TInt aNbConn = aConnSlice.size();
1859 ADDMSG(MYDEBUG, "[");
1860 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1861 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1863 ADDMSG(MYDEBUG, "] ");
1865 ADDMSG(MYDEBUG, "} ");
1867 ADDMSG(MYDEBUG, std::endl);
1873 //-----------------------------------------------------------------
1876 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1877 EConnectivite theConnMode,
1882 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1884 if (theErr && *theErr < 0)
1887 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1888 TInt aNbElem = GetNbNodes(theMeshInfo);
1890 anInfo[eNOEUD][ePOINT1] = aNbElem;
1891 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1892 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1893 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1894 for (; anIter != anIterEnd; anIter++) {
1895 const EEntiteMaillage& anEntity = anIter->first;
1896 const TGeomSet& aGeomSet = anIter->second;
1897 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1898 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1899 for (; anIter2 != anIterEnd2; anIter2++) {
1900 const EGeometrieElement& aGeom = *anIter2;
1901 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1903 if (anEntity == eSTRUCT_ELEMENT) {
1904 const TInt nbStructTypes = aNbElem;
1905 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1906 // check type name to keep only "MED_BALL" structured element
1907 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1908 char geotypename[ MED_NAME_SIZE + 1] = "";
1909 med_geometry_type geotype;
1910 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1911 med_entity_type(anEntity), structType+1,
1912 geotypename, &geotype);
1913 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1914 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1915 theConnMode, theErr);
1917 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1922 anInfo[anEntity][aGeom] = aNbElem;
1929 else { // eSTRUCTURE
1930 EGrilleType aGrilleType;
1934 TInt aDim = theMeshInfo.GetDim();
1935 EGeometrieElement aGeom, aSubGeom;
1936 EEntiteMaillage aSubEntity = eMAILLE;
1938 GetGrilleType(theMeshInfo, aGrilleType);
1940 TIntVector aStruct(aDim);
1941 if (aGrilleType == eGRILLE_STANDARD)
1943 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1946 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1947 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1948 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1949 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1951 for (med_int i = 0; i < aDim; i++) {
1952 aNbNodes = aNbNodes * aStruct[i];
1953 aNbElem = aNbElem * (aStruct[i] - 1);
1962 aSubEntity = eARETE;
1964 (aStruct[0]) * (aStruct[1]-1) +
1965 (aStruct[0]-1) * (aStruct[1]);
1972 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1973 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1974 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1977 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1978 anInfo[eMAILLE][aGeom] = aNbElem;
1980 anInfo[aSubEntity][aSubGeom] = aNbSub;
1985 //-----------------------------------------------------------------
1988 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1989 EEntiteMaillage theEntity,
1990 EGeometrieElement theGeom,
1991 EConnectivite theConnMode,
1994 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1996 if (theErr && *theErr < 0)
1999 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2000 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2001 med_bool chgt, trsf;
2004 case MED::ePOLYGONE:
2005 case MED::ePOLYGON2:
2007 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2008 MED_NO_DT, MED_NO_IT,
2009 med_entity_type(theEntity), med_geometry_type(theGeom),
2010 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2013 case MED::ePOLYEDRE:
2015 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2016 MED_NO_DT, MED_NO_IT,
2017 med_entity_type(theEntity), MED_POLYHEDRON,
2018 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2023 return GetNbBalls(theMeshInfo);
2027 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2028 MED_NO_DT, MED_NO_IT,
2029 med_entity_type(theEntity), med_geometry_type(theGeom),
2030 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2037 //----------------------------------------------------------------------------
2040 ::GetCellInfo(MED::TCellInfo& theInfo,
2043 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2045 if (theErr && *theErr < 0)
2048 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2050 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2051 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2052 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2053 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2054 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2055 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2056 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2057 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2058 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2059 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2060 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2061 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2064 aRet = MEDmeshElementRd(myFile->Id(),
2083 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2085 if (anIsFamNum == MED_FALSE)
2087 int mySize = (int) theInfo.myFamNum->size();
2088 theInfo.myFamNum->clear();
2089 theInfo.myFamNum->resize(mySize, 0);
2094 //----------------------------------------------------------------------------
2097 ::SetCellInfo(const MED::TCellInfo& theInfo,
2100 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2103 //----------------------------------------------------------------------------
2106 ::SetCellInfo(const MED::TCellInfo& theInfo,
2110 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2112 if (theErr && *theErr < 0)
2115 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2116 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2118 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2119 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2120 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2121 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2122 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2123 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2124 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2125 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2126 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2127 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2128 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2129 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2130 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2133 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2145 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2154 MEDmeshEntityNameWr(myFile->Id(),
2163 MEDmeshEntityNumberWr(myFile->Id(),
2174 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2177 //----------------------------------------------------------------------------
2180 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2181 EEntiteMaillage theEntity,
2182 EGeometrieElement theGeom,
2184 EConnectivite theConnMode,
2185 EBooleen theIsElemNum,
2186 EBooleen theIsElemNames,
2187 EModeSwitch theMode)
2189 return PCellInfo(new TTCellInfo
2200 //----------------------------------------------------------------------------
2203 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2204 EEntiteMaillage theEntity,
2205 EGeometrieElement theGeom,
2206 const TIntVector& theConnectivities,
2207 EConnectivite theConnMode,
2208 const TIntVector& theFamilyNums,
2209 const TIntVector& theElemNums,
2210 const TStringVector& theElemNames,
2211 EModeSwitch theMode)
2213 return PCellInfo(new TTCellInfo
2225 //----------------------------------------------------------------------------
2228 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2229 const PCellInfo& theInfo)
2231 return PCellInfo(new TTCellInfo
2236 //----------------------------------------------------------------------------
2239 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2240 EEntiteMaillage theEntity,
2241 EGeometrieElement theGeom,
2242 EConnectivite theConnMode,
2245 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2247 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2248 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2249 GetCellInfo(anInfo, theErr);
2252 TInt aConnDim = anInfo->GetConnDim();
2253 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2254 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2255 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2256 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2257 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2258 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2260 ADDMSG(MYVALUEDEBUG, " ");
2262 ADDMSG(MYDEBUG, std::endl);
2264 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2265 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2266 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2268 ADDMSG(MYVALUEDEBUG, std::endl);
2270 if (anInfo->IsElemNum()) {
2271 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2272 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2273 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2275 ADDMSG(MYVALUEDEBUG, std::endl);
2277 ADDMSG(MYDEBUG, std::endl);
2283 //----------------------------------------------------------------------------
2286 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2289 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2291 // read med_geometry_type of "MED_BALL" element
2292 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2293 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2296 //----------------------------------------------------------------------------
2299 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2302 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2304 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2308 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2311 //----------------------------------------------------------------------------
2314 ::GetBallInfo(TBallInfo& theInfo,
2317 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2319 // check geometry of MED_BALL
2320 if (theInfo.myGeom == eBALL)
2322 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2323 if (theInfo.myGeom < 0) {
2325 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2326 *theErr = theInfo.myGeom;
2332 GetCellInfo(theInfo);
2335 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2336 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2337 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2338 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2340 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2341 MED_NO_DT, MED_NO_IT,
2348 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2351 //----------------------------------------------------------------------------
2354 ::SetBallInfo(const TBallInfo& theInfo,
2357 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2360 //----------------------------------------------------------------------------
2363 ::SetBallInfo(const TBallInfo& theInfo,
2367 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2370 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2371 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2374 // no ball model in the file, create support mesh for it
2375 char dummyname [MED_NAME_SIZE*3+1] = "";
2376 if ((ret = MEDsupportMeshCr(myFile->Id(),
2378 theInfo.myMeshInfo->GetSpaceDim(),
2379 theInfo.myMeshInfo->GetDim(),
2380 "Support mesh for a ball model",
2382 /*axisname=*/dummyname,
2383 /*unitname=*/dummyname)) < 0) {
2385 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2389 // write coordinates of 1 node
2390 med_float coord[3] = {0, 0, 0};
2391 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2392 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2393 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2395 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2399 // ball model creation
2400 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2401 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2403 theInfo.myMeshInfo->GetSpaceDim(),
2405 MED_NODE,MED_NONE)) < 0) {
2407 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2411 // create diameter attribute
2412 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2413 geotypename, MED_BALL_DIAMETER,
2414 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2416 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2422 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2423 aBallInfo.myGeom = ballGeom;
2426 SetCellInfo(theInfo, theMode, theErr);
2427 if (theErr && theErr < 0)
2431 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2432 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2433 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2434 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2435 MED_NO_DT, MED_NO_IT,
2436 aGeom, MED_BALL_DIAMETER,
2437 theInfo.myNbElem, &aDiam);
2441 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2444 //----------------------------------------------------------------------------
2447 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2449 EBooleen theIsElemNum)
2451 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2454 //----------------------------------------------------------------------------
2457 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2458 const TIntVector& theNodes,
2459 TFloatVector& theDiameters,
2460 const TIntVector& theFamilyNums,
2461 const TIntVector& theElemNums)
2463 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2464 theFamilyNums, theElemNums));
2467 //----------------------------------------------------------------------------
2470 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2471 const PBallInfo& theInfo)
2473 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2476 //----------------------------------------------------------------------------
2479 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2481 TInt nbBalls = GetNbBalls(theMeshInfo);
2482 if (nbBalls < 1) return PBallInfo();
2484 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2485 GetBallInfo(anInfo);
2490 //-----------------------------------------------------------------
2493 ::GetNbFields(TErr* theErr)
2495 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2497 if (theErr && *theErr < 0)
2500 return MEDnField(myFile->Id());
2503 //----------------------------------------------------------------------------
2506 ::GetNbComp(TInt theFieldId,
2509 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2511 if (theErr && *theErr < 0)
2514 return MEDfieldnComponent(myFile->Id(), theFieldId);
2517 //----------------------------------------------------------------------------
2520 ::GetFieldInfo(TInt theFieldId,
2521 MED::TFieldInfo& theInfo,
2524 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2526 if (theErr && *theErr < 0)
2529 TString aFieldName(256); // Protect from memory problems with too long names
2530 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2531 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2532 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2533 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2537 char dtunit[MED_SNAME_SIZE+1];
2538 char local_mesh_name[MED_NAME_SIZE+1]="";
2540 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2541 aRet = MEDfieldInfo(myFile->Id(),
2552 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2558 theInfo.SetName(aFieldName);
2563 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2566 //----------------------------------------------------------------------------
2569 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2573 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2576 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2582 //----------------------------------------------------------------------------
2585 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2589 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2591 if (theErr && *theErr < 0)
2594 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2596 TValueHolder<TString, char> aFieldName(anInfo.myName);
2597 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2598 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2599 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2600 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2602 char dtunit[MED_SNAME_SIZE+1];
2603 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2604 aRet = MEDfieldCr(myFile->Id(),
2611 &aMeshInfo.myName[0]);
2615 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2618 //----------------------------------------------------------------------------
2621 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2624 const std::string& theValue,
2625 EBooleen theIsLocal,
2628 return PFieldInfo(new TTFieldInfo
2637 //----------------------------------------------------------------------------
2640 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2641 const PFieldInfo& theInfo)
2643 return PFieldInfo(new TTFieldInfo
2648 //----------------------------------------------------------------------------
2651 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2655 TInt aNbComp = GetNbComp(theId);
2656 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2657 GetFieldInfo(theId, *anInfo, theErr);
2662 "- aName = '"<<anInfo->GetName()<<"'"<<
2663 "; aType = "<<anInfo->GetType()<<
2664 "; aNbComp = "<<aNbComp<<
2671 //----------------------------------------------------------------------------
2674 ::GetNbGauss(TErr* theErr)
2676 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2678 if (theErr && *theErr < 0)
2681 return MEDnLocalization(myFile->Id());
2684 //----------------------------------------------------------------------------
2687 ::GetGaussPreInfo(TInt theId,
2690 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2692 if (theErr && *theErr < 0)
2693 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2695 med_int aNbGaussPoints = med_int();
2696 TVector<char> aName(GetNOMLength()+1);
2697 med_geometry_type aGeom = MED_NONE;
2701 char geointerpname[MED_NAME_SIZE+1] = "";
2702 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2703 med_int nsectionmeshcell;
2704 med_geometry_type sectiongeotype;
2705 aRet = MEDlocalizationInfo (myFile->Id(),
2712 ipointstructmeshname,
2718 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2719 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2720 TInt(aNbGaussPoints));
2723 //----------------------------------------------------------------------------
2726 ::GetGaussInfo(TInt theId,
2727 TGaussInfo& theInfo,
2730 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2732 if (theErr && *theErr < 0)
2735 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2736 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2737 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2738 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2739 TValueHolder<TString, char> aGaussName(theInfo.myName);
2742 aRet = MEDlocalizationRd(myFile->Id(),
2752 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2755 //----------------------------------------------------------------------------
2758 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2759 EModeSwitch theMode)
2761 return PGaussInfo(new TTGaussInfo
2766 //-----------------------------------------------------------------
2769 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2770 const MED::TEntityInfo& theEntityInfo,
2771 EEntiteMaillage& theEntity,
2772 TGeom2Size& theGeom2Size,
2775 theEntity = EEntiteMaillage(-1);
2776 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2779 if (theEntityInfo.empty())
2784 else if (theEntityInfo.empty())
2785 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2787 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2789 theGeom2Size.clear();
2790 TInt aNbTimeStamps = 0;
2791 TIdt anId = myFile->Id();
2793 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2794 TValueHolder<TString, char> aFieldName(anInfo.myName);
2795 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2797 // workaround for IPAL13676
2798 MED::TEntityInfo localEntityInfo = theEntityInfo;
2799 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2800 if (anLocalIter != localEntityInfo.end()) {
2801 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2804 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2805 for (; anIter != localEntityInfo.end(); anIter++) {
2806 med_entity_type anEntity = med_entity_type(anIter->first);
2807 const TGeom2Size& aGeom2Size = anIter->second;
2808 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2809 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2810 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2811 char aMeshName[MED_NAME_SIZE+1];
2814 char dtunit[MED_SNAME_SIZE+1];
2815 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2816 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2817 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2819 MEDfieldInfoByName(anId,
2836 MEDfieldComputingStepInfo(anId,
2842 char profilename[MED_NAME_SIZE+1];
2843 char locname[MED_NAME_SIZE+1];
2847 // protection from crash (division by zero)
2848 // inside MEDfieldnValueWithProfile function
2849 // caused by the workaround for IPAL13676 (see above)
2850 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2853 nval = MEDfieldnValueWithProfile(anId,
2858 med_geometry_type(aGeom),
2866 bool anIsSatisfied =(nval > 0);
2867 if (anIsSatisfied) {
2869 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2870 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2871 if (anIsPerformAdditionalCheck) {
2872 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2873 if (!anIsSatisfied) {
2875 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2876 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2880 if (anIsSatisfied) {
2881 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2882 theEntity = EEntiteMaillage(anEntity);
2883 aNbTimeStamps = aNbStamps;
2886 if (!theGeom2Size.empty())
2889 return aNbTimeStamps;
2892 //----------------------------------------------------------------------------
2895 ::GetTimeStampInfo(TInt theTimeStampId,
2896 MED::TTimeStampInfo& theInfo,
2899 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2901 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2904 if (aGeom2Size.empty())
2909 else if (aGeom2Size.empty())
2910 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2912 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2913 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2915 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2916 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2917 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2918 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2919 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2920 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2921 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2922 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2923 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2925 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2927 // just to get a time stamp unit (anUnitDt)
2928 med_field_type aFieldType;
2929 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2930 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2931 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2933 MEDfieldInfoByName(myFile->Id(),
2942 delete [] aCompName;
2943 delete [] aCompUnit;
2945 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2946 for (; anIter != aGeom2Size.end(); anIter++) {
2947 const EGeometrieElement& aGeom = anIter->first;
2948 med_int aNbGauss = -1;
2951 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2957 char profilename[MED_NAME_SIZE+1];
2959 char locname[MED_NAME_SIZE+1];
2960 MEDfieldnValueWithProfile(myFile->Id(),
2965 med_geometry_type(aGeom),
2973 static TInt MAX_NB_GAUSS_POINTS = 32;
2974 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2977 aGeom2NbGauss[aGeom] = aNbGauss;
2982 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2986 //----------------------------------------------------------------------------
2989 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
2990 EEntiteMaillage theEntity,
2991 const TGeom2Size& theGeom2Size,
2992 const TGeom2NbGauss& theGeom2NbGauss,
2996 const std::string& theUnitDt,
2997 const TGeom2Gauss& theGeom2Gauss)
2999 return PTimeStampInfo(new TTTimeStampInfo
3011 //----------------------------------------------------------------------------
3014 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3015 const PTimeStampInfo& theInfo)
3017 return PTimeStampInfo(new TTTimeStampInfo
3022 //----------------------------------------------------------------------------
3025 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3026 EEntiteMaillage theEntity,
3027 const TGeom2Size& theGeom2Size,
3031 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3032 GetTimeStampInfo(theId, *anInfo, theErr);
3035 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3036 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3037 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3038 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3039 const EGeometrieElement& aGeom = anIter->first;
3040 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3047 //----------------------------------------------------------------------------
3050 ::GetNbProfiles(TErr* theErr)
3052 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3054 if (theErr && *theErr < 0)
3057 return MEDnProfile(myFile->Id());
3060 //----------------------------------------------------------------------------
3063 ::GetProfilePreInfo(TInt theId,
3066 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3068 if (theErr && *theErr < 0)
3069 return TProfileInfo::TInfo();
3072 TVector<char> aName(GetNOMLength()+1);
3075 aRet = MEDprofileInfo(myFile->Id(),
3082 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3084 return TProfileInfo::TInfo(&aName[0], aSize);
3087 //----------------------------------------------------------------------------
3090 ::GetProfileInfo(TInt theId,
3091 TProfileInfo& theInfo,
3094 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3096 if (theErr && *theErr < 0)
3099 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3100 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3101 TValueHolder<TString, char> aProfileName(anInfo.myName);
3104 aRet = MEDprofileRd(myFile->Id(),
3110 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3113 //----------------------------------------------------------------------------
3116 ::SetProfileInfo(const TProfileInfo& theInfo,
3120 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3123 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3126 SetProfileInfo(theInfo, eCREATION, &aRet);
3132 //----------------------------------------------------------------------------
3135 ::SetProfileInfo(const TProfileInfo& theInfo,
3139 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3141 if (theErr && *theErr < 0)
3144 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3145 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3146 TValueHolder<TString, char> aProfileName(anInfo.myName);
3149 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3150 &aProfileName, // tableau de valeurs du profil.
3151 theInfo.GetSize(), // taille du profil.
3152 &anElemNum); // nom profil.
3156 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3159 //----------------------------------------------------------------------------
3162 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3163 EModeProfil theMode)
3165 return PProfileInfo(new TTProfileInfo
3170 //----------------------------------------------------------------------------
3173 ::GetPProfileInfo(TInt theId,
3174 EModeProfil theMode,
3177 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3178 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3179 GetProfileInfo(theId, *anInfo, theErr);
3184 //----------------------------------------------------------------------------
3187 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3188 const TMKey2Profile& theMKey2Profile,
3189 const TKey2Gauss& theKey2Gauss,
3192 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3194 if (theErr && *theErr < 0)
3197 TIdt anId = myFile->Id();
3199 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3200 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3202 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3203 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3204 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3205 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3207 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3208 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3209 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3211 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3212 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3214 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3215 TVector<char> aGaussName(GetNOMLength()+1);
3217 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3218 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3219 TVector<char> aProfileName(GetNOMLength()+1);
3221 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3222 TGeom2Size::iterator anIter = aGeom2Size.begin();
3223 for (; anIter != aGeom2Size.end(); anIter++) {
3224 EGeometrieElement aGeom = anIter->first;
3225 TInt aNbElem = anIter->second;
3226 med_int profilesize, aNbGauss;
3228 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3233 med_geometry_type(aGeom),
3246 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3249 TInt aNbComp = aFieldInfo->myNbComp;
3250 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3251 theTimeStampValue->AllocateValue(aGeom,
3255 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3258 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3259 "; aNbVal = "<<aNbVal<<
3260 "; aNbValue = "<<aNbValue<<
3261 "; aNbGauss = "<<aNbGauss<<
3262 "; aNbComp = "<<aNbComp<<
3265 TErr aRet = MEDfieldValueWithProfileRd(anId,
3270 med_geometry_type(aGeom),
3274 MED_ALL_CONSTITUENT,
3275 theTimeStampValue->GetValuePtr(aGeom));
3278 *theErr = MED_FALSE;
3281 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3284 MED::PGaussInfo aGaussInfo;
3285 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3286 if (strcmp(&aGaussName[0], "") != 0) {
3287 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3288 if (anIter != theKey2Gauss.end()) {
3289 aGaussInfo = anIter->second;
3290 aGeom2Gauss[aGeom] = aGaussInfo;
3294 MED::PProfileInfo aProfileInfo;
3295 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3296 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3297 if (anIter != aKey2Profile.end()) {
3298 aProfileInfo = anIter->second;
3299 aGeom2Profile[aGeom] = aProfileInfo;
3303 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3305 *theErr = MED_FALSE;
3308 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3311 if (aProfileInfo && aProfileInfo->IsPresent()) {
3312 TInt aNbSubElem = aProfileInfo->GetSize();
3313 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3314 if (aProfileSize != aValueSize) {
3319 EXCEPTION(std::runtime_error,
3320 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3321 ") != aValueSize("<<aValueSize<<
3322 "); aNbVal = "<<aNbVal<<
3323 "; anEntity = "<<anEntity<<
3324 "; aGeom = "<<aGeom<<
3325 "; aNbElem = "<<aNbElem<<
3326 "; aNbSubElem = "<<aNbSubElem<<
3327 "; aNbComp = "<<aNbComp<<
3328 "; aNbGauss = "<<aNbGauss<<
3333 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3338 EXCEPTION(std::runtime_error,
3339 "GetTimeStampValue - aNbElem("<<aNbElem<<
3340 ") != aNbValue("<<aNbValue<<
3341 "); aNbVal = "<<aNbVal<<
3342 "; anEntity = "<<anEntity<<
3343 "; aGeom = "<<aGeom<<
3344 "; aNbElem = "<<aNbElem<<
3345 "; aNbComp = "<<aNbComp<<
3346 "; aNbGauss = "<<aNbGauss<<
3353 //----------------------------------------------------------------------------
3356 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3360 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3363 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3369 //----------------------------------------------------------------------------
3372 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3376 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3378 if (theErr && *theErr < 0)
3382 TIdt anId = myFile->Id();
3384 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3385 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3387 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3388 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3389 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3390 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3391 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3392 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3393 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3395 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3396 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3398 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3399 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3401 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3402 TGeomSet::const_iterator anIter = aGeomSet.begin();
3403 for (; anIter != aGeomSet.end(); anIter++) {
3404 EGeometrieElement aGeom = *anIter;
3406 TVector<char> aGaussName(GetNOMLength()+1);
3407 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3408 if (aGaussIter != aGeom2Gauss.end()) {
3409 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3410 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3413 TVector<char> aProfileName(GetNOMLength()+1);
3414 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3415 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3416 if (aProfileIter != aGeom2Profile.end()) {
3417 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3418 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3419 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3422 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3424 aRet = MEDfieldValueWithProfileWr(anId,
3430 med_geometry_type(aGeom),
3435 MED_ALL_CONSTITUENT,
3437 theTimeStampValue->GetValuePtr(aGeom));
3440 *theErr = MED_FALSE;
3443 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3448 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3451 //----------------------------------------------------------------------------
3454 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3455 ETypeChamp theTypeChamp,
3456 const TGeom2Profile& theGeom2Profile,
3457 EModeSwitch theMode)
3459 if (theTypeChamp == eFLOAT64)
3460 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3465 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3472 //----------------------------------------------------------------------------
3475 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3476 const TGeom2Profile& theGeom2Profile,
3477 EModeSwitch theMode)
3479 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3480 return CrTimeStampValue(theTimeStampInfo,
3481 aFieldInfo->GetType(),
3486 //----------------------------------------------------------------------------
3489 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3490 const PTimeStampValueBase& theInfo,
3491 ETypeChamp theTypeChamp)
3493 if (theTypeChamp == eFLOAT64)
3494 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3498 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3504 //----------------------------------------------------------------------------
3507 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3508 const PTimeStampValueBase& theInfo)
3510 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3511 return CrTimeStampValue(theTimeStampInfo,
3513 aFieldInfo->GetType());
3516 //----------------------------------------------------------------------------
3519 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3520 const TMKey2Profile& theMKey2Profile,
3521 const TKey2Gauss& theKey2Gauss,
3524 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3525 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3526 aFieldInfo->GetType());
3527 GetTimeStampValue(anInfo,
3532 if (aFieldInfo->GetType() == eFLOAT64)
3533 Print<TFloatTimeStampValue>(anInfo);
3535 Print<TIntTimeStampValue>(anInfo);
3540 //----------------------------------------------------------------------------
3543 ::GetTimeStampVal(const PTimeStampVal& theVal,
3544 const TMKey2Profile& theMKey2Profile,
3545 const TKey2Gauss& theKey2Gauss,
3548 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3549 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3550 if (aFieldInfo->GetType() == eFLOAT64)
3551 GetTimeStampValue(theVal,
3556 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3559 GetTimeStampValue(aVal,
3563 CopyTimeStampValueBase(aVal, theVal);
3567 //----------------------------------------------------------------------------
3570 ::SetTimeStamp(const PTimeStampVal& theVal,
3573 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3574 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3575 if (aFieldInfo->GetType() == eFLOAT64)
3576 SetTimeStampValue(theVal, theErr);
3578 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3580 theVal->GetGeom2Profile(),
3581 theVal->GetModeSwitch());
3582 CopyTimeStampValueBase(theVal, aVal);
3583 SetTimeStampValue(aVal, theErr);
3587 //----------------------------------------------------------------------------
3590 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3591 const TGeom2Profile& theGeom2Profile,
3592 EModeSwitch theMode)
3594 return CrTimeStampValue(theTimeStampInfo,
3600 //----------------------------------------------------------------------------
3603 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3604 const PTimeStampVal& theInfo)
3606 return CrTimeStampValue(theTimeStampInfo,
3611 //----------------------------------------------------------------------------
3614 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3615 const TMKey2Profile& theMKey2Profile,
3616 const TKey2Gauss& theKey2Gauss,
3619 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3620 GetTimeStampVal(anInfo,
3627 //----------------------------------------------------------------------------
3630 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3632 if (theMeshInfo->GetType() != eSTRUCTURE)
3633 return PGrilleInfo();
3636 GetGrilleType(*theMeshInfo, type);
3638 if (type == eGRILLE_STANDARD) {
3639 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3640 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3644 aVec.resize(theMeshInfo->GetDim());
3645 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3646 ETable aATable = eCOOR_IND1;
3649 aATable = eCOOR_IND1;
3652 aATable = eCOOR_IND2;
3655 aATable = eCOOR_IND3;
3658 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3660 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3663 GetGrilleInfo(anInfo);
3664 anInfo->SetGrilleType(type);
3667 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3669 TInt aNbElem = anInfo->GetNbNodes();
3670 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3671 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3672 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3674 TInt aNbCells = anInfo->GetNbCells();
3675 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3676 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3677 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3679 ADDMSG(MYVALUEDEBUG, std::endl);
3680 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3681 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3682 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3684 ADDMSG(MYVALUEDEBUG, std::endl);
3685 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3686 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3687 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3689 ADDMSG(MYVALUEDEBUG, std::endl);
3697 //----------------------------------------------------------------------------
3700 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3701 const PGrilleInfo& theInfo)
3703 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3707 //----------------------------------------------------------------------------
3710 ::GetGrilleInfo(TGrilleInfo& theInfo,
3713 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3715 if (theErr && *theErr < 0)
3718 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3719 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3720 EMaillage aMaillageType = aMeshInfo.myType;
3722 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3723 EGrilleType aGrilleType = theInfo.myGrilleType;
3726 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3727 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3729 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3730 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3731 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3732 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3733 //med_axis_type aRepere;
3735 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3745 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3747 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3748 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3750 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3759 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3761 int mySize = (int)theInfo.myFamNumNode.size();
3762 theInfo.myFamNumNode.clear();
3763 theInfo.myFamNumNode.resize(mySize,0);
3767 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3772 //============================
3775 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3776 ETable aTable = eCOOR_IND1;
3777 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3780 aTable = eCOOR_IND1;
3783 aTable = eCOOR_IND2;
3786 aTable = eCOOR_IND3;
3795 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3797 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3799 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3801 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3802 //TValueHolder<ETable, med_data_type > table(aTable);
3803 //char aCompNames[MED_SNAME_SIZE+1];
3804 //char anUnitNames[MED_SNAME_SIZE+1];
3805 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3807 MED_NO_DT,MED_NO_IT,
3811 //theInfo.SetCoordName(anAxis-1, aCompNames);
3812 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3813 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3818 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3822 EGeometrieElement aGeom = theInfo.GetGeom();
3823 EEntiteMaillage aEntity = theInfo.GetEntity();
3824 TInt aNbCells = theInfo.GetNbCells();
3826 theInfo.myFamNum.resize(aNbCells);
3827 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3829 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3830 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3831 med_geometry_type(aGeom), &aFamNum);
3833 if (aMeshInfo.myDim == 3)
3835 aGeom = theInfo.GetSubGeom();
3836 aEntity = theInfo.GetSubEntity();
3837 aNbCells = theInfo.GetNbSubCells();
3839 theInfo.myFamSubNum.resize(aNbCells, 0);
3840 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3842 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3846 med_entity_type(aEntity),
3847 med_geometry_type(aGeom),
3851 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3853 int mySize = (int)theInfo.myFamNumNode.size();
3854 theInfo.myFamNumNode.clear();
3855 theInfo.myFamNumNode.resize(mySize, 0);
3859 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3865 //----------------------------------------------------------------------------
3868 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3871 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3874 //----------------------------------------------------------------------------
3877 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3881 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3883 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3885 if (theErr && *theErr < 0)
3888 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3890 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3891 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3893 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3896 aRet = MEDmeshGridTypeRd(myFile->Id(),
3902 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3904 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3905 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3906 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3907 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3908 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3909 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3910 //med_axis_type aRepere = MED_CARTESIAN;
3912 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3922 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3924 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3925 aRet = MEDmeshGridStructWr(myFile->Id(),
3932 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3936 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3937 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3943 anInfo.GetIndexes(aAxis).size(),
3944 &anInfo.GetIndexes(aAxis)[0]);
3947 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3955 //----------------------------------------------------------------------------
3958 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3959 const PGrilleInfo& theInfo)
3961 return PGrilleInfo(new TTGrilleInfo
3966 //----------------------------------------------------------------------------
3969 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
3971 return PGrilleInfo(); // not implemented????
3974 //----------------------------------------------------------------------------
3977 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3978 const EGrilleType& type)
3980 return PGrilleInfo(new TTGrilleInfo
3985 //----------------------------------------------------------------------------
3988 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3989 const EGrilleType& type,
3990 const TInt& nbNodes)
3992 return PGrilleInfo(new TTGrilleInfo
3998 //----------------------------------------------------------------------------
4001 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4002 const EGrilleType& type,
4003 const MED::TIntVector& nbNodeVec)
4005 return PGrilleInfo(new TTGrilleInfo
4011 //----------------------------------------------------------------------------
4014 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4015 EGrilleType& theGridType,
4018 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4020 if (theErr && *theErr < 0)
4021 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4023 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4025 if (aMeshInfo.myType == eSTRUCTURE) {
4026 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4027 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4028 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4033 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4037 //----------------------------------------------------------------------------
4040 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4041 TIntVector& theStruct,
4044 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4046 if (theErr && *theErr < 0)
4050 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4052 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4053 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4055 aRet = MEDmeshGridStructRd(myFile->Id(),
4063 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");