]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
MPV: fix for bug 13568
authormpv <mpv@opencascade.com>
Fri, 13 Oct 2006 12:40:52 +0000 (12:40 +0000)
committermpv <mpv@opencascade.com>
Fri, 13 Oct 2006 12:40:52 +0000 (12:40 +0000)
Problems with synchronization. There must be only one MED wrapper per Med converter.

src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index 24bac3c41a1cfd9f04fb392f8b71fbc7803bc1b0..8ea23b0f3828b3ca6d1b0e6c64c1545905cd6ddf 100644 (file)
@@ -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 = "<<aNbMeshes<<"\n");
@@ -1180,7 +1180,7 @@ VISU_MedConvertor
 #endif
       TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
 
-      MED::PMeshInfo aMeshInfo = aMed->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 = "<<aNbMeshes<<"\n");
@@ -1292,7 +1291,7 @@ VISU_MedConvertor
 #endif
       TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
 
-      MED::PMeshInfo aMeshInfo = aMed->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"<<exc.what());
@@ -1340,12 +1339,11 @@ VISU_MedConvertor
 
   TSetIsDone aSetIsDone(myIsMinMaxDone);
   TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
 
-  MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
-  MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
+  MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(myMed);
+  MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(myMed);
 
-  TInt aNbMeshes = aMed->GetNbMeshes();
+  TInt aNbMeshes = myMed->GetNbMeshes();
   TMeshMap& aMeshMap = myMeshMap;
 
   INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
@@ -1356,7 +1354,7 @@ VISU_MedConvertor
 #endif
       TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
 
-      MED::PMeshInfo aMeshInfo = aMed->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 = '"<<aMeshName<<"'"<<
                "; aNbFields = "<<aNbFields<<"\n");
 
-       MED::TEntityInfo anEntityInfo = aMed->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 = '"<<aFieldName<<"'\n");
          
          MED::TGeom2Size aGeom2Size;
          MED::EEntiteMaillage aMEntity;
-         TInt aNbTimeStamps = aMed->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 = "<<aNbMeshes<<"\n");
@@ -1556,7 +1553,7 @@ VISU_MedConvertor
 #endif
       TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
 
-      MED::PMeshInfo aMeshInfo = aMed->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"<<endl);
 
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->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"<<endl);
 
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   const TEntity& anEntity = theMeshOnEntity->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"<<endl);
 
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
   int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
   TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
   for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
     PMEDFamily aFamily = *aFamilyIter;
     const TEntity& anEntity = aFamily->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"<<endl);
 
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
-
   const TEntity& anEntity = theMeshOnEntity->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"<<endl);
 
-  MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
-
   const TEntity& anEntity = theMeshOnEntity->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);
 }
index c467f0c13339ff24e35fbf8b9fed52f5d6ea1c54..a16d04fe00e0d437a47991436df0ddc735252fce 100644 (file)
@@ -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