1 // Copyright (C) 2007-2023 CEA, EDF, 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"
26 #include "MED_TFile.hxx"
28 #include "MEDFileUtilities.hxx"
31 #include <med_proto.h>
37 #include <boost/version.hpp>
41 //---------------------------------------------------------------
43 ::TLockProxy(TWrapper* theWrapper):
46 #if BOOST_VERSION >= 103500
47 myWrapper->myMutex.lock();
49 boost::detail::thread::lock_ops<TWrapper::TMutex>::lock(myWrapper->myMutex);
51 INITMSG("TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
57 INITMSG("~TLockProxy() - this -"<<this<<"; myWrapper = "<<myWrapper<<std::endl);
58 #if BOOST_VERSION >= 103500
59 myWrapper->myMutex.unlock();
61 boost::detail::thread::lock_ops<TWrapper::TMutex>::unlock(myWrapper->myMutex);
67 ::operator->() const // never throws
72 //---------------------------------------------------------------
73 const TIdt& MEDIDTHoder::Id() const
76 EXCEPTION(std::runtime_error, "TFile - GetFid() < 0");
80 void TMemFile::Open(EModeAcces theMode, TErr* theErr)
82 if (this->myCount++ == 0)
84 std::string dftFileName = MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInMem();
85 med_access_mode modeTmp(MED_ACC_CREAT);
86 if(memfile.app_image_ptr)
87 modeTmp = med_access_mode(theMode);
88 myFid = MEDmemFileOpen(dftFileName.c_str(),&memfile,MED_FALSE,modeTmp);
91 *theErr = TErr(myFid);
93 EXCEPTION(std::runtime_error,"TMemFile - MEDmemFileOpen");
96 TFile::TFile(const std::string& theFileName, TInt theMajor, TInt theMinor):
97 myFileName(theFileName),
101 if ((myMajor < 0) || (myMajor > MED_MAJOR_NUM)) myMajor = MED_MAJOR_NUM;
102 if ((myMinor < 0) || (myMajor == MED_MAJOR_NUM && myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
105 void TFile::Open(EModeAcces theMode, TErr* theErr)
107 if (myCount++ == 0) {
108 const char* aFileName = myFileName.c_str();
110 if (med_access_mode(theMode) == MED_ACC_RDWR) {
111 // Force removing readonly attribute from a file under Windows, because of a bug in the HDF5
112 std::string aReadOlnyRmCmd = "attrib -r \"" + myFileName + "\"> nul 2>&1";
114 const char* to_decode = aReadOlnyRmCmd.c_str();
115 int size_needed = MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), NULL, 0);
116 wchar_t* awReadOlnyRmCmd = new wchar_t[size_needed + 1];
117 MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), awReadOlnyRmCmd, size_needed);
118 awReadOlnyRmCmd[size_needed] = '\0';
119 _wsystem(awReadOlnyRmCmd);
120 delete[] awReadOlnyRmCmd;
122 system(aReadOlnyRmCmd.c_str());
126 myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM);
129 *theErr = TErr(myFid);
131 EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<<myFileName<<"',"<<theMode<<"',"<< myMajor <<"',"<< myMinor<<"',"<< MED_RELEASE_NUM<<")");
134 //---------------------------------------------------------------
137 PFileInternal myFile;
141 TFileWrapper(const PFileInternal& theFile,
148 if (myMinor < 0) myMinor = MED_MINOR_NUM;
149 myFile->Open(theMode, theErr);
158 //----------------------------------------------------------------------------
159 template<class TimeStampValueType>
161 Print(SharedPtr<TimeStampValueType> theTimeStampValue)
163 INITMSG("Print - TimeStampValue\n");
164 typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
165 typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
166 for (; anIter != aGeom2Value.end(); anIter++) {
167 const EGeometrieElement& aGeom = anIter->first;
168 const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second;
169 TInt aNbElem = aMeshValue.myNbElem;
170 TInt aNbGauss = aMeshValue.myNbGauss;
171 TInt aNbComp = aMeshValue.myNbComp;
172 INITMSG("aGeom = "<<aGeom<<" - "<<aNbElem<<": ");
173 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
174 typename TimeStampValueType::TTMeshValue::TCValueSliceArr aValueSliceArr =
175 aMeshValue.GetGaussValueSliceArr(iElem);
177 for (TInt iGauss = 0; iGauss < aNbGauss; iGauss++) {
178 const typename TimeStampValueType::TTMeshValue::TCValueSlice& aValueSlice =
179 aValueSliceArr[iGauss];
180 for (TInt iComp = 0; iComp < aNbComp; iComp++) {
181 ADDMSG(aValueSlice[iComp]<<" ");
191 //---------------------------------------------------------------
193 ::TWrapper(const std::string& theFileName, bool write, TFileInternal *tfileInst, TInt theMajor, TInt theMinor):
198 myFile.reset(new TFile(theFileName, theMajor, theMinor) );
200 myFile.reset(new TFileDecorator(tfileInst) );
204 myFile->Open(eLECTURE_ECRITURE, &aRet);
207 myFile->Open(eCREATION, &aRet);
211 myFile->Open(eLECTURE, &aRet);
215 //----------------------------------------------------------------------------
221 //----------------------------------------------------------------------------
224 ::GetNbMeshes(TErr* theErr)
226 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
228 if (theErr && *theErr < 0)
231 return MEDnMesh(myFile->Id());
234 //----------------------------------------------------------------------------
237 ::GetMeshInfo(TInt theMeshId,
238 MED::TMeshInfo& theInfo,
241 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
243 if (theErr && *theErr < 0)
246 TValueHolder<TString, char> aMeshName(theInfo.myName);
247 TValueHolder<TInt, med_int> aDim(theInfo.myDim);
248 TValueHolder<TInt, med_int> aSpaceDim(theInfo.mySpaceDim);
249 TValueHolder<EMaillage, med_mesh_type> aType(theInfo.myType);
250 char dtunit[MED_SNAME_SIZE+1];
251 med_sorting_type sorttype;
254 int naxis = MEDmeshnAxis(myFile->Id(), theMeshId);
255 char *axisname = new char[naxis*MED_SNAME_SIZE+1];
256 char *axisunit = new char[naxis*MED_SNAME_SIZE+1];
257 TErr aRet = MEDmeshInfo(myFile->Id(),
273 EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)");
276 //----------------------------------------------------------------------------
279 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
283 SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet);
286 SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet);
289 SetMeshInfo(theInfo, eCREATION, &aRet);
295 //----------------------------------------------------------------------------
298 ::SetMeshInfo(const MED::TMeshInfo& theInfo,
302 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
304 if (theErr && *theErr < 0)
307 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
309 TValueHolder<TString, char> aMeshName(anInfo.myName);
310 TValueHolder<TInt, med_int> aDim(anInfo.myDim);
311 TValueHolder<TInt, med_int> aSpaceDim(anInfo.mySpaceDim);
312 TValueHolder<EMaillage, med_mesh_type> aType(anInfo.myType);
313 TValueHolder<TString, char> aDesc(anInfo.myDesc);
315 char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1];
316 std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0');
317 char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1];
318 std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0');
319 TErr aRet = MEDmeshCr(myFile->Id(),
334 // aRet = MEDunvCr(myFile->Id(),&aMeshName);
336 INITMSG("TWrapper::SetMeshInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
341 EXCEPTION(std::runtime_error, "SetMeshInfo - MEDmeshCr(...)");
344 //----------------------------------------------------------------------------
347 ::CrMeshInfo(TInt theDim,
349 const std::string& theValue,
351 const std::string& theDesc)
353 return PMeshInfo(new TTMeshInfo
361 //----------------------------------------------------------------------------
364 ::CrMeshInfo(const PMeshInfo& theInfo)
366 return PMeshInfo(new TTMeshInfo(theInfo));
369 //----------------------------------------------------------------------------
372 ::GetPMeshInfo(TInt theId,
375 PMeshInfo anInfo = CrMeshInfo();
376 GetMeshInfo(theId, *anInfo, theErr);
380 //----------------------------------------------------------------------------
383 ::GetNbFamilies(const MED::TMeshInfo& theInfo,
386 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
388 if (theErr && *theErr < 0)
391 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
392 TValueHolder<TString, char> aName(anInfo.myName);
393 return MEDnFamily(myFile->Id(), &aName);
396 //----------------------------------------------------------------------------
399 ::GetNbFamAttr(TInt theFamId,
400 const MED::TMeshInfo& theInfo,
403 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
405 if (theErr && *theErr < 0)
408 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
410 TValueHolder<TString, char> aName(anInfo.myName);
412 return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId);
415 //----------------------------------------------------------------------------
418 ::GetNbFamGroup(TInt theFamId,
419 const MED::TMeshInfo& theInfo,
422 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
424 if (theErr && *theErr < 0)
427 MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
429 TValueHolder<TString, char> aName(anInfo.myName);
431 return MEDnFamilyGroup(myFile->Id(), &aName, theFamId);
434 //----------------------------------------------------------------------------
437 ::GetFamilyInfo(TInt theFamId,
438 MED::TFamilyInfo& theInfo,
441 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
443 if (theErr && *theErr < 0)
446 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
448 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
449 TValueHolder<TString, char> aFamilyName(theInfo.myName);
450 TValueHolder<TInt, med_int> aFamilyId(theInfo.myId);
451 TValueHolder<TFamAttr, med_int> anAttrId(theInfo.myAttrId);
452 TValueHolder<TFamAttr, med_int> anAttrVal(theInfo.myAttrVal);
453 TValueHolder<TString, char> anAttrDesc(theInfo.myAttrDesc);
454 TValueHolder<TString, char> aGroupNames(theInfo.myGroupNames);
456 TErr aRet = MEDfamily23Info(myFile->Id(),
469 EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<<
470 " aMeshInfo.myName = '"<<&aMeshName<<
471 "'; theFamId = "<<theFamId<<
472 "; theInfo.myNbGroup = "<<theInfo.myNbGroup<<
473 "; theInfo.myNbAttr = "<<theInfo.myNbAttr);
476 //----------------------------------------------------------------------------
479 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
483 SetFamilyInfo(theInfo, eLECTURE_ECRITURE, &aRet);
486 SetFamilyInfo(theInfo, eLECTURE_AJOUT, &aRet);
492 //----------------------------------------------------------------------------
495 ::SetFamilyInfo(const MED::TFamilyInfo& theInfo,
499 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
501 if (theErr && *theErr < 0)
504 MED::TFamilyInfo& anInfo = const_cast<MED::TFamilyInfo&>(theInfo);
505 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
507 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
508 TValueHolder<TString, char> aFamilyName(anInfo.myName);
509 TValueHolder<TInt, med_int> aFamilyId(anInfo.myId);
510 TValueHolder<TFamAttr, med_int> anAttrId(anInfo.myAttrId);
511 TValueHolder<TFamAttr, med_int> anAttrVal(anInfo.myAttrVal);
512 TValueHolder<TInt, med_int> aNbAttr(anInfo.myNbAttr);
513 TValueHolder<TString, char> anAttrDesc(anInfo.myAttrDesc);
514 TValueHolder<TInt, med_int> aNbGroup(anInfo.myNbGroup);
515 TValueHolder<TString, char> aGroupNames(anInfo.myGroupNames);
517 TErr aRet = MEDfamilyCr(myFile->Id(),
524 INITMSG("TWrapper::SetFamilyInfo - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
529 EXCEPTION(std::runtime_error, "SetFamilyInfo - MEDfamilyCr(...)");
532 //----------------------------------------------------------------------------
535 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
539 const std::string& theValue)
541 return PFamilyInfo(new TTFamilyInfo
549 //----------------------------------------------------------------------------
552 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
553 const std::string& theValue,
555 const MED::TStringSet& theGroupNames,
556 const MED::TStringVector& theAttrDescs,
557 const MED::TIntVector& theAttrIds,
558 const MED::TIntVector& theAttrVals)
560 return PFamilyInfo(new TTFamilyInfo
570 //----------------------------------------------------------------------------
573 ::CrFamilyInfo(const PMeshInfo& theMeshInfo,
574 const PFamilyInfo& theInfo)
576 return PFamilyInfo(new TTFamilyInfo
581 //----------------------------------------------------------------------------
584 ::GetPFamilyInfo(const PMeshInfo& theMeshInfo,
588 // must be reimplemented in connection with mesh type eSTRUCTURE
589 // if (theMeshInfo->GetType() != eNON_STRUCTURE)
590 // return PFamilyInfo();
592 TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo);
593 TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo);
594 PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr);
595 GetFamilyInfo(theId, *anInfo, theErr);
597 if (SALOME::VerbosityActivated())
599 std::string aName = anInfo->GetName();
600 INITMSG("GetPFamilyInfo - aFamilyName = '"<<aName<<
601 "'; andId = "<<anInfo->GetId()<<
602 "; aNbAttr = "<<aNbAttr<<
603 "; aNbGroup = "<<aNbGroup<<"\n");
604 for (TInt iGroup = 0; iGroup < aNbGroup; iGroup++) {
605 aName = anInfo->GetGroupName(iGroup);
606 INITMSG("aGroupName = '"<<aName<<"'\n");
613 //----------------------------------------------------------------------------
616 ::GetNames(TElemInfo& theInfo,
618 EEntiteMaillage theEntity,
619 EGeometrieElement theGeom,
622 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
624 if (theErr && *theErr < 0)
627 if (theGeom == eBALL)
628 theGeom = GetBallGeom(theInfo.myMeshInfo);
630 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
632 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
633 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
634 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
635 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
637 TErr aRet = MEDmeshEntityNameRd(myFile->Id(),
645 theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ;
651 //----------------------------------------------------------------------------
654 ::SetNames(const TElemInfo& theInfo,
655 EEntiteMaillage theEntity,
656 EGeometrieElement theGeom,
659 SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
662 //----------------------------------------------------------------------------
665 ::SetNames(const TElemInfo& theInfo,
667 EEntiteMaillage theEntity,
668 EGeometrieElement theGeom,
671 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
673 if (theErr && *theErr < 0)
676 if (theGeom == eBALL)
677 theGeom = GetBallGeom(theInfo.myMeshInfo);
679 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
680 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
683 if (theInfo.myIsElemNames) {
684 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
685 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
686 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
687 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
689 aRet = MEDmeshEntityNameWr(myFile->Id(),
695 (TInt)anInfo.myElemNames->size(),
700 EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)");
704 //----------------------------------------------------------------------------
707 ::GetNumeration(TElemInfo& theInfo,
709 EEntiteMaillage theEntity,
710 EGeometrieElement theGeom,
713 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
715 if (theErr && *theErr < 0)
718 if (theGeom == eBALL)
719 theGeom = GetBallGeom(theInfo.myMeshInfo);
721 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
723 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
724 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
725 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
726 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
728 TErr aRet = MEDmeshEntityNumberRd(myFile->Id(),
736 theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI;
742 //----------------------------------------------------------------------------
745 ::SetNumeration(const TElemInfo& theInfo,
746 EEntiteMaillage theEntity,
747 EGeometrieElement theGeom,
750 SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
753 //----------------------------------------------------------------------------
756 ::SetNumeration(const TElemInfo& theInfo,
758 EEntiteMaillage theEntity,
759 EGeometrieElement theGeom,
762 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
764 if (theErr && *theErr < 0)
767 if (theGeom == eBALL)
768 theGeom = GetBallGeom(theInfo.myMeshInfo);
770 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
771 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
774 if (theInfo.myIsElemNum) {
775 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
776 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
777 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
778 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
780 aRet = MEDmeshEntityNumberWr(myFile->Id(),
786 (TInt)anInfo.myElemNum->size(),
791 EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)");
795 //----------------------------------------------------------------------------
798 ::GetFamilies(TElemInfo& theInfo,
800 EEntiteMaillage theEntity,
801 EGeometrieElement theGeom,
804 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
806 if (theErr && *theErr < 0)
809 if (theGeom == eBALL)
810 theGeom = GetBallGeom(theInfo.myMeshInfo);
812 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
814 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
815 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
816 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
817 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
819 TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
828 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
830 int aSize = (int)theInfo.myFamNum->size();
831 theInfo.myFamNum->clear();
832 theInfo.myFamNum->resize(aSize,0);
836 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS");
842 //----------------------------------------------------------------------------
845 ::SetFamilies(const TElemInfo& theInfo,
846 EEntiteMaillage theEntity,
847 EGeometrieElement theGeom,
850 SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr);
853 //----------------------------------------------------------------------------
856 ::SetFamilies(const TElemInfo& theInfo,
858 EEntiteMaillage theEntity,
859 EGeometrieElement theGeom,
862 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
864 if (theErr && *theErr < 0)
867 if (theGeom == eBALL)
868 theGeom = GetBallGeom(theInfo.myMeshInfo);
870 MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
871 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
873 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
874 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
875 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theEntity);
876 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theGeom);
878 TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
884 (TInt)anInfo.myFamNum->size(),
890 EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)");
893 //----------------------------------------------------------------------------
896 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
899 return GetNbNodes(theMeshInfo, eCOOR, theErr);
902 //----------------------------------------------------------------------------
905 ::GetNbNodes(const MED::TMeshInfo& theMeshInfo,
909 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
911 if (theErr && *theErr < 0)
914 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
916 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
917 TValueHolder<ETable, med_data_type > aTable(theTable);
919 return MEDmeshnEntity(myFile->Id(),
931 //----------------------------------------------------------------------------
934 ::GetNodeInfo(MED::TNodeInfo& theInfo,
937 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
939 if (theErr && *theErr < 0)
942 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
944 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
945 TValueHolder<TInt, med_int> aDim(aMeshInfo.myDim);
946 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
947 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
948 TValueHolder<ERepere, med_axis_type> aSystem(theInfo.mySystem);
949 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
950 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
951 TValueHolder<TString, char> anElemNames(theInfo.myElemNames);
952 //TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
953 TValueHolder<TElemNum, med_int> anElemNum(theInfo.myElemNum);
954 //TValueHolder<EBooleen, med_bool> anIsElemNum(theInfo.myIsElemNum);
955 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
956 TValueHolder<TInt, med_int> aNbElem(theInfo.myNbElem);
958 TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
965 TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(),
973 // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
975 int mySize = (int)theInfo.myFamNum->size();
976 theInfo.myFamNum->clear();
977 theInfo.myFamNum->resize(mySize,0);
980 // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)");
983 if (MEDmeshEntityNameRd(myFile->Id(),
989 &anElemNames) < 0) theInfo.myIsElemNames=eFAUX;
991 if (MEDmeshEntityNumberRd(myFile->Id(),
997 &anElemNum) < 0) theInfo.myIsElemNum=eFAUX;
1002 EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)");
1005 //----------------------------------------------------------------------------
1008 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1012 SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet);
1015 SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet);
1021 //----------------------------------------------------------------------------
1024 ::SetNodeInfo(const MED::TNodeInfo& theInfo,
1028 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1030 if (theErr && *theErr < 0)
1033 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
1034 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1036 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
1037 TValueHolder<TNodeCoord, med_float> aCoord (anInfo.myCoord);
1038 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
1039 TValueHolder<ERepere, med_axis_type> aSystem (anInfo.mySystem);
1040 TValueHolder<TString, char> aCoordNames (anInfo.myCoordNames);
1041 TValueHolder<TString, char> aCoordUnits (anInfo.myCoordUnits);
1042 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
1043 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
1044 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
1045 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
1046 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
1047 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
1049 TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
1058 MEDmeshEntityFamilyNumberWr(myFile->Id(),
1067 MEDmeshEntityNameWr(myFile->Id(),
1076 MEDmeshEntityNumberWr(myFile->Id(),
1087 EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)");
1090 //----------------------------------------------------------------------------
1093 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1095 EModeSwitch theMode,
1097 EBooleen theIsElemNum,
1098 EBooleen theIsElemNames)
1100 return PNodeInfo(new TTNodeInfo
1109 //----------------------------------------------------------------------------
1112 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1113 const TFloatVector& theNodeCoords,
1114 EModeSwitch theMode,
1116 const TStringVector& theCoordNames,
1117 const TStringVector& theCoordUnits,
1118 const TIntVector& theFamilyNums,
1119 const TIntVector& theElemNums,
1120 const TStringVector& theElemNames)
1122 return PNodeInfo(new TTNodeInfo
1134 //----------------------------------------------------------------------------
1137 ::CrNodeInfo(const PMeshInfo& theMeshInfo,
1138 const PNodeInfo& theInfo)
1140 return PNodeInfo(new TTNodeInfo
1145 //----------------------------------------------------------------------------
1148 ::GetPNodeInfo(const PMeshInfo& theMeshInfo,
1151 TInt aNbElems = GetNbNodes(*theMeshInfo);
1152 if (aNbElems == 0) {
1156 PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems);
1157 GetNodeInfo(*anInfo, theErr);
1159 if (SALOME::VerbosityActivated())
1161 TInt aDim = theMeshInfo->myDim;
1162 TInt aNbElem = anInfo->GetNbElem();
1163 INITMSG("GetPNodeInfo: ");
1165 INITMSG("aCoords: "<<aNbElem<<": ");
1166 TNodeCoord& aCoord = anInfo->myCoord;
1167 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1168 for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) {
1169 ADDMSG(aCoord[anId]<<",");
1175 BEGMSG("GetFamNum: ");
1176 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1177 ADDMSG(anInfo->GetFamNum(iElem)<<", ");
1181 if (anInfo->IsElemNum()) {
1182 BEGMSG("GetElemNum: ");
1183 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1184 ADDMSG(anInfo->GetElemNum(iElem)<<", ");
1195 //----------------------------------------------------------------------------
1198 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1200 EBooleen theIsElemNum,
1201 EBooleen theIsElemNames)
1203 return PElemInfo(new TTElemInfo
1210 //----------------------------------------------------------------------------
1213 ::CrElemInfo(const PMeshInfo& theMeshInfo,
1215 const TIntVector& theFamNum,
1216 const TIntVector& aElemNum,
1217 const TStringVector& aElemNames)
1219 return PElemInfo(new TTElemInfo
1227 //----------------------------------------------------------------------------
1230 ::GetPElemInfo(const PMeshInfo& theMeshInfo,
1231 EEntiteMaillage theEntity,
1232 EGeometrieElement theGeom,
1233 EConnectivite theConnMode,
1236 EMaillage aType = theMeshInfo->GetType();
1237 if (aType == eNON_STRUCTURE) {
1240 if (theEntity == eNOEUD)
1241 return GetPNodeInfo(theMeshInfo, theErr);
1242 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1245 return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1248 return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode);
1251 return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1255 PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo);
1258 EBooleen theIsElemNum = eFAUX;
1262 nbElems = aGrille->GetNbNodes();
1263 theIsElemNum = eVRAI;
1268 nbElems = aGrille->GetNbCells();
1275 TIntVector aElemNum;
1276 TStringVector aElemNames;
1278 PElemInfo aElemInfo;
1280 if (theGeom == ePOINT1) {
1281 aElemInfo = CrElemInfo(theMeshInfo,
1284 MED::TElemInfo &aTElemInfo = *aElemInfo;
1286 // must be reimplemente in connection with mesh type eSTRUCTURE
1287 // GetNumeration(aTElemInfo,
1293 GetFamilies(aTElemInfo,
1299 // must be reimplemente in connection with mesh type eSTRUCTURE
1300 // GetNames(aTElemInfo,
1307 aElemInfo = CrElemInfo(theMeshInfo,
1319 //----------------------------------------------------------------------------
1322 ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo,
1323 EEntiteMaillage theEntity,
1324 EGeometrieElement theGeom,
1325 EConnectivite theConnMode,
1328 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1331 //----------------------------------------------------------------------------
1334 ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo,
1335 EEntiteMaillage theEntity,
1336 EGeometrieElement theGeom,
1337 EConnectivite theConnMode,
1340 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1342 if (theErr && *theErr < 0)
1345 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1347 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1348 med_int aTaille = 0;
1350 aTaille=MEDmeshnEntity(myFile->Id(),
1354 med_entity_type(theEntity),
1355 med_geometry_type(theGeom),
1357 med_connectivity_mode(theConnMode),
1362 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1364 return TInt(aTaille);
1367 //-----------------------------------------------------------------
1370 ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
1373 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1375 if (theErr && *theErr < 0)
1378 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1380 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1381 TValueHolder<TElemNum, med_int > anIndex (theInfo.myIndex);
1382 TValueHolder<TElemNum, med_int > aConn (theInfo.myConn);
1383 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (theInfo.myEntity);
1384 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
1385 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1386 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1389 aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName,
1390 MED_NO_DT, MED_NO_IT,
1392 aConnMode, &anIndex, &aConn);
1397 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)");
1399 if (theInfo.myIsElemNames) {
1400 GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1405 if (theInfo.myIsElemNum) {
1406 GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1411 GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet);
1416 //----------------------------------------------------------------------------
1419 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1422 SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr);
1425 //----------------------------------------------------------------------------
1428 ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo,
1432 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1434 if (theErr && *theErr < 0)
1437 MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
1438 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1440 TValueHolder<TString, char > aMeshName(aMeshInfo.myName);
1441 TValueHolder<TElemNum, med_int > anIndex (anInfo.myIndex);
1442 TValueHolder<TElemNum, med_int > aConn (anInfo.myConn);
1443 TValueHolder<EEntiteMaillage, med_entity_type > anEntity (anInfo.myEntity);
1444 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
1445 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1447 TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName,
1448 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
1450 aConnMode, anInfo.myNbElem + 1,
1455 EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)");
1457 SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1461 SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1465 SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet);
1470 //----------------------------------------------------------------------------
1473 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1474 EEntiteMaillage theEntity,
1475 EGeometrieElement theGeom,
1478 EConnectivite theConnMode,
1479 EBooleen theIsElemNum,
1480 EBooleen theIsElemNames)
1482 return PPolygoneInfo(new TTPolygoneInfo
1493 //----------------------------------------------------------------------------
1496 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1497 EEntiteMaillage theEntity,
1498 EGeometrieElement theGeom,
1499 const TIntVector& theIndexes,
1500 const TIntVector& theConnectivities,
1501 EConnectivite theConnMode,
1502 const TIntVector& theFamilyNums,
1503 const TIntVector& theElemNums,
1504 const TStringVector& theElemNames)
1506 return PPolygoneInfo(new TTPolygoneInfo
1518 //----------------------------------------------------------------------------
1521 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
1522 const PPolygoneInfo& theInfo)
1524 return PPolygoneInfo(new TTPolygoneInfo
1529 //----------------------------------------------------------------------------
1532 ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo,
1533 EEntiteMaillage theEntity,
1534 EGeometrieElement theGeom,
1535 EConnectivite theConnMode)
1537 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1538 return PPolygoneInfo();
1540 TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode);
1541 TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode);
1542 PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode);
1543 GetPolygoneInfo(anInfo);
1545 if (SALOME::VerbosityActivated())
1547 INITMSG("GetPPolygoneInfo"<<
1548 " - theGeom = "<<theGeom<<
1549 "; aNbElem = "<<aNbElem<<": ");
1550 for (TInt iElem = 1; iElem < aNbElem; iElem++) {
1551 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
1552 TInt aConnDim = aConnSlice.size();
1553 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
1554 ADDMSG(aConnSlice[iConn]<<",");
1564 //----------------------------------------------------------------------------
1567 ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo,
1568 EEntiteMaillage theEntity,
1569 EGeometrieElement theGeom,
1570 EConnectivite theConnMode,
1573 return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr);
1576 //----------------------------------------------------------------------------
1579 ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo,
1582 EConnectivite theConnMode,
1585 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1587 if (theErr && *theErr < 0)
1588 EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
1590 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
1592 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1593 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theConnMode);
1594 //TValueHolder<TInt, med_int> aNbFaces(theNbFaces);
1595 //TValueHolder<TInt, med_int> aConnSize(theConnSize);
1597 med_bool chgt, trsf;
1598 theNbFaces = MEDmeshnEntity(myFile->Id(),
1609 theConnSize = MEDmeshnEntity(myFile->Id(),
1620 if (theNbFaces < 0 || theConnSize<0)
1621 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)");
1625 //-----------------------------------------------------------------
1628 ::GetPolyedreInfo(TPolyedreInfo& theInfo,
1631 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1633 if (theErr && *theErr < 0)
1636 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
1638 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1639 TInt aNbElem = (TInt)theInfo.myElemNum->size();
1640 TValueHolder<TElemNum, med_int> anIndex(theInfo.myIndex);
1641 TValueHolder<TElemNum, med_int> aFaces(theInfo.myFaces);
1642 TValueHolder<TElemNum, med_int> aConn(theInfo.myConn);
1643 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(theInfo.myConnMode);
1646 aRet = MEDmeshPolyhedronRd(myFile->Id(),
1659 EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)");
1661 if (theInfo.myIsElemNames) {
1662 GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1667 if (theInfo.myIsElemNum) {
1668 GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1673 GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet);
1678 //----------------------------------------------------------------------------
1681 ::SetPolyedreInfo(const TPolyedreInfo& theInfo,
1684 SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr);
1687 //----------------------------------------------------------------------------
1690 ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo,
1694 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
1696 if (theErr && *theErr < 0)
1699 MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
1700 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
1702 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
1703 TValueHolder<TElemNum, med_int> anIndex(anInfo.myIndex);
1704 TValueHolder<TElemNum, med_int> aFaces(anInfo.myFaces);
1705 TValueHolder<TElemNum, med_int> aConn(anInfo.myConn);
1706 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode(anInfo.myConnMode);
1709 aRet = MEDmeshPolyhedronWr(myFile->Id(),
1718 (TInt)anInfo.myFaces->size(),
1725 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)");
1727 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(anInfo.myEntity);
1729 if (theInfo.myIsElemNames) {
1730 TValueHolder<TString, char> anElemNames(anInfo.myElemNames);
1731 aRet = MEDmeshEntityNameWr(myFile->Id(),
1737 (TInt)anInfo.myElemNames->size(),
1742 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)");
1745 if (theInfo.myIsElemNum) {
1746 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
1747 aRet = MEDmeshEntityNumberWr(myFile->Id(),
1753 (TInt)anInfo.myElemNum->size(),
1758 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)");
1761 TValueHolder<TElemNum, med_int> aFamNum(anInfo.myFamNum);
1762 aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(),
1768 (TInt)anInfo.myFamNum->size(),
1774 EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)");
1777 //----------------------------------------------------------------------------
1780 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1781 EEntiteMaillage theEntity,
1782 EGeometrieElement theGeom,
1786 EConnectivite theConnMode,
1787 EBooleen theIsElemNum,
1788 EBooleen theIsElemNames)
1790 return PPolyedreInfo(new TTPolyedreInfo
1802 //----------------------------------------------------------------------------
1805 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1806 EEntiteMaillage theEntity,
1807 EGeometrieElement theGeom,
1808 const TIntVector& theIndexes,
1809 const TIntVector& theFaces,
1810 const TIntVector& theConnectivities,
1811 EConnectivite theConnMode,
1812 const TIntVector& theFamilyNums,
1813 const TIntVector& theElemNums,
1814 const TStringVector& theElemNames)
1816 return PPolyedreInfo(new TTPolyedreInfo
1829 //----------------------------------------------------------------------------
1832 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
1833 const PPolyedreInfo& theInfo)
1835 return PPolyedreInfo(new TTPolyedreInfo
1840 //----------------------------------------------------------------------------
1843 ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo,
1844 EEntiteMaillage theEntity,
1845 EGeometrieElement theGeom,
1846 EConnectivite theConnMode)
1848 if (theMeshInfo->GetType() != eNON_STRUCTURE)
1849 return PPolyedreInfo();
1850 TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode);
1851 TInt aNbFaces, aConnSize;
1852 GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode);
1853 PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode);
1854 GetPolyedreInfo(anInfo);
1856 if (SALOME::VerbosityActivated())
1858 INITMSG("GetPPolyedreInfo"<<
1859 " - theGeom = "<<theGeom<<
1860 "; aNbElem = "<<aNbElem<<": ");
1861 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
1862 TCConnSliceArr aConnSliceArr = anInfo->GetConnSliceArr(iElem);
1863 TInt aNbFaces = aConnSliceArr.size();
1865 for (TInt iFace = 0; iFace < aNbFaces; iFace++) {
1866 TCConnSlice aConnSlice = aConnSliceArr[iFace];
1867 TInt aNbConn = aConnSlice.size();
1869 for (TInt iConn = 0; iConn < aNbConn; iConn++) {
1870 ADDMSG(aConnSlice[iConn]<<",");
1882 //-----------------------------------------------------------------
1885 ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo,
1886 EConnectivite theConnMode,
1891 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
1893 if (theErr && *theErr < 0)
1896 if (theMeshInfo.GetType() == eNON_STRUCTURE) {
1897 TInt aNbElem = GetNbNodes(theMeshInfo);
1899 anInfo[eNOEUD][ePOINT1] = aNbElem;
1900 const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet();
1901 TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin();
1902 TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end();
1903 for (; anIter != anIterEnd; anIter++) {
1904 const EEntiteMaillage& anEntity = anIter->first;
1905 const TGeomSet& aGeomSet = anIter->second;
1906 TGeomSet::const_iterator anIter2 = aGeomSet.begin();
1907 TGeomSet::const_iterator anIterEnd2 = aGeomSet.end();
1908 for (; anIter2 != anIterEnd2; anIter2++) {
1909 const EGeometrieElement& aGeom = *anIter2;
1910 aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr);
1912 if (anEntity == eSTRUCT_ELEMENT) {
1913 const TInt nbStructTypes = aNbElem;
1914 for (TInt structType = 0; structType < nbStructTypes; ++structType) {
1915 // check type name to keep only "MED_BALL" structured element
1916 TValueHolder<TString, char> aMeshName((TString&) theMeshInfo.myName);
1917 char geotypename[ MED_NAME_SIZE + 1] = "";
1918 med_geometry_type geotype;
1919 MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT,
1920 med_entity_type(anEntity), structType+1,
1921 geotypename, &geotype);
1922 if (strcmp(geotypename, MED_BALL_NAME) == 0) {
1923 aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype),
1924 theConnMode, theErr);
1926 anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem;
1931 anInfo[anEntity][aGeom] = aNbElem;
1938 else { // eSTRUCTURE
1939 EGrilleType aGrilleType;
1943 TInt aDim = theMeshInfo.GetDim();
1944 EGeometrieElement aGeom, aSubGeom;
1945 EEntiteMaillage aSubEntity = eMAILLE;
1947 GetGrilleType(theMeshInfo, aGrilleType);
1949 TIntVector aStruct(aDim);
1950 if (aGrilleType == eGRILLE_STANDARD)
1952 GetGrilleStruct(theMeshInfo, aStruct, theErr);
1955 { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE
1956 ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 };
1957 for (med_int anAxis = 0; anAxis < aDim; anAxis++)
1958 aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]);
1960 for (med_int i = 0; i < aDim; i++) {
1961 aNbNodes = aNbNodes * aStruct[i];
1962 aNbElem = aNbElem * (aStruct[i] - 1);
1971 aSubEntity = eARETE;
1973 (aStruct[0]) * (aStruct[1]-1) +
1974 (aStruct[0]-1) * (aStruct[1]);
1981 (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) +
1982 (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) +
1983 (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]);
1986 anInfo[eNOEUD][ePOINT1] = aNbNodes;
1987 anInfo[eMAILLE][aGeom] = aNbElem;
1989 anInfo[aSubEntity][aSubGeom] = aNbSub;
1994 //-----------------------------------------------------------------
1997 ::GetNbCells(const MED::TMeshInfo& theMeshInfo,
1998 EEntiteMaillage theEntity,
1999 EGeometrieElement theGeom,
2000 EConnectivite theConnMode,
2003 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2005 if (theErr && *theErr < 0)
2008 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
2009 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2010 med_bool chgt, trsf;
2013 case MED::ePOLYGONE:
2014 case MED::ePOLYGON2:
2016 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2017 MED_NO_DT, MED_NO_IT,
2018 med_entity_type(theEntity), med_geometry_type(theGeom),
2019 MED_INDEX_NODE, med_connectivity_mode(theConnMode),
2022 case MED::ePOLYEDRE:
2024 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2025 MED_NO_DT, MED_NO_IT,
2026 med_entity_type(theEntity), MED_POLYHEDRON,
2027 MED_INDEX_FACE, med_connectivity_mode(theConnMode),
2032 return GetNbBalls(theMeshInfo);
2036 return MEDmeshnEntity(myFile->Id(), &aMeshName,
2037 MED_NO_DT, MED_NO_IT,
2038 med_entity_type(theEntity), med_geometry_type(theGeom),
2039 MED_CONNECTIVITY, med_connectivity_mode(theConnMode),
2046 //----------------------------------------------------------------------------
2049 ::GetCellInfo(MED::TCellInfo& theInfo,
2052 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2054 if (theErr && *theErr < 0)
2057 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
2059 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2060 TValueHolder<TElemNum, med_int> aConn (theInfo.myConn);
2061 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (theInfo.myModeSwitch);
2062 TValueHolder<TString, char> anElemNames (theInfo.myElemNames);
2063 TValueHolder<EBooleen, med_bool> anIsElemNames(theInfo.myIsElemNames);
2064 TValueHolder<TElemNum, med_int> anElemNum (theInfo.myElemNum);
2065 TValueHolder<EBooleen, med_bool> anIsElemNum (theInfo.myIsElemNum);
2066 TValueHolder<TElemNum, med_int> aFamNum (theInfo.myFamNum);
2067 TValueHolder<EBooleen, med_bool> anIsFamNum (theInfo.myIsFamNum);
2068 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (theInfo.myEntity);
2069 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2070 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (theInfo.myConnMode);
2074 aRet = MEDmeshnEntity(myFile->Id(),
2085 // names are present in the file, they will be read in spite of theInfo.myIsElemNames
2086 theInfo.myIsElemNames = eVRAI;
2087 theInfo.myElemNames.reset( new TString( theInfo.myNbElem * GetPNOMLength() + 1 ));
2088 anElemNames.myRepresentation = & ((TString&) theInfo.myElemNames )[0];
2091 aRet = MEDmeshElementRd(myFile->Id(),
2110 EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)");
2112 if (anIsFamNum == MED_FALSE)
2114 int mySize = (int) theInfo.myFamNum->size();
2115 theInfo.myFamNum->clear();
2116 theInfo.myFamNum->resize(mySize, 0);
2121 //----------------------------------------------------------------------------
2124 ::SetCellInfo(const MED::TCellInfo& theInfo,
2127 SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr);
2130 //----------------------------------------------------------------------------
2133 ::SetCellInfo(const MED::TCellInfo& theInfo,
2137 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2139 if (theErr && *theErr < 0)
2142 MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
2143 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
2145 TValueHolder<TString, char> aMeshName (aMeshInfo.myName);
2146 TValueHolder<TElemNum, med_int> aConn (anInfo.myConn);
2147 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch (anInfo.myModeSwitch);
2148 TValueHolder<TString, char> anElemNames (anInfo.myElemNames);
2149 TValueHolder<EBooleen, med_bool> anIsElemNames(anInfo.myIsElemNames);
2150 TValueHolder<TElemNum, med_int> anElemNum (anInfo.myElemNum);
2151 TValueHolder<EBooleen, med_bool> anIsElemNum (anInfo.myIsElemNum);
2152 TValueHolder<TElemNum, med_int> aFamNum (anInfo.myFamNum);
2153 TValueHolder<EBooleen, med_bool> anIsFamNum (anInfo.myIsFamNum);
2154 TValueHolder<EEntiteMaillage, med_entity_type> anEntity (anInfo.myEntity);
2155 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (anInfo.myGeom);
2156 TValueHolder<EConnectivite, med_connectivity_mode> aConnMode (anInfo.myConnMode);
2157 TValueHolder<TInt, med_int> aNbElem (anInfo.myNbElem);
2160 aRet = MEDmeshElementConnectivityWr(myFile->Id(),
2172 MEDmeshEntityFamilyNumberWr(myFile->Id(),
2181 MEDmeshEntityNameWr(myFile->Id(),
2190 MEDmeshEntityNumberWr(myFile->Id(),
2201 EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet);
2204 //----------------------------------------------------------------------------
2207 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2208 EEntiteMaillage theEntity,
2209 EGeometrieElement theGeom,
2211 EConnectivite theConnMode,
2212 EBooleen theIsElemNum,
2213 EBooleen theIsElemNames,
2214 EModeSwitch theMode)
2216 return PCellInfo(new TTCellInfo
2227 //----------------------------------------------------------------------------
2230 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2231 EEntiteMaillage theEntity,
2232 EGeometrieElement theGeom,
2233 const TIntVector& theConnectivities,
2234 EConnectivite theConnMode,
2235 const TIntVector& theFamilyNums,
2236 const TIntVector& theElemNums,
2237 const TStringVector& theElemNames,
2238 EModeSwitch theMode)
2240 return PCellInfo(new TTCellInfo
2252 //----------------------------------------------------------------------------
2255 ::CrCellInfo(const PMeshInfo& theMeshInfo,
2256 const PCellInfo& theInfo)
2258 return PCellInfo(new TTCellInfo
2263 //----------------------------------------------------------------------------
2266 ::GetPCellInfo(const PMeshInfo& theMeshInfo,
2267 EEntiteMaillage theEntity,
2268 EGeometrieElement theGeom,
2269 EConnectivite theConnMode,
2272 if (theMeshInfo->GetType() != eNON_STRUCTURE)
2274 TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode);
2275 PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode);
2276 GetCellInfo(anInfo, theErr);
2278 if (SALOME::VerbosityActivated())
2280 TInt aConnDim = anInfo->GetConnDim();
2281 INITMSG("GetPCellInfo - theEntity = "<<theEntity<<"; theGeom = "<<theGeom<<"; aConnDim: "<<aConnDim<<"\n");
2282 BEGMSG("GetPCellInfo - aNbElem: "<<aNbElem<<": ");
2283 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2284 TCConnSlice aConnSlice = anInfo->GetConnSlice(iElem);
2285 for (TInt iConn = 0; iConn < aConnDim; iConn++) {
2286 ADDMSG(aConnSlice[iConn]<<",");
2292 BEGMSG("GetPCellInfo - GetFamNum: ");
2293 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2294 ADDMSG(anInfo->GetFamNum(iElem)<<", ");
2298 if (anInfo->IsElemNum()) {
2299 BEGMSG("GetPCellInfo - GetElemNum: ");
2300 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
2301 ADDMSG(anInfo->GetElemNum(iElem)<<", ");
2311 //----------------------------------------------------------------------------
2314 ::GetBallGeom(const TMeshInfo& /*theMeshInfo*/)
2317 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2319 // read med_geometry_type of "MED_BALL" element
2320 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2321 return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename));
2324 //----------------------------------------------------------------------------
2327 ::GetNbBalls(const TMeshInfo& theMeshInfo)
2330 TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
2332 EGeometrieElement ballType = GetBallGeom(theMeshInfo);
2336 return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD);
2339 //----------------------------------------------------------------------------
2342 ::GetBallInfo(TBallInfo& theInfo,
2345 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2347 // check geometry of MED_BALL
2348 if (theInfo.myGeom == eBALL)
2350 theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo);
2351 if (theInfo.myGeom < 0) {
2353 EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh");
2354 *theErr = theInfo.myGeom;
2360 GetCellInfo(theInfo);
2363 TValueHolder<TString, char> aMeshName (theInfo.myMeshInfo->myName);
2364 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (theInfo.myGeom);
2365 TValueHolder<TFloatVector, void> aDiam (theInfo.myDiameters);
2366 char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER;
2368 TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName,
2369 MED_NO_DT, MED_NO_IT,
2376 EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters");
2379 //----------------------------------------------------------------------------
2382 ::SetBallInfo(const TBallInfo& theInfo,
2385 SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr);
2388 //----------------------------------------------------------------------------
2391 ::SetBallInfo(const TBallInfo& theInfo,
2395 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2398 char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
2399 EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo);
2402 // no ball model in the file, create support mesh for it
2403 char dummyname [MED_NAME_SIZE*3+1] = "";
2404 if ((ret = MEDsupportMeshCr(myFile->Id(),
2406 theInfo.myMeshInfo->GetSpaceDim(),
2407 theInfo.myMeshInfo->GetDim(),
2408 "Support mesh for a ball model",
2410 /*axisname=*/dummyname,
2411 /*unitname=*/dummyname)) < 0) {
2413 EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr");
2417 // write coordinates of 1 node
2418 med_float coord[3] = {0, 0, 0};
2419 if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(),
2420 ballsupportname, MED_NO_DT, MED_NO_IT, 0.0,
2421 MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) {
2423 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr");
2427 // ball model creation
2428 char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
2429 if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(),
2431 theInfo.myMeshInfo->GetSpaceDim(),
2433 MED_NODE,MED_NONE)) < 0) {
2435 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr");
2439 // create diameter attribute
2440 if ((ret = MEDstructElementVarAttCr(myFile->Id(),
2441 geotypename, MED_BALL_DIAMETER,
2442 MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) {
2444 EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr");
2450 TBallInfo& aBallInfo = ((TBallInfo&) theInfo);
2451 aBallInfo.myGeom = ballGeom;
2454 SetCellInfo(theInfo, theMode, theErr);
2455 if (theErr && *theErr < 0)
2459 TValueHolder<TString, char> aMeshName (aBallInfo.myMeshInfo->myName);
2460 TValueHolder<EGeometrieElement, med_geometry_type> aGeom (aBallInfo.myGeom);
2461 TValueHolder<TFloatVector, void> aDiam (aBallInfo.myDiameters);
2462 ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName,
2463 MED_NO_DT, MED_NO_IT,
2464 aGeom, MED_BALL_DIAMETER,
2465 theInfo.myNbElem, &aDiam);
2469 EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr");
2472 //----------------------------------------------------------------------------
2475 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2477 EBooleen theIsElemNum)
2479 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
2482 //----------------------------------------------------------------------------
2485 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2486 const TIntVector& theNodes,
2487 TFloatVector& theDiameters,
2488 const TIntVector& theFamilyNums,
2489 const TIntVector& theElemNums)
2491 return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters,
2492 theFamilyNums, theElemNums));
2495 //----------------------------------------------------------------------------
2498 ::CrBallInfo(const PMeshInfo& theMeshInfo,
2499 const PBallInfo& theInfo)
2501 return PBallInfo(new TTBallInfo(theMeshInfo, theInfo));
2504 //----------------------------------------------------------------------------
2507 ::GetPBallInfo(const PMeshInfo& theMeshInfo)
2509 TInt nbBalls = GetNbBalls(theMeshInfo);
2510 if (nbBalls < 1) return PBallInfo();
2512 PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls);
2513 GetBallInfo(anInfo);
2518 //-----------------------------------------------------------------
2521 ::GetNbFields(TErr* theErr)
2523 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2525 if (theErr && *theErr < 0)
2528 return MEDnField(myFile->Id());
2531 //----------------------------------------------------------------------------
2534 ::GetNbComp(TInt theFieldId,
2537 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2539 if (theErr && *theErr < 0)
2542 return MEDfieldnComponent(myFile->Id(), theFieldId);
2545 //----------------------------------------------------------------------------
2548 ::GetFieldInfo(TInt theFieldId,
2549 MED::TFieldInfo& theInfo,
2552 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2554 if (theErr && *theErr < 0)
2557 TString aFieldName(256); // Protect from memory problems with too long names
2558 TValueHolder<ETypeChamp, med_field_type> aType(theInfo.myType);
2559 TValueHolder<TString, char> aCompNames(theInfo.myCompNames);
2560 TValueHolder<TString, char> anUnitNames(theInfo.myUnitNames);
2561 MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo;
2565 char dtunit[MED_SNAME_SIZE+1];
2566 char local_mesh_name[MED_NAME_SIZE+1]="";
2568 theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId);
2569 aRet = MEDfieldInfo(myFile->Id(),
2580 if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) {
2586 theInfo.SetName(aFieldName);
2591 EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)");
2594 //----------------------------------------------------------------------------
2597 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2601 SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet);
2604 SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet);
2610 //----------------------------------------------------------------------------
2613 ::SetFieldInfo(const MED::TFieldInfo& theInfo,
2617 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
2619 if (theErr && *theErr < 0)
2622 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2624 TValueHolder<TString, char> aFieldName(anInfo.myName);
2625 TValueHolder<ETypeChamp, med_field_type> aType(anInfo.myType);
2626 TValueHolder<TString, char> aCompNames(anInfo.myCompNames);
2627 TValueHolder<TString, char> anUnitNames(anInfo.myUnitNames);
2628 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2630 char dtunit[MED_SNAME_SIZE+1];
2631 std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0');
2632 aRet = MEDfieldCr(myFile->Id(),
2639 &aMeshInfo.myName[0]);
2643 EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)");
2646 //----------------------------------------------------------------------------
2649 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2652 const std::string& theValue,
2653 EBooleen theIsLocal,
2656 return PFieldInfo(new TTFieldInfo
2665 //----------------------------------------------------------------------------
2668 ::CrFieldInfo(const PMeshInfo& theMeshInfo,
2669 const PFieldInfo& theInfo)
2671 return PFieldInfo(new TTFieldInfo
2676 //----------------------------------------------------------------------------
2679 ::GetPFieldInfo(const PMeshInfo& theMeshInfo,
2683 TInt aNbComp = GetNbComp(theId);
2684 PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp);
2685 GetFieldInfo(theId, *anInfo, theErr);
2687 if (SALOME::VerbosityActivated())
2689 INITMSG("GetPFieldInfo "<<
2690 "- aName = '"<<anInfo->GetName()<<"'"<<
2691 "; aType = "<<anInfo->GetType()<<
2692 "; aNbComp = "<<aNbComp<<
2699 //----------------------------------------------------------------------------
2702 ::GetNbGauss(TErr* theErr)
2704 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2706 if (theErr && *theErr < 0)
2709 return MEDnLocalization(myFile->Id());
2712 //----------------------------------------------------------------------------
2715 ::GetGaussPreInfo(TInt theId,
2718 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2720 if (theErr && *theErr < 0)
2721 return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
2723 med_int aNbGaussPoints = med_int();
2724 TVector<char> aName(GetNOMLength()+1);
2725 med_geometry_type aGeom = MED_NONE;
2729 char geointerpname[MED_NAME_SIZE+1] = "";
2730 char ipointstructmeshname[MED_NAME_SIZE+1] = "";
2731 med_int nsectionmeshcell;
2732 med_geometry_type sectiongeotype;
2733 aRet = MEDlocalizationInfo (myFile->Id(),
2740 ipointstructmeshname,
2746 EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)");
2747 return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]),
2748 TInt(aNbGaussPoints));
2751 //----------------------------------------------------------------------------
2754 ::GetGaussInfo(TInt /*theId*/,
2755 TGaussInfo& theInfo,
2758 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2760 if (theErr && *theErr < 0)
2763 TValueHolder<TNodeCoord, med_float> aRefCoord(theInfo.myRefCoord);
2764 TValueHolder<TNodeCoord, med_float> aGaussCoord(theInfo.myGaussCoord);
2765 TValueHolder<TWeight, med_float> aWeight(theInfo.myWeight);
2766 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
2767 TValueHolder<TString, char> aGaussName(theInfo.myName);
2770 aRet = MEDlocalizationRd(myFile->Id(),
2780 EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)");
2783 //----------------------------------------------------------------------------
2786 ::CrGaussInfo(const TGaussInfo::TInfo& theInfo,
2787 EModeSwitch theMode)
2789 return PGaussInfo(new TTGaussInfo
2794 //-----------------------------------------------------------------
2797 ::GetNbTimeStamps(const MED::TFieldInfo& theInfo,
2798 const MED::TEntityInfo& theEntityInfo,
2799 EEntiteMaillage& theEntity,
2800 TGeom2Size& theGeom2Size,
2803 theEntity = EEntiteMaillage(-1);
2804 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2807 if (theEntityInfo.empty())
2812 else if (theEntityInfo.empty())
2813 EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh");
2815 bool anIsPerformAdditionalCheck = GetNbMeshes() > 1;
2817 theGeom2Size.clear();
2818 TInt aNbTimeStamps = 0;
2819 TIdt anId = myFile->Id();
2821 MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
2822 TValueHolder<TString, char> aFieldName(anInfo.myName);
2823 MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo;
2825 // workaround for IPAL13676
2826 MED::TEntityInfo localEntityInfo = theEntityInfo;
2827 TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE);
2828 if (anLocalIter != localEntityInfo.end()) {
2829 localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second;
2832 TEntityInfo::const_iterator anIter = localEntityInfo.begin();
2833 for (; anIter != localEntityInfo.end(); anIter++) {
2834 med_entity_type anEntity = med_entity_type(anIter->first);
2835 const TGeom2Size& aGeom2Size = anIter->second;
2836 TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin();
2837 for (; anGeomIter != aGeom2Size.end(); anGeomIter++) {
2838 med_geometry_type aGeom = med_geometry_type(anGeomIter->first);
2839 char aMeshName[MED_NAME_SIZE+1];
2842 char dtunit[MED_SNAME_SIZE+1];
2843 med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName);
2844 char *cname=new char[myNbComp*MED_SNAME_SIZE+1];
2845 char *unitname=new char[myNbComp*MED_SNAME_SIZE+1];
2847 MEDfieldInfoByName(anId,
2864 MEDfieldComputingStepInfo(anId,
2870 char profilename[MED_NAME_SIZE+1];
2871 char locname[MED_NAME_SIZE+1];
2875 // protection from crash (division by zero)
2876 // inside MEDfieldnValueWithProfile function
2877 // caused by the workaround for IPAL13676 (see above)
2878 if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0)
2881 nval = MEDfieldnValueWithProfile(anId,
2886 med_geometry_type(aGeom),
2894 bool anIsSatisfied =(nval > 0);
2895 if (anIsSatisfied) {
2896 INITMSG("GetNbTimeStamps aNbTimeStamps = "<<aNbStamps<<
2897 "; aGeom = "<<aGeom<<"; anEntity = "<<anEntity<<"\n");
2898 if (anIsPerformAdditionalCheck) {
2899 anIsSatisfied = !strcmp(&aMeshName[0], &aMeshInfo.myName[0]);
2900 if (!anIsSatisfied) {
2901 INITMSG("GetNbTimeStamps aMeshName = '"<<&aMeshName[0]<<"' != "<<
2902 "; aMeshInfo.myName = '"<<&aMeshInfo.myName[0]<<"'\n");
2906 if (anIsSatisfied) {
2907 theGeom2Size[EGeometrieElement(aGeom)] = anGeomIter->second;
2908 theEntity = EEntiteMaillage(anEntity);
2909 aNbTimeStamps = aNbStamps;
2912 if (!theGeom2Size.empty())
2915 return aNbTimeStamps;
2918 //----------------------------------------------------------------------------
2921 ::GetTimeStampInfo(TInt theTimeStampId,
2922 MED::TTimeStampInfo& theInfo,
2925 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
2927 const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
2930 if (aGeom2Size.empty())
2935 else if (aGeom2Size.empty())
2936 EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell");
2938 MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
2939 MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
2941 TValueHolder<TString, char> aFieldName(aFieldInfo.myName);
2942 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(theInfo.myEntity);
2943 TValueHolder<TInt, med_int> aNumDt(theInfo.myNumDt);
2944 TValueHolder<TInt, med_int> aNumOrd(theInfo.myNumOrd);
2945 TValueHolder<TString, char> anUnitDt(theInfo.myUnitDt);
2946 TValueHolder<TFloat, med_float> aDt(theInfo.myDt);
2947 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
2948 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo.myIsLocal);
2949 TValueHolder<TInt, med_int> aNbRef(aFieldInfo.myNbRef);
2951 TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss;
2953 // just to get a time stamp unit (anUnitDt)
2954 med_field_type aFieldType;
2955 med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName);
2956 char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1];
2957 char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1];
2959 MEDfieldInfoByName(myFile->Id(),
2968 delete [] aCompName;
2969 delete [] aCompUnit;
2971 TGeom2Size::const_iterator anIter = aGeom2Size.begin();
2972 for (; anIter != aGeom2Size.end(); anIter++) {
2973 const EGeometrieElement& aGeom = anIter->first;
2974 med_int aNbGauss = -1;
2977 aRet = MEDfieldComputingStepInfo(myFile->Id(),
2983 char profilename[MED_NAME_SIZE+1];
2985 char locname[MED_NAME_SIZE+1];
2986 MEDfieldnValueWithProfile(myFile->Id(),
2991 med_geometry_type(aGeom),
2999 static TInt MAX_NB_GAUSS_POINTS = 32;
3000 if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS)
3003 aGeom2NbGauss[aGeom] = aNbGauss;
3008 EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)");
3012 //----------------------------------------------------------------------------
3015 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3016 EEntiteMaillage theEntity,
3017 const TGeom2Size& theGeom2Size,
3018 const TGeom2NbGauss& theGeom2NbGauss,
3022 const std::string& theUnitDt,
3023 const TGeom2Gauss& theGeom2Gauss)
3025 return PTimeStampInfo(new TTTimeStampInfo
3037 //----------------------------------------------------------------------------
3040 ::CrTimeStampInfo(const PFieldInfo& theFieldInfo,
3041 const PTimeStampInfo& theInfo)
3043 return PTimeStampInfo(new TTTimeStampInfo
3048 //----------------------------------------------------------------------------
3051 ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo,
3052 EEntiteMaillage theEntity,
3053 const TGeom2Size& theGeom2Size,
3057 PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size);
3058 GetTimeStampInfo(theId, *anInfo, theErr);
3060 if (SALOME::VerbosityActivated())
3062 INITMSG("GetPTimeStampInfo - anEntity = "<<anInfo->GetEntity()<<"\n");
3063 TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss;
3064 TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin();
3065 for (; anIter != aGeom2NbGauss.end(); anIter++) {
3066 const EGeometrieElement& aGeom = anIter->first;
3067 INITMSG("aGeom = "<<aGeom<<" - "<<aGeom2NbGauss[aGeom]<<";\n");
3074 //----------------------------------------------------------------------------
3077 ::GetNbProfiles(TErr* theErr)
3079 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3081 if (theErr && *theErr < 0)
3084 return MEDnProfile(myFile->Id());
3087 //----------------------------------------------------------------------------
3090 ::GetProfilePreInfo(TInt theId,
3093 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3095 if (theErr && *theErr < 0)
3096 return TProfileInfo::TInfo();
3099 TVector<char> aName(GetNOMLength()+1);
3102 aRet = MEDprofileInfo(myFile->Id(),
3109 EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)");
3111 return TProfileInfo::TInfo(&aName[0], aSize);
3114 //----------------------------------------------------------------------------
3117 ::GetProfileInfo(TInt /*theId*/,
3118 TProfileInfo& theInfo,
3121 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3123 if (theErr && *theErr < 0)
3126 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3127 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3128 TValueHolder<TString, char> aProfileName(anInfo.myName);
3131 aRet = MEDprofileRd(myFile->Id(),
3137 EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)");
3140 //----------------------------------------------------------------------------
3143 ::SetProfileInfo(const TProfileInfo& theInfo,
3147 SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet);
3150 SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet);
3153 SetProfileInfo(theInfo, eCREATION, &aRet);
3159 //----------------------------------------------------------------------------
3162 ::SetProfileInfo(const TProfileInfo& theInfo,
3166 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3168 if (theErr && *theErr < 0)
3171 TProfileInfo& anInfo = const_cast<TProfileInfo&>(theInfo);
3172 TValueHolder<TElemNum, med_int> anElemNum(anInfo.myElemNum);
3173 TValueHolder<TString, char> aProfileName(anInfo.myName);
3176 aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier.
3177 &aProfileName, // tableau de valeurs du profil.
3178 theInfo.GetSize(), // taille du profil.
3179 &anElemNum); // nom profil.
3183 EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)");
3186 //----------------------------------------------------------------------------
3189 ::CrProfileInfo(const TProfileInfo::TInfo& theInfo,
3190 EModeProfil theMode)
3192 return PProfileInfo(new TTProfileInfo
3197 //----------------------------------------------------------------------------
3200 ::GetPProfileInfo(TInt theId,
3201 EModeProfil theMode,
3204 TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId);
3205 PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode);
3206 GetProfileInfo(theId, *anInfo, theErr);
3211 //----------------------------------------------------------------------------
3214 ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3215 const TMKey2Profile& theMKey2Profile,
3216 const TKey2Gauss& theKey2Gauss,
3219 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3221 if (theErr && *theErr < 0)
3224 TIdt anId = myFile->Id();
3226 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3227 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3229 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3230 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3231 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3232 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3234 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3235 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3236 TValueHolder<EBooleen, med_bool> anIsLocal(aFieldInfo->myIsLocal);
3238 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3239 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3241 TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3242 TVector<char> aGaussName(GetNOMLength()+1);
3244 med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile));
3245 MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile);
3246 TVector<char> aProfileName(GetNOMLength()+1);
3248 TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size;
3249 TGeom2Size::iterator anIter = aGeom2Size.begin();
3250 for (; anIter != aGeom2Size.end(); anIter++) {
3251 EGeometrieElement aGeom = anIter->first;
3252 TInt aNbElem = anIter->second;
3253 med_int profilesize, aNbGauss;
3255 TInt aNbVal = MEDfieldnValueWithProfile(anId,
3260 med_geometry_type(aGeom),
3273 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<<aNbVal<<" <= 0");
3276 TInt aNbComp = aFieldInfo->myNbComp;
3277 TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed
3278 theTimeStampValue->AllocateValue(aGeom,
3282 TInt aValueSize = theTimeStampValue->GetValueSize(aGeom);
3284 INITMSG("TWrapper::GetTimeStampValue - aGeom = "<<aGeom<<
3285 "; aNbVal = "<<aNbVal<<
3286 "; aNbValue = "<<aNbValue<<
3287 "; aNbGauss = "<<aNbGauss<<
3288 "; aNbComp = "<<aNbComp<<
3291 TErr aRet = MEDfieldValueWithProfileRd(anId,
3296 med_geometry_type(aGeom),
3300 MED_ALL_CONSTITUENT,
3301 theTimeStampValue->GetValuePtr(aGeom));
3304 *theErr = MED_FALSE;
3307 EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldValueWithProfileRd(...)");
3310 MED::PGaussInfo aGaussInfo;
3311 TGaussInfo::TKey aKey(aGeom, &aGaussName[0]);
3312 if (strcmp(&aGaussName[0], "") != 0) {
3313 MED::TKey2Gauss::const_iterator anIter = theKey2Gauss.find(aKey);
3314 if (anIter != theKey2Gauss.end()) {
3315 aGaussInfo = anIter->second;
3316 aGeom2Gauss[aGeom] = aGaussInfo;
3320 MED::PProfileInfo aProfileInfo;
3321 if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) {
3322 MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]);
3323 if (anIter != aKey2Profile.end()) {
3324 aProfileInfo = anIter->second;
3325 aGeom2Profile[aGeom] = aProfileInfo;
3329 if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) {
3331 *theErr = MED_FALSE;
3334 EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()");
3337 if (aProfileInfo && aProfileInfo->IsPresent()) {
3338 TInt aNbSubElem = aProfileInfo->GetSize();
3339 TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss;
3340 if (aProfileSize != aValueSize) {
3345 EXCEPTION(std::runtime_error,
3346 "GetTimeStampValue - aProfileSize("<<aProfileSize<<
3347 ") != aValueSize("<<aValueSize<<
3348 "); aNbVal = "<<aNbVal<<
3349 "; anEntity = "<<anEntity<<
3350 "; aGeom = "<<aGeom<<
3351 "; aNbElem = "<<aNbElem<<
3352 "; aNbSubElem = "<<aNbSubElem<<
3353 "; aNbComp = "<<aNbComp<<
3354 "; aNbGauss = "<<aNbGauss<<
3359 if ((aProfileMode == MED_GLOBAL_STMODE) && (aNbElem != aNbValue)) {
3364 EXCEPTION(std::runtime_error,
3365 "GetTimeStampValue - aNbElem("<<aNbElem<<
3366 ") != aNbValue("<<aNbValue<<
3367 "); aNbVal = "<<aNbVal<<
3368 "; anEntity = "<<anEntity<<
3369 "; aGeom = "<<aGeom<<
3370 "; aNbElem = "<<aNbElem<<
3371 "; aNbComp = "<<aNbComp<<
3372 "; aNbGauss = "<<aNbGauss<<
3379 //----------------------------------------------------------------------------
3382 ::SetTimeStampValue(const PTimeStampValueBase& theTimeStampValue,
3386 SetTimeStampValue(theTimeStampValue, eLECTURE_ECRITURE, &aRet);
3389 SetTimeStampValue(theTimeStampValue, eLECTURE_AJOUT, &aRet);
3395 //----------------------------------------------------------------------------
3398 ::SetTimeStampValue(const MED::PTimeStampValueBase& theTimeStampValue,
3402 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3404 if (theErr && *theErr < 0)
3408 TIdt anId = myFile->Id();
3410 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theTimeStampValue->myModeSwitch);
3411 MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile;
3413 MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo;
3414 TValueHolder<EEntiteMaillage, med_entity_type> anEntity(aTimeStampInfo->myEntity);
3415 TValueHolder<TInt, med_int> aNumDt(aTimeStampInfo->myNumDt);
3416 TValueHolder<TInt, med_int> aNumOrd(aTimeStampInfo->myNumOrd);
3417 TValueHolder<TString, char> anUnitDt(aTimeStampInfo->myUnitDt);
3418 TValueHolder<TFloat, med_float> aDt(aTimeStampInfo->myDt);
3419 MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss;
3421 MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo;
3422 TValueHolder<TString, char> aFieldName(aFieldInfo->myName);
3424 MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo;
3425 TValueHolder<TString, char> aMeshName(aMeshInfo->myName);
3427 const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet;
3428 TGeomSet::const_iterator anIter = aGeomSet.begin();
3429 for (; anIter != aGeomSet.end(); anIter++) {
3430 EGeometrieElement aGeom = *anIter;
3432 TVector<char> aGaussName(GetNOMLength()+1);
3433 MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom);
3434 if (aGaussIter != aGeom2Gauss.end()) {
3435 MED::PGaussInfo aGaussInfo = aGaussIter->second;
3436 strcpy(&aGaussName[0], &aGaussInfo->myName[0]);
3439 TVector<char> aProfileName(GetNOMLength()+1);
3440 med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD);
3441 MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom);
3442 if (aProfileIter != aGeom2Profile.end()) {
3443 MED::PProfileInfo aProfileInfo = aProfileIter->second;
3444 aProfileMode = med_storage_mode(aProfileInfo->myMode);
3445 strcpy(&aProfileName[0], &aProfileInfo->myName[0]);
3448 med_int aNbVal = theTimeStampValue->GetNbVal(aGeom);
3450 aRet = MEDfieldValueWithProfileWr(anId,
3456 med_geometry_type(aGeom),
3461 MED_ALL_CONSTITUENT,
3463 theTimeStampValue->GetValuePtr(aGeom));
3466 *theErr = MED_FALSE;
3469 EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)");
3474 INITMSG("TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<<theMode<<"; aRet = "<<aRet<<std::endl);
3477 //----------------------------------------------------------------------------
3480 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3481 ETypeChamp theTypeChamp,
3482 const TGeom2Profile& theGeom2Profile,
3483 EModeSwitch theMode)
3485 if (theTypeChamp == eFLOAT64)
3486 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3491 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3498 //----------------------------------------------------------------------------
3501 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3502 const TGeom2Profile& theGeom2Profile,
3503 EModeSwitch theMode)
3505 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3506 return CrTimeStampValue(theTimeStampInfo,
3507 aFieldInfo->GetType(),
3512 //----------------------------------------------------------------------------
3515 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3516 const PTimeStampValueBase& theInfo,
3517 ETypeChamp theTypeChamp)
3519 if (theTypeChamp == eFLOAT64)
3520 return PTimeStampValueBase(new TTTimeStampValue<TFloatMeshValue>
3524 return PTimeStampValueBase(new TTTimeStampValue<TIntMeshValue>
3530 //----------------------------------------------------------------------------
3533 ::CrTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3534 const PTimeStampValueBase& theInfo)
3536 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3537 return CrTimeStampValue(theTimeStampInfo,
3539 aFieldInfo->GetType());
3542 //----------------------------------------------------------------------------
3545 ::GetPTimeStampValue(const PTimeStampInfo& theTimeStampInfo,
3546 const TMKey2Profile& theMKey2Profile,
3547 const TKey2Gauss& theKey2Gauss,
3550 PFieldInfo aFieldInfo = theTimeStampInfo->GetFieldInfo();
3551 PTimeStampValueBase anInfo = CrTimeStampValue(theTimeStampInfo,
3552 aFieldInfo->GetType());
3553 GetTimeStampValue(anInfo,
3557 if (SALOME::VerbosityActivated())
3559 if (aFieldInfo->GetType() == eFLOAT64)
3560 Print<TFloatTimeStampValue>(anInfo);
3562 Print<TIntTimeStampValue>(anInfo);
3567 //----------------------------------------------------------------------------
3570 ::GetTimeStampVal(const PTimeStampVal& theVal,
3571 const TMKey2Profile& theMKey2Profile,
3572 const TKey2Gauss& theKey2Gauss,
3575 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3576 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3577 if (aFieldInfo->GetType() == eFLOAT64)
3578 GetTimeStampValue(theVal,
3583 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3586 GetTimeStampValue(aVal,
3590 CopyTimeStampValueBase(aVal, theVal);
3594 //----------------------------------------------------------------------------
3597 ::SetTimeStamp(const PTimeStampVal& theVal,
3600 PTimeStampInfo aTimeStampInfo = theVal->GetTimeStampInfo();
3601 PFieldInfo aFieldInfo = aTimeStampInfo->GetFieldInfo();
3602 if (aFieldInfo->GetType() == eFLOAT64)
3603 SetTimeStampValue(theVal, theErr);
3605 PTimeStampValueBase aVal = CrTimeStampValue(aTimeStampInfo,
3607 theVal->GetGeom2Profile(),
3608 theVal->GetModeSwitch());
3609 CopyTimeStampValueBase(theVal, aVal);
3610 SetTimeStampValue(aVal, theErr);
3614 //----------------------------------------------------------------------------
3617 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3618 const TGeom2Profile& theGeom2Profile,
3619 EModeSwitch theMode)
3621 return CrTimeStampValue(theTimeStampInfo,
3627 //----------------------------------------------------------------------------
3630 ::CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3631 const PTimeStampVal& theInfo)
3633 return CrTimeStampValue(theTimeStampInfo,
3638 //----------------------------------------------------------------------------
3641 ::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo,
3642 const TMKey2Profile& theMKey2Profile,
3643 const TKey2Gauss& theKey2Gauss,
3646 PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo);
3647 GetTimeStampVal(anInfo,
3654 //----------------------------------------------------------------------------
3657 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo)
3659 if (theMeshInfo->GetType() != eSTRUCTURE)
3660 return PGrilleInfo();
3663 GetGrilleType(*theMeshInfo, type);
3665 if (type == eGRILLE_STANDARD) {
3666 const TInt nnoeuds = GetNbNodes(*theMeshInfo);
3667 anInfo = CrGrilleInfo(theMeshInfo, type, nnoeuds);
3671 aVec.resize(theMeshInfo->GetDim());
3672 for (int aAxe=0;aAxe<theMeshInfo->GetDim();aAxe++) {
3673 ETable aATable = eCOOR_IND1;
3676 aATable = eCOOR_IND1;
3679 aATable = eCOOR_IND2;
3682 aATable = eCOOR_IND3;
3685 aVec[aAxe] = GetNbNodes(*theMeshInfo, aATable);
3687 anInfo = CrGrilleInfo(theMeshInfo, type, aVec);
3690 GetGrilleInfo(anInfo);
3691 anInfo->SetGrilleType(type);
3693 if (SALOME::VerbosityActivated())
3695 INITMSG("GetPGrilleInfo: ");
3697 TInt aNbElem = anInfo->GetNbNodes();
3698 BEGMSG("GetFamNumNode: ");
3699 for (TInt iElem = 0; iElem < aNbElem; iElem++) {
3700 ADDMSG(anInfo->GetFamNumNode(iElem)<<", ");
3702 TInt aNbCells = anInfo->GetNbCells();
3703 BEGMSG("GetFamNum: ");
3704 for (TInt iElem = 0; iElem < aNbCells; iElem++) {
3705 ADDMSG(anInfo->GetFamNum(iElem)<<", ");
3708 BEGMSG("GetCoordName: ");
3709 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3710 ADDMSG(anInfo->GetCoordName(iElem)<<", ");
3713 BEGMSG("GetCoordUnit: ");
3714 for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) {
3715 ADDMSG(anInfo->GetCoordUnit(iElem)<<", ");
3723 //----------------------------------------------------------------------------
3726 ::GetPGrilleInfo(const PMeshInfo& theMeshInfo,
3727 const PGrilleInfo& theInfo)
3729 PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo);
3733 //----------------------------------------------------------------------------
3736 ::GetGrilleInfo(TGrilleInfo& theInfo,
3739 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
3741 if (theErr && *theErr < 0)
3744 MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
3745 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3746 EMaillage aMaillageType = aMeshInfo.myType;
3748 GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr);
3749 EGrilleType aGrilleType = theInfo.myGrilleType;
3752 if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) {
3753 GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr);
3755 TValueHolder<TNodeCoord, med_float> aCoord(theInfo.myCoord);
3756 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(theInfo.myModeSwitch);
3757 TValueHolder<TString, char> aCoordNames(theInfo.myCoordNames);
3758 TValueHolder<TString, char> aCoordUnits(theInfo.myCoordUnits);
3759 //med_axis_type aRepere;
3761 aRet = MEDmeshNodeCoordinateRd(myFile->Id(),
3771 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)");
3773 //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo);
3774 TValueHolder<TElemNum, med_int> aFamNumNode(theInfo.myFamNumNode);
3776 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3785 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3787 int mySize = (int)theInfo.myFamNumNode.size();
3788 theInfo.myFamNumNode.clear();
3789 theInfo.myFamNumNode.resize(mySize,0);
3793 // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3798 //============================
3801 if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) {
3802 ETable aTable = eCOOR_IND1;
3803 for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) {
3806 aTable = eCOOR_IND1;
3809 aTable = eCOOR_IND2;
3812 aTable = eCOOR_IND3;
3821 EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)");
3823 TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable);
3825 EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice");
3827 TValueHolder<TFloatVector, med_float> anIndexes(theInfo.GetIndexes(anAxis-1));
3828 //TValueHolder<ETable, med_data_type > table(aTable);
3829 //char aCompNames[MED_SNAME_SIZE+1];
3830 //char anUnitNames[MED_SNAME_SIZE+1];
3831 aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(),
3833 MED_NO_DT,MED_NO_IT,
3837 //theInfo.SetCoordName(anAxis-1, aCompNames);
3838 //theInfo.SetCoordUnit(anAxis-1, anUnitNames);
3839 theInfo.SetGrilleStructure(anAxis-1, aNbIndexes);
3844 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)");
3848 EGeometrieElement aGeom = theInfo.GetGeom();
3849 EEntiteMaillage aEntity = theInfo.GetEntity();
3850 TInt aNbCells = theInfo.GetNbCells();
3852 theInfo.myFamNum.resize(aNbCells);
3853 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamNum);
3855 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3856 &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity),
3857 med_geometry_type(aGeom), &aFamNum);
3859 if (aMeshInfo.myDim == 3)
3861 aGeom = theInfo.GetSubGeom();
3862 aEntity = theInfo.GetSubEntity();
3863 aNbCells = theInfo.GetNbSubCells();
3865 theInfo.myFamSubNum.resize(aNbCells, 0);
3866 TValueHolder<TElemNum, med_int> aFamNum(theInfo.myFamSubNum);
3868 aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(),
3872 med_entity_type(aEntity),
3873 med_geometry_type(aGeom),
3877 // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files
3879 int mySize = (int)theInfo.myFamNumNode.size();
3880 theInfo.myFamNumNode.clear();
3881 theInfo.myFamNumNode.resize(mySize, 0);
3885 // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)");
3891 //----------------------------------------------------------------------------
3894 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3897 SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr);
3900 //----------------------------------------------------------------------------
3903 ::SetGrilleInfo(const MED::TGrilleInfo& theInfo,
3907 if (theInfo.myMeshInfo->myType != eSTRUCTURE)
3909 TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
3911 if (theErr && *theErr < 0)
3914 MED::TGrilleInfo& anInfo = const_cast<MED::TGrilleInfo&>(theInfo);
3916 MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
3917 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
3919 TValueHolder<EGrilleType, med_grid_type > aGrilleType(anInfo.myGrilleType);
3922 aRet = MEDmeshGridTypeRd(myFile->Id(),
3928 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)");
3930 if (anInfo.myGrilleType == eGRILLE_STANDARD) {
3931 TValueHolder<TNodeCoord, med_float> aCoord(anInfo.myCoord);
3932 TValueHolder<EModeSwitch, med_switch_mode> aModeSwitch(anInfo.myModeSwitch);
3933 TValueHolder<TString, char> aCoordNames(anInfo.myCoordNames);
3934 TValueHolder<TString, char> aCoordUnits(anInfo.myCoordUnits);
3935 med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim);
3936 //med_axis_type aRepere = MED_CARTESIAN;
3938 aRet = MEDmeshNodeCoordinateWr(myFile->Id(),
3948 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)");
3950 TValueHolder<TIntVector, med_int> aGrilleStructure(anInfo.myGrilleStructure);
3951 aRet = MEDmeshGridStructWr(myFile->Id(),
3958 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)");
3962 for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) {
3963 aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(),
3969 anInfo.GetIndexes(aAxis).size(),
3970 &anInfo.GetIndexes(aAxis)[0]);
3973 EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)");
3981 //----------------------------------------------------------------------------
3984 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
3985 const PGrilleInfo& theInfo)
3987 return PGrilleInfo(new TTGrilleInfo
3992 //----------------------------------------------------------------------------
3995 ::CrGrilleInfo(const PMeshInfo& /*theMeshInfo*/)
3997 return PGrilleInfo(); // not implemented????
4000 //----------------------------------------------------------------------------
4003 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4004 const EGrilleType& type)
4006 return PGrilleInfo(new TTGrilleInfo
4011 //----------------------------------------------------------------------------
4014 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4015 const EGrilleType& type,
4016 const TInt& nbNodes)
4018 return PGrilleInfo(new TTGrilleInfo
4024 //----------------------------------------------------------------------------
4027 ::CrGrilleInfo(const PMeshInfo& theMeshInfo,
4028 const EGrilleType& type,
4029 const MED::TIntVector& nbNodeVec)
4031 return PGrilleInfo(new TTGrilleInfo
4037 //----------------------------------------------------------------------------
4040 ::GetGrilleType(const MED::TMeshInfo& theMeshInfo,
4041 EGrilleType& theGridType,
4044 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4046 if (theErr && *theErr < 0)
4047 EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
4049 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4051 if (aMeshInfo.myType == eSTRUCTURE) {
4052 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4053 TValueHolder<EGrilleType, med_grid_type> aGridType(theGridType);
4054 TErr aRet = MEDmeshGridTypeRd(myFile->Id(),
4059 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)");
4063 //----------------------------------------------------------------------------
4066 ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo,
4067 TIntVector& theStruct,
4070 TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
4072 if (theErr && *theErr < 0)
4076 MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
4078 TValueHolder<TString, char> aMeshName(aMeshInfo.myName);
4079 TValueHolder<TIntVector, med_int> aGridStructure(theStruct);
4081 aRet = MEDmeshGridStructRd(myFile->Id(),
4089 EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)");