// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MED_Wrapper.hxx" #include "MED_TStructures.hxx" #include "MED_Utilities.hxx" #include "MED_TFile.hxx" #include "MEDFileUtilities.hxx" #include #include #include #ifdef WIN32 #include #endif #include namespace MED { //--------------------------------------------------------------- TLockProxy ::TLockProxy(TWrapper* theWrapper): myWrapper(theWrapper) { #if BOOST_VERSION >= 103500 myWrapper->myMutex.lock(); #else boost::detail::thread::lock_ops::lock(myWrapper->myMutex); #endif INITMSG("TLockProxy() - this -"<myCount++ == 0) { std::string dftFileName = MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInMem(); med_access_mode modeTmp(MED_ACC_CREAT); if(memfile.app_image_ptr) modeTmp = med_access_mode(theMode); myFid = MEDmemFileOpen(dftFileName.c_str(),&memfile,MED_FALSE,modeTmp); } if (theErr) *theErr = TErr(myFid); else if (myFid < 0) EXCEPTION(std::runtime_error,"TMemFile - MEDmemFileOpen"); } TFile::TFile(const std::string& theFileName, TInt theMajor, TInt theMinor): myFileName(theFileName), myMajor(theMajor), myMinor(theMinor) { if ((myMajor < 0) || (myMajor > MED_MAJOR_NUM)) myMajor = MED_MAJOR_NUM; if ((myMinor < 0) || (myMajor == MED_MAJOR_NUM && myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM; } void TFile::Open(EModeAcces theMode, TErr* theErr) { if (myCount++ == 0) { const char* aFileName = myFileName.c_str(); #ifdef WIN32 if (med_access_mode(theMode) == MED_ACC_RDWR) { // Force removing readonly attribute from a file under Windows, because of a bug in the HDF5 std::string aReadOlnyRmCmd = "attrib -r \"" + myFileName + "\"> nul 2>&1"; #ifdef UNICODE const char* to_decode = aReadOlnyRmCmd.c_str(); int size_needed = MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), NULL, 0); wchar_t* awReadOlnyRmCmd = new wchar_t[size_needed + 1]; MultiByteToWideChar(CP_UTF8, 0, to_decode, strlen(to_decode), awReadOlnyRmCmd, size_needed); awReadOlnyRmCmd[size_needed] = '\0'; _wsystem(awReadOlnyRmCmd); delete[] awReadOlnyRmCmd; #else system(aReadOlnyRmCmd.c_str()); #endif } #endif myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), myMajor, myMinor, MED_RELEASE_NUM); } if (theErr) *theErr = TErr(myFid); else if (myFid < 0) EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<Open(theMode, theErr); } ~TFileWrapper() { myFile->Close(); } }; //---------------------------------------------------------------------------- template void Print(SharedPtr theTimeStampValue) { INITMSG("Print - TimeStampValue\n"); typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value; typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin(); for (; anIter != aGeom2Value.end(); anIter++) { const EGeometrieElement& aGeom = anIter->first; const typename TimeStampValueType::TTMeshValue& aMeshValue = anIter->second; TInt aNbElem = aMeshValue.myNbElem; TInt aNbGauss = aMeshValue.myNbGauss; TInt aNbComp = aMeshValue.myNbComp; INITMSG("aGeom = "<Open(eLECTURE_ECRITURE, &aRet); if (aRet < 0) { myFile->Close(); myFile->Open(eCREATION, &aRet); } } else { myFile->Open(eLECTURE, &aRet); } } //---------------------------------------------------------------------------- TWrapper:: ~TWrapper() { } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbMeshes(TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; return MEDnMesh(myFile->Id()); } //---------------------------------------------------------------------------- void TWrapper ::GetMeshInfo(TInt theMeshId, MED::TMeshInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TValueHolder aMeshName(theInfo.myName); TValueHolder aDim(theInfo.myDim); TValueHolder aSpaceDim(theInfo.mySpaceDim); TValueHolder aType(theInfo.myType); char dtunit[MED_SNAME_SIZE+1]; med_sorting_type sorttype; med_int nstep; med_axis_type at; int naxis = MEDmeshnAxis(myFile->Id(), theMeshId); char *axisname = new char[naxis*MED_SNAME_SIZE+1]; char *axisunit = new char[naxis*MED_SNAME_SIZE+1]; TErr aRet = MEDmeshInfo(myFile->Id(), theMeshId, &aMeshName, &aSpaceDim, &aDim, &aType, &theInfo.myDesc[0], dtunit, &sorttype, &nstep, &at, axisname, axisunit); delete [] axisname; delete [] axisunit; if (aRet < 0) EXCEPTION(std::runtime_error, "GetMeshInfo - MEDmeshInfo(...)"); } //---------------------------------------------------------------------------- void TWrapper ::SetMeshInfo(const MED::TMeshInfo& theInfo, TErr* theErr) { TErr aRet; SetMeshInfo(theInfo, eLECTURE_ECRITURE, &aRet); if (aRet < 0) SetMeshInfo(theInfo, eLECTURE_AJOUT, &aRet); if (aRet < 0) SetMeshInfo(theInfo, eCREATION, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetMeshInfo(const MED::TMeshInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& anInfo = const_cast(theInfo); TValueHolder aMeshName(anInfo.myName); TValueHolder aDim(anInfo.myDim); TValueHolder aSpaceDim(anInfo.mySpaceDim); TValueHolder aType(anInfo.myType); TValueHolder aDesc(anInfo.myDesc); char *nam = new char[aSpaceDim*MED_SNAME_SIZE+1]; std::fill(nam, nam+aSpaceDim*MED_SNAME_SIZE+1, '\0'); char *unit = new char[aSpaceDim*MED_SNAME_SIZE+1]; std::fill(unit, unit+aSpaceDim*MED_SNAME_SIZE+1, '\0'); TErr aRet = MEDmeshCr(myFile->Id(), &aMeshName, aSpaceDim, aDim, aType, &aDesc, "", MED_SORT_DTIT, MED_CARTESIAN, nam, unit); delete [] nam; delete [] unit; //if (aRet == 0) // aRet = MEDunvCr(myFile->Id(),&aMeshName); INITMSG("TWrapper::SetMeshInfo - MED_MODE_ACCES = "<(theInfo); TValueHolder aName(anInfo.myName); return MEDnFamily(myFile->Id(), &aName); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbFamAttr(TInt theFamId, const MED::TMeshInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; MED::TMeshInfo& anInfo = const_cast(theInfo); TValueHolder aName(anInfo.myName); return MEDnFamily23Attribute(myFile->Id(), &aName, theFamId); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbFamGroup(TInt theFamId, const MED::TMeshInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; MED::TMeshInfo& anInfo = const_cast(theInfo); TValueHolder aName(anInfo.myName); return MEDnFamilyGroup(myFile->Id(), &aName, theFamId); } //---------------------------------------------------------------------------- void TWrapper ::GetFamilyInfo(TInt theFamId, MED::TFamilyInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aFamilyName(theInfo.myName); TValueHolder aFamilyId(theInfo.myId); TValueHolder anAttrId(theInfo.myAttrId); TValueHolder anAttrVal(theInfo.myAttrVal); TValueHolder anAttrDesc(theInfo.myAttrDesc); TValueHolder aGroupNames(theInfo.myGroupNames); TErr aRet = MEDfamily23Info(myFile->Id(), &aMeshName, theFamId, &aFamilyName, &anAttrId, &anAttrVal, &anAttrDesc, &aFamilyId, &aGroupNames); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetFamilyInfo - MEDfamily23Info(...) - "<< " aMeshInfo.myName = '"<<&aMeshName<< "'; theFamId = "<GetType() != eNON_STRUCTURE) // return PFamilyInfo(); TInt aNbAttr = GetNbFamAttr(theId, *theMeshInfo); TInt aNbGroup = GetNbFamGroup(theId, *theMeshInfo); PFamilyInfo anInfo = CrFamilyInfo(theMeshInfo, aNbGroup, aNbAttr); GetFamilyInfo(theId, *anInfo, theErr); #ifdef _DEBUG_ std::string aName = anInfo->GetName(); INITMSG("GetPFamilyInfo - aFamilyName = '"<GetGroupName(iGroup); INITMSG("aGroupName = '"< aMeshName (aMeshInfo.myName); TValueHolder anElemNames(theInfo.myElemNames); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); TErr aRet = MEDmeshEntityNameRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, &anElemNames); theInfo.myIsElemNames = aRet != 0? eFAUX : eVRAI ; if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetNames(const TElemInfo& theInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { SetNames(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetNames(const TElemInfo& theInfo, EModeAcces theMode, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; if (theGeom == eBALL) theGeom = GetBallGeom(theInfo.myMeshInfo); MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TErr aRet = 0; if (theInfo.myIsElemNames) { TValueHolder aMeshName (aMeshInfo.myName); TValueHolder anElemNames(anInfo.myElemNames); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); aRet = MEDmeshEntityNameWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, (TInt)anInfo.myElemNames->size(), &anElemNames); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetNames - MEDmeshEntityNameWr(...)"); } } //---------------------------------------------------------------------------- void TWrapper ::GetNumeration(TElemInfo& theInfo, TInt /*theNb*/, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; if (theGeom == eBALL) theGeom = GetBallGeom(theInfo.myMeshInfo); MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anElemNum(theInfo.myElemNum); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); TErr aRet = MEDmeshEntityNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, &anElemNum); theInfo.myIsElemNum = aRet != 0? eFAUX : eVRAI; if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetNumeration(const TElemInfo& theInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { SetNumeration(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetNumeration(const TElemInfo& theInfo, EModeAcces theMode, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; if (theGeom == eBALL) theGeom = GetBallGeom(theInfo.myMeshInfo); MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TErr aRet = 0; if (theInfo.myIsElemNum) { TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anElemNum(anInfo.myElemNum); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); aRet = MEDmeshEntityNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, (TInt)anInfo.myElemNum->size(), &anElemNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetNumeration - MEDmeshEntityNumberWr(...)"); } } //---------------------------------------------------------------------------- void TWrapper ::GetFamilies(TElemInfo& theInfo, TInt /*theNb*/, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; if (theGeom == eBALL) theGeom = GetBallGeom(theInfo.myMeshInfo); MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aFamNum (theInfo.myFamNum); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); TErr aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, &aFamNum); if (aRet < 0) { // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files { int aSize = (int)theInfo.myFamNum->size(); theInfo.myFamNum->clear(); theInfo.myFamNum->resize(aSize,0); aRet = 0; } // else // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...) of CELLS"); } if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetFamilies(const TElemInfo& theInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { SetFamilies(theInfo, eLECTURE_ECRITURE, theEntity, theGeom, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetFamilies(const TElemInfo& theInfo, EModeAcces theMode, EEntiteMaillage theEntity, EGeometrieElement theGeom, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; if (theGeom == eBALL) theGeom = GetBallGeom(theInfo.myMeshInfo); MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aFamNum (anInfo.myFamNum); TValueHolder anEntity (theEntity); TValueHolder aGeom (theGeom); TErr aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, (TInt)anInfo.myFamNum->size(), &aFamNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetFamilies - MEDmeshEntityFamilyNumberWr(...)"); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbNodes(const MED::TMeshInfo& theMeshInfo, TErr* theErr) { return GetNbNodes(theMeshInfo, eCOOR, theErr); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbNodes(const MED::TMeshInfo& theMeshInfo, ETable theTable, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aTable(theTable); med_bool chgt,trsf; return MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, aTable, MED_NO_CMODE, &chgt, &trsf); } //---------------------------------------------------------------------------- void TWrapper ::GetNodeInfo(MED::TNodeInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aDim(aMeshInfo.myDim); TValueHolder aCoord(theInfo.myCoord); TValueHolder aModeSwitch(theInfo.myModeSwitch); TValueHolder aSystem(theInfo.mySystem); TValueHolder aCoordNames(theInfo.myCoordNames); TValueHolder aCoordUnits(theInfo.myCoordUnits); TValueHolder anElemNames(theInfo.myElemNames); //TValueHolder anIsElemNames(theInfo.myIsElemNames); TValueHolder anElemNum(theInfo.myElemNum); //TValueHolder anIsElemNum(theInfo.myIsElemNum); TValueHolder aFamNum(theInfo.myFamNum); TValueHolder aNbElem(theInfo.myNbElem); TErr aRet = MEDmeshNodeCoordinateRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, aModeSwitch, &aCoord); TErr aRet2 =MEDmeshEntityFamilyNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, &aFamNum); if (aRet2 < 0) { // if (aRet2 == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files { int mySize = (int)theInfo.myFamNum->size(); theInfo.myFamNum->clear(); theInfo.myFamNum->resize(mySize,0); } // else // EXCEPTION(std::runtime_error,"GetNodeInfo - MEDmeshEntityFamilyNumberRd(...)"); } if (MEDmeshEntityNameRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, &anElemNames) < 0) theInfo.myIsElemNames=eFAUX; if (MEDmeshEntityNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, &anElemNum) < 0) theInfo.myIsElemNum=eFAUX; if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetNodeInfo - MEDmeshNodeCoordinateRd(...)"); } //---------------------------------------------------------------------------- void TWrapper ::SetNodeInfo(const MED::TNodeInfo& theInfo, TErr* theErr) { TErr aRet; SetNodeInfo(theInfo, eLECTURE_ECRITURE, &aRet); if (aRet < 0) SetNodeInfo(theInfo, eLECTURE_AJOUT, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetNodeInfo(const MED::TNodeInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TNodeInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName (aMeshInfo.myName); TValueHolder aCoord (anInfo.myCoord); TValueHolder aModeSwitch (anInfo.myModeSwitch); TValueHolder aSystem (anInfo.mySystem); TValueHolder aCoordNames (anInfo.myCoordNames); TValueHolder aCoordUnits (anInfo.myCoordUnits); TValueHolder anElemNames (anInfo.myElemNames); TValueHolder anIsElemNames(anInfo.myIsElemNames); TValueHolder anElemNum (anInfo.myElemNum); TValueHolder anIsElemNum (anInfo.myIsElemNum); TValueHolder aFamNum (anInfo.myFamNum); TValueHolder aNbElem (anInfo.myNbElem); TErr aRet = MEDmeshNodeCoordinateWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NO_DT, aModeSwitch, aNbElem, &aCoord); MEDmeshEntityFamilyNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, aNbElem, &aFamNum); if (anIsElemNames) MEDmeshEntityNameWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, aNbElem, &anElemNames); if (anIsElemNum) MEDmeshEntityNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, aNbElem, &anElemNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetNodeInfo - MEDmeshNodeCoordinateWr(...)"); } //---------------------------------------------------------------------------- PNodeInfo TWrapper ::CrNodeInfo(const PMeshInfo& theMeshInfo, TInt theNbElem, EModeSwitch theMode, ERepere theSystem, EBooleen theIsElemNum, EBooleen theIsElemNames) { return PNodeInfo(new TTNodeInfo (theMeshInfo, theNbElem, theMode, theSystem, theIsElemNum, theIsElemNames)); } //---------------------------------------------------------------------------- PNodeInfo TWrapper ::CrNodeInfo(const PMeshInfo& theMeshInfo, const TFloatVector& theNodeCoords, EModeSwitch theMode, ERepere theSystem, const TStringVector& theCoordNames, const TStringVector& theCoordUnits, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames) { return PNodeInfo(new TTNodeInfo (theMeshInfo, theNodeCoords, theMode, theSystem, theCoordNames, theCoordUnits, theFamilyNums, theElemNums, theElemNames)); } //---------------------------------------------------------------------------- PNodeInfo TWrapper ::CrNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo) { return PNodeInfo(new TTNodeInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PNodeInfo TWrapper ::GetPNodeInfo(const PMeshInfo& theMeshInfo, TErr* theErr) { TInt aNbElems = GetNbNodes(*theMeshInfo); if (aNbElems == 0) { return PNodeInfo(); } PNodeInfo anInfo = CrNodeInfo(theMeshInfo, aNbElems); GetNodeInfo(*anInfo, theErr); #ifdef _DEBUG_ TInt aDim = theMeshInfo->myDim; TInt aNbElem = anInfo->GetNbElem(); INITMSG("GetPNodeInfo: "); { INITMSG("aCoords: "<myCoord; for (TInt iElem = 0; iElem < aNbElem; iElem++) { for (TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++) { ADDMSG(aCoord[anId]<<","); } ADDMSG(" "); } ADDMSG(std::endl); BEGMSG("GetFamNum: "); for (TInt iElem = 0; iElem < aNbElem; iElem++) { ADDMSG(anInfo->GetFamNum(iElem)<<", "); } ADDMSG(std::endl); if (anInfo->IsElemNum()) { BEGMSG("GetElemNum: "); for (TInt iElem = 0; iElem < aNbElem; iElem++) { ADDMSG(anInfo->GetElemNum(iElem)<<", "); } ADDMSG(std::endl); } } ADDMSG(std::endl); #endif return anInfo; } //---------------------------------------------------------------------------- PElemInfo TWrapper ::CrElemInfo(const PMeshInfo& theMeshInfo, TInt theNbElem, EBooleen theIsElemNum, EBooleen theIsElemNames) { return PElemInfo(new TTElemInfo (theMeshInfo, theNbElem, theIsElemNum, theIsElemNames)); } //---------------------------------------------------------------------------- PElemInfo TWrapper ::CrElemInfo(const PMeshInfo& theMeshInfo, TInt theNbElem, const TIntVector& theFamNum, const TIntVector& aElemNum, const TStringVector& aElemNames) { return PElemInfo(new TTElemInfo (theMeshInfo, theNbElem, theFamNum, aElemNum, aElemNames)); } //---------------------------------------------------------------------------- PElemInfo TWrapper ::GetPElemInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { EMaillage aType = theMeshInfo->GetType(); if (aType == eNON_STRUCTURE) { switch (theGeom) { case ePOINT1: if (theEntity == eNOEUD) return GetPNodeInfo(theMeshInfo, theErr); return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr); break; case ePOLYGONE: return GetPPolygoneInfo(theMeshInfo, theEntity, theGeom, theConnMode); break; case ePOLYEDRE: return GetPPolyedreInfo(theMeshInfo, theEntity, theGeom, theConnMode); break; default: return GetPCellInfo(theMeshInfo, theEntity, theGeom, theConnMode, theErr); } } else { PGrilleInfo aGrille = GetPGrilleInfo(theMeshInfo); TInt nbElems; EBooleen theIsElemNum = eFAUX; // nodes switch (theGeom) { case ePOINT1: nbElems = aGrille->GetNbNodes(); theIsElemNum = eVRAI; break; case eSEG2: case eQUAD4: case eHEXA8: nbElems = aGrille->GetNbCells(); break; default: nbElems = 0; } TIntVector aFamNum; TIntVector aElemNum; TStringVector aElemNames; PElemInfo aElemInfo; if (theGeom == ePOINT1) { aElemInfo = CrElemInfo(theMeshInfo, nbElems, theIsElemNum); MED::TElemInfo &aTElemInfo = *aElemInfo; // must be reimplemente in connection with mesh type eSTRUCTURE // GetNumeration(aTElemInfo, // nbElems, // theEntity, // theGeom, // theErr); GetFamilies(aTElemInfo, nbElems, theEntity, theGeom, theErr); // must be reimplemente in connection with mesh type eSTRUCTURE // GetNames(aTElemInfo, // nbElems, // theEntity, // theGeom, // theErr); } else { aElemInfo = CrElemInfo(theMeshInfo, nbElems, aFamNum, aElemNum, aElemNames); } return aElemInfo; } return PElemInfo(); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr); } //---------------------------------------------------------------------------- TInt TWrapper ::GetPolygoneConnSize(const MED::TMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return 0; MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); TValueHolder aMeshName(aMeshInfo.myName); med_int aTaille = 0; med_bool chgt,trsf; aTaille=MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(theEntity), med_geometry_type(theGeom), MED_CONNECTIVITY, med_connectivity_mode(theConnMode), &chgt, &trsf); if (aTaille < 0) EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)"); return TInt(aTaille); } //----------------------------------------------------------------- void TWrapper ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anIndex (theInfo.myIndex); TValueHolder aConn (theInfo.myConn); TValueHolder anEntity (theInfo.myEntity); TValueHolder aGeom (theInfo.myGeom); TValueHolder aConnMode(theInfo.myConnMode); TInt aNbElem = (TInt)theInfo.myElemNum->size(); TErr aRet; aRet = MEDmeshPolygon2Rd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, aConnMode, &anIndex, &aConn); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolygonRd(...)"); if (theInfo.myIsElemNames) { GetNames(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet); if (theErr) *theErr = aRet; } if (theInfo.myIsElemNum) { GetNumeration(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet); if (theErr) *theErr = aRet; } GetFamilies(theInfo, aNbElem, theInfo.myEntity, theInfo.myGeom, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, TErr* theErr) { SetPolygoneInfo(theInfo, eLECTURE_ECRITURE, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TPolygoneInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anIndex (anInfo.myIndex); TValueHolder aConn (anInfo.myConn); TValueHolder anEntity (anInfo.myEntity); TValueHolder aGeom (anInfo.myGeom); TValueHolder aConnMode(anInfo.myConnMode); TErr aRet = MEDmeshPolygon2Wr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, anEntity, aGeom, aConnMode, anInfo.myNbElem + 1, &anIndex, &aConn); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetPolygoneInfo - MEDmeshPolygonWr(...)"); SetNames(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet); if (theErr) *theErr = aRet; SetNumeration(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet); if (theErr) *theErr = aRet; SetFamilies(anInfo, theInfo.myEntity, anInfo.myGeom, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- PPolygoneInfo TWrapper ::CrPolygoneInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TInt theNbElem, TInt theConnSize, EConnectivite theConnMode, EBooleen theIsElemNum, EBooleen theIsElemNames) { return PPolygoneInfo(new TTPolygoneInfo (theMeshInfo, theEntity, theGeom, theNbElem, theConnSize, theConnMode, theIsElemNum, theIsElemNames)); } //---------------------------------------------------------------------------- PPolygoneInfo TWrapper ::CrPolygoneInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, const TIntVector& theIndexes, const TIntVector& theConnectivities, EConnectivite theConnMode, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames) { return PPolygoneInfo(new TTPolygoneInfo (theMeshInfo, theEntity, theGeom, theIndexes, theConnectivities, theConnMode, theFamilyNums, theElemNums, theElemNames)); } //---------------------------------------------------------------------------- PPolygoneInfo TWrapper ::CrPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo) { return PPolygoneInfo(new TTPolygoneInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PPolygoneInfo TWrapper ::GetPPolygoneInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode) { if (theMeshInfo->GetType() != eNON_STRUCTURE) return PPolygoneInfo(); TInt aNbElem = GetNbPolygones(theMeshInfo, theEntity, theGeom, theConnMode); TInt aConnSize = GetPolygoneConnSize(theMeshInfo, theEntity, theGeom, theConnMode); PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo, theEntity, theGeom, aNbElem, aConnSize, theConnMode); GetPolygoneInfo(anInfo); #ifdef _DEBUG_ INITMSG("GetPPolygoneInfo"<< " - theGeom = "<GetConnSlice(iElem); TInt aConnDim = aConnSlice.size(); for (TInt iConn = 0; iConn < aConnDim; iConn++) { ADDMSG(aConnSlice[iConn]<<","); } ADDMSG(" "); } ADDMSG(std::endl); #endif return anInfo; } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { return GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode, theErr); } //---------------------------------------------------------------------------- void TWrapper ::GetPolyedreConnSize(const TMeshInfo& theMeshInfo, TInt& theNbFaces, TInt& theConnSize, EConnectivite theConnMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)"); MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aConnMode(theConnMode); //TValueHolder aNbFaces(theNbFaces); //TValueHolder aConnSize(theConnSize); med_bool chgt, trsf; theNbFaces = MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_CELL, MED_POLYHEDRON, MED_INDEX_NODE, aConnMode, &chgt, &trsf); theConnSize = MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_CELL, MED_POLYHEDRON, MED_CONNECTIVITY, aConnMode, &chgt, &trsf); if (theNbFaces < 0 || theConnSize<0) EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshnEntity(...)"); } //----------------------------------------------------------------- void TWrapper ::GetPolyedreInfo(TPolyedreInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TInt aNbElem = (TInt)theInfo.myElemNum->size(); TValueHolder anIndex(theInfo.myIndex); TValueHolder aFaces(theInfo.myFaces); TValueHolder aConn(theInfo.myConn); TValueHolder aConnMode(theInfo.myConnMode); TErr aRet; aRet = MEDmeshPolyhedronRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_CELL, aConnMode, &anIndex, &aFaces, &aConn); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetPolygoneInfo - MEDmeshPolyhedronRd(...)"); if (theInfo.myIsElemNames) { GetNames(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet); if (theErr) *theErr = aRet; } if (theInfo.myIsElemNum) { GetNumeration(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet); if (theErr) *theErr = aRet; } GetFamilies(theInfo, aNbElem, theInfo.myEntity, ePOLYEDRE, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetPolyedreInfo(const TPolyedreInfo& theInfo, TErr* theErr) { SetPolyedreInfo(theInfo, eLECTURE_ECRITURE, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TPolyedreInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anIndex(anInfo.myIndex); TValueHolder aFaces(anInfo.myFaces); TValueHolder aConn(anInfo.myConn); TValueHolder aConnMode(anInfo.myConnMode); TErr aRet; aRet = MEDmeshPolyhedronWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_CELL, aConnMode, anInfo.myNbElem+1, &anIndex, (TInt)anInfo.myFaces->size(), &aFaces, &aConn); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshPolyhedronWr(...)"); TValueHolder anEntity(anInfo.myEntity); if (theInfo.myIsElemNames) { TValueHolder anElemNames(anInfo.myElemNames); aRet = MEDmeshEntityNameWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, MED_POLYHEDRON, (TInt)anInfo.myElemNames->size(), &anElemNames); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNameWr(...)"); } if (theInfo.myIsElemNum) { TValueHolder anElemNum(anInfo.myElemNum); aRet = MEDmeshEntityNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, MED_POLYHEDRON, (TInt)anInfo.myElemNum->size(), &anElemNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityNumberWr(...)"); } TValueHolder aFamNum(anInfo.myFamNum); aRet = MEDmeshEntityFamilyNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, MED_POLYHEDRON, (TInt)anInfo.myFamNum->size(), &aFamNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetPolyedreInfo - MEDmeshEntityFamilyNumberWr(...)"); } //---------------------------------------------------------------------------- PPolyedreInfo TWrapper ::CrPolyedreInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TInt theNbElem, TInt theNbFaces, TInt theConnSize, EConnectivite theConnMode, EBooleen theIsElemNum, EBooleen theIsElemNames) { return PPolyedreInfo(new TTPolyedreInfo (theMeshInfo, theEntity, theGeom, theNbElem, theNbFaces, theConnSize, theConnMode, theIsElemNum, theIsElemNames)); } //---------------------------------------------------------------------------- PPolyedreInfo TWrapper ::CrPolyedreInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, const TIntVector& theIndexes, const TIntVector& theFaces, const TIntVector& theConnectivities, EConnectivite theConnMode, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames) { return PPolyedreInfo(new TTPolyedreInfo (theMeshInfo, theEntity, theGeom, theIndexes, theFaces, theConnectivities, theConnMode, theFamilyNums, theElemNums, theElemNames)); } //---------------------------------------------------------------------------- PPolyedreInfo TWrapper ::CrPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo) { return PPolyedreInfo(new TTPolyedreInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PPolyedreInfo TWrapper ::GetPPolyedreInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode) { if (theMeshInfo->GetType() != eNON_STRUCTURE) return PPolyedreInfo(); TInt aNbElem = GetNbPolyedres(theMeshInfo, theEntity, theGeom, theConnMode); TInt aNbFaces, aConnSize; GetPolyedreConnSize(theMeshInfo, aNbFaces, aConnSize, theConnMode); PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo, theEntity, theGeom, aNbElem, aNbFaces, aConnSize, theConnMode); GetPolyedreInfo(anInfo); #ifdef _DEBUG_ INITMSG("GetPPolyedreInfo"<< " - theGeom = "<GetConnSliceArr(iElem); TInt aNbFaces = aConnSliceArr.size(); ADDMSG("{"); for (TInt iFace = 0; iFace < aNbFaces; iFace++) { TCConnSlice aConnSlice = aConnSliceArr[iFace]; TInt aNbConn = aConnSlice.size(); ADDMSG("["); for (TInt iConn = 0; iConn < aNbConn; iConn++) { ADDMSG(aConnSlice[iConn]<<","); } ADDMSG("] "); } ADDMSG("} "); } ADDMSG(std::endl); #endif return anInfo; } //----------------------------------------------------------------- TEntityInfo TWrapper ::GetEntityInfo(const MED::TMeshInfo& theMeshInfo, EConnectivite theConnMode, TErr* theErr) { TEntityInfo anInfo; TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return anInfo; if (theMeshInfo.GetType() == eNON_STRUCTURE) { TInt aNbElem = GetNbNodes(theMeshInfo); if (aNbElem > 0) { anInfo[eNOEUD][ePOINT1] = aNbElem; const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); TEntity2GeomSet::const_iterator anIterEnd = anEntity2GeomSet.end(); for (; anIter != anIterEnd; anIter++) { const EEntiteMaillage& anEntity = anIter->first; const TGeomSet& aGeomSet = anIter->second; TGeomSet::const_iterator anIter2 = aGeomSet.begin(); TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); for (; anIter2 != anIterEnd2; anIter2++) { const EGeometrieElement& aGeom = *anIter2; aNbElem = GetNbCells(theMeshInfo, anEntity, aGeom, theConnMode, theErr); if (aNbElem > 0) { if (anEntity == eSTRUCT_ELEMENT) { const TInt nbStructTypes = aNbElem; for (TInt structType = 0; structType < nbStructTypes; ++structType) { // check type name to keep only "MED_BALL" structured element TValueHolder aMeshName((TString&) theMeshInfo.myName); char geotypename[ MED_NAME_SIZE + 1] = ""; med_geometry_type geotype; MEDmeshEntityInfo(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(anEntity), structType+1, geotypename, &geotype); if (strcmp(geotypename, MED_BALL_NAME) == 0) { aNbElem = GetNbCells(theMeshInfo, anEntity, EGeometrieElement(geotype), theConnMode, theErr); if (aNbElem > 0) anInfo[anEntity][EGeometrieElement(geotype)] = aNbElem; } } } else { anInfo[anEntity][aGeom] = aNbElem; } } } } } } else { // eSTRUCTURE EGrilleType aGrilleType; TInt aNbNodes = 1; TInt aNbElem = 1; TInt aNbSub = 0; TInt aDim = theMeshInfo.GetDim(); EGeometrieElement aGeom, aSubGeom; EEntiteMaillage aSubEntity = eMAILLE; GetGrilleType(theMeshInfo, aGrilleType); TIntVector aStruct(aDim); if (aGrilleType == eGRILLE_STANDARD) { GetGrilleStruct(theMeshInfo, aStruct, theErr); } else { // eGRILLE_CARTESIENNE and eGRILLE_POLAIRE ETable aTable[3] = { eCOOR_IND1, eCOOR_IND2, eCOOR_IND3 }; for (med_int anAxis = 0; anAxis < aDim; anAxis++) aStruct[ anAxis ] = GetNbNodes(theMeshInfo, aTable[anAxis]); } for (med_int i = 0; i < aDim; i++) { aNbNodes = aNbNodes * aStruct[i]; aNbElem = aNbElem * (aStruct[i] - 1); } switch (aDim) { case 1: aGeom = eSEG2; break; case 2: aGeom = eQUAD4; aSubGeom = eSEG2; aSubEntity = eARETE; aNbSub = (aStruct[0]) * (aStruct[1]-1) + (aStruct[0]-1) * (aStruct[1]); break; case 3: aGeom = eHEXA8; aSubGeom = eQUAD4; aSubEntity = eFACE; aNbSub = (aStruct[0]) * (aStruct[1]-1) * (aStruct[2]-1) + (aStruct[0]-1) * (aStruct[1]) * (aStruct[2]-1) + (aStruct[0]-1) * (aStruct[1]-1) * (aStruct[2]); break; } anInfo[eNOEUD][ePOINT1] = aNbNodes; anInfo[eMAILLE][aGeom] = aNbElem; if (aDim > 1) anInfo[aSubEntity][aSubGeom] = aNbSub; } return anInfo; } //----------------------------------------------------------------- TInt TWrapper ::GetNbCells(const MED::TMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); TValueHolder aMeshName(aMeshInfo.myName); med_bool chgt, trsf; switch (theGeom) { case MED::ePOLYGONE: case MED::ePOLYGON2: { return MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(theEntity), med_geometry_type(theGeom), MED_INDEX_NODE, med_connectivity_mode(theConnMode), &chgt, &trsf)-1; } case MED::ePOLYEDRE: { return MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(theEntity), MED_POLYHEDRON, MED_INDEX_FACE, med_connectivity_mode(theConnMode), &chgt, &trsf)-1; } case MED::eBALL: { return GetNbBalls(theMeshInfo); } default: { return MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(theEntity), med_geometry_type(theGeom), MED_CONNECTIVITY, med_connectivity_mode(theConnMode), &chgt, &trsf); } } return 0; } //---------------------------------------------------------------------------- void TWrapper ::GetCellInfo(MED::TCellInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName (aMeshInfo.myName); TValueHolder aConn (theInfo.myConn); TValueHolder aModeSwitch (theInfo.myModeSwitch); TValueHolder anElemNames (theInfo.myElemNames); TValueHolder anIsElemNames(theInfo.myIsElemNames); TValueHolder anElemNum (theInfo.myElemNum); TValueHolder anIsElemNum (theInfo.myIsElemNum); TValueHolder aFamNum (theInfo.myFamNum); TValueHolder anIsFamNum (theInfo.myIsFamNum); TValueHolder anEntity (theInfo.myEntity); TValueHolder aGeom (theInfo.myGeom); TValueHolder aConnMode (theInfo.myConnMode); TErr aRet; med_bool dummy; aRet = MEDmeshnEntity(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, MED_NAME, aConnMode, &dummy, &dummy); if ( aRet > 0 ) { // names are present in the file, they will be read in spite of theInfo.myIsElemNames theInfo.myIsElemNames = eVRAI; theInfo.myElemNames.reset( new TString( theInfo.myNbElem * GetPNOMLength() + 1 )); anElemNames.myRepresentation = & ((TString&) theInfo.myElemNames )[0]; } aRet = MEDmeshElementRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, aConnMode, aModeSwitch, &aConn, &anIsElemNames, &anElemNames, &anIsElemNum, &anElemNum, &anIsFamNum, &aFamNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetCellInfo - MEDmeshElementRd(...)"); if (anIsFamNum == MED_FALSE) { int mySize = (int) theInfo.myFamNum->size(); theInfo.myFamNum->clear(); theInfo.myFamNum->resize(mySize, 0); } } //---------------------------------------------------------------------------- void TWrapper ::SetCellInfo(const MED::TCellInfo& theInfo, TErr* theErr) { SetCellInfo(theInfo, eLECTURE_ECRITURE, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetCellInfo(const MED::TCellInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TCellInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName (aMeshInfo.myName); TValueHolder aConn (anInfo.myConn); TValueHolder aModeSwitch (anInfo.myModeSwitch); TValueHolder anElemNames (anInfo.myElemNames); TValueHolder anIsElemNames(anInfo.myIsElemNames); TValueHolder anElemNum (anInfo.myElemNum); TValueHolder anIsElemNum (anInfo.myIsElemNum); TValueHolder aFamNum (anInfo.myFamNum); TValueHolder anIsFamNum (anInfo.myIsFamNum); TValueHolder anEntity (anInfo.myEntity); TValueHolder aGeom (anInfo.myGeom); TValueHolder aConnMode (anInfo.myConnMode); TValueHolder aNbElem (anInfo.myNbElem); TErr aRet; aRet = MEDmeshElementConnectivityWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, anEntity, aGeom, aConnMode, aModeSwitch, aNbElem, &aConn); MEDmeshEntityFamilyNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, aNbElem, &aFamNum); if (anIsElemNames) MEDmeshEntityNameWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, aNbElem, &anElemNames); if (anIsElemNum) MEDmeshEntityNumberWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, anEntity, aGeom, aNbElem, &anElemNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetCellInfo - MEDmeshElementWr(...), ret="<< aRet); } //---------------------------------------------------------------------------- PCellInfo TWrapper ::CrCellInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, TInt theNbElem, EConnectivite theConnMode, EBooleen theIsElemNum, EBooleen theIsElemNames, EModeSwitch theMode) { return PCellInfo(new TTCellInfo (theMeshInfo, theEntity, theGeom, theNbElem, theConnMode, theIsElemNum, theIsElemNames, theMode)); } //---------------------------------------------------------------------------- PCellInfo TWrapper ::CrCellInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, const TIntVector& theConnectivities, EConnectivite theConnMode, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames, EModeSwitch theMode) { return PCellInfo(new TTCellInfo (theMeshInfo, theEntity, theGeom, theConnectivities, theConnMode, theFamilyNums, theElemNums, theElemNames, theMode)); } //---------------------------------------------------------------------------- PCellInfo TWrapper ::CrCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo) { return PCellInfo(new TTCellInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PCellInfo TWrapper ::GetPCellInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, EConnectivite theConnMode, TErr* theErr) { if (theMeshInfo->GetType() != eNON_STRUCTURE) return PCellInfo(); TInt aNbElem = GetNbCells(theMeshInfo, theEntity, theGeom, theConnMode); PCellInfo anInfo = CrCellInfo(theMeshInfo, theEntity, theGeom, aNbElem, theConnMode); GetCellInfo(anInfo, theErr); #ifdef _DEBUG_ TInt aConnDim = anInfo->GetConnDim(); INITMSG("GetPCellInfo - theEntity = "<GetConnSlice(iElem); for (TInt iConn = 0; iConn < aConnDim; iConn++) { ADDMSG(aConnSlice[iConn]<<","); } ADDMSG(" "); } ADDMSG(std::endl); BEGMSG("GetPCellInfo - GetFamNum: "); for (TInt iElem = 0; iElem < aNbElem; iElem++) { ADDMSG(anInfo->GetFamNum(iElem)<<", "); } ADDMSG(std::endl); if (anInfo->IsElemNum()) { BEGMSG("GetPCellInfo - GetElemNum: "); for (TInt iElem = 0; iElem < aNbElem; iElem++) { ADDMSG(anInfo->GetElemNum(iElem)<<", "); } ADDMSG(std::endl); } ADDMSG(std::endl); #endif return anInfo; } //---------------------------------------------------------------------------- EGeometrieElement TWrapper ::GetBallGeom(const TMeshInfo& /*theMeshInfo*/) { TErr anError; TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor); // read med_geometry_type of "MED_BALL" element char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME; return EGeometrieElement(MEDstructElementGeotype(myFile->Id(), geotypename)); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbBalls(const TMeshInfo& theMeshInfo) { TErr anError; TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor); EGeometrieElement ballType = GetBallGeom(theMeshInfo); if (ballType < 0) return 0; return GetNbCells(theMeshInfo, eSTRUCT_ELEMENT, ballType, eNOD); } //---------------------------------------------------------------------------- void TWrapper ::GetBallInfo(TBallInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); // check geometry of MED_BALL if (theInfo.myGeom == eBALL) { theInfo.myGeom = GetBallGeom(*theInfo.myMeshInfo); if (theInfo.myGeom < 0) { if (!theErr) EXCEPTION(std::runtime_error, "GetBallInfo - no balls in the mesh"); *theErr = theInfo.myGeom; return; } } // read nodes ids GetCellInfo(theInfo); // read diameters TValueHolder aMeshName (theInfo.myMeshInfo->myName); TValueHolder aGeom (theInfo.myGeom); TValueHolder aDiam (theInfo.myDiameters); char varattname[ MED_NAME_SIZE + 1] = MED_BALL_DIAMETER; TErr aRet = MEDmeshStructElementVarAttRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, aGeom, varattname, &aDiam); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetBallInfo - pb at reading diameters"); } //---------------------------------------------------------------------------- void TWrapper ::SetBallInfo(const TBallInfo& theInfo, TErr* theErr) { SetBallInfo(theInfo, eLECTURE_ECRITURE, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetBallInfo(const TBallInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); TErr ret; char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH"; EGeometrieElement ballGeom = GetBallGeom(*theInfo.myMeshInfo); if (ballGeom < 0) { // no ball model in the file, create support mesh for it char dummyname [MED_NAME_SIZE*3+1] = ""; if ((ret = MEDsupportMeshCr(myFile->Id(), ballsupportname, theInfo.myMeshInfo->GetSpaceDim(), theInfo.myMeshInfo->GetDim(), "Support mesh for a ball model", MED_CARTESIAN, /*axisname=*/dummyname, /*unitname=*/dummyname)) < 0) { if (!theErr) EXCEPTION(std::runtime_error, "SetBallInfo - MEDsupportMeshCr"); *theErr = ret; return; } // write coordinates of 1 node med_float coord[3] = {0, 0, 0}; if ((ret = MEDmeshNodeCoordinateWr(myFile->Id(), ballsupportname, MED_NO_DT, MED_NO_IT, 0.0, MED_FULL_INTERLACE, /*nnode=*/1, coord)) < 0) { if (!theErr) EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshNodeCoordinateWr"); *theErr = ret; return; } // ball model creation char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME; if ((ballGeom = (EGeometrieElement) MEDstructElementCr(myFile->Id(), geotypename, theInfo.myMeshInfo->GetSpaceDim(), ballsupportname, MED_NODE,MED_NONE)) < 0) { if (!theErr) EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementCr"); *theErr = ret; return; } // create diameter attribute if ((ret = MEDstructElementVarAttCr(myFile->Id(), geotypename, MED_BALL_DIAMETER, MED_ATT_FLOAT64, /*ncomp=*/1)) < 0) { if (!theErr) EXCEPTION(std::runtime_error, "SetBallInfo - MEDstructElementVarAttCr"); *theErr = ret; return; } } // ballGeom < 0 TBallInfo& aBallInfo = ((TBallInfo&) theInfo); aBallInfo.myGeom = ballGeom; // write node ids SetCellInfo(theInfo, theMode, theErr); if (theErr && *theErr < 0) return; // write diameter TValueHolder aMeshName (aBallInfo.myMeshInfo->myName); TValueHolder aGeom (aBallInfo.myGeom); TValueHolder aDiam (aBallInfo.myDiameters); ret = MEDmeshStructElementVarAttWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, aGeom, MED_BALL_DIAMETER, theInfo.myNbElem, &aDiam); if (theErr) *theErr = ret; else if (ret < 0) EXCEPTION(std::runtime_error, "SetBallInfo - MEDmeshStructElementVarAttWr"); } //---------------------------------------------------------------------------- PBallInfo TWrapper ::CrBallInfo(const PMeshInfo& theMeshInfo, TInt theNbBalls, EBooleen theIsElemNum) { return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum)); } //---------------------------------------------------------------------------- PBallInfo TWrapper ::CrBallInfo(const PMeshInfo& theMeshInfo, const TIntVector& theNodes, TFloatVector& theDiameters, const TIntVector& theFamilyNums, const TIntVector& theElemNums) { return PBallInfo(new TTBallInfo(theMeshInfo, theNodes, theDiameters, theFamilyNums, theElemNums)); } //---------------------------------------------------------------------------- PBallInfo TWrapper ::CrBallInfo(const PMeshInfo& theMeshInfo, const PBallInfo& theInfo) { return PBallInfo(new TTBallInfo(theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PBallInfo TWrapper ::GetPBallInfo(const PMeshInfo& theMeshInfo) { TInt nbBalls = GetNbBalls(theMeshInfo); if (nbBalls < 1) return PBallInfo(); PBallInfo anInfo = CrBallInfo(theMeshInfo, nbBalls); GetBallInfo(anInfo); return anInfo; } //----------------------------------------------------------------- TInt TWrapper ::GetNbFields(TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; return MEDnField(myFile->Id()); } //---------------------------------------------------------------------------- TInt TWrapper ::GetNbComp(TInt theFieldId, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return -1; return MEDfieldnComponent(myFile->Id(), theFieldId); } //---------------------------------------------------------------------------- void TWrapper ::GetFieldInfo(TInt theFieldId, MED::TFieldInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TString aFieldName(256); // Protect from memory problems with too long names TValueHolder aType(theInfo.myType); TValueHolder aCompNames(theInfo.myCompNames); TValueHolder anUnitNames(theInfo.myUnitNames); MED::TMeshInfo& aMeshInfo = theInfo.myMeshInfo; TErr aRet; med_bool local; char dtunit[MED_SNAME_SIZE+1]; char local_mesh_name[MED_NAME_SIZE+1]=""; med_int nbofstp; theInfo.myNbComp = MEDfieldnComponent(myFile->Id(), theFieldId); aRet = MEDfieldInfo(myFile->Id(), theFieldId, &aFieldName[0], local_mesh_name, &local, &aType, &aCompNames, &anUnitNames, dtunit, &nbofstp); if (strcmp(&aMeshInfo.myName[0], local_mesh_name) != 0) { if (theErr) *theErr = -1; return; } theInfo.SetName(aFieldName); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetFieldInfo - MEDfieldInfo(...)"); } //---------------------------------------------------------------------------- void TWrapper ::SetFieldInfo(const MED::TFieldInfo& theInfo, TErr* theErr) { TErr aRet; SetFieldInfo(theInfo, eLECTURE_ECRITURE, &aRet); if (aRet < 0) SetFieldInfo(theInfo, eLECTURE_AJOUT, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetFieldInfo(const MED::TFieldInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TFieldInfo& anInfo = const_cast(theInfo); TValueHolder aFieldName(anInfo.myName); TValueHolder aType(anInfo.myType); TValueHolder aCompNames(anInfo.myCompNames); TValueHolder anUnitNames(anInfo.myUnitNames); MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo; TErr aRet; char dtunit[MED_SNAME_SIZE+1]; std::fill(dtunit, dtunit+MED_SNAME_SIZE+1, '\0'); aRet = MEDfieldCr(myFile->Id(), &aFieldName, aType, anInfo.myNbComp, &aCompNames, &anUnitNames, dtunit, &aMeshInfo.myName[0]); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetFieldInfo - MEDfieldCr(...)"); } //---------------------------------------------------------------------------- PFieldInfo TWrapper ::CrFieldInfo(const PMeshInfo& theMeshInfo, TInt theNbComp, ETypeChamp theType, const std::string& theValue, EBooleen theIsLocal, TInt theNbRef) { return PFieldInfo(new TTFieldInfo (theMeshInfo, theNbComp, theType, theValue, theIsLocal, theNbRef)); } //---------------------------------------------------------------------------- PFieldInfo TWrapper ::CrFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo) { return PFieldInfo(new TTFieldInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PFieldInfo TWrapper ::GetPFieldInfo(const PMeshInfo& theMeshInfo, TInt theId, TErr* theErr) { TInt aNbComp = GetNbComp(theId); PFieldInfo anInfo = CrFieldInfo(theMeshInfo, aNbComp); GetFieldInfo(theId, *anInfo, theErr); #ifdef _DEBUG_ INITMSG("GetPFieldInfo "<< "- aName = '"<GetName()<<"'"<< "; aType = "<GetType()<< "; aNbComp = "<Id()); } //---------------------------------------------------------------------------- TGaussInfo::TInfo TWrapper ::GetGaussPreInfo(TInt theId, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0); med_int aNbGaussPoints = med_int(); TVector aName(GetNOMLength()+1); med_geometry_type aGeom = MED_NONE; TErr aRet; med_int dim; char geointerpname[MED_NAME_SIZE+1] = ""; char ipointstructmeshname[MED_NAME_SIZE+1] = ""; med_int nsectionmeshcell; med_geometry_type sectiongeotype; aRet = MEDlocalizationInfo (myFile->Id(), theId, &aName[0], &aGeom, &dim, &aNbGaussPoints, geointerpname, ipointstructmeshname, &nsectionmeshcell, §iongeotype); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGaussPreInfo - MEDlocalizationInfo(...)"); return TGaussInfo::TInfo(TGaussInfo::TKey(EGeometrieElement(aGeom), &aName[0]), TInt(aNbGaussPoints)); } //---------------------------------------------------------------------------- void TWrapper ::GetGaussInfo(TInt /*theId*/, TGaussInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TValueHolder aRefCoord(theInfo.myRefCoord); TValueHolder aGaussCoord(theInfo.myGaussCoord); TValueHolder aWeight(theInfo.myWeight); TValueHolder aModeSwitch(theInfo.myModeSwitch); TValueHolder aGaussName(theInfo.myName); TErr aRet; aRet = MEDlocalizationRd(myFile->Id(), &aGaussName, aModeSwitch, &aRefCoord, &aGaussCoord, &aWeight); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGaussInfo - MEDlocalizationRd(...)"); } //---------------------------------------------------------------------------- PGaussInfo TWrapper ::CrGaussInfo(const TGaussInfo::TInfo& theInfo, EModeSwitch theMode) { return PGaussInfo(new TTGaussInfo (theInfo, theMode)); } //----------------------------------------------------------------- TInt TWrapper ::GetNbTimeStamps(const MED::TFieldInfo& theInfo, const MED::TEntityInfo& theEntityInfo, EEntiteMaillage& theEntity, TGeom2Size& theGeom2Size, TErr* theErr) { theEntity = EEntiteMaillage(-1); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr) { if (theEntityInfo.empty()) *theErr = -1; if (*theErr < 0) return -1; } else if (theEntityInfo.empty()) EXCEPTION(std::runtime_error, "GetNbTimeStamps - There is no any Entity on the Mesh"); bool anIsPerformAdditionalCheck = GetNbMeshes() > 1; theGeom2Size.clear(); TInt aNbTimeStamps = 0; TIdt anId = myFile->Id(); MED::TFieldInfo& anInfo = const_cast(theInfo); TValueHolder aFieldName(anInfo.myName); MED::TMeshInfo& aMeshInfo = anInfo.myMeshInfo; // workaround for IPAL13676 MED::TEntityInfo localEntityInfo = theEntityInfo; TEntityInfo::iterator anLocalIter = localEntityInfo.find(eMAILLE); if (anLocalIter != localEntityInfo.end()) { localEntityInfo[eNOEUD_ELEMENT] = anLocalIter->second; } TEntityInfo::const_iterator anIter = localEntityInfo.begin(); for (; anIter != localEntityInfo.end(); anIter++) { med_entity_type anEntity = med_entity_type(anIter->first); const TGeom2Size& aGeom2Size = anIter->second; TGeom2Size::const_iterator anGeomIter = aGeom2Size.begin(); for (; anGeomIter != aGeom2Size.end(); anGeomIter++) { med_geometry_type aGeom = med_geometry_type(anGeomIter->first); char aMeshName[MED_NAME_SIZE+1]; med_bool islocal; med_field_type ft; char dtunit[MED_SNAME_SIZE+1]; med_int myNbComp = MEDfieldnComponentByName(anId, &aFieldName); char *cname=new char[myNbComp*MED_SNAME_SIZE+1]; char *unitname=new char[myNbComp*MED_SNAME_SIZE+1]; TInt aNbStamps; MEDfieldInfoByName(anId, &aFieldName, aMeshName, &islocal, &ft, cname, unitname, dtunit, &aNbStamps); delete [] cname; delete [] unitname; med_int nval = 0; med_int aNumDt; med_int aNumOrd; med_float aDt; if (aNbStamps > 0) { MEDfieldComputingStepInfo(anId, &aFieldName, 1, &aNumDt, &aNumOrd, &aDt); char profilename[MED_NAME_SIZE+1]; char locname[MED_NAME_SIZE+1]; med_int profilsize; med_int aNbGauss; // protection from crash (division by zero) // inside MEDfieldnValueWithProfile function // caused by the workaround for IPAL13676 (see above) if (anEntity == MED_NODE_ELEMENT && aGeom % 100 == 0) continue; nval = MEDfieldnValueWithProfile(anId, &aFieldName, aNumDt, aNumOrd, anEntity, med_geometry_type(aGeom), 1, MED_COMPACT_STMODE, profilename, &profilsize, locname, &aNbGauss); } bool anIsSatisfied =(nval > 0); if (anIsSatisfied) { INITMSG("GetNbTimeStamps aNbTimeStamps = "<second; theEntity = EEntiteMaillage(anEntity); aNbTimeStamps = aNbStamps; } } if (!theGeom2Size.empty()) break; } return aNbTimeStamps; } //---------------------------------------------------------------------------- void TWrapper ::GetTimeStampInfo(TInt theTimeStampId, MED::TTimeStampInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); const TGeom2Size& aGeom2Size = theInfo.myGeom2Size; if (theErr) { if (aGeom2Size.empty()) *theErr = -1; if (*theErr < 0) return; } else if (aGeom2Size.empty()) EXCEPTION(std::runtime_error, "GetTimeStampInfo - There is no any cell"); MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; TValueHolder aFieldName(aFieldInfo.myName); TValueHolder anEntity(theInfo.myEntity); TValueHolder aNumDt(theInfo.myNumDt); TValueHolder aNumOrd(theInfo.myNumOrd); TValueHolder anUnitDt(theInfo.myUnitDt); TValueHolder aDt(theInfo.myDt); TValueHolder aMeshName(aMeshInfo.myName); TValueHolder anIsLocal(aFieldInfo.myIsLocal); TValueHolder aNbRef(aFieldInfo.myNbRef); TGeom2NbGauss& aGeom2NbGauss = theInfo.myGeom2NbGauss; // just to get a time stamp unit (anUnitDt) med_field_type aFieldType; med_int aNbComp = MEDfieldnComponentByName(myFile->Id(), &aFieldName); char *aCompName = new char[aNbComp*MED_SNAME_SIZE+1]; char *aCompUnit = new char[aNbComp*MED_SNAME_SIZE+1]; TInt aNbStamps; MEDfieldInfoByName(myFile->Id(), &aFieldName, &aMeshName, &anIsLocal, &aFieldType, aCompName, aCompUnit, &anUnitDt, &aNbStamps); delete [] aCompName; delete [] aCompUnit; TGeom2Size::const_iterator anIter = aGeom2Size.begin(); for (; anIter != aGeom2Size.end(); anIter++) { const EGeometrieElement& aGeom = anIter->first; med_int aNbGauss = -1; TErr aRet; aRet = MEDfieldComputingStepInfo(myFile->Id(), &aFieldName, theTimeStampId, &aNumDt, &aNumOrd, &aDt); char profilename[MED_NAME_SIZE+1]; med_int profilsize; char locname[MED_NAME_SIZE+1]; MEDfieldnValueWithProfile(myFile->Id(), &aFieldName, aNumDt, aNumOrd, anEntity, med_geometry_type(aGeom), 1, MED_COMPACT_STMODE, profilename, &profilsize, locname, &aNbGauss); static TInt MAX_NB_GAUSS_POINTS = 32; if (aNbGauss <= 0 || aNbGauss > MAX_NB_GAUSS_POINTS) aNbGauss = 1; aGeom2NbGauss[aGeom] = aNbGauss; if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetTimeStampInfo - MEDfieldnValueWithProfile(...)"); } } //---------------------------------------------------------------------------- PTimeStampInfo TWrapper ::CrTimeStampInfo(const PFieldInfo& theFieldInfo, EEntiteMaillage theEntity, const TGeom2Size& theGeom2Size, const TGeom2NbGauss& theGeom2NbGauss, TInt theNumDt, TInt theNumOrd, TFloat theDt, const std::string& theUnitDt, const TGeom2Gauss& theGeom2Gauss) { return PTimeStampInfo(new TTTimeStampInfo (theFieldInfo, theEntity, theGeom2Size, theGeom2NbGauss, theNumDt, theNumOrd, theDt, theUnitDt, theGeom2Gauss)); } //---------------------------------------------------------------------------- PTimeStampInfo TWrapper ::CrTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo) { return PTimeStampInfo(new TTTimeStampInfo (theFieldInfo, theInfo)); } //---------------------------------------------------------------------------- PTimeStampInfo TWrapper ::GetPTimeStampInfo(const PFieldInfo& theFieldInfo, EEntiteMaillage theEntity, const TGeom2Size& theGeom2Size, TInt theId, TErr* theErr) { PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo, theEntity, theGeom2Size); GetTimeStampInfo(theId, *anInfo, theErr); #ifdef _DEBUG_ INITMSG("GetPTimeStampInfo - anEntity = "<GetEntity()<<"\n"); TGeom2NbGauss& aGeom2NbGauss = anInfo->myGeom2NbGauss; TGeom2NbGauss::const_iterator anIter = aGeom2NbGauss.begin(); for (; anIter != aGeom2NbGauss.end(); anIter++) { const EGeometrieElement& aGeom = anIter->first; INITMSG("aGeom = "<Id()); } //---------------------------------------------------------------------------- TProfileInfo::TInfo TWrapper ::GetProfilePreInfo(TInt theId, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return TProfileInfo::TInfo(); med_int aSize = -1; TVector aName(GetNOMLength()+1); TErr aRet; aRet = MEDprofileInfo(myFile->Id(), theId, &aName[0], &aSize); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetProfilePreInfo - MEDprofileInfo(...)"); return TProfileInfo::TInfo(&aName[0], aSize); } //---------------------------------------------------------------------------- void TWrapper ::GetProfileInfo(TInt /*theId*/, TProfileInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TProfileInfo& anInfo = const_cast(theInfo); TValueHolder anElemNum(anInfo.myElemNum); TValueHolder aProfileName(anInfo.myName); TErr aRet; aRet = MEDprofileRd(myFile->Id(), &aProfileName, &anElemNum); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetProfileInfo - MEDprofileRd(...)"); } //---------------------------------------------------------------------------- void TWrapper ::SetProfileInfo(const TProfileInfo& theInfo, TErr* theErr) { TErr aRet; SetProfileInfo(theInfo, eLECTURE_ECRITURE, &aRet); if (aRet < 0) SetProfileInfo(theInfo, eLECTURE_AJOUT, &aRet); if (aRet < 0) SetProfileInfo(theInfo, eCREATION, &aRet); if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetProfileInfo(const TProfileInfo& theInfo, EModeAcces theMode, TErr* theErr) { TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; TProfileInfo& anInfo = const_cast(theInfo); TValueHolder anElemNum(anInfo.myElemNum); TValueHolder aProfileName(anInfo.myName); TErr aRet; aRet = MEDprofileWr(myFile->Id(), // descripteur du fichier. &aProfileName, // tableau de valeurs du profil. theInfo.GetSize(), // taille du profil. &anElemNum); // nom profil. if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetProfileInfo - MEDprofileWr(...)"); } //---------------------------------------------------------------------------- PProfileInfo TWrapper ::CrProfileInfo(const TProfileInfo::TInfo& theInfo, EModeProfil theMode) { return PProfileInfo(new TTProfileInfo (theInfo, theMode)); } //---------------------------------------------------------------------------- PProfileInfo TWrapper ::GetPProfileInfo(TInt theId, EModeProfil theMode, TErr* theErr) { TProfileInfo::TInfo aPreInfo = GetProfilePreInfo(theId); PProfileInfo anInfo = CrProfileInfo(aPreInfo, theMode); GetProfileInfo(theId, *anInfo, theErr); return anInfo; } //---------------------------------------------------------------------------- void TWrapper ::GetTimeStampValue(const PTimeStampValueBase& theTimeStampValue, const TMKey2Profile& theMKey2Profile, const TKey2Gauss& theKey2Gauss, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TIdt anId = myFile->Id(); TValueHolder aModeSwitch(theTimeStampValue->myModeSwitch); MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile; MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo; TValueHolder anEntity(aTimeStampInfo->myEntity); TValueHolder aNumDt(aTimeStampInfo->myNumDt); TValueHolder aNumOrd(aTimeStampInfo->myNumOrd); MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo; TValueHolder aFieldName(aFieldInfo->myName); TValueHolder anIsLocal(aFieldInfo->myIsLocal); MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo; TValueHolder aMeshName(aMeshInfo->myName); TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss; TVector aGaussName(GetNOMLength()+1); med_storage_mode aProfileMode = med_storage_mode(boost::get<0>(theMKey2Profile)); MED::TKey2Profile aKey2Profile = boost::get<1>(theMKey2Profile); TVector aProfileName(GetNOMLength()+1); TGeom2Size& aGeom2Size = aTimeStampInfo->myGeom2Size; TGeom2Size::iterator anIter = aGeom2Size.begin(); for (; anIter != aGeom2Size.end(); anIter++) { EGeometrieElement aGeom = anIter->first; TInt aNbElem = anIter->second; med_int profilesize, aNbGauss; TInt aNbVal = MEDfieldnValueWithProfile(anId, &aFieldName, aNumDt, aNumOrd, anEntity, med_geometry_type(aGeom), 1, aProfileMode, &aProfileName[0], &profilesize, &aGaussName[0], &aNbGauss); if (aNbVal <= 0) { if (theErr) { *theErr = -1; return; } EXCEPTION(std::runtime_error, "GetTimeStampValue - MEDfieldnValueWithProfile(...) - aNbVal == "<myNbComp; TInt aNbValue = aNbVal;// / aNbGauss; rules in MED changed theTimeStampValue->AllocateValue(aGeom, aNbValue, aNbGauss, aNbComp); TInt aValueSize = theTimeStampValue->GetValueSize(aGeom); INITMSG("TWrapper::GetTimeStampValue - aGeom = "<second; aGeom2Gauss[aGeom] = aGaussInfo; } } MED::PProfileInfo aProfileInfo; if (strcmp(&aProfileName[0], MED_NO_PROFILE) != 0) { MED::TKey2Profile::const_iterator anIter = aKey2Profile.find(&aProfileName[0]); if (anIter != aKey2Profile.end()) { aProfileInfo = anIter->second; aGeom2Profile[aGeom] = aProfileInfo; } } if (aGaussInfo && aNbGauss != aGaussInfo->GetNbGauss()) { if (theErr) { *theErr = MED_FALSE; return; } EXCEPTION(std::runtime_error, "GetTimeStampValue - aNbGauss != aGaussInfo->GetNbGauss()"); } if (aProfileInfo && aProfileInfo->IsPresent()) { TInt aNbSubElem = aProfileInfo->GetSize(); TInt aProfileSize = aNbSubElem*aNbComp*aNbGauss; if (aProfileSize != aValueSize) { if (theErr) { *theErr = -1; return; } EXCEPTION(std::runtime_error, "GetTimeStampValue - aProfileSize("<Id(); TValueHolder aModeSwitch(theTimeStampValue->myModeSwitch); MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->myGeom2Profile; MED::PTimeStampInfo aTimeStampInfo = theTimeStampValue->myTimeStampInfo; TValueHolder anEntity(aTimeStampInfo->myEntity); TValueHolder aNumDt(aTimeStampInfo->myNumDt); TValueHolder aNumOrd(aTimeStampInfo->myNumOrd); TValueHolder anUnitDt(aTimeStampInfo->myUnitDt); TValueHolder aDt(aTimeStampInfo->myDt); MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->myGeom2Gauss; MED::PFieldInfo aFieldInfo = aTimeStampInfo->myFieldInfo; TValueHolder aFieldName(aFieldInfo->myName); MED::PMeshInfo aMeshInfo = aFieldInfo->myMeshInfo; TValueHolder aMeshName(aMeshInfo->myName); const TGeomSet& aGeomSet = theTimeStampValue->myGeomSet; TGeomSet::const_iterator anIter = aGeomSet.begin(); for (; anIter != aGeomSet.end(); anIter++) { EGeometrieElement aGeom = *anIter; TVector aGaussName(GetNOMLength()+1); MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aGeom); if (aGaussIter != aGeom2Gauss.end()) { MED::PGaussInfo aGaussInfo = aGaussIter->second; strcpy(&aGaussName[0], &aGaussInfo->myName[0]); } TVector aProfileName(GetNOMLength()+1); med_storage_mode aProfileMode = med_storage_mode(eNO_PFLMOD); MED::TGeom2Profile::const_iterator aProfileIter = aGeom2Profile.find(aGeom); if (aProfileIter != aGeom2Profile.end()) { MED::PProfileInfo aProfileInfo = aProfileIter->second; aProfileMode = med_storage_mode(aProfileInfo->myMode); strcpy(&aProfileName[0], &aProfileInfo->myName[0]); } med_int aNbVal = theTimeStampValue->GetNbVal(aGeom); aRet = MEDfieldValueWithProfileWr(anId, &aFieldName, aNumDt, aNumOrd, aDt, anEntity, med_geometry_type(aGeom), aProfileMode, &aProfileName[0], &aGaussName[0], aModeSwitch, MED_ALL_CONSTITUENT, aNbVal, theTimeStampValue->GetValuePtr(aGeom)); if (aRet < 0) { if (theErr) { *theErr = MED_FALSE; break; } EXCEPTION(std::runtime_error, "SetTimeStampValue - MEDfieldValueWithProfileWr(...)"); } } INITMSG("TWrapper::SetTimeStampValue - MED_MODE_ACCES = "<GetNbNodes(); BEGMSG("GetFamNumNode: "); for (TInt iElem = 0; iElem < aNbElem; iElem++) { ADDMSG(anInfo->GetFamNumNode(iElem)<<", "); } TInt aNbCells = anInfo->GetNbCells(); BEGMSG("GetFamNum: "); for (TInt iElem = 0; iElem < aNbCells; iElem++) { ADDMSG(anInfo->GetFamNum(iElem)<<", "); } ADDMSG(std::endl); BEGMSG("GetCoordName: "); for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) { ADDMSG(anInfo->GetCoordName(iElem)<<", "); } ADDMSG(std::endl); BEGMSG("GetCoordUnit: "); for (TInt iElem = 0; iElem < theMeshInfo->GetDim(); iElem++) { ADDMSG(anInfo->GetCoordUnit(iElem)<<", "); } ADDMSG(std::endl); } #endif return anInfo; } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::GetPGrilleInfo(const PMeshInfo& theMeshInfo, const PGrilleInfo& theInfo) { PGrilleInfo anInfo = CrGrilleInfo(theMeshInfo, theInfo); return anInfo; } //---------------------------------------------------------------------------- void TWrapper ::GetGrilleInfo(TGrilleInfo& theInfo, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); EMaillage aMaillageType = aMeshInfo.myType; GetGrilleType(aMeshInfo, theInfo.myGrilleType, theErr); EGrilleType aGrilleType = theInfo.myGrilleType; TErr aRet = 0; if (aMaillageType == eSTRUCTURE && aGrilleType == eGRILLE_STANDARD) { GetGrilleStruct(aMeshInfo, theInfo.myGrilleStructure, theErr); TValueHolder aCoord(theInfo.myCoord); TValueHolder aModeSwitch(theInfo.myModeSwitch); TValueHolder aCoordNames(theInfo.myCoordNames); TValueHolder aCoordUnits(theInfo.myCoordUnits); //med_axis_type aRepere; aRet = MEDmeshNodeCoordinateRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, aModeSwitch, &aCoord); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshNodeCoordinateRd(...)"); //TInt aNbNodes = theInfo.GetNbNodes();//GetNbFamilies(aMeshInfo); TValueHolder aFamNumNode(theInfo.myFamNumNode); aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, &aFamNumNode); if (aRet < 0) { // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files { int mySize = (int)theInfo.myFamNumNode.size(); theInfo.myFamNumNode.clear(); theInfo.myFamNumNode.resize(mySize,0); aRet = 0; } // else // EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)"); } if (theErr) *theErr = aRet; //============================ } if (aMaillageType == eSTRUCTURE && aGrilleType != eGRILLE_STANDARD) { ETable aTable = eCOOR_IND1; for (med_int anAxis = 1; anAxis <= aMeshInfo.myDim; anAxis++) { switch (anAxis) { case 1: aTable = eCOOR_IND1; break; case 2: aTable = eCOOR_IND2; break; case 3: aTable = eCOOR_IND3; break; default: aRet = -1; } if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - anAxis number out of range(...)"); TInt aNbIndexes = GetNbNodes(aMeshInfo, aTable); if (aNbIndexes < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - Erreur a la lecture de la taille de l'indice"); TValueHolder anIndexes(theInfo.GetIndexes(anAxis-1)); //TValueHolder table(aTable); //char aCompNames[MED_SNAME_SIZE+1]; //char anUnitNames[MED_SNAME_SIZE+1]; aRet=MEDmeshGridIndexCoordinateRd(myFile->Id(), &aMeshName, MED_NO_DT,MED_NO_IT, anAxis, &anIndexes); //theInfo.SetCoordName(anAxis-1, aCompNames); //theInfo.SetCoordUnit(anAxis-1, anUnitNames); theInfo.SetGrilleStructure(anAxis-1, aNbIndexes); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDindicesCoordLire(...)"); } } EGeometrieElement aGeom = theInfo.GetGeom(); EEntiteMaillage aEntity = theInfo.GetEntity(); TInt aNbCells = theInfo.GetNbCells(); theInfo.myFamNum.resize(aNbCells); TValueHolder aFamNum(theInfo.myFamNum); aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity), med_geometry_type(aGeom), &aFamNum); if (aMeshInfo.myDim == 3) { aGeom = theInfo.GetSubGeom(); aEntity = theInfo.GetSubEntity(); aNbCells = theInfo.GetNbSubCells(); theInfo.myFamSubNum.resize(aNbCells, 0); TValueHolder aFamNum(theInfo.myFamSubNum); aRet = MEDmeshEntityFamilyNumberRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, med_entity_type(aEntity), med_geometry_type(aGeom), &aFamNum); } if (aRet < 0) { // if (aRet == MED_ERR_DOESNTEXIST) // --- only valid with MED3.x files { int mySize = (int)theInfo.myFamNumNode.size(); theInfo.myFamNumNode.clear(); theInfo.myFamNumNode.resize(mySize, 0); aRet = 0; } // else // EXCEPTION(std::runtime_error,"GetGrilleInfo - MEDmeshEntityFamilyNumberRd(...)"); } if (theErr) *theErr = aRet; } //---------------------------------------------------------------------------- void TWrapper ::SetGrilleInfo(const MED::TGrilleInfo& theInfo, TErr* theErr) { SetGrilleInfo(theInfo, eLECTURE_ECRITURE, theErr); } //---------------------------------------------------------------------------- void TWrapper ::SetGrilleInfo(const MED::TGrilleInfo& theInfo, EModeAcces theMode, TErr* theErr) { if (theInfo.myMeshInfo->myType != eSTRUCTURE) return; TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor); if (theErr && *theErr < 0) return; MED::TGrilleInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aGrilleType(anInfo.myGrilleType); TErr aRet = 0; aRet = MEDmeshGridTypeRd(myFile->Id(), &aMeshName, &aGrilleType); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridTypeRd(...)"); if (anInfo.myGrilleType == eGRILLE_STANDARD) { TValueHolder aCoord(anInfo.myCoord); TValueHolder aModeSwitch(anInfo.myModeSwitch); TValueHolder aCoordNames(anInfo.myCoordNames); TValueHolder aCoordUnits(anInfo.myCoordUnits); med_int aNbNoeuds = med_int(anInfo.myCoord.size() / aMeshInfo.myDim); //med_axis_type aRepere = MED_CARTESIAN; aRet = MEDmeshNodeCoordinateWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, aModeSwitch, aNbNoeuds, &aCoord); if (aRet < 0) EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshNodeCoordinateWr(...)"); TValueHolder aGrilleStructure(anInfo.myGrilleStructure); aRet = MEDmeshGridStructWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, &aGrilleStructure); if (aRet < 0) EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridStructWr(...)"); } else { for (med_int aAxis = 0; aAxis < aMeshInfo.myDim; aAxis++) { aRet = MEDmeshGridIndexCoordinateWr(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, aAxis+1, anInfo.GetIndexes(aAxis).size(), &anInfo.GetIndexes(aAxis)[0]); if (aRet < 0) EXCEPTION(std::runtime_error, "SetGrilleInfo - MEDmeshGridIndexCoordinateWr(...)"); } } return; } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::CrGrilleInfo(const PMeshInfo& theMeshInfo, const PGrilleInfo& theInfo) { return PGrilleInfo(new TTGrilleInfo (theMeshInfo, theInfo)); } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::CrGrilleInfo(const PMeshInfo& /*theMeshInfo*/) { return PGrilleInfo(); // not implemented???? } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::CrGrilleInfo(const PMeshInfo& theMeshInfo, const EGrilleType& type) { return PGrilleInfo(new TTGrilleInfo (theMeshInfo, type)); } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::CrGrilleInfo(const PMeshInfo& theMeshInfo, const EGrilleType& type, const TInt& nbNodes) { return PGrilleInfo(new TTGrilleInfo (theMeshInfo, type, nbNodes)); } //---------------------------------------------------------------------------- PGrilleInfo TWrapper ::CrGrilleInfo(const PMeshInfo& theMeshInfo, const EGrilleType& type, const MED::TIntVector& nbNodeVec) { return PGrilleInfo(new TTGrilleInfo (theMeshInfo, type, nbNodeVec)); } //---------------------------------------------------------------------------- void TWrapper ::GetGrilleType(const MED::TMeshInfo& theMeshInfo, EGrilleType& theGridType, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)"); MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); if (aMeshInfo.myType == eSTRUCTURE) { TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aGridType(theGridType); TErr aRet = MEDmeshGridTypeRd(myFile->Id(), &aMeshName, &aGridType); if (aRet < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridTypeRd(...)"); } } //---------------------------------------------------------------------------- void TWrapper ::GetGrilleStruct(const MED::TMeshInfo& theMeshInfo, TIntVector& theStruct, TErr* theErr) { TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor); if (theErr && *theErr < 0) return; TErr aRet; MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); TValueHolder aMeshName(aMeshInfo.myName); TValueHolder aGridStructure(theStruct); aRet = MEDmeshGridStructRd(myFile->Id(), &aMeshName, MED_NO_DT, MED_NO_IT, &aGridStructure); if (theErr) *theErr = aRet; else if (aRet < 0) EXCEPTION(std::runtime_error, "GetGrilleInfo - MEDmeshGridStructRd(...)"); } }