1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MED_Wrapper.hxx"
24 #include "MED_TStructures.hxx"
25 #include "MED_Utilities.hxx"
30 #include <boost/version.hpp>
33 static int MYDEBUG = 0;
34 static int MYVALUEDEBUG = 0;
36 static int MYDEBUG = 0;
37 static int MYVALUEDEBUG = 0;
42 //---------------------------------------------------------------
44 ::TLockProxy(TWrapper* theWrapper):
47 #if BOOST_VERSION >= 103500
48 myWrapper->myMutex.lock();
50 boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
52 INITMSG(MYDEBUG, "TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
58 INITMSG(MYDEBUG, "~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
59 #if BOOST_VERSION >= 103500
60 myWrapper->myMutex.unlock();
62 boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
68 ::operator->() const // never throws
73 //---------------------------------------------------------------
80 TFile(const std::string& theFileName):
83 myFileName(theFileName)
92 Open(EModeAcces theMode,
96 const char* aFileName = myFileName.c_str();
97 myFid = MEDfileOpen(aFileName, med_access_mode(theMode));
100 *theErr = TErr(myFid);
102 EXCEPTION(std::runtime_error, "TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
109 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
123 std::string myFileName;
126 //---------------------------------------------------------------
132 TFileWrapper(const PFile& theFile,
134 TErr* theErr = NULL):
137 myFile->Open(theMode, theErr);
146 //----------------------------------------------------------------------------
147 template<class TimeStampValueType>
149 Print(SharedPtr<TimeStampValueType> theTimeStampValue)
151 INITMSG(MYDEBUG,"Print - TimeStampValue\n");
152 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
153 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
154 for (; anIter != aGeom2Value.end(); anIter++) {
155 const EGeometrieElement& aGeom = anIter->first;
156 const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
157 TInt aNbElem = aMeshValue.myNbElem;
158 TInt aNbGauss = aMeshValue.myNbGauss;
159 TInt aNbComp = aMeshValue.myNbComp;
160 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
161 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
162 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
163 aMeshValue.GetGaussValueSliceArr(iElem);
164 ADDMSG(MYVALUEDEBUG, "{");
165 for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
166 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
167 aValueSliceArr[iGauss];
168 for (TInt iComp = 0; iComp < aNbComp; iComp++) {
169 ADDMSG(MYVALUEDEBUG, aValueSlice[iComp]<<" ");
171 ADDMSG(MYVALUEDEBUG, "| ");
173 ADDMSG(MYVALUEDEBUG, "} ");
175 ADDMSG(MYDEBUG, "\n");
179 //---------------------------------------------------------------
181 ::TWrapper(const std::string& theFileName):
182 myFile(new TFile(theFileName))
185 myFile->Open(eLECTURE_ECRITURE, &aRet);
188 // myFile->Open(eLECTURE_AJOUT, &aRet);
192 myFile->Open(eLECTURE, &aRet);
196 myFile->Open(eCREATION, &aRet);
200 //----------------------------------------------------------------------------
206 //----------------------------------------------------------------------------
209 ::GetNbMeshes(TErr* theErr)
211 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
213 if (theErr && *theErr < 0)
216 return MEDnMesh(myFile->Id());
219 //----------------------------------------------------------------------------
222 ::GetMeshInfo(TInt theMeshId,
223 MED::TMeshInfo& theInfo,
226 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
228 if (theErr && *theErr < 0)
231 TValueHolder<TString, char> aMeshName(theInfo.myName);
232 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
233 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
234 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
235 char dtunit[MED_SNAME_SIZE+1];
236 med_sorting_type sorttype;
239 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
240 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
241 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
242 TErr aRet = MEDmeshInfo(myFile->Id(),
258 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
261 //----------------------------------------------------------------------------
264 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
268 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
271 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
274 SetMeshInfo(theInfo, eCREATION, &aRet);
280 //----------------------------------------------------------------------------
283 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
287 TFileWrapper aFileWrapper(myFile, theMode, theErr);
289 if (theErr && *theErr < 0)
292 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
294 TValueHolder<TString, char> aMeshName(anInfo.myName);
295 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
296 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
297 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
298 TValueHolder<TString, char> aDesc(anInfo.myDesc);
300 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
301 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
302 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
303 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
304 TErr aRet = MEDmeshCr(myFile->Id(),
319 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
321 INITMSG(MYDEBUG, "TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
326 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
329 //----------------------------------------------------------------------------
332 ::CrMeshInfo(TInt theDim,
334 const std::string& theValue,
336 const std::string& theDesc)
338 return PMeshInfo(new TTMeshInfo
346 //----------------------------------------------------------------------------
349 ::CrMeshInfo(const PMeshInfo& theInfo)
351 return PMeshInfo(new TTMeshInfo(theInfo));
354 //----------------------------------------------------------------------------
357 ::GetPMeshInfo(TInt theId,
360 PMeshInfo anInfo = CrMeshInfo();
361 GetMeshInfo(theId, *anInfo, theErr);
365 //----------------------------------------------------------------------------
368 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
371 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
373 if (theErr && *theErr < 0)
376 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
377 TValueHolder<TString, char> aName(anInfo.myName);
378 return MEDnFamily(myFile->Id(), &aName);
381 //----------------------------------------------------------------------------
384 ::GetNbFamAttr(TInt theFamId,
385 const MED::TMeshInfo& theInfo,
388 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
390 if (theErr && *theErr < 0)
393 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
395 TValueHolder<TString, char> aName(anInfo.myName);
397 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
400 //----------------------------------------------------------------------------
403 ::GetNbFamGroup(TInt theFamId,
404 const MED::TMeshInfo& theInfo,
407 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
409 if (theErr && *theErr < 0)
412 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
414 TValueHolder<TString, char> aName(anInfo.myName);
416 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
419 //----------------------------------------------------------------------------
422 ::GetFamilyInfo(TInt theFamId,
423 MED::TFamilyInfo& theInfo,
426 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
428 if (theErr && *theErr < 0)
431 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
433 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
434 TValueHolder<TString, char> aFamilyName(theInfo.myName);
435 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
436 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
437 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
438 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
439 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
441 TErr aRet = MEDfamily23Info(myFile->Id(),
454 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
455 " aMeshInfo.myName = '"<<&aMeshName<<
456 "'; theFamId = "<<theFamId<<
457 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
458 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
461 //----------------------------------------------------------------------------
464 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
468 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
471 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
477 //----------------------------------------------------------------------------
480 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
484 TFileWrapper aFileWrapper(myFile, theMode, theErr);
486 if (theErr && *theErr < 0)
489 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
490 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
492 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
493 TValueHolder<TString, char> aFamilyName(anInfo.myName);
494 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
495 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
496 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
497 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
498 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
499 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
500 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
502 TErr aRet = MEDfamilyCr(myFile->Id(),
509 INITMSG(MYDEBUG, "TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
514 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
517 //----------------------------------------------------------------------------
520 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
524 const std::string& theValue)
526 return PFamilyInfo(new TTFamilyInfo
534 //----------------------------------------------------------------------------
537 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
538 const std::string& theValue,
540 const MED::TStringSet& theGroupNames,
541 const MED::TStringVector& theAttrDescs,
542 const MED::TIntVector& theAttrIds,
543 const MED::TIntVector& theAttrVals)
545 return PFamilyInfo(new TTFamilyInfo
555 //----------------------------------------------------------------------------
558 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
559 const PFamilyInfo& theInfo)
561 return PFamilyInfo(new TTFamilyInfo
566 //----------------------------------------------------------------------------
569 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
573 // must be reimplemented in connection with mesh type eSTRUCTURE
574 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
575 // return PFamilyInfo();
577 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
578 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
579 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
580 GetFamilyInfo(theId, *anInfo, theErr);
583 std::string aName = anInfo->GetName();
584 INITMSG(MYDEBUG, "GetPFamilyInfo - aFamilyName = '"<<aName<<
585 "'; andId = "<<anInfo->GetId()<<
586 "; aNbAttr = "<<aNbAttr<<
587 "; aNbGroup = "<<aNbGroup<<"\n");
588 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
589 aName = anInfo->GetGroupName(iGroup);
590 INITMSG(MYDEBUG, "aGroupName = '"<<aName<<"'\n");
597 //----------------------------------------------------------------------------
600 ::GetNames(TElemInfo& theInfo,
602 EEntiteMaillage theEntity,
603 EGeometrieElement theGeom,
606 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
608 if (theErr && *theErr < 0)
611 if (theGeom == eBALL)
612 theGeom = GetBallGeom(theInfo.myMeshInfo);
614 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
616 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
617 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
618 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
619 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
621 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
629 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
635 //----------------------------------------------------------------------------
638 ::SetNames(const TElemInfo& theInfo,
639 EEntiteMaillage theEntity,
640 EGeometrieElement theGeom,
643 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
646 //----------------------------------------------------------------------------
649 ::SetNames(const TElemInfo& theInfo,
651 EEntiteMaillage theEntity,
652 EGeometrieElement theGeom,
655 TFileWrapper aFileWrapper(myFile, theMode, theErr);
657 if (theErr && *theErr < 0)
660 if (theGeom == eBALL)
661 theGeom = GetBallGeom(theInfo.myMeshInfo);
663 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
664 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
667 if (theInfo.myIsElemNames) {
668 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
669 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
670 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
671 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
673 aRet = MEDmeshEntityNameWr(myFile->Id(),
679 (TInt)anInfo.myElemNames->size(),
684 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
688 //----------------------------------------------------------------------------
691 ::GetNumeration(TElemInfo& theInfo,
693 EEntiteMaillage theEntity,
694 EGeometrieElement theGeom,
697 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
699 if (theErr && *theErr < 0)
702 if (theGeom == eBALL)
703 theGeom = GetBallGeom(theInfo.myMeshInfo);
705 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
707 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
708 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
709 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
710 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
712 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
720 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
726 //----------------------------------------------------------------------------
729 ::SetNumeration(const TElemInfo& theInfo,
730 EEntiteMaillage theEntity,
731 EGeometrieElement theGeom,
734 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
737 //----------------------------------------------------------------------------
740 ::SetNumeration(const TElemInfo& theInfo,
742 EEntiteMaillage theEntity,
743 EGeometrieElement theGeom,
746 TFileWrapper aFileWrapper(myFile, theMode, theErr);
748 if (theErr && *theErr < 0)
751 if (theGeom == eBALL)
752 theGeom = GetBallGeom(theInfo.myMeshInfo);
754 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
755 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
758 if (theInfo.myIsElemNum) {
759 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
760 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
761 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
762 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
764 aRet = MEDmeshEntityNumberWr(myFile->Id(),
770 (TInt)anInfo.myElemNum->size(),
775 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
779 //----------------------------------------------------------------------------
782 ::GetFamilies(TElemInfo& theInfo,
784 EEntiteMaillage theEntity,
785 EGeometrieElement theGeom,
788 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
790 if (theErr && *theErr < 0)
793 if (theGeom == eBALL)
794 theGeom = GetBallGeom(theInfo.myMeshInfo);
796 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
798 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
799 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
800 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
801 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
803 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
812 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
814 int aSize = (int)theInfo.myFamNum->size();
815 theInfo.myFamNum->clear();
816 theInfo.myFamNum->resize(aSize,0);
820 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
826 //----------------------------------------------------------------------------
829 ::SetFamilies(const TElemInfo& theInfo,
830 EEntiteMaillage theEntity,
831 EGeometrieElement theGeom,
834 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
837 //----------------------------------------------------------------------------
840 ::SetFamilies(const TElemInfo& theInfo,
842 EEntiteMaillage theEntity,
843 EGeometrieElement theGeom,
846 TFileWrapper aFileWrapper(myFile, theMode, theErr);
848 if (theErr && *theErr < 0)
851 if (theGeom == eBALL)
852 theGeom = GetBallGeom(theInfo.myMeshInfo);
854 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
855 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
857 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
858 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
859 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
860 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
862 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
868 (TInt)anInfo.myFamNum->size(),
874 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
877 //----------------------------------------------------------------------------
880 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
883 return GetNbNodes(theMeshInfo, eCOOR, theErr);
886 //----------------------------------------------------------------------------
889 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
893 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
895 if (theErr && *theErr < 0)
898 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
900 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
901 TValueHolder<ETable, med_data_type > aTable(theTable);
903 return MEDmeshnEntity(myFile->Id(),
915 //----------------------------------------------------------------------------
918 ::GetNodeInfo(MED::TNodeInfo& theInfo,
921 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
923 if (theErr && *theErr < 0)
926 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
928 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
929 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
930 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
931 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
932 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
933 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
934 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
935 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
936 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
937 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
938 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
939 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
940 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
942 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
949 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
957 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
959 int mySize = (int)theInfo.myFamNum->size();
960 theInfo.myFamNum->clear();
961 theInfo.myFamNum->resize(mySize,0);
964 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
967 if (MEDmeshEntityNameRd(myFile->Id(),
973 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
975 if (MEDmeshEntityNumberRd(myFile->Id(),
981 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
986 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
989 //----------------------------------------------------------------------------
992 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
996 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
999 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1005 //----------------------------------------------------------------------------
1008 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1012 TFileWrapper aFileWrapper(myFile, theMode, theErr);
1014 if (theErr && *theErr < 0)
1017 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1018 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1020 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1021 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1022 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1023 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1024 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1025 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1026 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1027 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1028 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1029 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1030 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1031 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1033 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1042 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1051 MEDmeshEntityNameWr(myFile->Id(),
1060 MEDmeshEntityNumberWr(myFile->Id(),
1071 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1074 //----------------------------------------------------------------------------
1077 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1079 EModeSwitch theMode,
1081 EBooleen theIsElemNum,
1082 EBooleen theIsElemNames)
1084 return PNodeInfo(new TTNodeInfo
1093 //----------------------------------------------------------------------------
1096 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1097 const TFloatVector& theNodeCoords,
1098 EModeSwitch theMode,
1100 const TStringVector& theCoordNames,
1101 const TStringVector& theCoordUnits,
1102 const TIntVector& theFamilyNums,
1103 const TIntVector& theElemNums,
1104 const TStringVector& theElemNames)
1106 return PNodeInfo(new TTNodeInfo
1118 //----------------------------------------------------------------------------
1121 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1122 const PNodeInfo& theInfo)
1124 return PNodeInfo(new TTNodeInfo
1129 //----------------------------------------------------------------------------
1132 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1135 TInt aNbElems = GetNbNodes(*theMeshInfo);
1136 if (aNbElems == 0) {
1140 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1141 GetNodeInfo(*anInfo, theErr);
1144 TInt aDim = theMeshInfo->myDim;
1145 TInt aNbElem = anInfo->GetNbElem();
1146 INITMSG(MYDEBUG, "GetPNodeInfo: ");
1148 INITMSG(MYDEBUG, "aCoords: "<<aNbElem<<": ");
1149 TNodeCoord& aCoord = anInfo->myCoord;
1150 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1151 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1152 ADDMSG(MYVALUEDEBUG, aCoord[anId]<<",");
1154 ADDMSG(MYVALUEDEBUG, " ");
1156 ADDMSG(MYDEBUG, std::endl);
1158 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
1159 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1160 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
1162 ADDMSG(MYVALUEDEBUG, std::endl);
1164 if (anInfo->IsElemNum()) {
1165 BEGMSG(MYVALUEDEBUG, "GetElemNum: ");
1166 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1167 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
1169 ADDMSG(MYVALUEDEBUG, std::endl);
1172 ADDMSG(MYDEBUG, std::endl);
1178 //----------------------------------------------------------------------------
1181 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1183 EBooleen theIsElemNum,
1184 EBooleen theIsElemNames)
1186 return PElemInfo(new TTElemInfo
1193 //----------------------------------------------------------------------------
1196 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1198 const TIntVector& theFamNum,
1199 const TIntVector& aElemNum,
1200 const TStringVector& aElemNames)
1202 return PElemInfo(new TTElemInfo
1210 //----------------------------------------------------------------------------
1213 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1214 EEntiteMaillage theEntity,
1215 EGeometrieElement theGeom,
1216 EConnectivite theConnMode,
1219 EMaillage aType = theMeshInfo->GetType();
1220 if (aType == eNON_STRUCTURE) {
1223 if (theEntity == eNOEUD)
1224 return GetPNodeInfo(theMeshInfo, theErr);
1225 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1228 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1231 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1234 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1238 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1241 EBooleen theIsElemNum = eFAUX;
1245 nbElems = aGrille->GetNbNodes();
1246 theIsElemNum = eVRAI;
1251 nbElems = aGrille->GetNbCells();
1258 TIntVector aElemNum;
1259 TStringVector aElemNames;
1261 PElemInfo aElemInfo;
1263 if (theGeom == ePOINT1) {
1264 aElemInfo = CrElemInfo(theMeshInfo,
1267 MED::TElemInfo &aTElemInfo = *aElemInfo;
1269 // must be reimplemente in connection with mesh type eSTRUCTURE
1270 // GetNumeration(aTElemInfo,
1276 GetFamilies(aTElemInfo,
1282 // must be reimplemente in connection with mesh type eSTRUCTURE
1283 // GetNames(aTElemInfo,
1290 aElemInfo = CrElemInfo(theMeshInfo,
1302 //----------------------------------------------------------------------------
1305 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1306 EEntiteMaillage theEntity,
1307 EGeometrieElement theGeom,
1308 EConnectivite theConnMode,
1311 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1314 //----------------------------------------------------------------------------
1317 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1318 EEntiteMaillage theEntity,
1319 EGeometrieElement theGeom,
1320 EConnectivite theConnMode,
1323 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1325 if (theErr && *theErr < 0)
1328 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1330 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1331 med_int aTaille = 0;
1333 aTaille=MEDmeshnEntity(myFile->Id(),
1337 med_entity_type(theEntity),
1338 med_geometry_type(theGeom),
1340 med_connectivity_mode(theConnMode),
1345 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1347 return TInt(aTaille);
1350 //-----------------------------------------------------------------
1353 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1356 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1358 if (theErr && *theErr < 0)
1361 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1363 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1364 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1365 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1366 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1367 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1368 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1369 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1372 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1373 MED_NO_DT, MED_NO_IT,
1375 aConnMode, &anIndex, &aConn);
1380 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1382 if (theInfo.myIsElemNames) {
1383 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1388 if (theInfo.myIsElemNum) {
1389 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1394 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1399 //----------------------------------------------------------------------------
1402 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1405 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1408 //----------------------------------------------------------------------------
1411 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1415 TFileWrapper aFileWrapper(myFile, theMode, theErr);
1417 if (theErr && *theErr < 0)
1420 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1421 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1423 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1424 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1425 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1426 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1427 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1428 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1430 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1431 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1433 aConnMode, anInfo.myNbElem + 1,
1438 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1440 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1444 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1448 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1453 //----------------------------------------------------------------------------
1456 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1457 EEntiteMaillage theEntity,
1458 EGeometrieElement theGeom,
1461 EConnectivite theConnMode,
1462 EBooleen theIsElemNum,
1463 EBooleen theIsElemNames)
1465 return PPolygoneInfo(new TTPolygoneInfo
1476 //----------------------------------------------------------------------------
1479 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1480 EEntiteMaillage theEntity,
1481 EGeometrieElement theGeom,
1482 const TIntVector& theIndexes,
1483 const TIntVector& theConnectivities,
1484 EConnectivite theConnMode,
1485 const TIntVector& theFamilyNums,
1486 const TIntVector& theElemNums,
1487 const TStringVector& theElemNames)
1489 return PPolygoneInfo(new TTPolygoneInfo
1501 //----------------------------------------------------------------------------
1504 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1505 const PPolygoneInfo& theInfo)
1507 return PPolygoneInfo(new TTPolygoneInfo
1512 //----------------------------------------------------------------------------
1515 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1516 EEntiteMaillage theEntity,
1517 EGeometrieElement theGeom,
1518 EConnectivite theConnMode)
1520 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1521 return PPolygoneInfo();
1523 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1524 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1525 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1526 GetPolygoneInfo(anInfo);
1529 INITMSG(MYDEBUG, "GetPPolygoneInfo"<<
1530 " - theGeom = "<<theGeom<<
1531 "; aNbElem = "<<aNbElem<<": ");
1532 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1533 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1534 TInt aConnDim = aConnSlice.size();
1535 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1536 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1538 ADDMSG(MYDEBUG, " ");
1540 ADDMSG(MYDEBUG, std::endl);
1546 //----------------------------------------------------------------------------
1549 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1550 EEntiteMaillage theEntity,
1551 EGeometrieElement theGeom,
1552 EConnectivite theConnMode,
1555 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1558 //----------------------------------------------------------------------------
1561 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1564 EConnectivite theConnMode,
1567 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1569 if (theErr && *theErr < 0)
1570 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1572 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1574 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1575 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1576 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1577 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1579 med_bool chgt, trsf;
1580 theNbFaces = MEDmeshnEntity(myFile->Id(),
1591 theConnSize = MEDmeshnEntity(myFile->Id(),
1602 if (theNbFaces < 0 || theConnSize<0)
1603 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1607 //-----------------------------------------------------------------
1610 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1613 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1615 if (theErr && *theErr < 0)
1618 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1620 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1621 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1622 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1623 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1624 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1625 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1628 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1641 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1643 if (theInfo.myIsElemNames) {
1644 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1649 if (theInfo.myIsElemNum) {
1650 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1655 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1660 //----------------------------------------------------------------------------
1663 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1666 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1669 //----------------------------------------------------------------------------
1672 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1676 TFileWrapper aFileWrapper(myFile, theMode, theErr);
1678 if (theErr && *theErr < 0)
1681 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1682 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1684 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1685 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1686 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1687 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1688 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1691 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1700 (TInt)anInfo.myFaces->size(),
1707 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1709 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1711 if (theInfo.myIsElemNames) {
1712 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1713 aRet = MEDmeshEntityNameWr(myFile->Id(),
1719 (TInt)anInfo.myElemNames->size(),
1724 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1727 if (theInfo.myIsElemNum) {
1728 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1729 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1735 (TInt)anInfo.myElemNum->size(),
1740 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1743 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1744 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1750 (TInt)anInfo.myFamNum->size(),
1756 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1759 //----------------------------------------------------------------------------
1762 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1763 EEntiteMaillage theEntity,
1764 EGeometrieElement theGeom,
1768 EConnectivite theConnMode,
1769 EBooleen theIsElemNum,
1770 EBooleen theIsElemNames)
1772 return PPolyedreInfo(new TTPolyedreInfo
1784 //----------------------------------------------------------------------------
1787 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1788 EEntiteMaillage theEntity,
1789 EGeometrieElement theGeom,
1790 const TIntVector& theIndexes,
1791 const TIntVector& theFaces,
1792 const TIntVector& theConnectivities,
1793 EConnectivite theConnMode,
1794 const TIntVector& theFamilyNums,
1795 const TIntVector& theElemNums,
1796 const TStringVector& theElemNames)
1798 return PPolyedreInfo(new TTPolyedreInfo
1811 //----------------------------------------------------------------------------
1814 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1815 const PPolyedreInfo& theInfo)
1817 return PPolyedreInfo(new TTPolyedreInfo
1822 //----------------------------------------------------------------------------
1825 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1826 EEntiteMaillage theEntity,
1827 EGeometrieElement theGeom,
1828 EConnectivite theConnMode)
1830 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1831 return PPolyedreInfo();
1832 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1833 TInt aNbFaces, aConnSize;
1834 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1835 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1836 GetPolyedreInfo(anInfo);
1839 INITMSG(MYDEBUG, "GetPPolyedreInfo"<<
1840 " - theGeom = "<<theGeom<<
1841 "; aNbElem = "<<aNbElem<<": ");
1842 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1843 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1844 TInt aNbFaces = aConnSliceArr.size();
1845 ADDMSG(MYDEBUG, "{");
1846 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1847 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1848 TInt aNbConn = aConnSlice.size();
1849 ADDMSG(MYDEBUG, "[");
1850 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1851 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
1853 ADDMSG(MYDEBUG, "] ");
1855 ADDMSG(MYDEBUG, "} ");
1857 ADDMSG(MYDEBUG, std::endl);
1863 //-----------------------------------------------------------------
1866 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1867 EConnectivite theConnMode,
1872 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1874 if (theErr && *theErr < 0)
1877 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1878 TInt aNbElem = GetNbNodes(theMeshInfo);
1880 anInfo[eNOEUD][ePOINT1] = aNbElem;
1881 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1882 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1883 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1884 for (; anIter != anIterEnd; anIter++) {
1885 const EEntiteMaillage& anEntity = anIter->first;
1886 const TGeomSet& aGeomSet = anIter->second;
1887 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1888 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1889 for (; anIter2 != anIterEnd2; anIter2++) {
1890 const EGeometrieElement& aGeom = *anIter2;
1891 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1893 if (anEntity == eSTRUCT_ELEMENT) {
1894 const TInt nbStructTypes = aNbElem;
1895 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1896 // check type name to keep only "MED_BALL" structured element
1897 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1898 char geotypename[ MED_NAME_SIZE + 1] = "";
1899 med_geometry_type geotype;
1900 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1901 med_entity_type(anEntity), structType+1,
1902 geotypename, &geotype);
1903 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1904 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1905 theConnMode, theErr);
1907 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1912 anInfo[anEntity][aGeom] = aNbElem;
1919 else { // eSTRUCTURE
1920 EGrilleType aGrilleType;
1924 TInt aDim = theMeshInfo.GetDim();
1925 EGeometrieElement aGeom, aSubGeom;
1926 EEntiteMaillage aSubEntity = eMAILLE;
1928 GetGrilleType(theMeshInfo, aGrilleType);
1930 TIntVector aStruct(aDim);
1931 if (aGrilleType == eGRILLE_STANDARD)
1933 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1936 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1937 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1938 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1939 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1941 for (med_int i = 0; i < aDim; i++) {
1942 aNbNodes = aNbNodes * aStruct[i];
1943 aNbElem = aNbElem * (aStruct[i] - 1);
1952 aSubEntity = eARETE;
1954 (aStruct[0]) * (aStruct[1]-1) +
1955 (aStruct[0]-1) * (aStruct[1]);
1962 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1963 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1964 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1967 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1968 anInfo[eMAILLE][aGeom] = aNbElem;
1970 anInfo[aSubEntity][aSubGeom] = aNbSub;
1975 //-----------------------------------------------------------------
1978 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1979 EEntiteMaillage theEntity,
1980 EGeometrieElement theGeom,
1981 EConnectivite theConnMode,
1984 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
1986 if (theErr && *theErr < 0)
1989 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1990 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1991 med_bool chgt, trsf;
1994 case MED::ePOLYGONE:
1995 case MED::ePOLYGON2:
1997 return MEDmeshnEntity(myFile->Id(), &aMeshName,
1998 MED_NO_DT, MED_NO_IT,
1999 med_entity_type(theEntity), med_geometry_type(theGeom),
2000 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2003 case MED::ePOLYEDRE:
2005 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2006 MED_NO_DT, MED_NO_IT,
2007 med_entity_type(theEntity), MED_POLYHEDRON,
2008 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2013 return GetNbBalls(theMeshInfo);
2017 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2018 MED_NO_DT, MED_NO_IT,
2019 med_entity_type(theEntity), med_geometry_type(theGeom),
2020 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2027 //----------------------------------------------------------------------------
2030 ::GetCellInfo(MED::TCellInfo& theInfo,
2033 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2035 if (theErr && *theErr < 0)
2038 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2040 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2041 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2042 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2043 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2044 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2045 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2046 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2047 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2048 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2049 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2050 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2051 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2054 aRet = MEDmeshElementRd(myFile->Id(),
2073 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2075 if (anIsFamNum == MED_FALSE)
2077 int mySize = (int) theInfo.myFamNum->size();
2078 theInfo.myFamNum->clear();
2079 theInfo.myFamNum->resize(mySize, 0);
2084 //----------------------------------------------------------------------------
2087 ::SetCellInfo(const MED::TCellInfo& theInfo,
2090 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2093 //----------------------------------------------------------------------------
2096 ::SetCellInfo(const MED::TCellInfo& theInfo,
2100 TFileWrapper aFileWrapper(myFile, theMode, theErr);
2102 if (theErr && *theErr < 0)
2105 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2106 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2108 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2109 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2110 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2111 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2112 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2113 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2114 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2115 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2116 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2117 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2118 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2119 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2120 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2123 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2135 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2144 MEDmeshEntityNameWr(myFile->Id(),
2153 MEDmeshEntityNumberWr(myFile->Id(),
2164 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...)");
2167 //----------------------------------------------------------------------------
2170 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2171 EEntiteMaillage theEntity,
2172 EGeometrieElement theGeom,
2174 EConnectivite theConnMode,
2175 EBooleen theIsElemNum,
2176 EBooleen theIsElemNames,
2177 EModeSwitch theMode)
2179 return PCellInfo(new TTCellInfo
2190 //----------------------------------------------------------------------------
2193 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2194 EEntiteMaillage theEntity,
2195 EGeometrieElement theGeom,
2196 const TIntVector& theConnectivities,
2197 EConnectivite theConnMode,
2198 const TIntVector& theFamilyNums,
2199 const TIntVector& theElemNums,
2200 const TStringVector& theElemNames,
2201 EModeSwitch theMode)
2203 return PCellInfo(new TTCellInfo
2215 //----------------------------------------------------------------------------
2218 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2219 const PCellInfo& theInfo)
2221 return PCellInfo(new TTCellInfo
2226 //----------------------------------------------------------------------------
2229 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2230 EEntiteMaillage theEntity,
2231 EGeometrieElement theGeom,
2232 EConnectivite theConnMode,
2235 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2237 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2238 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2239 GetCellInfo(anInfo, theErr);
2242 TInt aConnDim = anInfo->GetConnDim();
2243 INITMSG(MYDEBUG, "GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2244 BEGMSG(MYDEBUG, "GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2245 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2246 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2247 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2248 ADDMSG(MYVALUEDEBUG, aConnSlice[iConn]<<",");
2250 ADDMSG(MYVALUEDEBUG, " ");
2252 ADDMSG(MYDEBUG, std::endl);
2254 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetFamNum: ");
2255 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2256 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
2258 ADDMSG(MYVALUEDEBUG, std::endl);
2260 if (anInfo->IsElemNum()) {
2261 BEGMSG(MYVALUEDEBUG, "GetPCellInfo - GetElemNum: ");
2262 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2263 ADDMSG(MYVALUEDEBUG, anInfo->GetElemNum(iElem)<<", ");
2265 ADDMSG(MYVALUEDEBUG, std::endl);
2267 ADDMSG(MYDEBUG, std::endl);
2273 //----------------------------------------------------------------------------
2276 ::GetBallGeom(const TMeshInfo& theMeshInfo)
2278 TFileWrapper aFileWrapper(myFile, eLECTURE);
2280 // read med_geometry_type of "MED_BALL" element
2281 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2282 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2285 //----------------------------------------------------------------------------
2288 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2290 TFileWrapper aFileWrapper(myFile, eLECTURE);
2292 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2296 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2299 //----------------------------------------------------------------------------
2302 ::GetBallInfo(TBallInfo& theInfo,
2305 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2307 // check geometry of MED_BALL
2308 if (theInfo.myGeom == eBALL)
2310 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2311 if (theInfo.myGeom < 0) {
2313 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2314 *theErr = theInfo.myGeom;
2320 GetCellInfo(theInfo);
2323 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2324 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2325 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2326 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2328 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2329 MED_NO_DT, MED_NO_IT,
2336 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2339 //----------------------------------------------------------------------------
2342 ::SetBallInfo(const TBallInfo& theInfo,
2345 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2348 //----------------------------------------------------------------------------
2351 ::SetBallInfo(const TBallInfo& theInfo,
2355 TFileWrapper aFileWrapper(myFile, theMode, theErr);
2358 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2359 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2362 // no ball model in the file, create support mesh for it
2363 char dummyname [MED_NAME_SIZE*3+1] = "";
2364 if ((ret = MEDsupportMeshCr(myFile->Id(),
2366 theInfo.myMeshInfo->GetSpaceDim(),
2367 theInfo.myMeshInfo->GetDim(),
2368 "Support mesh for a ball model",
2370 /*axisname=*/dummyname,
2371 /*unitname=*/dummyname)) < 0) {
2373 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2377 // write coordinates of 1 node
2378 med_float coord[3] = {0, 0, 0};
2379 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2380 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2381 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2383 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2387 // ball model creation
2388 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2389 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2391 theInfo.myMeshInfo->GetSpaceDim(),
2393 MED_NODE,MED_NONE)) < 0) {
2395 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2399 // create diameter attribute
2400 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2401 geotypename, MED_BALL_DIAMETER,
2402 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2404 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2410 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2411 aBallInfo.myGeom = ballGeom;
2414 SetCellInfo(theInfo, theMode, theErr);
2415 if (theErr && theErr < 0)
2419 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2420 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2421 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2422 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2423 MED_NO_DT, MED_NO_IT,
2424 aGeom, MED_BALL_DIAMETER,
2425 theInfo.myNbElem, &aDiam);
2429 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2432 //----------------------------------------------------------------------------
2435 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2437 EBooleen theIsElemNum)
2439 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2442 //----------------------------------------------------------------------------
2445 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2446 const TIntVector& theNodes,
2447 TFloatVector& theDiameters,
2448 const TIntVector& theFamilyNums,
2449 const TIntVector& theElemNums)
2451 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2452 theFamilyNums, theElemNums));
2455 //----------------------------------------------------------------------------
2458 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2459 const PBallInfo& theInfo)
2461 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2464 //----------------------------------------------------------------------------
2467 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2469 TInt nbBalls = GetNbBalls(theMeshInfo);
2470 if (nbBalls < 1) return PBallInfo();
2472 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2473 GetBallInfo(anInfo);
2478 //-----------------------------------------------------------------
2481 ::GetNbFields(TErr* theErr)
2483 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2485 if (theErr && *theErr < 0)
2488 return MEDnField(myFile->Id());
2491 //----------------------------------------------------------------------------
2494 ::GetNbComp(TInt theFieldId,
2497 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2499 if (theErr && *theErr < 0)
2502 return MEDfieldnComponent(myFile->Id(), theFieldId);
2505 //----------------------------------------------------------------------------
2508 ::GetFieldInfo(TInt theFieldId,
2509 MED::TFieldInfo& theInfo,
2512 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2514 if (theErr && *theErr < 0)
2517 TString aFieldName(256); // Protect from memory problems with too long names
2518 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2519 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2520 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2521 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2525 char dtunit[MED_SNAME_SIZE+1];
2526 char local_mesh_name[MED_NAME_SIZE+1]="";
2528 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2529 aRet = MEDfieldInfo(myFile->Id(),
2540 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2546 theInfo.SetName(aFieldName);
2551 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2554 //----------------------------------------------------------------------------
2557 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2561 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2564 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2570 //----------------------------------------------------------------------------
2573 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2577 TFileWrapper aFileWrapper(myFile, theMode, theErr);
2579 if (theErr && *theErr < 0)
2582 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2584 TValueHolder<TString, char> aFieldName(anInfo.myName);
2585 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2586 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2587 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2588 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2590 char dtunit[MED_SNAME_SIZE+1];
2591 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2592 aRet = MEDfieldCr(myFile->Id(),
2599 &aMeshInfo.myName[0]);
2603 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2606 //----------------------------------------------------------------------------
2609 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2612 const std::string& theValue,
2613 EBooleen theIsLocal,
2616 return PFieldInfo(new TTFieldInfo
2625 //----------------------------------------------------------------------------
2628 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2629 const PFieldInfo& theInfo)
2631 return PFieldInfo(new TTFieldInfo
2636 //----------------------------------------------------------------------------
2639 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2643 TInt aNbComp = GetNbComp(theId);
2644 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2645 GetFieldInfo(theId, *anInfo, theErr);
2650 "- aName = '"<<anInfo->GetName()<<"'"<<
2651 "; aType = "<<anInfo->GetType()<<
2652 "; aNbComp = "<<aNbComp<<
2659 //----------------------------------------------------------------------------
2662 ::GetNbGauss(TErr* theErr)
2664 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2666 if (theErr && *theErr < 0)
2669 return MEDnLocalization(myFile->Id());
2672 //----------------------------------------------------------------------------
2675 ::GetGaussPreInfo(TInt theId,
2678 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2680 if (theErr && *theErr < 0)
2681 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2683 med_int aNbGaussPoints = med_int();
2684 TVector<char> aName(GetNOMLength()+1);
2685 med_geometry_type aGeom = MED_NONE;
2689 char geointerpname[MED_NAME_SIZE+1] = "";
2690 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2691 med_int nsectionmeshcell;
2692 med_geometry_type sectiongeotype;
2693 aRet = MEDlocalizationInfo (myFile->Id(),
2700 ipointstructmeshname,
2706 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2707 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2708 TInt(aNbGaussPoints));
2711 //----------------------------------------------------------------------------
2714 ::GetGaussInfo(TInt theId,
2715 TGaussInfo& theInfo,
2718 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2720 if (theErr && *theErr < 0)
2723 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2724 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2725 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2726 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2727 TValueHolder<TString, char> aGaussName(theInfo.myName);
2730 aRet = MEDlocalizationRd(myFile->Id(),
2740 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2743 //----------------------------------------------------------------------------
2746 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2747 EModeSwitch theMode)
2749 return PGaussInfo(new TTGaussInfo
2754 //-----------------------------------------------------------------
2757 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2758 const MED::TEntityInfo& theEntityInfo,
2759 EEntiteMaillage& theEntity,
2760 TGeom2Size& theGeom2Size,
2763 theEntity = EEntiteMaillage(-1);
2764 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2767 if (theEntityInfo.empty())
2772 else if (theEntityInfo.empty())
2773 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2775 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2777 theGeom2Size.clear();
2778 TInt aNbTimeStamps = 0;
2779 TIdt anId = myFile->Id();
2781 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2782 TValueHolder<TString, char> aFieldName(anInfo.myName);
2783 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2785 // workaround for IPAL13676
2786 MED::TEntityInfo localEntityInfo = theEntityInfo;
2787 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2788 if (anLocalIter != localEntityInfo.end()) {
2789 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2792 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2793 for (; anIter != localEntityInfo.end(); anIter++) {
2794 med_entity_type anEntity = med_entity_type(anIter->first);
2795 const TGeom2Size& aGeom2Size = anIter->second;
2796 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2797 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2798 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2799 char aMeshName[MED_NAME_SIZE+1];
2802 char dtunit[MED_SNAME_SIZE+1];
2803 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2804 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2805 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2807 MEDfieldInfoByName(anId,
2824 MEDfieldComputingStepInfo(anId,
2830 char profilename[MED_NAME_SIZE+1];
2831 char locname[MED_NAME_SIZE+1];
2835 // protection from crash (division by zero)
2836 // inside MEDfieldnValueWithProfile function
2837 // caused by the workaround for IPAL13676 (see above)
2838 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2841 nval = MEDfieldnValueWithProfile(anId,
2846 med_geometry_type(aGeom),
2854 bool anIsSatisfied =(nval > 0);
2855 if (anIsSatisfied) {
2857 "GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2858 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2859 if (anIsPerformAdditionalCheck) {
2860 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2861 if (!anIsSatisfied) {
2863 "GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2864 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2868 if (anIsSatisfied) {
2869 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2870 theEntity = EEntiteMaillage(anEntity);
2871 aNbTimeStamps = aNbStamps;
2874 if (!theGeom2Size.empty())
2877 return aNbTimeStamps;
2880 //----------------------------------------------------------------------------
2883 ::GetTimeStampInfo(TInt theTimeStampId,
2884 MED::TTimeStampInfo& theInfo,
2887 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
2889 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2892 if (aGeom2Size.empty())
2897 else if (aGeom2Size.empty())
2898 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2900 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2901 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2903 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2904 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2905 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2906 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2907 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2908 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2909 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2910 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2911 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2913 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2915 // just to get a time stamp unit (anUnitDt)
2916 med_field_type aFieldType;
2917 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2918 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2919 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2921 MEDfieldInfoByName(myFile->Id(),
2930 delete [] aCompName;
2931 delete [] aCompUnit;
2933 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2934 for (; anIter != aGeom2Size.end(); anIter++) {
2935 const EGeometrieElement& aGeom = anIter->first;
2936 med_int aNbGauss = -1;
2939 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2945 char profilename[MED_NAME_SIZE+1];
2947 char locname[MED_NAME_SIZE+1];
2948 MEDfieldnValueWithProfile(myFile->Id(),
2953 med_geometry_type(aGeom),
2961 static TInt MAX_NB_GAUSS_POINTS = 32;
2962 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
2965 aGeom2NbGauss[aGeom] = aNbGauss;
2970 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
2974 //----------------------------------------------------------------------------
2977 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
2978 EEntiteMaillage theEntity,
2979 const TGeom2Size& theGeom2Size,
2980 const TGeom2NbGauss& theGeom2NbGauss,
2984 const std::string& theUnitDt,
2985 const TGeom2Gauss& theGeom2Gauss)
2987 return PTimeStampInfo(new TTTimeStampInfo
2999 //----------------------------------------------------------------------------
3002 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3003 const PTimeStampInfo& theInfo)
3005 return PTimeStampInfo(new TTTimeStampInfo
3010 //----------------------------------------------------------------------------
3013 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3014 EEntiteMaillage theEntity,
3015 const TGeom2Size& theGeom2Size,
3019 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3020 GetTimeStampInfo(theId, *anInfo, theErr);
3023 INITMSG(MYDEBUG, "GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3024 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3025 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3026 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3027 const EGeometrieElement& aGeom = anIter->first;
3028 INITMSG(MYDEBUG, "aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3035 //----------------------------------------------------------------------------
3038 ::GetNbProfiles(TErr* theErr)
3040 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
3042 if (theErr && *theErr < 0)
3045 return MEDnProfile(myFile->Id());
3048 //----------------------------------------------------------------------------
3051 ::GetProfilePreInfo(TInt theId,
3054 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
3056 if (theErr && *theErr < 0)
3057 return TProfileInfo::TInfo();
3060 TVector<char> aName(GetNOMLength()+1);
3063 aRet = MEDprofileInfo(myFile->Id(),
3070 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3072 return TProfileInfo::TInfo(&aName[0], aSize);
3075 //----------------------------------------------------------------------------
3078 ::GetProfileInfo(TInt theId,
3079 TProfileInfo& theInfo,
3082 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
3084 if (theErr && *theErr < 0)
3087 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3088 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3089 TValueHolder<TString, char> aProfileName(anInfo.myName);
3092 aRet = MEDprofileRd(myFile->Id(),
3098 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3101 //----------------------------------------------------------------------------
3104 ::SetProfileInfo(const TProfileInfo& theInfo,
3108 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3111 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3114 SetProfileInfo(theInfo, eCREATION, &aRet);
3120 //----------------------------------------------------------------------------
3123 ::SetProfileInfo(const TProfileInfo& theInfo,
3127 TFileWrapper aFileWrapper(myFile, theMode, theErr);
3129 if (theErr && *theErr < 0)
3132 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3133 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3134 TValueHolder<TString, char> aProfileName(anInfo.myName);
3137 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3138 &aProfileName, // tableau de valeurs du profil.
3139 theInfo.GetSize(), // taille du profil.
3140 &anElemNum); // nom profil.
3144 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3147 //----------------------------------------------------------------------------
3150 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3151 EModeProfil theMode)
3153 return PProfileInfo(new TTProfileInfo
3158 //----------------------------------------------------------------------------
3161 ::GetPProfileInfo(TInt theId,
3162 EModeProfil theMode,
3165 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3166 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3167 GetProfileInfo(theId, *anInfo, theErr);
3172 //----------------------------------------------------------------------------
3175 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3176 const TMKey2Profile& theMKey2Profile,
3177 const TKey2Gauss& theKey2Gauss,
3180 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
3182 if (theErr && *theErr < 0)
3185 TIdt anId = myFile->Id();
3187 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3188 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3190 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3191 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3192 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3193 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3195 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3196 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3197 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3199 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3200 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3202 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3203 TVector<char> aGaussName(GetNOMLength()+1);
3205 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3206 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3207 TVector<char> aProfileName(GetNOMLength()+1);
3209 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3210 TGeom2Size::iterator anIter = aGeom2Size.begin();
3211 for (; anIter != aGeom2Size.end(); anIter++) {
3212 EGeometrieElement aGeom = anIter->first;
3213 TInt aNbElem = anIter->second;
3214 med_int profilesize, aNbGauss;
3216 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3221 med_geometry_type(aGeom),
3234 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3237 TInt aNbComp = aFieldInfo->myNbComp;
3238 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3239 theTimeStampValue->AllocateValue(aGeom,
3243 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3246 "TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3247 "; aNbVal = "<<aNbVal<<
3248 "; aNbValue = "<<aNbValue<<
3249 "; aNbGauss = "<<aNbGauss<<
3250 "; aNbComp = "<<aNbComp<<
3253 TErr aRet = MEDfieldValueWithProfileRd(anId,
3258 med_geometry_type(aGeom),
3262 MED_ALL_CONSTITUENT,
3263 theTimeStampValue->GetValuePtr(aGeom));
3266 *theErr = MED_FALSE;
3269 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3272 MED::PGaussInfo aGaussInfo;
3273 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3274 if (strcmp(&aGaussName[0], "") != 0) {
3275 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3276 if (anIter != theKey2Gauss.end()) {
3277 aGaussInfo = anIter->second;
3278 aGeom2Gauss[aGeom] = aGaussInfo;
3282 MED::PProfileInfo aProfileInfo;
3283 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3284 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3285 if (anIter != aKey2Profile.end()) {
3286 aProfileInfo = anIter->second;
3287 aGeom2Profile[aGeom] = aProfileInfo;
3291 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3293 *theErr = MED_FALSE;
3296 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3299 if (aProfileInfo && aProfileInfo->IsPresent()) {
3300 TInt aNbSubElem = aProfileInfo->GetSize();
3301 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3302 if (aProfileSize != aValueSize) {
3307 EXCEPTION(std::runtime_error,
3308 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3309 ") != aValueSize("<<aValueSize<<
3310 "); aNbVal = "<<aNbVal<<
3311 "; anEntity = "<<anEntity<<
3312 "; aGeom = "<<aGeom<<
3313 "; aNbElem = "<<aNbElem<<
3314 "; aNbSubElem = "<<aNbSubElem<<
3315 "; aNbComp = "<<aNbComp<<
3316 "; aNbGauss = "<<aNbGauss<<
3321 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3326 EXCEPTION(std::runtime_error,
3327 "GetTimeStampValue - aNbElem("<<aNbElem<<
3328 ") != aNbValue("<<aNbValue<<
3329 "); aNbVal = "<<aNbVal<<
3330 "; anEntity = "<<anEntity<<
3331 "; aGeom = "<<aGeom<<
3332 "; aNbElem = "<<aNbElem<<
3333 "; aNbComp = "<<aNbComp<<
3334 "; aNbGauss = "<<aNbGauss<<
3341 //----------------------------------------------------------------------------
3344 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3348 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3351 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3357 //----------------------------------------------------------------------------
3360 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3364 TFileWrapper aFileWrapper(myFile, theMode, theErr);
3366 if (theErr && *theErr < 0)
3370 TIdt anId = myFile->Id();
3372 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3373 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3375 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3376 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3377 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3378 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3379 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3380 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3381 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3383 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3384 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3386 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3387 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3389 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3390 TGeomSet::const_iterator anIter = aGeomSet.begin();
3391 for (; anIter != aGeomSet.end(); anIter++) {
3392 EGeometrieElement aGeom = *anIter;
3394 TVector<char> aGaussName(GetNOMLength()+1);
3395 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3396 if (aGaussIter != aGeom2Gauss.end()) {
3397 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3398 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3401 TVector<char> aProfileName(GetNOMLength()+1);
3402 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3403 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3404 if (aProfileIter != aGeom2Profile.end()) {
3405 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3406 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3407 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3410 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3412 aRet = MEDfieldValueWithProfileWr(anId,
3418 med_geometry_type(aGeom),
3423 MED_ALL_CONSTITUENT,
3425 theTimeStampValue->GetValuePtr(aGeom));
3428 *theErr = MED_FALSE;
3431 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3436 INITMSG(MYDEBUG, "TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3439 //----------------------------------------------------------------------------
3442 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3443 ETypeChamp theTypeChamp,
3444 const TGeom2Profile& theGeom2Profile,
3445 EModeSwitch theMode)
3447 if (theTypeChamp == eFLOAT64)
3448 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3453 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3460 //----------------------------------------------------------------------------
3463 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3464 const TGeom2Profile& theGeom2Profile,
3465 EModeSwitch theMode)
3467 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3468 return CrTimeStampValue(theTimeStampInfo,
3469 aFieldInfo->GetType(),
3474 //----------------------------------------------------------------------------
3477 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3478 const PTimeStampValueBase& theInfo,
3479 ETypeChamp theTypeChamp)
3481 if (theTypeChamp == eFLOAT64)
3482 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3486 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3492 //----------------------------------------------------------------------------
3495 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3496 const PTimeStampValueBase& theInfo)
3498 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3499 return CrTimeStampValue(theTimeStampInfo,
3501 aFieldInfo->GetType());
3504 //----------------------------------------------------------------------------
3507 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3508 const TMKey2Profile& theMKey2Profile,
3509 const TKey2Gauss& theKey2Gauss,
3512 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3513 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3514 aFieldInfo->GetType());
3515 GetTimeStampValue(anInfo,
3520 if (aFieldInfo->GetType() == eFLOAT64)
3521 Print<TFloatTimeStampValue>(anInfo);
3523 Print<TIntTimeStampValue>(anInfo);
3528 //----------------------------------------------------------------------------
3531 ::GetTimeStampVal(const PTimeStampVal& theVal,
3532 const TMKey2Profile& theMKey2Profile,
3533 const TKey2Gauss& theKey2Gauss,
3536 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3537 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3538 if (aFieldInfo->GetType() == eFLOAT64)
3539 GetTimeStampValue(theVal,
3544 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3547 GetTimeStampValue(aVal,
3551 CopyTimeStampValueBase(aVal, theVal);
3555 //----------------------------------------------------------------------------
3558 ::SetTimeStamp(const PTimeStampVal& theVal,
3561 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3562 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3563 if (aFieldInfo->GetType() == eFLOAT64)
3564 SetTimeStampValue(theVal, theErr);
3566 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3568 theVal->GetGeom2Profile(),
3569 theVal->GetModeSwitch());
3570 CopyTimeStampValueBase(theVal, aVal);
3571 SetTimeStampValue(aVal, theErr);
3575 //----------------------------------------------------------------------------
3578 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3579 const TGeom2Profile& theGeom2Profile,
3580 EModeSwitch theMode)
3582 return CrTimeStampValue(theTimeStampInfo,
3588 //----------------------------------------------------------------------------
3591 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3592 const PTimeStampVal& theInfo)
3594 return CrTimeStampValue(theTimeStampInfo,
3599 //----------------------------------------------------------------------------
3602 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3603 const TMKey2Profile& theMKey2Profile,
3604 const TKey2Gauss& theKey2Gauss,
3607 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3608 GetTimeStampVal(anInfo,
3615 //----------------------------------------------------------------------------
3618 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3620 if (theMeshInfo->GetType() != eSTRUCTURE)
3621 return PGrilleInfo();
3624 GetGrilleType(*theMeshInfo, type);
3626 if (type == eGRILLE_STANDARD) {
3627 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3628 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3632 aVec.resize(theMeshInfo->GetDim());
3633 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3634 ETable aATable = eCOOR_IND1;
3637 aATable = eCOOR_IND1;
3640 aATable = eCOOR_IND2;
3643 aATable = eCOOR_IND3;
3646 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3648 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3651 GetGrilleInfo(anInfo);
3652 anInfo->SetGrilleType(type);
3655 INITMSG(MYDEBUG, "GetPGrilleInfo: ");
3657 TInt aNbElem = anInfo->GetNbNodes();
3658 BEGMSG(MYVALUEDEBUG, "GetFamNumNode: ");
3659 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3660 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNumNode(iElem)<<", ");
3662 TInt aNbCells = anInfo->GetNbCells();
3663 BEGMSG(MYVALUEDEBUG, "GetFamNum: ");
3664 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3665 ADDMSG(MYVALUEDEBUG, anInfo->GetFamNum(iElem)<<", ");
3667 ADDMSG(MYVALUEDEBUG, std::endl);
3668 BEGMSG(MYVALUEDEBUG, "GetCoordName: ");
3669 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3670 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordName(iElem)<<", ");
3672 ADDMSG(MYVALUEDEBUG, std::endl);
3673 BEGMSG(MYVALUEDEBUG, "GetCoordUnit: ");
3674 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3675 ADDMSG(MYVALUEDEBUG, anInfo->GetCoordUnit(iElem)<<", ");
3677 ADDMSG(MYVALUEDEBUG, std::endl);
3685 //----------------------------------------------------------------------------
3688 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3689 const PGrilleInfo& theInfo)
3691 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3695 //----------------------------------------------------------------------------
3698 ::GetGrilleInfo(TGrilleInfo& theInfo,
3701 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
3703 if (theErr && *theErr < 0)
3706 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3707 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3708 EMaillage aMaillageType = aMeshInfo.myType;
3710 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3711 EGrilleType aGrilleType = theInfo.myGrilleType;
3714 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3715 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3717 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3718 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3719 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3720 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3721 //med_axis_type aRepere;
3723 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3733 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3735 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3736 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3738 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3747 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3749 int mySize = (int)theInfo.myFamNumNode.size();
3750 theInfo.myFamNumNode.clear();
3751 theInfo.myFamNumNode.resize(mySize,0);
3755 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3760 //============================
3763 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3764 ETable aTable = eCOOR_IND1;
3765 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3768 aTable = eCOOR_IND1;
3771 aTable = eCOOR_IND2;
3774 aTable = eCOOR_IND3;
3783 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3785 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3787 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3789 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3790 //TValueHolder<ETable, med_data_type > table(aTable);
3791 //char aCompNames[MED_SNAME_SIZE+1];
3792 //char anUnitNames[MED_SNAME_SIZE+1];
3793 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3795 MED_NO_DT,MED_NO_IT,
3799 //theInfo.SetCoordName(anAxis-1, aCompNames);
3800 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3801 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3806 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3810 EGeometrieElement aGeom = theInfo.GetGeom();
3811 EEntiteMaillage aEntity = theInfo.GetEntity();
3812 TInt aNbCells = theInfo.GetNbCells();
3814 theInfo.myFamNum.resize(aNbCells);
3815 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3817 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3818 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3819 med_geometry_type(aGeom), &aFamNum);
3821 if (aMeshInfo.myDim == 3)
3823 aGeom = theInfo.GetSubGeom();
3824 aEntity = theInfo.GetSubEntity();
3825 aNbCells = theInfo.GetNbSubCells();
3827 theInfo.myFamSubNum.resize(aNbCells, 0);
3828 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3830 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3834 med_entity_type(aEntity),
3835 med_geometry_type(aGeom),
3839 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3841 int mySize = (int)theInfo.myFamNumNode.size();
3842 theInfo.myFamNumNode.clear();
3843 theInfo.myFamNumNode.resize(mySize, 0);
3847 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3853 //----------------------------------------------------------------------------
3856 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3859 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3862 //----------------------------------------------------------------------------
3865 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3869 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3871 TFileWrapper aFileWrapper(myFile, theMode, theErr);
3873 if (theErr && *theErr < 0)
3876 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3878 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3879 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3881 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3884 aRet = MEDmeshGridTypeRd(myFile->Id(),
3890 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3892 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3893 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3894 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3895 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3896 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3897 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3898 //med_axis_type aRepere = MED_CARTESIAN;
3900 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3910 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3912 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3913 aRet = MEDmeshGridStructWr(myFile->Id(),
3920 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3924 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3925 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3931 anInfo.GetIndexes(aAxis).size(),
3932 &anInfo.GetIndexes(aAxis)[0]);
3935 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3943 //----------------------------------------------------------------------------
3946 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3947 const PGrilleInfo& theInfo)
3949 return PGrilleInfo(new TTGrilleInfo
3954 //----------------------------------------------------------------------------
3957 ::CrGrilleInfo(const PMeshInfo& theMeshInfo)
3959 return PGrilleInfo(); // not implemented????
3962 //----------------------------------------------------------------------------
3965 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3966 const EGrilleType& type)
3968 return PGrilleInfo(new TTGrilleInfo
3973 //----------------------------------------------------------------------------
3976 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3977 const EGrilleType& type,
3978 const TInt& nbNodes)
3980 return PGrilleInfo(new TTGrilleInfo
3986 //----------------------------------------------------------------------------
3989 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3990 const EGrilleType& type,
3991 const MED::TIntVector& nbNodeVec)
3993 return PGrilleInfo(new TTGrilleInfo
3999 //----------------------------------------------------------------------------
4002 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4003 EGrilleType& theGridType,
4006 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
4008 if (theErr && *theErr < 0)
4009 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4011 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4013 if (aMeshInfo.myType == eSTRUCTURE) {
4014 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4015 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4016 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4021 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4025 //----------------------------------------------------------------------------
4028 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4029 TIntVector& theStruct,
4032 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
4034 if (theErr && *theErr < 0)
4038 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4040 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4041 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4043 aRet = MEDmeshGridStructRd(myFile->Id(),
4051 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");