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);
2061 aRet = MEDmeshElementRd(myFile->Id(),
2080 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2082 if (anIsFamNum == MED_FALSE)
2084 int mySize = (int) theInfo.myFamNum->size();
2085 theInfo.myFamNum->clear();
2086 theInfo.myFamNum->resize(mySize, 0);
2091 //----------------------------------------------------------------------------
2094 ::SetCellInfo(const MED::TCellInfo& theInfo,
2097 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2100 //----------------------------------------------------------------------------
2103 ::SetCellInfo(const MED::TCellInfo& theInfo,
2107 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2109 if (theErr && *theErr < 0)
2112 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2113 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2115 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2116 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2117 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2118 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2119 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2120 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2121 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2122 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2123 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2124 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2125 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2126 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2127 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2130 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2142 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2151 MEDmeshEntityNameWr(myFile->Id(),
2160 MEDmeshEntityNumberWr(myFile->Id(),
2171 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2174 //----------------------------------------------------------------------------
2177 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2178 EEntiteMaillage theEntity,
2179 EGeometrieElement theGeom,
2181 EConnectivite theConnMode,
2182 EBooleen theIsElemNum,
2183 EBooleen theIsElemNames,
2184 EModeSwitch theMode)
2186 return PCellInfo(new TTCellInfo
2197 //----------------------------------------------------------------------------
2200 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2201 EEntiteMaillage theEntity,
2202 EGeometrieElement theGeom,
2203 const TIntVector& theConnectivities,
2204 EConnectivite theConnMode,
2205 const TIntVector& theFamilyNums,
2206 const TIntVector& theElemNums,
2207 const TStringVector& theElemNames,
2208 EModeSwitch theMode)
2210 return PCellInfo(new TTCellInfo
2222 //----------------------------------------------------------------------------
2225 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2226 const PCellInfo& theInfo)
2228 return PCellInfo(new TTCellInfo
2233 //----------------------------------------------------------------------------
2236 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2237 EEntiteMaillage theEntity,
2238 EGeometrieElement theGeom,
2239 EConnectivite theConnMode,
2242 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2244 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2245 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2246 GetCellInfo(anInfo, theErr);
2249 TInt aConnDim = anInfo->GetConnDim();
2250 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2251 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2252 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2253 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2254 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2255 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2257 ADDMSG(MYVALUEDEBUG, " ");
2259 ADDMSG(MYDEBUG, std::endl);
2261 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2262 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2263 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2265 ADDMSG(MYVALUEDEBUG, std::endl);
2267 if (anInfo->IsElemNum()) {
2268 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2269 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2270 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2272 ADDMSG(MYVALUEDEBUG, std::endl);
2274 ADDMSG(MYDEBUG, std::endl);
2280 //----------------------------------------------------------------------------
2283 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2286 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2288 // read med_geometry_type of "MED_BALL" element
2289 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2290 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2293 //----------------------------------------------------------------------------
2296 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2299 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2301 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2305 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2308 //----------------------------------------------------------------------------
2311 ::GetBallInfo(TBallInfo& theInfo,
2314 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2316 // check geometry of MED_BALL
2317 if (theInfo.myGeom == eBALL)
2319 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2320 if (theInfo.myGeom < 0) {
2322 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2323 *theErr = theInfo.myGeom;
2329 GetCellInfo(theInfo);
2332 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2333 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2334 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2335 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2337 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2338 MED_NO_DT, MED_NO_IT,
2345 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2348 //----------------------------------------------------------------------------
2351 ::SetBallInfo(const TBallInfo& theInfo,
2354 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2357 //----------------------------------------------------------------------------
2360 ::SetBallInfo(const TBallInfo& theInfo,
2364 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2367 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2368 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2371 // no ball model in the file, create support mesh for it
2372 char dummyname [MED_NAME_SIZE*3+1] = "";
2373 if ((ret = MEDsupportMeshCr(myFile->Id(),
2375 theInfo.myMeshInfo->GetSpaceDim(),
2376 theInfo.myMeshInfo->GetDim(),
2377 "Support mesh for a ball model",
2379 /*axisname=*/dummyname,
2380 /*unitname=*/dummyname)) < 0) {
2382 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2386 // write coordinates of 1 node
2387 med_float coord[3] = {0, 0, 0};
2388 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2389 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2390 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2392 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2396 // ball model creation
2397 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2398 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2400 theInfo.myMeshInfo->GetSpaceDim(),
2402 MED_NODE,MED_NONE)) < 0) {
2404 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2408 // create diameter attribute
2409 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2410 geotypename, MED_BALL_DIAMETER,
2411 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2413 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2419 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2420 aBallInfo.myGeom = ballGeom;
2423 SetCellInfo(theInfo, theMode, theErr);
2424 if (theErr && theErr < 0)
2428 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2429 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2430 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2431 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2432 MED_NO_DT, MED_NO_IT,
2433 aGeom, MED_BALL_DIAMETER,
2434 theInfo.myNbElem, &aDiam);
2438 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2441 //----------------------------------------------------------------------------
2444 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2446 EBooleen theIsElemNum)
2448 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2451 //----------------------------------------------------------------------------
2454 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2455 const TIntVector& theNodes,
2456 TFloatVector& theDiameters,
2457 const TIntVector& theFamilyNums,
2458 const TIntVector& theElemNums)
2460 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2461 theFamilyNums, theElemNums));
2464 //----------------------------------------------------------------------------
2467 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2468 const PBallInfo& theInfo)
2470 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2473 //----------------------------------------------------------------------------
2476 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2478 TInt nbBalls = GetNbBalls(theMeshInfo);
2479 if (nbBalls < 1) return PBallInfo();
2481 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2482 GetBallInfo(anInfo);
2487 //-----------------------------------------------------------------
2490 ::GetNbFields(TErr* theErr)
2492 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2494 if (theErr && *theErr < 0)
2497 return MEDnField(myFile->Id());
2500 //----------------------------------------------------------------------------
2503 ::GetNbComp(TInt theFieldId,
2506 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2508 if (theErr && *theErr < 0)
2511 return MEDfieldnComponent(myFile->Id(), theFieldId);
2514 //----------------------------------------------------------------------------
2517 ::GetFieldInfo(TInt theFieldId,
2518 MED::TFieldInfo& theInfo,
2521 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2523 if (theErr && *theErr < 0)
2526 TString aFieldName(256); // Protect from memory problems with too long names
2527 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2528 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2529 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2530 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2534 char dtunit[MED_SNAME_SIZE+1];
2535 char local_mesh_name[MED_NAME_SIZE+1]="";
2537 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2538 aRet = MEDfieldInfo(myFile->Id(),
2549 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2555 theInfo.SetName(aFieldName);
2560 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2563 //----------------------------------------------------------------------------
2566 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2570 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2573 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2579 //----------------------------------------------------------------------------
2582 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2586 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2588 if (theErr && *theErr < 0)
2591 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2593 TValueHolder<TString, char> aFieldName(anInfo.myName);
2594 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2595 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2596 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2597 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2599 char dtunit[MED_SNAME_SIZE+1];
2600 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2601 aRet = MEDfieldCr(myFile->Id(),
2608 &aMeshInfo.myName[0]);
2612 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2615 //----------------------------------------------------------------------------
2618 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2621 const std::string& theValue,
2622 EBooleen theIsLocal,
2625 return PFieldInfo(new TTFieldInfo
2634 //----------------------------------------------------------------------------
2637 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2638 const PFieldInfo& theInfo)
2640 return PFieldInfo(new TTFieldInfo
2645 //----------------------------------------------------------------------------
2648 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2652 TInt aNbComp = GetNbComp(theId);
2653 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2654 GetFieldInfo(theId, *anInfo, theErr);
2659 "- aName = '"<<anInfo->GetName()<<"'"<<
2660 "; aType = "<<anInfo->GetType()<<
2661 "; aNbComp = "<<aNbComp<<
2668 //----------------------------------------------------------------------------
2671 ::GetNbGauss(TErr* theErr)
2673 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2675 if (theErr && *theErr < 0)
2678 return MEDnLocalization(myFile->Id());
2681 //----------------------------------------------------------------------------
2684 ::GetGaussPreInfo(TInt theId,
2687 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2689 if (theErr && *theErr < 0)
2690 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2692 med_int aNbGaussPoints = med_int();
2693 TVector<char> aName(GetNOMLength()+1);
2694 med_geometry_type aGeom = MED_NONE;
2698 char geointerpname[MED_NAME_SIZE+1] = "";
2699 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2700 med_int nsectionmeshcell;
2701 med_geometry_type sectiongeotype;
2702 aRet = MEDlocalizationInfo (myFile->Id(),
2709 ipointstructmeshname,
2715 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2716 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2717 TInt(aNbGaussPoints));
2720 //----------------------------------------------------------------------------
2723 ::GetGaussInfo(TInt theId,
2724 TGaussInfo& theInfo,
2727 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2729 if (theErr && *theErr < 0)
2732 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2733 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2734 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2735 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2736 TValueHolder<TString, char> aGaussName(theInfo.myName);
2739 aRet = MEDlocalizationRd(myFile->Id(),
2749 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2752 //----------------------------------------------------------------------------
2755 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2756 EModeSwitch theMode)
2758 return PGaussInfo(new TTGaussInfo
2763 //-----------------------------------------------------------------
2766 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2767 const MED::TEntityInfo& theEntityInfo,
2768 EEntiteMaillage& theEntity,
2769 TGeom2Size& theGeom2Size,
2772 theEntity = EEntiteMaillage(-1);
2773 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2776 if (theEntityInfo.empty())
2781 else if (theEntityInfo.empty())
2782 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2784 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2786 theGeom2Size.clear();
2787 TInt aNbTimeStamps = 0;
2788 TIdt anId = myFile->Id();
2790 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2791 TValueHolder<TString, char> aFieldName(anInfo.myName);
2792 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2794 // workaround for IPAL13676
2795 MED::TEntityInfo localEntityInfo = theEntityInfo;
2796 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2797 if (anLocalIter != localEntityInfo.end()) {
2798 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2801 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2802 for (; anIter != localEntityInfo.end(); anIter++) {
2803 med_entity_type anEntity = med_entity_type(anIter->first);
2804 const TGeom2Size& aGeom2Size = anIter->second;
2805 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2806 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2807 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2808 char aMeshName[MED_NAME_SIZE+1];
2811 char dtunit[MED_SNAME_SIZE+1];
2812 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2813 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2814 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2816 MEDfieldInfoByName(anId,
2833 MEDfieldComputingStepInfo(anId,
2839 char profilename[MED_NAME_SIZE+1];
2840 char locname[MED_NAME_SIZE+1];
2844 // protection from crash (division by zero)
2845 // inside MEDfieldnValueWithProfile function
2846 // caused by the workaround for IPAL13676 (see above)
2847 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2850 nval = MEDfieldnValueWithProfile(anId,
2855 med_geometry_type(aGeom),
2863 bool anIsSatisfied =(nval > 0);
2864 if (anIsSatisfied) {
2866 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2867 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2868 if (anIsPerformAdditionalCheck) {
2869 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2870 if (!anIsSatisfied) {
2872 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2873 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2877 if (anIsSatisfied) {
2878 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2879 theEntity = EEntiteMaillage(anEntity);
2880 aNbTimeStamps = aNbStamps;
2883 if (!theGeom2Size.empty())
2886 return aNbTimeStamps;
2889 //----------------------------------------------------------------------------
2892 ::GetTimeStampInfo(TInt theTimeStampId,
2893 MED::TTimeStampInfo& theInfo,
2896 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2898 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2901 if (aGeom2Size.empty())
2906 else if (aGeom2Size.empty())
2907 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2909 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2910 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2912 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2913 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2914 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2915 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2916 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2917 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2918 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2919 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2920 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2922 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2924 // just to get a time stamp unit (anUnitDt)
2925 med_field_type aFieldType;
2926 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2927 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2928 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2930 MEDfieldInfoByName(myFile->Id(),
2939 delete [] aCompName;
2940 delete [] aCompUnit;
2942 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2943 for (; anIter != aGeom2Size.end(); anIter++) {
2944 const EGeometrieElement& aGeom = anIter->first;
2945 med_int aNbGauss = -1;
2948 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2954 char profilename[MED_NAME_SIZE+1];
2956 char locname[MED_NAME_SIZE+1];
2957 MEDfieldnValueWithProfile(myFile->Id(),
2962 med_geometry_type(aGeom),
2970 static TInt MAX_NB_GAUSS_POINTS = 32;
2971 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2974 aGeom2NbGauss[aGeom] = aNbGauss;
2979 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2983 //----------------------------------------------------------------------------
2986 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
2987 EEntiteMaillage theEntity,
2988 const TGeom2Size& theGeom2Size,
2989 const TGeom2NbGauss& theGeom2NbGauss,
2993 const std::string& theUnitDt,
2994 const TGeom2Gauss& theGeom2Gauss)
2996 return PTimeStampInfo(new TTTimeStampInfo
3008 //----------------------------------------------------------------------------
3011 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3012 const PTimeStampInfo& theInfo)
3014 return PTimeStampInfo(new TTTimeStampInfo
3019 //----------------------------------------------------------------------------
3022 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3023 EEntiteMaillage theEntity,
3024 const TGeom2Size& theGeom2Size,
3028 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3029 GetTimeStampInfo(theId, *anInfo, theErr);
3032 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3033 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3034 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3035 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3036 const EGeometrieElement& aGeom = anIter->first;
3037 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3044 //----------------------------------------------------------------------------
3047 ::GetNbProfiles(TErr* theErr)
3049 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3051 if (theErr && *theErr < 0)
3054 return MEDnProfile(myFile->Id());
3057 //----------------------------------------------------------------------------
3060 ::GetProfilePreInfo(TInt theId,
3063 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3065 if (theErr && *theErr < 0)
3066 return TProfileInfo::TInfo();
3069 TVector<char> aName(GetNOMLength()+1);
3072 aRet = MEDprofileInfo(myFile->Id(),
3079 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3081 return TProfileInfo::TInfo(&aName[0], aSize);
3084 //----------------------------------------------------------------------------
3087 ::GetProfileInfo(TInt theId,
3088 TProfileInfo& theInfo,
3091 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3093 if (theErr && *theErr < 0)
3096 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3097 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3098 TValueHolder<TString, char> aProfileName(anInfo.myName);
3101 aRet = MEDprofileRd(myFile->Id(),
3107 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3110 //----------------------------------------------------------------------------
3113 ::SetProfileInfo(const TProfileInfo& theInfo,
3117 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3120 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3123 SetProfileInfo(theInfo, eCREATION, &aRet);
3129 //----------------------------------------------------------------------------
3132 ::SetProfileInfo(const TProfileInfo& theInfo,
3136 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3138 if (theErr && *theErr < 0)
3141 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3142 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3143 TValueHolder<TString, char> aProfileName(anInfo.myName);
3146 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3147 &aProfileName, // tableau de valeurs du profil.
3148 theInfo.GetSize(), // taille du profil.
3149 &anElemNum); // nom profil.
3153 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3156 //----------------------------------------------------------------------------
3159 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3160 EModeProfil theMode)
3162 return PProfileInfo(new TTProfileInfo
3167 //----------------------------------------------------------------------------
3170 ::GetPProfileInfo(TInt theId,
3171 EModeProfil theMode,
3174 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3175 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3176 GetProfileInfo(theId, *anInfo, theErr);
3181 //----------------------------------------------------------------------------
3184 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3185 const TMKey2Profile& theMKey2Profile,
3186 const TKey2Gauss& theKey2Gauss,
3189 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3191 if (theErr && *theErr < 0)
3194 TIdt anId = myFile->Id();
3196 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3197 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3199 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3200 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3201 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3202 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3204 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3205 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3206 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3208 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3209 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3211 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3212 TVector<char> aGaussName(GetNOMLength()+1);
3214 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3215 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3216 TVector<char> aProfileName(GetNOMLength()+1);
3218 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3219 TGeom2Size::iterator anIter = aGeom2Size.begin();
3220 for (; anIter != aGeom2Size.end(); anIter++) {
3221 EGeometrieElement aGeom = anIter->first;
3222 TInt aNbElem = anIter->second;
3223 med_int profilesize, aNbGauss;
3225 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3230 med_geometry_type(aGeom),
3243 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3246 TInt aNbComp = aFieldInfo->myNbComp;
3247 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3248 theTimeStampValue->AllocateValue(aGeom,
3252 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3255 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3256 "; aNbVal = "<<aNbVal<<
3257 "; aNbValue = "<<aNbValue<<
3258 "; aNbGauss = "<<aNbGauss<<
3259 "; aNbComp = "<<aNbComp<<
3262 TErr aRet = MEDfieldValueWithProfileRd(anId,
3267 med_geometry_type(aGeom),
3271 MED_ALL_CONSTITUENT,
3272 theTimeStampValue->GetValuePtr(aGeom));
3275 *theErr = MED_FALSE;
3278 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3281 MED::PGaussInfo aGaussInfo;
3282 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3283 if (strcmp(&aGaussName[0], "") != 0) {
3284 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3285 if (anIter != theKey2Gauss.end()) {
3286 aGaussInfo = anIter->second;
3287 aGeom2Gauss[aGeom] = aGaussInfo;
3291 MED::PProfileInfo aProfileInfo;
3292 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3293 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3294 if (anIter != aKey2Profile.end()) {
3295 aProfileInfo = anIter->second;
3296 aGeom2Profile[aGeom] = aProfileInfo;
3300 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3302 *theErr = MED_FALSE;
3305 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3308 if (aProfileInfo && aProfileInfo->IsPresent()) {
3309 TInt aNbSubElem = aProfileInfo->GetSize();
3310 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3311 if (aProfileSize != aValueSize) {
3316 EXCEPTION(std::runtime_error,
3317 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3318 ") != aValueSize("<<aValueSize<<
3319 "); aNbVal = "<<aNbVal<<
3320 "; anEntity = "<<anEntity<<
3321 "; aGeom = "<<aGeom<<
3322 "; aNbElem = "<<aNbElem<<
3323 "; aNbSubElem = "<<aNbSubElem<<
3324 "; aNbComp = "<<aNbComp<<
3325 "; aNbGauss = "<<aNbGauss<<
3330 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3335 EXCEPTION(std::runtime_error,
3336 "GetTimeStampValue - aNbElem("<<aNbElem<<
3337 ") != aNbValue("<<aNbValue<<
3338 "); aNbVal = "<<aNbVal<<
3339 "; anEntity = "<<anEntity<<
3340 "; aGeom = "<<aGeom<<
3341 "; aNbElem = "<<aNbElem<<
3342 "; aNbComp = "<<aNbComp<<
3343 "; aNbGauss = "<<aNbGauss<<
3350 //----------------------------------------------------------------------------
3353 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3357 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3360 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3366 //----------------------------------------------------------------------------
3369 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3373 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3375 if (theErr && *theErr < 0)
3379 TIdt anId = myFile->Id();
3381 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3382 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3384 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3385 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3386 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3387 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3388 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3389 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3390 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3392 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3393 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3395 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3396 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3398 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3399 TGeomSet::const_iterator anIter = aGeomSet.begin();
3400 for (; anIter != aGeomSet.end(); anIter++) {
3401 EGeometrieElement aGeom = *anIter;
3403 TVector<char> aGaussName(GetNOMLength()+1);
3404 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3405 if (aGaussIter != aGeom2Gauss.end()) {
3406 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3407 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3410 TVector<char> aProfileName(GetNOMLength()+1);
3411 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3412 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3413 if (aProfileIter != aGeom2Profile.end()) {
3414 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3415 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3416 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3419 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3421 aRet = MEDfieldValueWithProfileWr(anId,
3427 med_geometry_type(aGeom),
3432 MED_ALL_CONSTITUENT,
3434 theTimeStampValue->GetValuePtr(aGeom));
3437 *theErr = MED_FALSE;
3440 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3445 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3448 //----------------------------------------------------------------------------
3451 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3452 ETypeChamp theTypeChamp,
3453 const TGeom2Profile& theGeom2Profile,
3454 EModeSwitch theMode)
3456 if (theTypeChamp == eFLOAT64)
3457 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3462 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3469 //----------------------------------------------------------------------------
3472 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3473 const TGeom2Profile& theGeom2Profile,
3474 EModeSwitch theMode)
3476 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3477 return CrTimeStampValue(theTimeStampInfo,
3478 aFieldInfo->GetType(),
3483 //----------------------------------------------------------------------------
3486 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3487 const PTimeStampValueBase& theInfo,
3488 ETypeChamp theTypeChamp)
3490 if (theTypeChamp == eFLOAT64)
3491 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3495 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3501 //----------------------------------------------------------------------------
3504 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3505 const PTimeStampValueBase& theInfo)
3507 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3508 return CrTimeStampValue(theTimeStampInfo,
3510 aFieldInfo->GetType());
3513 //----------------------------------------------------------------------------
3516 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3517 const TMKey2Profile& theMKey2Profile,
3518 const TKey2Gauss& theKey2Gauss,
3521 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3522 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3523 aFieldInfo->GetType());
3524 GetTimeStampValue(anInfo,
3529 if (aFieldInfo->GetType() == eFLOAT64)
3530 Print<TFloatTimeStampValue>(anInfo);
3532 Print<TIntTimeStampValue>(anInfo);
3537 //----------------------------------------------------------------------------
3540 ::GetTimeStampVal(const PTimeStampVal& theVal,
3541 const TMKey2Profile& theMKey2Profile,
3542 const TKey2Gauss& theKey2Gauss,
3545 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3546 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3547 if (aFieldInfo->GetType() == eFLOAT64)
3548 GetTimeStampValue(theVal,
3553 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3556 GetTimeStampValue(aVal,
3560 CopyTimeStampValueBase(aVal, theVal);
3564 //----------------------------------------------------------------------------
3567 ::SetTimeStamp(const PTimeStampVal& theVal,
3570 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3571 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3572 if (aFieldInfo->GetType() == eFLOAT64)
3573 SetTimeStampValue(theVal, theErr);
3575 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3577 theVal->GetGeom2Profile(),
3578 theVal->GetModeSwitch());
3579 CopyTimeStampValueBase(theVal, aVal);
3580 SetTimeStampValue(aVal, theErr);
3584 //----------------------------------------------------------------------------
3587 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3588 const TGeom2Profile& theGeom2Profile,
3589 EModeSwitch theMode)
3591 return CrTimeStampValue(theTimeStampInfo,
3597 //----------------------------------------------------------------------------
3600 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3601 const PTimeStampVal& theInfo)
3603 return CrTimeStampValue(theTimeStampInfo,
3608 //----------------------------------------------------------------------------
3611 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3612 const TMKey2Profile& theMKey2Profile,
3613 const TKey2Gauss& theKey2Gauss,
3616 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3617 GetTimeStampVal(anInfo,
3624 //----------------------------------------------------------------------------
3627 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3629 if (theMeshInfo->GetType() != eSTRUCTURE)
3630 return PGrilleInfo();
3633 GetGrilleType(*theMeshInfo, type);
3635 if (type == eGRILLE_STANDARD) {
3636 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3637 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3641 aVec.resize(theMeshInfo->GetDim());
3642 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3643 ETable aATable = eCOOR_IND1;
3646 aATable = eCOOR_IND1;
3649 aATable = eCOOR_IND2;
3652 aATable = eCOOR_IND3;
3655 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3657 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3660 GetGrilleInfo(anInfo);
3661 anInfo->SetGrilleType(type);
3664 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3666 TInt aNbElem = anInfo->GetNbNodes();
3667 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3668 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3669 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3671 TInt aNbCells = anInfo->GetNbCells();
3672 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3673 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3674 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3676 ADDMSG(MYVALUEDEBUG, std::endl);
3677 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3678 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3679 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3681 ADDMSG(MYVALUEDEBUG, std::endl);
3682 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3683 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3684 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3686 ADDMSG(MYVALUEDEBUG, std::endl);
3694 //----------------------------------------------------------------------------
3697 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3698 const PGrilleInfo& theInfo)
3700 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3704 //----------------------------------------------------------------------------
3707 ::GetGrilleInfo(TGrilleInfo& theInfo,
3710 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3712 if (theErr && *theErr < 0)
3715 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3716 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3717 EMaillage aMaillageType = aMeshInfo.myType;
3719 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3720 EGrilleType aGrilleType = theInfo.myGrilleType;
3723 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3724 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3726 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3727 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3728 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3729 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3730 //med_axis_type aRepere;
3732 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3742 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3744 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3745 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3747 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3756 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3758 int mySize = (int)theInfo.myFamNumNode.size();
3759 theInfo.myFamNumNode.clear();
3760 theInfo.myFamNumNode.resize(mySize,0);
3764 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3769 //============================
3772 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3773 ETable aTable = eCOOR_IND1;
3774 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3777 aTable = eCOOR_IND1;
3780 aTable = eCOOR_IND2;
3783 aTable = eCOOR_IND3;
3792 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3794 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3796 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3798 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3799 //TValueHolder<ETable, med_data_type > table(aTable);
3800 //char aCompNames[MED_SNAME_SIZE+1];
3801 //char anUnitNames[MED_SNAME_SIZE+1];
3802 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3804 MED_NO_DT,MED_NO_IT,
3808 //theInfo.SetCoordName(anAxis-1, aCompNames);
3809 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3810 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3815 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3819 EGeometrieElement aGeom = theInfo.GetGeom();
3820 EEntiteMaillage aEntity = theInfo.GetEntity();
3821 TInt aNbCells = theInfo.GetNbCells();
3823 theInfo.myFamNum.resize(aNbCells);
3824 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3826 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3827 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3828 med_geometry_type(aGeom), &aFamNum);
3830 if (aMeshInfo.myDim == 3)
3832 aGeom = theInfo.GetSubGeom();
3833 aEntity = theInfo.GetSubEntity();
3834 aNbCells = theInfo.GetNbSubCells();
3836 theInfo.myFamSubNum.resize(aNbCells, 0);
3837 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3839 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3843 med_entity_type(aEntity),
3844 med_geometry_type(aGeom),
3848 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3850 int mySize = (int)theInfo.myFamNumNode.size();
3851 theInfo.myFamNumNode.clear();
3852 theInfo.myFamNumNode.resize(mySize, 0);
3856 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3862 //----------------------------------------------------------------------------
3865 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3868 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3871 //----------------------------------------------------------------------------
3874 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3878 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3880 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3882 if (theErr && *theErr < 0)
3885 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3887 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3888 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3890 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3893 aRet = MEDmeshGridTypeRd(myFile->Id(),
3899 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3901 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3902 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3903 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3904 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3905 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3906 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3907 //med_axis_type aRepere = MED_CARTESIAN;
3909 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3919 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3921 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3922 aRet = MEDmeshGridStructWr(myFile->Id(),
3929 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3933 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3934 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3940 anInfo.GetIndexes(aAxis).size(),
3941 &anInfo.GetIndexes(aAxis)[0]);
3944 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3952 //----------------------------------------------------------------------------
3955 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3956 const PGrilleInfo& theInfo)
3958 return PGrilleInfo(new TTGrilleInfo
3963 //----------------------------------------------------------------------------
3966 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
3968 return PGrilleInfo(); // not implemented????
3971 //----------------------------------------------------------------------------
3974 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3975 const EGrilleType& type)
3977 return PGrilleInfo(new TTGrilleInfo
3982 //----------------------------------------------------------------------------
3985 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3986 const EGrilleType& type,
3987 const TInt& nbNodes)
3989 return PGrilleInfo(new TTGrilleInfo
3995 //----------------------------------------------------------------------------
3998 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3999 const EGrilleType& type,
4000 const MED::TIntVector& nbNodeVec)
4002 return PGrilleInfo(new TTGrilleInfo
4008 //----------------------------------------------------------------------------
4011 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4012 EGrilleType& theGridType,
4015 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4017 if (theErr && *theErr < 0)
4018 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4020 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4022 if (aMeshInfo.myType == eSTRUCTURE) {
4023 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4024 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4025 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4030 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4034 //----------------------------------------------------------------------------
4037 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4038 TIntVector& theStruct,
4041 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4043 if (theErr && *theErr < 0)
4047 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4049 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4050 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4052 aRet = MEDmeshGridStructRd(myFile->Id(),
4060 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");