]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL11482
authorapo <apo@opencascade.com>
Thu, 2 Feb 2006 10:13:51 +0000 (10:13 +0000)
committerapo <apo@opencascade.com>
Thu, 2 Feb 2006 10:13:51 +0000 (10:13 +0000)
  Regression of import time stemps from explored MED file

src/VISU_I/VISU_CorbaMedConvertor.cxx

index 06bd2b6b37aba556f2c95074ebfc1783eedc2613..629ba8fa69e26bb6358ca740d2df90a645cc509c 100644 (file)
@@ -234,7 +234,8 @@ namespace
 
   //---------------------------------------------------------------
   void 
-  GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
+  GetCellsSize(vtkIdType& theNbCells, 
+              vtkIdType& theCellsSize,
               SALOME_MED::MESH_ptr theMEDMesh,
               const VISU::TEntity& theVEntity)
   {
@@ -243,21 +244,22 @@ namespace
     int iGeomEnd = GetEntity2Geom(theVEntity,aGeomElems);
     const medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
     if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
-      for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
-       medGeometryElement aMEDGeom = aGeomElems[iGeom];
-       int iNumElemEnd = theMEDMesh->getNumberOfElements(aMEntity,aMEDGeom);
-       if(iNumElemEnd > 0){
-         if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
-         theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
-         theNbCells += iNumElemEnd;
-       }
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+      medGeometryElement aMEDGeom = aGeomElems[iGeom];
+      int iNumElemEnd = theMEDMesh->getNumberOfElements(aMEntity,aMEDGeom);
+      if(iNumElemEnd > 0){
+       if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+       theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
+       theNbCells += iNumElemEnd;
       }
+    }
   }
   
   
   //---------------------------------------------------------------
   void 
-  GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
+  GetCellsSize(vtkIdType& theNbCells, 
+              vtkIdType& theCellsSize,
               SALOME_MED::FAMILY_ptr theMEDFamily)
   {
     medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
@@ -288,23 +290,34 @@ namespace
     if(theEntity == NODE_ENTITY){
       aMeshOnEntity->myNbCells = theMesh->myNbPoints;
       aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
-      vtkIdType aNbCells, aCellsSize;
-      GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY);
-      if(aNbCells > 0){
-       TMeshOnEntityMap::iterator aIter = aMeshOnEntityMap.find(CELL_ENTITY);
-       if (aIter != aMeshOnEntityMap.end()){
-         VISU::PCMeshOnEntity aMeshOnCells = aIter->second;
-         aMeshOnCells->myEntity = VISU::CELL_ENTITY;
-         aMeshOnCells->myMeshName = theMesh->myName;
-         aMeshOnCells->myNbCells = aNbCells;
-         aMeshOnCells->myCellsSize = aCellsSize;
-       }
-      }
     }else{
       GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
     }
   }
-  
+
+  //---------------------------------------------------------------
+  PCMeshOnEntity 
+  InitMeshOnEntity(const VISU::PCMesh& theMesh,
+                  const VISU::TEntity& theEntity,
+                  const VISU::PCMeshOnEntity& theMeshOnEntity)
+  {
+    PCMeshOnEntity aMeshOnEntity;
+    TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+    TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
+    if(anIter == aMeshOnEntityMap.end()){
+      aMeshOnEntity.reset(new TCMeshOnEntity());
+      *aMeshOnEntity = *theMeshOnEntity;
+      aMeshOnEntity->myEntity = theEntity;
+      aMeshOnEntityMap[theEntity] = aMeshOnEntity;
+    }else
+      aMeshOnEntity = anIter->second;
+
+    GetCellsSize(theMesh,theMesh->myMesh,theEntity);
+
+    return aMeshOnEntity;
+  }
 }
 
 
@@ -346,18 +359,12 @@ VISU_MEDFieldConvertor::Build()
   aMeshOnEntity->myMeshName = aMeshName.in();
   aMeshOnEntity->mySupport = aMEDSupport;
 
-  if(aVEntity == NODE_ENTITY){
-    PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
-    *aMeshOnEntity2 = *aMeshOnEntity;
-    aMeshOnEntity->myEntity = CELL_ENTITY;
-    GetCellsSize(aMesh,aMEDMesh,CELL_ENTITY);
-  }else{
-    PCMeshOnEntity aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
-    *aMeshOnEntity2 = *aMeshOnEntity;
-    aMeshOnEntity->myEntity = NODE_ENTITY;
-    GetCellsSize(aMesh,aMEDMesh,NODE_ENTITY);
-  }
-  GetCellsSize(aMesh,aMEDMesh,aVEntity);
+  if(aVEntity == NODE_ENTITY)
+    ::InitMeshOnEntity(aMesh,CELL_ENTITY,aMeshOnEntity);
+  else
+    ::InitMeshOnEntity(aMesh,NODE_ENTITY,aMeshOnEntity);
+
+  ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
 
   TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
   PCField aField = aFieldMap[aFieldName.in()](new TCField());
@@ -577,7 +584,7 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
            aNbCells = aMesh->myNbPoints;
            aCellsSize = 2*aMesh->myNbPoints;
          }else
-           GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
+           ::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
          
          if(aNbCells > 0){
            TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
@@ -622,7 +629,7 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
          int aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
          CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
          if(!anIsOnAllElements)
-           GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
+           ::GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
 
          if(MYDEBUG) 
            MESSAGE("VISU_MEDConvertor::Build "<<
@@ -844,34 +851,12 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
     }else
       aMeshOnEntity = aMeshOnEntityMapIter->second;
 
-    PCMeshOnEntity aMeshOnEntity2;
-    if(aVEntity == NODE_ENTITY){
-      TEntity aVEntity2 = CELL_ENTITY;
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter2 = aMeshOnEntityMap.find(aVEntity2);
-      if(aMeshOnEntityMapIter2 == aMeshOnEntityMap.end()){
-       aMeshOnEntity2.reset(new TCMeshOnEntity());
-       aMeshOnEntity2->myEntity = aVEntity2;
-       aMeshOnEntity2->myMeshName = aMeshName.in();
-       aMeshOnEntity2->mySupport = aMEDSupport;
-       aMeshOnEntityMap[aVEntity2] = aMeshOnEntity2;
-      }else
-       aMeshOnEntity2 = aMeshOnEntityMapIter2->second;
-      GetCellsSize(aMesh,aMEDMesh,aVEntity2);
-    }else{
-      TEntity aVEntity2 = NODE_ENTITY;
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter2 = aMeshOnEntityMap.find(aVEntity2);
-      if(aMeshOnEntityMapIter2 == aMeshOnEntityMap.end()){
-       aMeshOnEntity2.reset(new TCMeshOnEntity());
-       aMeshOnEntity2->myEntity = aVEntity2;
-       aMeshOnEntity2->myMeshName = aMeshName.in();
-       aMeshOnEntity2->mySupport = aMEDSupport;
-       aMeshOnEntityMap[aVEntity2] = aMeshOnEntity2;
-      }else
-       aMeshOnEntity2 = aMeshOnEntityMapIter2->second;
-      GetCellsSize(aMesh,aMEDMesh,aVEntity2);
-    }
+    if(aVEntity == NODE_ENTITY)
+      ::InitMeshOnEntity(aMesh,CELL_ENTITY,aMeshOnEntity);
+    else
+      ::InitMeshOnEntity(aMesh,NODE_ENTITY,aMeshOnEntity);
 
-    GetCellsSize(aMesh,aMEDMesh,aVEntity);
+    ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
 
     PCField aField;
     TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;