From 3ab23e30195cd2dcd44c4cb90db993d5abf70809 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 13 Oct 2006 12:40:52 +0000 Subject: [PATCH] MPV: fix for bug 13568 Problems with synchronization. There must be only one MED wrapper per Med converter. --- src/CONVERTOR/VISU_MedConvertor.cxx | 102 +++++++++++++--------------- src/CONVERTOR/VISU_MedConvertor.hxx | 4 +- 2 files changed, 49 insertions(+), 57 deletions(-) diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 24bac3c4..8ea23b0f 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1141,16 +1141,17 @@ VISU_Convertor* CreateConvertor(const string& theFileName) { if(MED::PWrapper aMed = MED::CrWrapper(theFileName,true)) - return new VISU_MedConvertor(theFileName); + return new VISU_MedConvertor(theFileName, aMed); return NULL; } VISU_MedConvertor -::VISU_MedConvertor(const string& theFileName): +::VISU_MedConvertor(const string& theFileName, MED::PWrapper theMed): myIsEntitiesDone(false), myIsFieldsDone(false), myIsGroupsDone(false), - myIsMinMaxDone(false) + myIsMinMaxDone(false), + myMed(theMed) { myFileInfo.setFile(QString(theFileName.c_str())); myName = myFileInfo.baseName().latin1(); @@ -1167,9 +1168,8 @@ VISU_MedConvertor TSetIsDone aSetIsDone(myIsEntitiesDone); TTimerLog aTimerLog(MYDEBUG,"BuildEntities"); - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); - TInt aNbMeshes = aMed->GetNbMeshes(); + TInt aNbMeshes = myMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<GetPMeshInfo(iMesh); + MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); TInt aDim = aMeshInfo->GetDim(); MED::EMaillage aType = aMeshInfo->GetType(); @@ -1198,8 +1198,8 @@ VISU_MedConvertor if(aType == MED::eNON_STRUCTURE){ - if(MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo)){ - MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); + if(MED::PNodeInfo aNodeInfo = myMed->GetPNodeInfo(aMeshInfo)){ + MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo); aMesh->myNbPoints = aNodeInfo->GetNbElem(); aMesh->myEntityInfo = anEntityInfo; @@ -1215,7 +1215,7 @@ VISU_MedConvertor BuildMeshOnEntityMap(aMesh, anEntityInfo, aNodeInfo, - aMed); + myMed); #ifndef _DEXCEPT_ }catch(std::exception& exc){ @@ -1227,7 +1227,7 @@ VISU_MedConvertor } } // NON STRUCTURED MESH else { - MED::PGrilleInfo aGrilleInfo = aMed->GetPGrilleInfo(aMeshInfo); + MED::PGrilleInfo aGrilleInfo = myMed->GetPGrilleInfo(aMeshInfo); MED::TEntityInfo anEntityInfo; anEntityInfo[MED::eNOEUD][MED::ePOINT1] = aGrilleInfo->GetNbNodes(); @@ -1244,7 +1244,7 @@ VISU_MedConvertor BuildMeshGrilleOnEntityMap(aMesh, anEntityInfo, aGrilleInfo, - aMed); + myMed); #ifndef _DEXCEPT_ }catch(std::exception& exc){ @@ -1279,9 +1279,8 @@ VISU_MedConvertor TSetIsDone aSetIsDone(myIsFieldsDone); TTimerLog aTimerLog(MYDEBUG,"BuildFields"); - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); - TInt aNbMeshes = aMed->GetNbMeshes(); + TInt aNbMeshes = myMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<GetPMeshInfo(iMesh); + MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); @@ -1304,11 +1303,11 @@ VISU_MedConvertor #ifndef _DEXCEPT_ try{ #endif - MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); + MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo); BuildFieldMap(aMesh, anEntityInfo, - aMed); + myMed); #ifndef _DEXCEPT_ }catch(std::exception& exc){ MSG(MYDEBUG,"Follow exception was occured in:\n"<GetNbMeshes(); + TInt aNbMeshes = myMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<GetPMeshInfo(iMesh); + MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); @@ -1367,23 +1365,23 @@ VISU_MedConvertor #ifndef _DEXCEPT_ try{ #endif - TInt aNbFields = aMed->GetNbFields(); + TInt aNbFields = myMed->GetNbFields(); INITMSG(MYDEBUG, "- aMeshName = '"<GetEntityInfo(aMeshInfo); + MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo); for(TInt iField = 1; iField <= aNbFields; iField++){ TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()"); - MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField); + MED::PFieldInfo aFieldInfo = myMed->GetPFieldInfo(aMeshInfo,iField); std::string aFieldName = aFieldInfo->GetName(); INITMSG(MYDEBUG,"- aFieldName = '"<GetNbTimeStamps(aFieldInfo, + TInt aNbTimeStamps = myMed->GetNbTimeStamps(aFieldInfo, anEntityInfo, aMEntity, aGeom2Size); @@ -1417,12 +1415,12 @@ VISU_MedConvertor try{ #endif #endif - MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo, + MED::PTimeStampInfo aTimeStampInfo = myMed->GetPTimeStampInfo(aFieldInfo, aMEntity, aGeom2Size, iTimeStamp); - MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo, + MED::PTimeStampVal aTimeStampVal = myMed->GetPTimeStampVal(aTimeStampInfo, aMKey2Profile, aKey2Gauss); @@ -1543,9 +1541,8 @@ VISU_MedConvertor TSetIsDone aSetIsDone(myIsGroupsDone); TTimerLog aTimerLog(MYDEBUG,"BuildGroups"); - MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); - TInt aNbMeshes = aMed->GetNbMeshes(); + TInt aNbMeshes = myMed->GetNbMeshes(); TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<GetPMeshInfo(iMesh); + MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); @@ -1568,27 +1565,27 @@ VISU_MedConvertor MED::EMaillage aType = aMeshInfo->GetType(); - MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); + MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo); MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = - MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo); + MED::GetEntity2TGeom2ElemInfo(myMed,aMeshInfo,anEntityInfo); #ifndef _DEXCEPT_ try{ #endif - MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo); + MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(myMed,aMeshInfo); if(aType == MED::eNON_STRUCTURE) BuildFamilyMap(aMesh, anEntityInfo, anEntity2TGeom2ElemInfo, aFamilyInfoSet, - aMed); + myMed); else BuildGrilleFamilyMap(aMesh, anEntityInfo, aFamilyInfoSet, - aMed); + myMed); BuildGroupMap(aMesh, aFamilyInfoSet); @@ -1622,15 +1619,14 @@ VISU_MedConvertor TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity"); INITMSG(MYDEBUG,"LoadMeshOnEntity"<myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; if(anEntity == NODE_ENTITY){ - isPointsUpdated += LoadPoints(aMed,theMesh); + isPointsUpdated += LoadPoints(myMed,theMesh); }else{ - isPointsUpdated += LoadPoints(aMed,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); + isPointsUpdated += LoadPoints(myMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity); } return (isPointsUpdated || isCellsOnEntityUpdated); @@ -1647,15 +1643,14 @@ VISU_MedConvertor TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity"); INITMSG(MYDEBUG,"LoadFamilyOnEntity"<myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; if(anEntity == NODE_ENTITY){ - isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily); + isPointsUpdated += LoadPointsOnFamily(myMed,theMesh,theFamily); }else{ - isPointsUpdated += LoadPoints(aMed,theMesh); - isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,theMeshOnEntity,theFamily); + isPointsUpdated += LoadPoints(myMed,theMesh); + isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,theMeshOnEntity,theFamily); } return (isPointsUpdated || isCellsOnEntityUpdated); @@ -1671,18 +1666,17 @@ VISU_MedConvertor TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup"); INITMSG(MYDEBUG,"LoadMeshOnGroup"<myEntity; const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; - isPointsUpdated += LoadPoints(aMed,theMesh); + isPointsUpdated += LoadPoints(myMed,theMesh); if(anEntity == NODE_ENTITY){ - isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily); + isPointsUpdated += LoadPointsOnFamily(myMed,theMesh,aFamily); }else{ - isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily); + isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,aMeshOnEntity,aFamily); } } @@ -1701,14 +1695,12 @@ VISU_MedConvertor TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh"); INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; - isPointsUpdated += LoadPoints(aMed,theMesh); + isPointsUpdated += LoadPoints(myMed,theMesh); if(anEntity != NODE_ENTITY) - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); - int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime); + isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity); + int isFieldUpdated = LoadValForTimeOnMesh(myMed,theMesh,theMeshOnEntity,theField,theValForTime); return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); } @@ -1725,13 +1717,11 @@ VISU_MedConvertor TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts"); INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; if(anEntity != NODE_ENTITY) - isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); - int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime); + isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity); + int isFieldUpdated = LoadValForTimeOnGaussPts(myMed,theMesh,theMeshOnEntity,theField,theValForTime); return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index c467f0c1..a16d04fe 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -21,6 +21,7 @@ #include "VISU_Convertor_impl.hxx" +#include "MED_Wrapper.hxx" #include "MED_Common.hxx" #include "MED_Structures.hxx" @@ -201,7 +202,7 @@ class VISU_MedConvertor: public VISU_Convertor_impl bool myIsMinMaxDone; public: - VISU_MedConvertor(const std::string& theFileName); + VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed); virtual VISU_Convertor* @@ -221,6 +222,7 @@ public: protected: QFileInfo myFileInfo; + MED::PWrapper myMed; // mpv : bug 13568: one med per converter virtual int -- 2.39.2