1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MED_Wrapper.hxx"
24 #include "MED_TStructures.hxx"
25 #include "MED_Utilities.hxx"
29 #include <med_proto.h>
31 #include <boost/version.hpp>
34 static int MYDEBUG = 0;
35 static int MYVALUEDEBUG = 0;
37 static int MYDEBUG = 0;
38 static int MYVALUEDEBUG = 0;
43 //---------------------------------------------------------------
45 ::TLockProxy(TWrapper* theWrapper):
48 #if BOOST_VERSION >= 103500
49 myWrapper->myMutex.lock();
51 boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
53 INITMSG(MYDEBUG, "TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
59 INITMSG(MYDEBUG, "~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
60 #if BOOST_VERSION >= 103500
61 myWrapper->myMutex.unlock();
63 boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
69 ::operator->() const // never throws
74 //---------------------------------------------------------------
81 TFile(const std::string& theFileName, TInt 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, bool write, TInt theMinor):
191 myFile(new TFile(theFileName, theMinor)),
196 myFile->Open(eLECTURE_ECRITURE, &aRet);
199 myFile->Open(eCREATION, &aRet);
203 myFile->Open(eLECTURE, &aRet);
207 //----------------------------------------------------------------------------
213 //----------------------------------------------------------------------------
216 ::GetNbMeshes(TErr* theErr)
218 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
220 if (theErr && *theErr < 0)
223 return MEDnMesh(myFile->Id());
226 //----------------------------------------------------------------------------
229 ::GetMeshInfo(TInt theMeshId,
230 MED::TMeshInfo& theInfo,
233 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
235 if (theErr && *theErr < 0)
238 TValueHolder<TString, char> aMeshName(theInfo.myName);
239 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
240 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
241 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
242 char dtunit[MED_SNAME_SIZE+1];
243 med_sorting_type sorttype;
246 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
247 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
248 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
249 TErr aRet = MEDmeshInfo(myFile->Id(),
265 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
268 //----------------------------------------------------------------------------
271 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
275 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
278 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
281 SetMeshInfo(theInfo, eCREATION, &aRet);
287 //----------------------------------------------------------------------------
290 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
294 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
296 if (theErr && *theErr < 0)
299 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
301 TValueHolder<TString, char> aMeshName(anInfo.myName);
302 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
303 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
304 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
305 TValueHolder<TString, char> aDesc(anInfo.myDesc);
307 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
308 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
309 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
310 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
311 TErr aRet = MEDmeshCr(myFile->Id(),
326 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
328 INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
333 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
336 //----------------------------------------------------------------------------
339 ::CrMeshInfo(TInt theDim,
341 const std::string& theValue,
343 const std::string& theDesc)
345 return PMeshInfo(new TTMeshInfo
353 //----------------------------------------------------------------------------
356 ::CrMeshInfo(const PMeshInfo& theInfo)
358 return PMeshInfo(new TTMeshInfo(theInfo));
361 //----------------------------------------------------------------------------
364 ::GetPMeshInfo(TInt theId,
367 PMeshInfo anInfo = CrMeshInfo();
368 GetMeshInfo(theId, *anInfo, theErr);
372 //----------------------------------------------------------------------------
375 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
378 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
380 if (theErr && *theErr < 0)
383 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
384 TValueHolder<TString, char> aName(anInfo.myName);
385 return MEDnFamily(myFile->Id(), &aName);
388 //----------------------------------------------------------------------------
391 ::GetNbFamAttr(TInt theFamId,
392 const MED::TMeshInfo& theInfo,
395 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
397 if (theErr && *theErr < 0)
400 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
402 TValueHolder<TString, char> aName(anInfo.myName);
404 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
407 //----------------------------------------------------------------------------
410 ::GetNbFamGroup(TInt theFamId,
411 const MED::TMeshInfo& theInfo,
414 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
416 if (theErr && *theErr < 0)
419 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
421 TValueHolder<TString, char> aName(anInfo.myName);
423 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
426 //----------------------------------------------------------------------------
429 ::GetFamilyInfo(TInt theFamId,
430 MED::TFamilyInfo& theInfo,
433 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
435 if (theErr && *theErr < 0)
438 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
440 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
441 TValueHolder<TString, char> aFamilyName(theInfo.myName);
442 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
443 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
444 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
445 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
446 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
448 TErr aRet = MEDfamily23Info(myFile->Id(),
461 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
462 " aMeshInfo.myName = '"<<&aMeshName<<
463 "'; theFamId = "<<theFamId<<
464 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
465 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
468 //----------------------------------------------------------------------------
471 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
475 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
478 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
484 //----------------------------------------------------------------------------
487 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
491 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
493 if (theErr && *theErr < 0)
496 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
497 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
499 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
500 TValueHolder<TString, char> aFamilyName(anInfo.myName);
501 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
502 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
503 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
504 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
505 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
506 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
507 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
509 TErr aRet = MEDfamilyCr(myFile->Id(),
516 INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
521 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
524 //----------------------------------------------------------------------------
527 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
531 const std::string& theValue)
533 return PFamilyInfo(new TTFamilyInfo
541 //----------------------------------------------------------------------------
544 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
545 const std::string& theValue,
547 const MED::TStringSet& theGroupNames,
548 const MED::TStringVector& theAttrDescs,
549 const MED::TIntVector& theAttrIds,
550 const MED::TIntVector& theAttrVals)
552 return PFamilyInfo(new TTFamilyInfo
562 //----------------------------------------------------------------------------
565 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
566 const PFamilyInfo& theInfo)
568 return PFamilyInfo(new TTFamilyInfo
573 //----------------------------------------------------------------------------
576 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
580 // must be reimplemented in connection with mesh type eSTRUCTURE
581 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
582 // return PFamilyInfo();
584 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
585 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
586 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
587 GetFamilyInfo(theId, *anInfo, theErr);
590 std::string aName = anInfo->GetName();
591 INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
592 "'; andId = "<<anInfo->GetId()<<
593 "; aNbAttr = "<<aNbAttr<<
594 "; aNbGroup = "<<aNbGroup<<"\n");
595 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
596 aName = anInfo->GetGroupName(iGroup);
597 INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
604 //----------------------------------------------------------------------------
607 ::GetNames(TElemInfo& theInfo,
609 EEntiteMaillage theEntity,
610 EGeometrieElement theGeom,
613 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
615 if (theErr && *theErr < 0)
618 if (theGeom == eBALL)
619 theGeom = GetBallGeom(theInfo.myMeshInfo);
621 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
623 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
624 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
625 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
626 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
628 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
636 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
642 //----------------------------------------------------------------------------
645 ::SetNames(const TElemInfo& theInfo,
646 EEntiteMaillage theEntity,
647 EGeometrieElement theGeom,
650 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
653 //----------------------------------------------------------------------------
656 ::SetNames(const TElemInfo& theInfo,
658 EEntiteMaillage theEntity,
659 EGeometrieElement theGeom,
662 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
664 if (theErr && *theErr < 0)
667 if (theGeom == eBALL)
668 theGeom = GetBallGeom(theInfo.myMeshInfo);
670 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
671 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
674 if (theInfo.myIsElemNames) {
675 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
676 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
677 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
678 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
680 aRet = MEDmeshEntityNameWr(myFile->Id(),
686 (TInt)anInfo.myElemNames->size(),
691 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
695 //----------------------------------------------------------------------------
698 ::GetNumeration(TElemInfo& theInfo,
700 EEntiteMaillage theEntity,
701 EGeometrieElement theGeom,
704 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
706 if (theErr && *theErr < 0)
709 if (theGeom == eBALL)
710 theGeom = GetBallGeom(theInfo.myMeshInfo);
712 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
714 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
715 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
716 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
717 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
719 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
727 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
733 //----------------------------------------------------------------------------
736 ::SetNumeration(const TElemInfo& theInfo,
737 EEntiteMaillage theEntity,
738 EGeometrieElement theGeom,
741 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
744 //----------------------------------------------------------------------------
747 ::SetNumeration(const TElemInfo& theInfo,
749 EEntiteMaillage theEntity,
750 EGeometrieElement theGeom,
753 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
755 if (theErr && *theErr < 0)
758 if (theGeom == eBALL)
759 theGeom = GetBallGeom(theInfo.myMeshInfo);
761 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
762 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
765 if (theInfo.myIsElemNum) {
766 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
767 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
768 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
769 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
771 aRet = MEDmeshEntityNumberWr(myFile->Id(),
777 (TInt)anInfo.myElemNum->size(),
782 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
786 //----------------------------------------------------------------------------
789 ::GetFamilies(TElemInfo& theInfo,
791 EEntiteMaillage theEntity,
792 EGeometrieElement theGeom,
795 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
797 if (theErr && *theErr < 0)
800 if (theGeom == eBALL)
801 theGeom = GetBallGeom(theInfo.myMeshInfo);
803 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
805 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
806 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
807 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
808 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
810 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
819 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
821 int aSize = (int)theInfo.myFamNum->size();
822 theInfo.myFamNum->clear();
823 theInfo.myFamNum->resize(aSize,0);
827 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
833 //----------------------------------------------------------------------------
836 ::SetFamilies(const TElemInfo& theInfo,
837 EEntiteMaillage theEntity,
838 EGeometrieElement theGeom,
841 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
844 //----------------------------------------------------------------------------
847 ::SetFamilies(const TElemInfo& theInfo,
849 EEntiteMaillage theEntity,
850 EGeometrieElement theGeom,
853 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
855 if (theErr && *theErr < 0)
858 if (theGeom == eBALL)
859 theGeom = GetBallGeom(theInfo.myMeshInfo);
861 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
862 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
864 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
865 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
866 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
867 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
869 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
875 (TInt)anInfo.myFamNum->size(),
881 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
884 //----------------------------------------------------------------------------
887 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
890 return GetNbNodes(theMeshInfo, eCOOR, theErr);
893 //----------------------------------------------------------------------------
896 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
900 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
902 if (theErr && *theErr < 0)
905 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
907 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
908 TValueHolder<ETable, med_data_type > aTable(theTable);
910 return MEDmeshnEntity(myFile->Id(),
922 //----------------------------------------------------------------------------
925 ::GetNodeInfo(MED::TNodeInfo& theInfo,
928 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
930 if (theErr && *theErr < 0)
933 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
935 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
936 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
937 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
938 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
939 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
940 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
941 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
942 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
943 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
944 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
945 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
946 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
947 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
949 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
956 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
964 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
966 int mySize = (int)theInfo.myFamNum->size();
967 theInfo.myFamNum->clear();
968 theInfo.myFamNum->resize(mySize,0);
971 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
974 if (MEDmeshEntityNameRd(myFile->Id(),
980 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
982 if (MEDmeshEntityNumberRd(myFile->Id(),
988 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
993 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
996 //----------------------------------------------------------------------------
999 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1003 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
1006 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1012 //----------------------------------------------------------------------------
1015 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1019 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1021 if (theErr && *theErr < 0)
1024 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1025 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1027 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1028 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1029 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1030 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1031 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1032 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1033 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1034 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1035 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1036 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1037 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1038 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1040 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1049 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1058 MEDmeshEntityNameWr(myFile->Id(),
1067 MEDmeshEntityNumberWr(myFile->Id(),
1078 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1081 //----------------------------------------------------------------------------
1084 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1086 EModeSwitch theMode,
1088 EBooleen theIsElemNum,
1089 EBooleen theIsElemNames)
1091 return PNodeInfo(new TTNodeInfo
1100 //----------------------------------------------------------------------------
1103 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1104 const TFloatVector& theNodeCoords,
1105 EModeSwitch theMode,
1107 const TStringVector& theCoordNames,
1108 const TStringVector& theCoordUnits,
1109 const TIntVector& theFamilyNums,
1110 const TIntVector& theElemNums,
1111 const TStringVector& theElemNames)
1113 return PNodeInfo(new TTNodeInfo
1125 //----------------------------------------------------------------------------
1128 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1129 const PNodeInfo& theInfo)
1131 return PNodeInfo(new TTNodeInfo
1136 //----------------------------------------------------------------------------
1139 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1142 TInt aNbElems = GetNbNodes(*theMeshInfo);
1143 if (aNbElems == 0) {
1147 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1148 GetNodeInfo(*anInfo, theErr);
1151 TInt aDim = theMeshInfo->myDim;
1152 TInt aNbElem = anInfo->GetNbElem();
1153 INITMSG(MYDEBUG, "GetPNodeInfo: ");
1155 INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
1156 TNodeCoord& aCoord = anInfo->myCoord;
1157 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1158 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1159 ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
1161 ADDMSG(MYVALUEDEBUG, " ");
1163 ADDMSG(MYDEBUG, std::endl);
1165 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
1166 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1167 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
1169 ADDMSG(MYVALUEDEBUG, std::endl);
1171 if (anInfo->IsElemNum()) {
1172 BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
1173 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1174 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
1176 ADDMSG(MYVALUEDEBUG, std::endl);
1179 ADDMSG(MYDEBUG, std::endl);
1185 //----------------------------------------------------------------------------
1188 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1190 EBooleen theIsElemNum,
1191 EBooleen theIsElemNames)
1193 return PElemInfo(new TTElemInfo
1200 //----------------------------------------------------------------------------
1203 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1205 const TIntVector& theFamNum,
1206 const TIntVector& aElemNum,
1207 const TStringVector& aElemNames)
1209 return PElemInfo(new TTElemInfo
1217 //----------------------------------------------------------------------------
1220 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1221 EEntiteMaillage theEntity,
1222 EGeometrieElement theGeom,
1223 EConnectivite theConnMode,
1226 EMaillage aType = theMeshInfo->GetType();
1227 if (aType == eNON_STRUCTURE) {
1230 if (theEntity == eNOEUD)
1231 return GetPNodeInfo(theMeshInfo, theErr);
1232 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1235 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1238 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1241 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1245 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1248 EBooleen theIsElemNum = eFAUX;
1252 nbElems = aGrille->GetNbNodes();
1253 theIsElemNum = eVRAI;
1258 nbElems = aGrille->GetNbCells();
1265 TIntVector aElemNum;
1266 TStringVector aElemNames;
1268 PElemInfo aElemInfo;
1270 if (theGeom == ePOINT1) {
1271 aElemInfo = CrElemInfo(theMeshInfo,
1274 MED::TElemInfo &aTElemInfo = *aElemInfo;
1276 // must be reimplemente in connection with mesh type eSTRUCTURE
1277 // GetNumeration(aTElemInfo,
1283 GetFamilies(aTElemInfo,
1289 // must be reimplemente in connection with mesh type eSTRUCTURE
1290 // GetNames(aTElemInfo,
1297 aElemInfo = CrElemInfo(theMeshInfo,
1309 //----------------------------------------------------------------------------
1312 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1313 EEntiteMaillage theEntity,
1314 EGeometrieElement theGeom,
1315 EConnectivite theConnMode,
1318 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1321 //----------------------------------------------------------------------------
1324 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1325 EEntiteMaillage theEntity,
1326 EGeometrieElement theGeom,
1327 EConnectivite theConnMode,
1330 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1332 if (theErr && *theErr < 0)
1335 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1337 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1338 med_int aTaille = 0;
1340 aTaille=MEDmeshnEntity(myFile->Id(),
1344 med_entity_type(theEntity),
1345 med_geometry_type(theGeom),
1347 med_connectivity_mode(theConnMode),
1352 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1354 return TInt(aTaille);
1357 //-----------------------------------------------------------------
1360 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1363 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1365 if (theErr && *theErr < 0)
1368 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1370 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1371 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1372 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1373 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1374 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1375 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1376 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1379 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1380 MED_NO_DT, MED_NO_IT,
1382 aConnMode, &anIndex, &aConn);
1387 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1389 if (theInfo.myIsElemNames) {
1390 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1395 if (theInfo.myIsElemNum) {
1396 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1401 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1406 //----------------------------------------------------------------------------
1409 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1412 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1415 //----------------------------------------------------------------------------
1418 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1422 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1424 if (theErr && *theErr < 0)
1427 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1428 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1430 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1431 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1432 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1433 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1434 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1435 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1437 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1438 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1440 aConnMode, anInfo.myNbElem + 1,
1445 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1447 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1451 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1455 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1460 //----------------------------------------------------------------------------
1463 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1464 EEntiteMaillage theEntity,
1465 EGeometrieElement theGeom,
1468 EConnectivite theConnMode,
1469 EBooleen theIsElemNum,
1470 EBooleen theIsElemNames)
1472 return PPolygoneInfo(new TTPolygoneInfo
1483 //----------------------------------------------------------------------------
1486 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1487 EEntiteMaillage theEntity,
1488 EGeometrieElement theGeom,
1489 const TIntVector& theIndexes,
1490 const TIntVector& theConnectivities,
1491 EConnectivite theConnMode,
1492 const TIntVector& theFamilyNums,
1493 const TIntVector& theElemNums,
1494 const TStringVector& theElemNames)
1496 return PPolygoneInfo(new TTPolygoneInfo
1508 //----------------------------------------------------------------------------
1511 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1512 const PPolygoneInfo& theInfo)
1514 return PPolygoneInfo(new TTPolygoneInfo
1519 //----------------------------------------------------------------------------
1522 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1523 EEntiteMaillage theEntity,
1524 EGeometrieElement theGeom,
1525 EConnectivite theConnMode)
1527 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1528 return PPolygoneInfo();
1530 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1531 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1532 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1533 GetPolygoneInfo(anInfo);
1536 INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
1537 " - theGeom = "<<theGeom<<
1538 "; aNbElem = "<<aNbElem<<": ");
1539 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1540 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1541 TInt aConnDim = aConnSlice.size();
1542 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1543 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1545 ADDMSG(MYDEBUG, " ");
1547 ADDMSG(MYDEBUG, std::endl);
1553 //----------------------------------------------------------------------------
1556 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1557 EEntiteMaillage theEntity,
1558 EGeometrieElement theGeom,
1559 EConnectivite theConnMode,
1562 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1565 //----------------------------------------------------------------------------
1568 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1571 EConnectivite theConnMode,
1574 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1576 if (theErr && *theErr < 0)
1577 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1579 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1581 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1582 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1583 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1584 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1586 med_bool chgt, trsf;
1587 theNbFaces = MEDmeshnEntity(myFile->Id(),
1598 theConnSize = MEDmeshnEntity(myFile->Id(),
1609 if (theNbFaces < 0 || theConnSize<0)
1610 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1614 //-----------------------------------------------------------------
1617 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1620 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1622 if (theErr && *theErr < 0)
1625 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1627 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1628 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1629 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1630 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1631 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1632 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1635 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1648 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1650 if (theInfo.myIsElemNames) {
1651 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1656 if (theInfo.myIsElemNum) {
1657 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1662 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1667 //----------------------------------------------------------------------------
1670 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1673 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1676 //----------------------------------------------------------------------------
1679 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1683 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1685 if (theErr && *theErr < 0)
1688 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1689 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1691 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1692 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1693 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1694 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1695 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1698 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1707 (TInt)anInfo.myFaces->size(),
1714 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1716 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1718 if (theInfo.myIsElemNames) {
1719 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1720 aRet = MEDmeshEntityNameWr(myFile->Id(),
1726 (TInt)anInfo.myElemNames->size(),
1731 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1734 if (theInfo.myIsElemNum) {
1735 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1736 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1742 (TInt)anInfo.myElemNum->size(),
1747 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1750 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1751 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1757 (TInt)anInfo.myFamNum->size(),
1763 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1766 //----------------------------------------------------------------------------
1769 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1770 EEntiteMaillage theEntity,
1771 EGeometrieElement theGeom,
1775 EConnectivite theConnMode,
1776 EBooleen theIsElemNum,
1777 EBooleen theIsElemNames)
1779 return PPolyedreInfo(new TTPolyedreInfo
1791 //----------------------------------------------------------------------------
1794 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1795 EEntiteMaillage theEntity,
1796 EGeometrieElement theGeom,
1797 const TIntVector& theIndexes,
1798 const TIntVector& theFaces,
1799 const TIntVector& theConnectivities,
1800 EConnectivite theConnMode,
1801 const TIntVector& theFamilyNums,
1802 const TIntVector& theElemNums,
1803 const TStringVector& theElemNames)
1805 return PPolyedreInfo(new TTPolyedreInfo
1818 //----------------------------------------------------------------------------
1821 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1822 const PPolyedreInfo& theInfo)
1824 return PPolyedreInfo(new TTPolyedreInfo
1829 //----------------------------------------------------------------------------
1832 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1833 EEntiteMaillage theEntity,
1834 EGeometrieElement theGeom,
1835 EConnectivite theConnMode)
1837 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1838 return PPolyedreInfo();
1839 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1840 TInt aNbFaces, aConnSize;
1841 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1842 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1843 GetPolyedreInfo(anInfo);
1846 INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
1847 " - theGeom = "<<theGeom<<
1848 "; aNbElem = "<<aNbElem<<": ");
1849 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1850 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1851 TInt aNbFaces = aConnSliceArr.size();
1852 ADDMSG(MYDEBUG, "{");
1853 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1854 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1855 TInt aNbConn = aConnSlice.size();
1856 ADDMSG(MYDEBUG, "[");
1857 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1858 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1860 ADDMSG(MYDEBUG, "] ");
1862 ADDMSG(MYDEBUG, "} ");
1864 ADDMSG(MYDEBUG, std::endl);
1870 //-----------------------------------------------------------------
1873 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1874 EConnectivite theConnMode,
1879 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1881 if (theErr && *theErr < 0)
1884 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1885 TInt aNbElem = GetNbNodes(theMeshInfo);
1887 anInfo[eNOEUD][ePOINT1] = aNbElem;
1888 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1889 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1890 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1891 for (; anIter != anIterEnd; anIter++) {
1892 const EEntiteMaillage& anEntity = anIter->first;
1893 const TGeomSet& aGeomSet = anIter->second;
1894 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1895 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1896 for (; anIter2 != anIterEnd2; anIter2++) {
1897 const EGeometrieElement& aGeom = *anIter2;
1898 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1900 if (anEntity == eSTRUCT_ELEMENT) {
1901 const TInt nbStructTypes = aNbElem;
1902 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1903 // check type name to keep only "MED_BALL" structured element
1904 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1905 char geotypename[ MED_NAME_SIZE + 1] = "";
1906 med_geometry_type geotype;
1907 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1908 med_entity_type(anEntity), structType+1,
1909 geotypename, &geotype);
1910 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1911 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1912 theConnMode, theErr);
1914 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1919 anInfo[anEntity][aGeom] = aNbElem;
1926 else { // eSTRUCTURE
1927 EGrilleType aGrilleType;
1931 TInt aDim = theMeshInfo.GetDim();
1932 EGeometrieElement aGeom, aSubGeom;
1933 EEntiteMaillage aSubEntity = eMAILLE;
1935 GetGrilleType(theMeshInfo, aGrilleType);
1937 TIntVector aStruct(aDim);
1938 if (aGrilleType == eGRILLE_STANDARD)
1940 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1943 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1944 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1945 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1946 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1948 for (med_int i = 0; i < aDim; i++) {
1949 aNbNodes = aNbNodes * aStruct[i];
1950 aNbElem = aNbElem * (aStruct[i] - 1);
1959 aSubEntity = eARETE;
1961 (aStruct[0]) * (aStruct[1]-1) +
1962 (aStruct[0]-1) * (aStruct[1]);
1969 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1970 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1971 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1974 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1975 anInfo[eMAILLE][aGeom] = aNbElem;
1977 anInfo[aSubEntity][aSubGeom] = aNbSub;
1982 //-----------------------------------------------------------------
1985 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1986 EEntiteMaillage theEntity,
1987 EGeometrieElement theGeom,
1988 EConnectivite theConnMode,
1991 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1993 if (theErr && *theErr < 0)
1996 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1997 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1998 med_bool chgt, trsf;
2001 case MED::ePOLYGONE:
2002 case MED::ePOLYGON2:
2004 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2005 MED_NO_DT, MED_NO_IT,
2006 med_entity_type(theEntity), med_geometry_type(theGeom),
2007 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2010 case MED::ePOLYEDRE:
2012 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2013 MED_NO_DT, MED_NO_IT,
2014 med_entity_type(theEntity), MED_POLYHEDRON,
2015 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2020 return GetNbBalls(theMeshInfo);
2024 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2025 MED_NO_DT, MED_NO_IT,
2026 med_entity_type(theEntity), med_geometry_type(theGeom),
2027 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2034 //----------------------------------------------------------------------------
2037 ::GetCellInfo(MED::TCellInfo& theInfo,
2040 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2042 if (theErr && *theErr < 0)
2045 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2047 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2048 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2049 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2050 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2051 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2052 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2053 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2054 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2055 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2056 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2057 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2058 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2062 aRet = MEDmeshnEntity(myFile->Id(),
2073 // names are present in the file, they will be read in spite of theInfo.myIsElemNames
2074 theInfo.myIsElemNames = eVRAI;
2075 theInfo.myElemNames.reset( new TString( theInfo.myNbElem * GetPNOMLength() + 1 ));
2076 anElemNames.myRepresentation = & ((TString&) theInfo.myElemNames )[0];
2079 aRet = MEDmeshElementRd(myFile->Id(),
2098 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2100 if (anIsFamNum == MED_FALSE)
2102 int mySize = (int) theInfo.myFamNum->size();
2103 theInfo.myFamNum->clear();
2104 theInfo.myFamNum->resize(mySize, 0);
2109 //----------------------------------------------------------------------------
2112 ::SetCellInfo(const MED::TCellInfo& theInfo,
2115 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2118 //----------------------------------------------------------------------------
2121 ::SetCellInfo(const MED::TCellInfo& theInfo,
2125 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2127 if (theErr && *theErr < 0)
2130 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2131 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2133 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2134 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2135 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2136 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2137 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2138 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2139 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2140 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2141 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2142 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2143 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2144 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2145 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2148 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2160 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2169 MEDmeshEntityNameWr(myFile->Id(),
2178 MEDmeshEntityNumberWr(myFile->Id(),
2189 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2192 //----------------------------------------------------------------------------
2195 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2196 EEntiteMaillage theEntity,
2197 EGeometrieElement theGeom,
2199 EConnectivite theConnMode,
2200 EBooleen theIsElemNum,
2201 EBooleen theIsElemNames,
2202 EModeSwitch theMode)
2204 return PCellInfo(new TTCellInfo
2215 //----------------------------------------------------------------------------
2218 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2219 EEntiteMaillage theEntity,
2220 EGeometrieElement theGeom,
2221 const TIntVector& theConnectivities,
2222 EConnectivite theConnMode,
2223 const TIntVector& theFamilyNums,
2224 const TIntVector& theElemNums,
2225 const TStringVector& theElemNames,
2226 EModeSwitch theMode)
2228 return PCellInfo(new TTCellInfo
2240 //----------------------------------------------------------------------------
2243 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2244 const PCellInfo& theInfo)
2246 return PCellInfo(new TTCellInfo
2251 //----------------------------------------------------------------------------
2254 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2255 EEntiteMaillage theEntity,
2256 EGeometrieElement theGeom,
2257 EConnectivite theConnMode,
2260 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2262 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2263 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2264 GetCellInfo(anInfo, theErr);
2267 TInt aConnDim = anInfo->GetConnDim();
2268 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2269 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2270 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2271 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2272 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2273 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2275 ADDMSG(MYVALUEDEBUG, " ");
2277 ADDMSG(MYDEBUG, std::endl);
2279 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2280 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2281 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2283 ADDMSG(MYVALUEDEBUG, std::endl);
2285 if (anInfo->IsElemNum()) {
2286 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2287 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2288 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2290 ADDMSG(MYVALUEDEBUG, std::endl);
2292 ADDMSG(MYDEBUG, std::endl);
2298 //----------------------------------------------------------------------------
2301 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2304 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2306 // read med_geometry_type of "MED_BALL" element
2307 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2308 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2311 //----------------------------------------------------------------------------
2314 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2317 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2319 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2323 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2326 //----------------------------------------------------------------------------
2329 ::GetBallInfo(TBallInfo& theInfo,
2332 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2334 // check geometry of MED_BALL
2335 if (theInfo.myGeom == eBALL)
2337 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2338 if (theInfo.myGeom < 0) {
2340 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2341 *theErr = theInfo.myGeom;
2347 GetCellInfo(theInfo);
2350 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2351 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2352 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2353 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2355 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2356 MED_NO_DT, MED_NO_IT,
2363 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2366 //----------------------------------------------------------------------------
2369 ::SetBallInfo(const TBallInfo& theInfo,
2372 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2375 //----------------------------------------------------------------------------
2378 ::SetBallInfo(const TBallInfo& theInfo,
2382 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2385 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2386 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2389 // no ball model in the file, create support mesh for it
2390 char dummyname [MED_NAME_SIZE*3+1] = "";
2391 if ((ret = MEDsupportMeshCr(myFile->Id(),
2393 theInfo.myMeshInfo->GetSpaceDim(),
2394 theInfo.myMeshInfo->GetDim(),
2395 "Support mesh for a ball model",
2397 /*axisname=*/dummyname,
2398 /*unitname=*/dummyname)) < 0) {
2400 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2404 // write coordinates of 1 node
2405 med_float coord[3] = {0, 0, 0};
2406 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2407 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2408 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2410 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2414 // ball model creation
2415 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2416 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2418 theInfo.myMeshInfo->GetSpaceDim(),
2420 MED_NODE,MED_NONE)) < 0) {
2422 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2426 // create diameter attribute
2427 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2428 geotypename, MED_BALL_DIAMETER,
2429 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2431 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2437 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2438 aBallInfo.myGeom = ballGeom;
2441 SetCellInfo(theInfo, theMode, theErr);
2442 if (theErr && theErr < 0)
2446 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2447 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2448 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2449 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2450 MED_NO_DT, MED_NO_IT,
2451 aGeom, MED_BALL_DIAMETER,
2452 theInfo.myNbElem, &aDiam);
2456 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2459 //----------------------------------------------------------------------------
2462 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2464 EBooleen theIsElemNum)
2466 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2469 //----------------------------------------------------------------------------
2472 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2473 const TIntVector& theNodes,
2474 TFloatVector& theDiameters,
2475 const TIntVector& theFamilyNums,
2476 const TIntVector& theElemNums)
2478 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2479 theFamilyNums, theElemNums));
2482 //----------------------------------------------------------------------------
2485 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2486 const PBallInfo& theInfo)
2488 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2491 //----------------------------------------------------------------------------
2494 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2496 TInt nbBalls = GetNbBalls(theMeshInfo);
2497 if (nbBalls < 1) return PBallInfo();
2499 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2500 GetBallInfo(anInfo);
2505 //-----------------------------------------------------------------
2508 ::GetNbFields(TErr* theErr)
2510 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2512 if (theErr && *theErr < 0)
2515 return MEDnField(myFile->Id());
2518 //----------------------------------------------------------------------------
2521 ::GetNbComp(TInt theFieldId,
2524 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2526 if (theErr && *theErr < 0)
2529 return MEDfieldnComponent(myFile->Id(), theFieldId);
2532 //----------------------------------------------------------------------------
2535 ::GetFieldInfo(TInt theFieldId,
2536 MED::TFieldInfo& theInfo,
2539 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2541 if (theErr && *theErr < 0)
2544 TString aFieldName(256); // Protect from memory problems with too long names
2545 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2546 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2547 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2548 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2552 char dtunit[MED_SNAME_SIZE+1];
2553 char local_mesh_name[MED_NAME_SIZE+1]="";
2555 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2556 aRet = MEDfieldInfo(myFile->Id(),
2567 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2573 theInfo.SetName(aFieldName);
2578 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2581 //----------------------------------------------------------------------------
2584 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2588 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2591 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2597 //----------------------------------------------------------------------------
2600 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2604 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2606 if (theErr && *theErr < 0)
2609 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2611 TValueHolder<TString, char> aFieldName(anInfo.myName);
2612 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2613 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2614 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2615 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2617 char dtunit[MED_SNAME_SIZE+1];
2618 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2619 aRet = MEDfieldCr(myFile->Id(),
2626 &aMeshInfo.myName[0]);
2630 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2633 //----------------------------------------------------------------------------
2636 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2639 const std::string& theValue,
2640 EBooleen theIsLocal,
2643 return PFieldInfo(new TTFieldInfo
2652 //----------------------------------------------------------------------------
2655 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2656 const PFieldInfo& theInfo)
2658 return PFieldInfo(new TTFieldInfo
2663 //----------------------------------------------------------------------------
2666 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2670 TInt aNbComp = GetNbComp(theId);
2671 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2672 GetFieldInfo(theId, *anInfo, theErr);
2677 "- aName = '"<<anInfo->GetName()<<"'"<<
2678 "; aType = "<<anInfo->GetType()<<
2679 "; aNbComp = "<<aNbComp<<
2686 //----------------------------------------------------------------------------
2689 ::GetNbGauss(TErr* theErr)
2691 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2693 if (theErr && *theErr < 0)
2696 return MEDnLocalization(myFile->Id());
2699 //----------------------------------------------------------------------------
2702 ::GetGaussPreInfo(TInt theId,
2705 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2707 if (theErr && *theErr < 0)
2708 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2710 med_int aNbGaussPoints = med_int();
2711 TVector<char> aName(GetNOMLength()+1);
2712 med_geometry_type aGeom = MED_NONE;
2716 char geointerpname[MED_NAME_SIZE+1] = "";
2717 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2718 med_int nsectionmeshcell;
2719 med_geometry_type sectiongeotype;
2720 aRet = MEDlocalizationInfo (myFile->Id(),
2727 ipointstructmeshname,
2733 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2734 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2735 TInt(aNbGaussPoints));
2738 //----------------------------------------------------------------------------
2741 ::GetGaussInfo(TInt theId,
2742 TGaussInfo& theInfo,
2745 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2747 if (theErr && *theErr < 0)
2750 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2751 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2752 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2753 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2754 TValueHolder<TString, char> aGaussName(theInfo.myName);
2757 aRet = MEDlocalizationRd(myFile->Id(),
2767 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2770 //----------------------------------------------------------------------------
2773 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2774 EModeSwitch theMode)
2776 return PGaussInfo(new TTGaussInfo
2781 //-----------------------------------------------------------------
2784 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2785 const MED::TEntityInfo& theEntityInfo,
2786 EEntiteMaillage& theEntity,
2787 TGeom2Size& theGeom2Size,
2790 theEntity = EEntiteMaillage(-1);
2791 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2794 if (theEntityInfo.empty())
2799 else if (theEntityInfo.empty())
2800 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2802 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2804 theGeom2Size.clear();
2805 TInt aNbTimeStamps = 0;
2806 TIdt anId = myFile->Id();
2808 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2809 TValueHolder<TString, char> aFieldName(anInfo.myName);
2810 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2812 // workaround for IPAL13676
2813 MED::TEntityInfo localEntityInfo = theEntityInfo;
2814 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2815 if (anLocalIter != localEntityInfo.end()) {
2816 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2819 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2820 for (; anIter != localEntityInfo.end(); anIter++) {
2821 med_entity_type anEntity = med_entity_type(anIter->first);
2822 const TGeom2Size& aGeom2Size = anIter->second;
2823 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2824 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2825 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2826 char aMeshName[MED_NAME_SIZE+1];
2829 char dtunit[MED_SNAME_SIZE+1];
2830 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2831 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2832 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2834 MEDfieldInfoByName(anId,
2851 MEDfieldComputingStepInfo(anId,
2857 char profilename[MED_NAME_SIZE+1];
2858 char locname[MED_NAME_SIZE+1];
2862 // protection from crash (division by zero)
2863 // inside MEDfieldnValueWithProfile function
2864 // caused by the workaround for IPAL13676 (see above)
2865 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2868 nval = MEDfieldnValueWithProfile(anId,
2873 med_geometry_type(aGeom),
2881 bool anIsSatisfied =(nval > 0);
2882 if (anIsSatisfied) {
2884 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2885 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2886 if (anIsPerformAdditionalCheck) {
2887 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2888 if (!anIsSatisfied) {
2890 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2891 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2895 if (anIsSatisfied) {
2896 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2897 theEntity = EEntiteMaillage(anEntity);
2898 aNbTimeStamps = aNbStamps;
2901 if (!theGeom2Size.empty())
2904 return aNbTimeStamps;
2907 //----------------------------------------------------------------------------
2910 ::GetTimeStampInfo(TInt theTimeStampId,
2911 MED::TTimeStampInfo& theInfo,
2914 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2916 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2919 if (aGeom2Size.empty())
2924 else if (aGeom2Size.empty())
2925 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2927 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2928 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2930 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2931 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2932 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2933 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2934 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2935 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2936 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2937 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2938 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2940 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2942 // just to get a time stamp unit (anUnitDt)
2943 med_field_type aFieldType;
2944 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2945 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2946 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2948 MEDfieldInfoByName(myFile->Id(),
2957 delete [] aCompName;
2958 delete [] aCompUnit;
2960 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2961 for (; anIter != aGeom2Size.end(); anIter++) {
2962 const EGeometrieElement& aGeom = anIter->first;
2963 med_int aNbGauss = -1;
2966 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2972 char profilename[MED_NAME_SIZE+1];
2974 char locname[MED_NAME_SIZE+1];
2975 MEDfieldnValueWithProfile(myFile->Id(),
2980 med_geometry_type(aGeom),
2988 static TInt MAX_NB_GAUSS_POINTS = 32;
2989 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2992 aGeom2NbGauss[aGeom] = aNbGauss;
2997 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
3001 //----------------------------------------------------------------------------
3004 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3005 EEntiteMaillage theEntity,
3006 const TGeom2Size& theGeom2Size,
3007 const TGeom2NbGauss& theGeom2NbGauss,
3011 const std::string& theUnitDt,
3012 const TGeom2Gauss& theGeom2Gauss)
3014 return PTimeStampInfo(new TTTimeStampInfo
3026 //----------------------------------------------------------------------------
3029 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3030 const PTimeStampInfo& theInfo)
3032 return PTimeStampInfo(new TTTimeStampInfo
3037 //----------------------------------------------------------------------------
3040 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3041 EEntiteMaillage theEntity,
3042 const TGeom2Size& theGeom2Size,
3046 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3047 GetTimeStampInfo(theId, *anInfo, theErr);
3050 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3051 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3052 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3053 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3054 const EGeometrieElement& aGeom = anIter->first;
3055 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3062 //----------------------------------------------------------------------------
3065 ::GetNbProfiles(TErr* theErr)
3067 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3069 if (theErr && *theErr < 0)
3072 return MEDnProfile(myFile->Id());
3075 //----------------------------------------------------------------------------
3078 ::GetProfilePreInfo(TInt theId,
3081 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3083 if (theErr && *theErr < 0)
3084 return TProfileInfo::TInfo();
3087 TVector<char> aName(GetNOMLength()+1);
3090 aRet = MEDprofileInfo(myFile->Id(),
3097 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3099 return TProfileInfo::TInfo(&aName[0], aSize);
3102 //----------------------------------------------------------------------------
3105 ::GetProfileInfo(TInt theId,
3106 TProfileInfo& theInfo,
3109 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3111 if (theErr && *theErr < 0)
3114 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3115 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3116 TValueHolder<TString, char> aProfileName(anInfo.myName);
3119 aRet = MEDprofileRd(myFile->Id(),
3125 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3128 //----------------------------------------------------------------------------
3131 ::SetProfileInfo(const TProfileInfo& theInfo,
3135 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3138 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3141 SetProfileInfo(theInfo, eCREATION, &aRet);
3147 //----------------------------------------------------------------------------
3150 ::SetProfileInfo(const TProfileInfo& theInfo,
3154 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3156 if (theErr && *theErr < 0)
3159 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3160 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3161 TValueHolder<TString, char> aProfileName(anInfo.myName);
3164 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3165 &aProfileName, // tableau de valeurs du profil.
3166 theInfo.GetSize(), // taille du profil.
3167 &anElemNum); // nom profil.
3171 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3174 //----------------------------------------------------------------------------
3177 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3178 EModeProfil theMode)
3180 return PProfileInfo(new TTProfileInfo
3185 //----------------------------------------------------------------------------
3188 ::GetPProfileInfo(TInt theId,
3189 EModeProfil theMode,
3192 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3193 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3194 GetProfileInfo(theId, *anInfo, theErr);
3199 //----------------------------------------------------------------------------
3202 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3203 const TMKey2Profile& theMKey2Profile,
3204 const TKey2Gauss& theKey2Gauss,
3207 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3209 if (theErr && *theErr < 0)
3212 TIdt anId = myFile->Id();
3214 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3215 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3217 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3218 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3219 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3220 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3222 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3223 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3224 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3226 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3227 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3229 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3230 TVector<char> aGaussName(GetNOMLength()+1);
3232 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3233 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3234 TVector<char> aProfileName(GetNOMLength()+1);
3236 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3237 TGeom2Size::iterator anIter = aGeom2Size.begin();
3238 for (; anIter != aGeom2Size.end(); anIter++) {
3239 EGeometrieElement aGeom = anIter->first;
3240 TInt aNbElem = anIter->second;
3241 med_int profilesize, aNbGauss;
3243 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3248 med_geometry_type(aGeom),
3261 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3264 TInt aNbComp = aFieldInfo->myNbComp;
3265 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3266 theTimeStampValue->AllocateValue(aGeom,
3270 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3273 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3274 "; aNbVal = "<<aNbVal<<
3275 "; aNbValue = "<<aNbValue<<
3276 "; aNbGauss = "<<aNbGauss<<
3277 "; aNbComp = "<<aNbComp<<
3280 TErr aRet = MEDfieldValueWithProfileRd(anId,
3285 med_geometry_type(aGeom),
3289 MED_ALL_CONSTITUENT,
3290 theTimeStampValue->GetValuePtr(aGeom));
3293 *theErr = MED_FALSE;
3296 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3299 MED::PGaussInfo aGaussInfo;
3300 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3301 if (strcmp(&aGaussName[0], "") != 0) {
3302 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3303 if (anIter != theKey2Gauss.end()) {
3304 aGaussInfo = anIter->second;
3305 aGeom2Gauss[aGeom] = aGaussInfo;
3309 MED::PProfileInfo aProfileInfo;
3310 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3311 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3312 if (anIter != aKey2Profile.end()) {
3313 aProfileInfo = anIter->second;
3314 aGeom2Profile[aGeom] = aProfileInfo;
3318 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3320 *theErr = MED_FALSE;
3323 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3326 if (aProfileInfo && aProfileInfo->IsPresent()) {
3327 TInt aNbSubElem = aProfileInfo->GetSize();
3328 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3329 if (aProfileSize != aValueSize) {
3334 EXCEPTION(std::runtime_error,
3335 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3336 ") != aValueSize("<<aValueSize<<
3337 "); aNbVal = "<<aNbVal<<
3338 "; anEntity = "<<anEntity<<
3339 "; aGeom = "<<aGeom<<
3340 "; aNbElem = "<<aNbElem<<
3341 "; aNbSubElem = "<<aNbSubElem<<
3342 "; aNbComp = "<<aNbComp<<
3343 "; aNbGauss = "<<aNbGauss<<
3348 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3353 EXCEPTION(std::runtime_error,
3354 "GetTimeStampValue - aNbElem("<<aNbElem<<
3355 ") != aNbValue("<<aNbValue<<
3356 "); aNbVal = "<<aNbVal<<
3357 "; anEntity = "<<anEntity<<
3358 "; aGeom = "<<aGeom<<
3359 "; aNbElem = "<<aNbElem<<
3360 "; aNbComp = "<<aNbComp<<
3361 "; aNbGauss = "<<aNbGauss<<
3368 //----------------------------------------------------------------------------
3371 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3375 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3378 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3384 //----------------------------------------------------------------------------
3387 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3391 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3393 if (theErr && *theErr < 0)
3397 TIdt anId = myFile->Id();
3399 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3400 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3402 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3403 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3404 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3405 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3406 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3407 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3408 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3410 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3411 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3413 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3414 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3416 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3417 TGeomSet::const_iterator anIter = aGeomSet.begin();
3418 for (; anIter != aGeomSet.end(); anIter++) {
3419 EGeometrieElement aGeom = *anIter;
3421 TVector<char> aGaussName(GetNOMLength()+1);
3422 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3423 if (aGaussIter != aGeom2Gauss.end()) {
3424 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3425 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3428 TVector<char> aProfileName(GetNOMLength()+1);
3429 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3430 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3431 if (aProfileIter != aGeom2Profile.end()) {
3432 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3433 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3434 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3437 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3439 aRet = MEDfieldValueWithProfileWr(anId,
3445 med_geometry_type(aGeom),
3450 MED_ALL_CONSTITUENT,
3452 theTimeStampValue->GetValuePtr(aGeom));
3455 *theErr = MED_FALSE;
3458 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3463 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3466 //----------------------------------------------------------------------------
3469 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3470 ETypeChamp theTypeChamp,
3471 const TGeom2Profile& theGeom2Profile,
3472 EModeSwitch theMode)
3474 if (theTypeChamp == eFLOAT64)
3475 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3480 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3487 //----------------------------------------------------------------------------
3490 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3491 const TGeom2Profile& theGeom2Profile,
3492 EModeSwitch theMode)
3494 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3495 return CrTimeStampValue(theTimeStampInfo,
3496 aFieldInfo->GetType(),
3501 //----------------------------------------------------------------------------
3504 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3505 const PTimeStampValueBase& theInfo,
3506 ETypeChamp theTypeChamp)
3508 if (theTypeChamp == eFLOAT64)
3509 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3513 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3519 //----------------------------------------------------------------------------
3522 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3523 const PTimeStampValueBase& theInfo)
3525 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3526 return CrTimeStampValue(theTimeStampInfo,
3528 aFieldInfo->GetType());
3531 //----------------------------------------------------------------------------
3534 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3535 const TMKey2Profile& theMKey2Profile,
3536 const TKey2Gauss& theKey2Gauss,
3539 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3540 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3541 aFieldInfo->GetType());
3542 GetTimeStampValue(anInfo,
3547 if (aFieldInfo->GetType() == eFLOAT64)
3548 Print<TFloatTimeStampValue>(anInfo);
3550 Print<TIntTimeStampValue>(anInfo);
3555 //----------------------------------------------------------------------------
3558 ::GetTimeStampVal(const PTimeStampVal& theVal,
3559 const TMKey2Profile& theMKey2Profile,
3560 const TKey2Gauss& theKey2Gauss,
3563 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3564 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3565 if (aFieldInfo->GetType() == eFLOAT64)
3566 GetTimeStampValue(theVal,
3571 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3574 GetTimeStampValue(aVal,
3578 CopyTimeStampValueBase(aVal, theVal);
3582 //----------------------------------------------------------------------------
3585 ::SetTimeStamp(const PTimeStampVal& theVal,
3588 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3589 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3590 if (aFieldInfo->GetType() == eFLOAT64)
3591 SetTimeStampValue(theVal, theErr);
3593 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3595 theVal->GetGeom2Profile(),
3596 theVal->GetModeSwitch());
3597 CopyTimeStampValueBase(theVal, aVal);
3598 SetTimeStampValue(aVal, theErr);
3602 //----------------------------------------------------------------------------
3605 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3606 const TGeom2Profile& theGeom2Profile,
3607 EModeSwitch theMode)
3609 return CrTimeStampValue(theTimeStampInfo,
3615 //----------------------------------------------------------------------------
3618 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3619 const PTimeStampVal& theInfo)
3621 return CrTimeStampValue(theTimeStampInfo,
3626 //----------------------------------------------------------------------------
3629 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3630 const TMKey2Profile& theMKey2Profile,
3631 const TKey2Gauss& theKey2Gauss,
3634 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3635 GetTimeStampVal(anInfo,
3642 //----------------------------------------------------------------------------
3645 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3647 if (theMeshInfo->GetType() != eSTRUCTURE)
3648 return PGrilleInfo();
3651 GetGrilleType(*theMeshInfo, type);
3653 if (type == eGRILLE_STANDARD) {
3654 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3655 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3659 aVec.resize(theMeshInfo->GetDim());
3660 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3661 ETable aATable = eCOOR_IND1;
3664 aATable = eCOOR_IND1;
3667 aATable = eCOOR_IND2;
3670 aATable = eCOOR_IND3;
3673 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3675 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3678 GetGrilleInfo(anInfo);
3679 anInfo->SetGrilleType(type);
3682 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3684 TInt aNbElem = anInfo->GetNbNodes();
3685 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3686 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3687 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3689 TInt aNbCells = anInfo->GetNbCells();
3690 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3691 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3692 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3694 ADDMSG(MYVALUEDEBUG, std::endl);
3695 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3696 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3697 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3699 ADDMSG(MYVALUEDEBUG, std::endl);
3700 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3701 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3702 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3704 ADDMSG(MYVALUEDEBUG, std::endl);
3712 //----------------------------------------------------------------------------
3715 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3716 const PGrilleInfo& theInfo)
3718 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3722 //----------------------------------------------------------------------------
3725 ::GetGrilleInfo(TGrilleInfo& theInfo,
3728 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3730 if (theErr && *theErr < 0)
3733 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3734 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3735 EMaillage aMaillageType = aMeshInfo.myType;
3737 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3738 EGrilleType aGrilleType = theInfo.myGrilleType;
3741 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3742 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3744 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3745 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3746 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3747 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3748 //med_axis_type aRepere;
3750 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3760 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3762 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3763 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3765 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3774 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3776 int mySize = (int)theInfo.myFamNumNode.size();
3777 theInfo.myFamNumNode.clear();
3778 theInfo.myFamNumNode.resize(mySize,0);
3782 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3787 //============================
3790 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3791 ETable aTable = eCOOR_IND1;
3792 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3795 aTable = eCOOR_IND1;
3798 aTable = eCOOR_IND2;
3801 aTable = eCOOR_IND3;
3810 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3812 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3814 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3816 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3817 //TValueHolder<ETable, med_data_type > table(aTable);
3818 //char aCompNames[MED_SNAME_SIZE+1];
3819 //char anUnitNames[MED_SNAME_SIZE+1];
3820 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3822 MED_NO_DT,MED_NO_IT,
3826 //theInfo.SetCoordName(anAxis-1, aCompNames);
3827 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3828 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3833 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3837 EGeometrieElement aGeom = theInfo.GetGeom();
3838 EEntiteMaillage aEntity = theInfo.GetEntity();
3839 TInt aNbCells = theInfo.GetNbCells();
3841 theInfo.myFamNum.resize(aNbCells);
3842 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3844 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3845 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3846 med_geometry_type(aGeom), &aFamNum);
3848 if (aMeshInfo.myDim == 3)
3850 aGeom = theInfo.GetSubGeom();
3851 aEntity = theInfo.GetSubEntity();
3852 aNbCells = theInfo.GetNbSubCells();
3854 theInfo.myFamSubNum.resize(aNbCells, 0);
3855 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3857 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3861 med_entity_type(aEntity),
3862 med_geometry_type(aGeom),
3866 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3868 int mySize = (int)theInfo.myFamNumNode.size();
3869 theInfo.myFamNumNode.clear();
3870 theInfo.myFamNumNode.resize(mySize, 0);
3874 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3880 //----------------------------------------------------------------------------
3883 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3886 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3889 //----------------------------------------------------------------------------
3892 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3896 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3898 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3900 if (theErr && *theErr < 0)
3903 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3905 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3906 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3908 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3911 aRet = MEDmeshGridTypeRd(myFile->Id(),
3917 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3919 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3920 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3921 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3922 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3923 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3924 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3925 //med_axis_type aRepere = MED_CARTESIAN;
3927 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3937 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3939 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3940 aRet = MEDmeshGridStructWr(myFile->Id(),
3947 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3951 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3952 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3958 anInfo.GetIndexes(aAxis).size(),
3959 &anInfo.GetIndexes(aAxis)[0]);
3962 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3970 //----------------------------------------------------------------------------
3973 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3974 const PGrilleInfo& theInfo)
3976 return PGrilleInfo(new TTGrilleInfo
3981 //----------------------------------------------------------------------------
3984 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
3986 return PGrilleInfo(); // not implemented????
3989 //----------------------------------------------------------------------------
3992 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3993 const EGrilleType& type)
3995 return PGrilleInfo(new TTGrilleInfo
4000 //----------------------------------------------------------------------------
4003 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4004 const EGrilleType& type,
4005 const TInt& nbNodes)
4007 return PGrilleInfo(new TTGrilleInfo
4013 //----------------------------------------------------------------------------
4016 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4017 const EGrilleType& type,
4018 const MED::TIntVector& nbNodeVec)
4020 return PGrilleInfo(new TTGrilleInfo
4026 //----------------------------------------------------------------------------
4029 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4030 EGrilleType& theGridType,
4033 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4035 if (theErr && *theErr < 0)
4036 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4038 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4040 if (aMeshInfo.myType == eSTRUCTURE) {
4041 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4042 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4043 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4048 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4052 //----------------------------------------------------------------------------
4055 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4056 TIntVector& theStruct,
4059 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4061 if (theErr && *theErr < 0)
4065 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4067 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4068 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4070 aRet = MEDmeshGridStructRd(myFile->Id(),
4078 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");