]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve importing sequence of timestamps from MED object
authorapo <apo@opencascade.com>
Fri, 13 Jan 2006 08:52:55 +0000 (08:52 +0000)
committerapo <apo@opencascade.com>
Fri, 13 Jan 2006 08:52:55 +0000 (08:52 +0000)
src/VISU_I/VISU_CorbaMedConvertor.cxx

index 98e81b68e6ac55e1aad273a530b8bf1feef65cf2..0994d246ba684286b41d94032ab45ad9f559c195 100644 (file)
@@ -39,7 +39,7 @@ using namespace VISU;
 #define USER_INTERLACE MED_FULL_INTERLACE
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -580,12 +580,16 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
            GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
          
          if(aNbCells > 0){
-           PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
-           aMeshOnEntity->myMeshName = aMeshName.in();
-           aMeshOnEntity->myEntity = aVEntity;
-           aMeshOnEntity->myNbCells = aNbCells;
-           aMeshOnEntity->myCellsSize = aCellsSize;
-           aMeshOnEntity->mySupport = aMEDSupport;
+           TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+           if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
+             PCMeshOnEntity aMeshOnEntity(new TCMeshOnEntity());
+             aMeshOnEntity->myMeshName = aMeshName.in();
+             aMeshOnEntity->myEntity = aVEntity;
+             aMeshOnEntity->myNbCells = aNbCells;
+             aMeshOnEntity->myCellsSize = aCellsSize;
+             aMeshOnEntity->mySupport = aMEDSupport;
+             aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
+           }
          }
        }
       }
@@ -621,20 +625,25 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
            GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
 
          if(MYDEBUG) 
-           MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<
-                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+           MESSAGE("VISU_MEDConvertor::Build "<<
+                   "- aFamily = '"<<aSupportName<<"'"<<
+                   "; anIsOnAllElements = "<<anIsOnAllElements<<
                    "; aVEntity = "<<aVEntity<<
                    "; aNbCells = "<<aNbCells);
 
          if(aNbCells > 0){
            TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
-           PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
-           aFamily->myEntity = aVEntity;
-           aFamily->myNbCells = aNbCells;
-           aFamily->myCellsSize = aCellsSize;
-           aFamily->myId = aMEDFamily->getIdentifier();
-           aFamily->myName = aSupportName.in();
-           aFamily->myFamily = aMEDFamily;
+           TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
+           if(aFamilyMapIter == aFamilyMap.end()){
+             PCFamily aFamily(new TCFamily());
+             aFamily->myEntity = aVEntity;
+             aFamily->myNbCells = aNbCells;
+             aFamily->myCellsSize = aCellsSize;
+             aFamily->myId = aMEDFamily->getIdentifier();
+             aFamily->myName = aSupportName.in();
+             aFamily->myFamily = aMEDFamily;
+             aFamilyMap[aSupportName.in()] = aFamily;
+           }
          }
        }
       }
@@ -662,8 +671,9 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
          CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
 
          if(MYDEBUG) 
-           MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<
-                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+           MESSAGE("VISU_MEDConvertor::Build "<<
+                   "- aGroup = '"<<aSupportName<<"'"<<
+                   "; anIsOnAllElements = "<<anIsOnAllElements<<
                    "; aVEntity = "<<aVEntity);
 
          PCGroup aGroup(new TCGroup());
@@ -800,53 +810,88 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
     CORBA::String_var aMeshName = aMEDMesh->getName();
     CORBA::String_var aFieldName = aMEDField->getName();
 
-    PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
-    aMesh->myNamedPointCoords(new TNamedPointCoords());
-    aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
-    aMesh->myDim = aMEDMesh->getSpaceDimension();
-    aMesh->myName = aMeshName.in();
-    aMesh->myMesh = aMEDMesh;
+    PCMesh aMesh;
+    TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
+    if(aMeshMapIter == myMeshMap.end()){
+      aMesh.reset(new TCMesh());
+      aMesh->myNamedPointCoords(new TNamedPointCoords());
+      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
+      aMesh->myDim = aMEDMesh->getSpaceDimension();
+      aMesh->myName = aMeshName.in();
+      aMesh->myMesh = aMEDMesh;
+      
+      TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+      aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
 
-    TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
-    aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+      myMeshMap[aMeshName.in()] = aMesh;
 
-    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
+      if(MYDEBUG) 
+       MESSAGE("VISU_MEDConvertor::Build "<<
+               "- aMeshName = '"<<aMeshName<<"'"<<
+               "; aDim = "<<aMesh->myDim);
+    }else
+      aMesh = aMeshMapIter->second;
 
+    PCMeshOnEntity aMeshOnEntity;
     TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-    PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
-    aMeshOnEntity->myEntity = aVEntity;
-    aMeshOnEntity->myMeshName = aMeshName.in();
-    aMeshOnEntity->mySupport = aMEDSupport;
+    TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+    if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
+      aMeshOnEntity.reset(new TCMeshOnEntity());
+      aMeshOnEntity->myEntity = aVEntity;
+      aMeshOnEntity->myMeshName = aMeshName.in();
+      aMeshOnEntity->mySupport = aMEDSupport;
+      aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
+    }else
+      aMeshOnEntity = aMeshOnEntityMapIter->second;
 
     PCMeshOnEntity aMeshOnEntity2;
     if(aVEntity == NODE_ENTITY){
-      aMeshOnEntity2 = aMeshOnEntityMap[CELL_ENTITY](new TCMeshOnEntity());
-      aMeshOnEntity2->myEntity = CELL_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{
-      aMeshOnEntity2 = aMeshOnEntityMap[NODE_ENTITY](new TCMeshOnEntity());
-      aMeshOnEntity2->myEntity = NODE_ENTITY;
+      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);
     }
 
-    aMeshOnEntity2->myMeshName = aMeshName.in();
-    aMeshOnEntity2->mySupport = aMEDSupport;
-    GetCellsSize(aMesh,aMEDMesh,aMeshOnEntity2->myEntity);
-
     GetCellsSize(aMesh,aMEDMesh,aVEntity);
-    TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-    TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+
     PCField aField;
+    TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+    TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
     if(aFieldMapIter == aFieldMap.end()){
-      aField = aFieldMap[aFieldName.in()](new TCField());
-      CORBA::Short iField = mySObject->Tag();
-      aField->myId = iField;
+      aField.reset(new TCField());
+      aField->myId = mySObject->Tag();
       aField->myName = aFieldName.in();
       aField->myEntity = aVEntity;
       aField->myMeshName = aMeshName.in();
       aField->InitArrays(aMEDField->getNumberOfComponents());
       aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+      
+      aFieldMap[aFieldName.in()] = aField;
+
       if(MYDEBUG) 
        MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
-    }
+    }else
+      aField = aFieldMapIter->second;
+
     TValField& aValField = aField->myValField;
     int anId = aMEDField->getIterationNumber();
     PCValForTime aValForTime = aValField[anId](new TCValForTime());
@@ -855,8 +900,11 @@ VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
     aValForTime->myTime = TTime(aDT,"");
     aValForTime->myField = aMEDField;
     if(MYDEBUG) 
-      MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
-             "'; myEntity = "<<aVEntity<<"; myTime = "<<aDT);
+      MESSAGE("VISU_MEDConvertor::Build "<<
+             "- aMeshName = '"<<aMeshName<<"'"<<
+             "; myEntity = "<<aVEntity<<
+             "; myTime = "<<aDT<<
+             "; anId = "<<anId);
   }
   return this; 
 }