]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve memory usage
authorapo <apo@opencascade.com>
Fri, 12 Aug 2005 10:21:46 +0000 (10:21 +0000)
committerapo <apo@opencascade.com>
Fri, 12 Aug 2005 10:21:46 +0000 (10:21 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 8c267acc9000b634d795d6f0a268068888b7a5e9..1abe7336076f14c640f16213a0feae96f314b25a 100644 (file)
@@ -83,18 +83,34 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  TSource::TSource():
-    mySource(vtkUnstructuredGrid::New())
+  TSource::TSource()
+  {}
+
+  const TVTKSource& 
+  TSource
+  ::GetSource() const
   {
-    mySource->Delete();
+    if(!mySource.GetPointer()){
+      mySource = vtkUnstructuredGrid::New();
+      mySource->Delete();
+    }
+    return mySource;
   }
 
 
   //---------------------------------------------------------------
-  TAppendFilter::TAppendFilter():
-    myFilter(vtkAppendFilter::New())
+  TAppendFilter::TAppendFilter()
+  {}
+
+  const TVTKAppendFilter& 
+  TAppendFilter
+  ::GetFilter() const
   {
-    myFilter->Delete();
+    if(!myFilter.GetPointer()){
+      myFilter = vtkAppendFilter::New();
+      myFilter->Delete();
+    }
+    return myFilter;
   }
 
 
@@ -466,8 +482,8 @@ namespace
 
   //---------------------------------------------------------------
   void
-  GetPoints(VISU::TVTKSource& theSource, 
-           VISU::PMeshImpl theMesh) 
+  GetPoints(const TVTKSource& theSource, 
+           const PMeshImpl& theMesh) 
   {
     TVTKPoints& aPoints = theMesh->myPoints;
     const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
@@ -551,9 +567,9 @@ namespace
 
   //---------------------------------------------------------------
   void
-  GetCellsOnEntity(VISU::TVTKSource& theSource,
-                  const VISU::PMeshOnEntityImpl theMeshOnEntity, 
-                  const string& theFamilyName) 
+  GetCellsOnEntity(const TVTKSource& theSource,
+                  const PMeshOnEntityImpl& theMeshOnEntity, 
+                  const std::string& theFamilyName) 
   {
     //Check on existing family
     PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
@@ -618,9 +634,9 @@ namespace
   
   //---------------------------------------------------------------
   void
-  GetCellsOnGroup(VISU::TVTKSource& theSource,
-                 VISU::PMeshImpl theMesh,
-                 const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
+  GetCellsOnGroup(const TVTKSource& theSource,
+                 const PMeshImpl& theMesh,
+                 const TFamilyAndEntitySet& theFamilyAndEntitySet) 
   {
     //Calculate dimentions of the group
     INITMSG(MYDEBUG,"GetCellsOnGroup\n");
@@ -686,8 +702,8 @@ namespace
   
   //---------------------------------------------------------------
   std::string
-  GenerateFieldName(const VISU::PFieldImpl theField,
-                   const VISU::PValForTimeImpl theValForTime)
+  GenerateFieldName(const PFieldImpl& theField,
+                   const PValForTimeImpl& theValForTime)
   {
     const VISU::TTime& aTime = theValForTime->myTime;
     string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + 
@@ -698,9 +714,9 @@ namespace
 
   //---------------------------------------------------------------
   void 
-  GetTimeStampOnProfile(VISU::TVTKSource& theSource,
-                       const VISU::PFieldImpl theField, 
-                       const VISU::PValForTimeImpl theValForTime)
+  GetTimeStampOnProfile(const TVTKSource& theSource,
+                       const PFieldImpl& theField, 
+                       const PValForTimeImpl& theValForTime)
   {
     int aNbTuples = theField->myDataSize/theField->myNbComp;
     string aFieldName = GenerateFieldName(theField,theValForTime);
@@ -800,9 +816,9 @@ namespace
 
   //---------------------------------------------------------------
   void
-  GetCells(VISU::TVTKSource& theSource,
-          PSubProfileImpl theSubProfile,
-          PMeshOnEntityImpl theMeshOnEntity)
+  GetCells(const TVTKSource& theSource,
+          const PSubProfileImpl& theSubProfile,
+          const PMeshOnEntityImpl& theMeshOnEntity)
   {
     vtkIdType aNbCells = theSubProfile->myNbCells;
     vtkIdType aCellsSize = theSubProfile->myCellsSize;
@@ -862,14 +878,14 @@ namespace
   
   //---------------------------------------------------------------
   void
-  GetMeshOnSubProfile(PMeshImpl theMesh,
-                     PMeshOnEntityImpl theMeshOnEntity,
-                     PProfileImpl theProfile,
-                     PSubProfileImpl theSubProfile)
+  GetMeshOnSubProfile(const PMeshImpl& theMesh,
+                     const PMeshOnEntityImpl& theMeshOnEntity,
+                     const PProfileImpl& theProfile,
+                     const PSubProfileImpl& theSubProfile)
   {
     INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<<theSubProfile->myGeom<<endl);
     
-    TVTKSource& aSource = theSubProfile->mySource;
+    const TVTKSource& aSource = theSubProfile->GetSource();
     if(theSubProfile->myIsVTKDone)
       return;
     
@@ -884,16 +900,16 @@ namespace
   
   //---------------------------------------------------------------
   void
-  GetMeshOnProfile(PMeshImpl theMesh,
-                  PMeshOnEntityImpl theMeshOnEntity,
-                  PProfileImpl theProfile)
+  GetMeshOnProfile(const PMeshImpl& theMesh,
+                  const PMeshOnEntityImpl& theMeshOnEntity,
+                  const PProfileImpl& theProfile)
   {
     if(theProfile->myIsVTKDone)
       return;
     
-    TVTKAppendFilter& anAppendFilter = theProfile->myFilter;
+    const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
     if(theProfile->myIsAll){
-      TVTKSource& aSource = theMeshOnEntity->mySource;
+      const TVTKSource& aSource = theMeshOnEntity->GetSource();
       anAppendFilter->AddInput(aSource.GetPointer());
     }else{
       const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
@@ -908,7 +924,7 @@ namespace
                            theProfile,
                            aSubProfile);
        
-       TVTKSource& aSource = aSubProfile->mySource;
+       const TVTKSource& aSource = aSubProfile->GetSource();
        anAppendFilter->AddInput(aSource.GetPointer());
       }
     }
@@ -920,9 +936,9 @@ namespace
   
   //---------------------------------------------------------------
   void 
-  GetTimeStampOnGaussMesh(VISU::TVTKSource& theSource,
-                         const VISU::PFieldImpl theField, 
-                         const VISU::PValForTimeImpl theValForTime)
+  GetTimeStampOnGaussMesh(const TVTKSource& theSource,
+                         const PFieldImpl& theField, 
+                         const PValForTimeImpl& theValForTime)
   {
     int aNbTuples = theSource->GetNumberOfPoints();
     std::string aFieldName = GenerateFieldName(theField,theValForTime);
@@ -1031,9 +1047,9 @@ namespace
 
   //---------------------------------------------------------------
   void
-  GetSource(VISU::TVTKSource& theSource,
-           PGaussSubMeshImpl theGaussSubMesh,
-           PMeshOnEntityImpl theMeshOnEntity)
+  GetSource(const TVTKSource& theSource,
+           const PGaussSubMeshImpl& theGaussSubMesh,
+           const PMeshOnEntityImpl& theMeshOnEntity)
   {
     const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
     vtkIdType aNbPoints = aCoords.GetNbPoints();
@@ -1075,7 +1091,7 @@ namespace
     for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
       aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
     
-    TVTKSource& aSource = theGaussSubMesh->mySource;
+    const TVTKSource& aSource = theGaussSubMesh->GetSource();
     aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
     aSource->SetPoints(aPoints.GetPointer());
     
@@ -1087,10 +1103,10 @@ namespace
   
   //---------------------------------------------------------------
   void
-  GetGaussSubMesh(PMeshImpl theMesh,
-                 PMeshOnEntityImpl theMeshOnEntity,
-                 PGaussMeshImpl theGaussMesh,
-                 PGaussSubMeshImpl theGaussSubMesh)
+  GetGaussSubMesh(const PMeshImpl& theMesh,
+                 const PMeshOnEntityImpl& theMeshOnEntity,
+                 const PGaussMeshImpl& theGaussMesh,
+                 const PGaussSubMeshImpl& theGaussSubMesh)
   {
     PGaussImpl aGauss = theGaussSubMesh->myGauss;
     INITMSG(MYDEBUG,"GetGaussSubMesh - aGeom = "<<aGauss->myGeom<<endl);
@@ -1101,7 +1117,7 @@ namespace
     if(theGaussSubMesh->myIsVTKDone)
       return;
     
-   TVTKSource& aSource = theGaussSubMesh->mySource;
+    const TVTKSource& aSource = theGaussSubMesh->GetSource();
     GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
@@ -1112,15 +1128,15 @@ namespace
   
   //---------------------------------------------------------------
   void
-  GetGaussMesh(PMeshImpl theMesh,
-              PMeshOnEntityImpl theMeshOnEntity,
-              PGaussMeshImpl theGaussMesh)
+  GetGaussMesh(const PMeshImpl& theMesh,
+              const PMeshOnEntityImpl& theMeshOnEntity,
+              const PGaussMeshImpl& theGaussMesh)
   {
     if(theGaussMesh->myIsVTKDone)
       return;
     
     INITMSG(MYDEBUG,"GetGaussMesh"<<endl);
-    TVTKAppendFilter& anAppendFilter = theGaussMesh->myFilter;
+    const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
     const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
     TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
     for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
@@ -1133,7 +1149,7 @@ namespace
                      theGaussMesh,
                      aGaussSubMesh);
       
-      TVTKSource& aSource = aGaussSubMesh->mySource;
+      const TVTKSource& aSource = aGaussSubMesh->GetSource();
       anAppendFilter->AddInput(aSource.GetPointer());
     }
     anAppendFilter->Update(); // Fix on VTK
@@ -1187,10 +1203,10 @@ VISU_Convertor_impl
   TVTKSource aSource;
   bool *anIsInitialized;
   if(aFamily){
-    aSource = aFamily->mySource;
+    aSource = aFamily->GetSource();
     anIsInitialized = &(aFamily->myIsVTKDone);
   }else{
-    aSource = aMeshOnEntity->mySource;
+    aSource = aMeshOnEntity->GetSource();
     anIsInitialized = &(aMeshOnEntity->myIsVTKDone);
   }
 
@@ -1254,7 +1270,7 @@ VISU_Convertor_impl
   const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
 
   //Main part of code
-  TVTKSource& aSource = aGroup->mySource;
+  const TVTKSource& aSource = aGroup->GetSource();
   try{
     if(!aGroup->myIsVTKDone){
       LoadMeshOnGroup(aMesh,aFamilyAndEntitySet);
@@ -1308,7 +1324,7 @@ VISU_Convertor_impl
   PFieldImpl aField = boost::get<3>(aFindTimeStamp);
 
   //Main part of code
-  TVTKSource& aSource = aValForTime->mySource;
+  const TVTKSource& aSource = aValForTime->GetSource();
 #ifndef _DEXCEPT_
   try{
 #endif
@@ -1333,14 +1349,14 @@ VISU_Convertor_impl
       if(!aGaussMesh){
        GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
      
-       TVTKAppendFilter& anAppendFilter = aProfile->myFilter;
+       const TVTKAppendFilter& anAppendFilter = aProfile->GetFilter();
        aSource->ShallowCopy(anAppendFilter->GetOutput());
        GetTimeStampOnProfile(aSource,aField,aValForTime);
       }else{
        const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
        GetGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
      
-       TVTKAppendFilter& anAppendFilter = aGaussMesh->myFilter;
+       const TVTKAppendFilter& anAppendFilter = aGaussMesh->GetFilter();
        aSource->ShallowCopy(anAppendFilter->GetOutput());
        GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
       }
index 989329f8a7cd84e575dbc4d2edbb5c698268a653..623f36807427e94472687640041dfdf157ea8f47 100644 (file)
@@ -53,18 +53,26 @@ namespace VISU
 
 
   //---------------------------------------------------------------
-  struct TSource: virtual TSizeCounter
+  class TSource: public virtual TSizeCounter
   {
+    mutable TVTKSource mySource;
+  public:
     TSource();
-    TVTKSource mySource;
+
+    const TVTKSource& 
+    GetSource() const;
   };
 
 
   //---------------------------------------------------------------
-  struct TAppendFilter: virtual TIsVTKDone
+  struct TAppendFilter: public virtual TIsVTKDone
   {
+    mutable TVTKAppendFilter myFilter;
+  public:
     TAppendFilter();
-    TVTKAppendFilter myFilter;
+
+    const TVTKAppendFilter& 
+    GetFilter() const;
   };
 
 
index 5f579fecaa4bbdeeb268a5006ce496dc0f5fac36..aac143c68372f6b4fa8a97159f4d9890e9162c5a 100644 (file)
@@ -47,10 +47,10 @@ using MED::TFloat;
 using MED::EBooleen;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
-static int MY_FAMILY_DEBUG = 1;
-static int MY_GROUP_DEBUG = 1;
+static int MY_FAMILY_DEBUG = 0;
+static int MY_GROUP_DEBUG = 0;
 #else
 static int MYDEBUG = 0;
 static int MYVALUEDEBUG = 0;
@@ -384,8 +384,7 @@ namespace
 
   void
   BuildMeshOnEntityMap(PMEDMesh theMesh,
-                      TFamilyCounterMap& theFamilyNbCellsCounterMap,
-                      TFamilyCounterMap& theFamilyCellsSizeCounterMap,
+                      TFamilyCounterMap& theFamilyID2CellsSize,
                       const MED::TEntityInfo& theEntityInfo,
                       MED::PNodeInfo theNodeInfo,
                       MED::PWrapper theMEDWrapper)
@@ -416,10 +415,8 @@ namespace
        
        for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
          TInt aFamId = theNodeInfo->GetFamNum(iElem);
-         if(aFamId != 0){
-           theFamilyNbCellsCounterMap[aFamId] += 1;
-           theFamilyCellsSizeCounterMap[aFamId] += 2;
-         }
+         if(aFamId != 0)
+           theFamilyID2CellsSize[aFamId] += 2;
        }
        
        INITMSG(MYDEBUG,
@@ -449,10 +446,8 @@ namespace
              TInt aNbConn = aPolygoneInfo->GetNbConn(anElemId);
              aMeshOnEntity->myCellsSize += aNbConn;
              TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
-             if(aFamId != 0){
-               theFamilyNbCellsCounterMap[aFamId] += 1;
-               theFamilyCellsSizeCounterMap[aFamId] += aNbConn + 1;
-             }
+             if(aFamId != 0)
+               theFamilyID2CellsSize[aFamId] += aNbConn + 1;
            }
            break;
          }
@@ -477,10 +472,8 @@ namespace
              }
              aMeshOnEntity->myCellsSize += aCellSize;
              TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
-             if(aFamId != 0){
-               theFamilyNbCellsCounterMap[aFamId] += 1;
-               theFamilyCellsSizeCounterMap[aFamId] += aCellSize + 1;
-             }
+             if(aFamId != 0)
+               theFamilyID2CellsSize[aFamId] += aCellSize + 1;
            }
            break;
          }
@@ -501,10 +494,8 @@ namespace
            
            for(TInt iElem = 0; iElem < aNbElem; iElem++){
              TInt aFamId = aCellInfo->GetFamNum(iElem);
-             if(aFamId != 0){
-               theFamilyNbCellsCounterMap[aFamId] += 1;
-               theFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
-             }
+             if(aFamId != 0)
+               theFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
            }
          }} // end switch(...)
        }
@@ -595,26 +586,25 @@ namespace
   //---------------------------------------------------------------
   void
   BuildFamilyMap(PMEDMesh theMesh,
-                const TFamilyCounterMap& theFamilyNbCellsCounterMap,
-                const TFamilyCounterMap& theFamilyCellsSizeCounterMap,
+                const TFamilyCounterMap& theFamilyID2CellsSize,
                 const MED::TEntityInfo& theEntityInfo,
-                const MED::TElemGroup& theElemGroup,
-                const MED::TFamilyGroup& theFamilyGroup,
+                const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
+                const MED::TFamilyInfoSet& theFamilyInfoSet,
                 MED::PWrapper theMEDWrapper)
   {
+    INITMSG(MYDEBUG,"BuildFamilyMap\n");
     MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
-    MED::TFamilyByEntity aFamilyByEntity = MED::GetFamiliesByEntity(theMEDWrapper,theElemGroup,theFamilyGroup);
-    MED::TFamilyByEntity::const_iterator aFamilyByEntityIter = aFamilyByEntity.begin();
-    INITMSG(MY_FAMILY_DEBUG,"BuildFamilyMap:\n");
-    for(; aFamilyByEntityIter != aFamilyByEntity.end(); aFamilyByEntityIter++){
-      const MED::EEntiteMaillage& aMEntity = aFamilyByEntityIter->first;
-      const MED::TFamilyGroup& aFamilyGroup = aFamilyByEntityIter->second;
+    MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
+    MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
+    for(; aEntity2FamilySetIter != aEntity2FamilySet.end(); aEntity2FamilySetIter++){
+      const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
+      const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
       
       TEntity aVEntity = MEDEntityToVTK(aMEntity);
       PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
       TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
        
-      if(aFamilyGroup.empty())
+      if(aFamilyTSizeSet.empty())
        continue;
        
       INITMSG(MY_FAMILY_DEBUG,
@@ -622,52 +612,111 @@ namespace
              "; aVEntity = "<<aVEntity<<
              endl);
 
-      MED::TFamilyGroup::const_iterator aFamilyGroupIter = aFamilyGroup.begin();
-      for(; aFamilyGroupIter != aFamilyGroup.end(); aFamilyGroupIter++){
-       const MED::PFamilyInfo& aFamilyInfo = *aFamilyGroupIter;
-       if (aFamilyInfo->GetId() == 0) 
+      MED::TFamilyTSizeSet::const_iterator aFamilyTSizeSetIter = aFamilyTSizeSet.begin();
+      for(; aFamilyTSizeSetIter != aFamilyTSizeSet.end(); aFamilyTSizeSetIter++){
+       const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
+       const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
+       TInt aSize = boost::get<1>(aFamilyTSize);
+       if(aFamilyInfo->GetId() == 0) 
          continue;
        
        TInt anId = aFamilyInfo->GetId();
        std::string aFamilyName = aFamilyInfo->GetName();
-       PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
 
+       PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
        aFamily->myId = anId;
-       aFamily->myName = aFamilyInfo->GetName();
        aFamily->myEntity = aVEntity;
-       {       
-         aFamily->myNbCells = 0;
-         TFamilyCounterMap::const_iterator anIter = theFamilyNbCellsCounterMap.find(anId);
-         if(anIter != theFamilyNbCellsCounterMap.end())
-           aFamily->myNbCells = anIter->second;
-       }
-       {       
-         aFamily->myCellsSize = 0;
-         TFamilyCounterMap::const_iterator anIter = theFamilyCellsSizeCounterMap.find(anId);
-         if(anIter != theFamilyCellsSizeCounterMap.end())
-           aFamily->myCellsSize = anIter->second;
-       }
+       aFamily->myNbCells = aSize;
+
+       aFamily->myCellsSize = 0;
+       TFamilyCounterMap::const_iterator anIter = theFamilyID2CellsSize.find(anId);
+       if(anIter != theFamilyID2CellsSize.end())
+         aFamily->myCellsSize = anIter->second;
        
        INITMSG(MY_FAMILY_DEBUG,
-               "- aFamilyName = '"<<aFamily->myName<<"'"<<
+               "- aFamilyName = '"<<aFamilyName<<"'"<<
                "; myId = "<<aFamily->myId<<"; "<<
                "; aNbAttr = "<<aFamilyInfo->GetNbAttr()<<
                "; aNbGroup = "<<aFamilyInfo->GetNbGroup()<<
-               "; myEntity = "<<aFamily->myEntity<<
+               "; aVEntity = "<<aVEntity<<
                "; myNbCells = "<<aFamily->myNbCells<<
                "; myCellsSize = "<<aFamily->myCellsSize<<
                endl);
-       
-       VISU::TBindGroups& aBindGroups = aFamily->myGroups;
+#ifdef _DEBUG_ 
        const TInt aNbGroup = aFamilyInfo->GetNbGroup();
        for(TInt i = 0; i < aNbGroup; i++){
          std::string aGroupName = aFamilyInfo->GetGroupName(i);
-         aBindGroups.insert(aGroupName);
          INITMSG(MY_FAMILY_DEBUG,"- aGroupName = '"<<aGroupName<<"'\n");
        }
+#endif
+
+      }
+    }
+  }
+
+
+  //---------------------------------------------------------------
+  void
+  BuildGroupMap(PMEDMesh theMesh,
+               const MED::TFamilyInfoSet& theFamilyInfoSet)
+  {
+    INITMSG(MY_GROUP_DEBUG,"BuildGroupMap:\n");
+    TGroupMap& aGroupMap = theMesh->myGroupMap;
+    MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
+    MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
+    for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
+      const std::string& aGroupName = aGroupInfoIter->first;
+      INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
+
+      PMEDGroup aGroup(new TMEDGroup());
+      
+      const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
+      MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
+      for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
+       const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
+       const std::string& aFamilyName = aFamilyInfo->GetName();
+       
+       TEntity aVEntity = TEntity(-1);
+       PMEDFamily aFamily;
+       
+       // Find aVisuEntity
+       const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+       TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
+       for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
+         const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
+         const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+         TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+         for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+           const std::string& aName = aFamilyMapIter->first;
+           aFamily = aFamilyMapIter->second;
+           if(aName == aFamilyName){
+             aVEntity = aFamily->myEntity;
+             goto exit_lable;
+           }
+         }
+       }
+      exit_lable:
+       if(aFamily && aVEntity >= 0){
+         aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
+         INITMSG(MY_GROUP_DEBUG,
+                 "- aFamilyName = '"<<aFamilyName<<"'"<<
+                 "; aVEntity = "<<aVEntity<<
+                 "\n");
+         
+         aGroup->myNbCells += aFamily->myNbCells;
+         aGroup->myCellsSize += aFamily->myCellsSize;
+       }
+      }
+      if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){
+       BEGMSG(MY_GROUP_DEBUG,
+              "- myNbCells = "<<aGroup->myNbCells<<
+              "; myCellsSize = "<<aGroup->myCellsSize<<
+              "\n");
+       aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
       }
     }
   }
+
 }
 
 
@@ -713,7 +762,8 @@ VISU_MedConvertor
       
       MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
       
-      MED::TElemGroup anElemGroup = MED::GetElemsByEntity(aMed,aMeshInfo,aEntityInfo);
+      MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo = 
+       MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo);
       
       // creating TMesh structure and TMeshOnEntityMap     
       TInt aDim = aMeshInfo->GetDim();
@@ -731,11 +781,10 @@ VISU_MedConvertor
              "; aDim = "<<aDim<<"\n");
       
       BEGMSG(MYDEBUG,"aEntityInfo.size() = "<<aEntityInfo.size()<<"\n");
-      TFamilyCounterMap aFamilyNbCellsCounterMap, aFamilyCellsSizeCounterMap;
+      TFamilyCounterMap aFamilyID2CellsSize;
 
       BuildMeshOnEntityMap(aMesh,
-                          aFamilyNbCellsCounterMap,
-                          aFamilyCellsSizeCounterMap,
+                          aFamilyID2CellsSize,
                           aEntityInfo,
                           aNodeInfo,
                           aMed);
@@ -746,78 +795,20 @@ VISU_MedConvertor
                    aKey2Gauss,
                    aMed);
 
-#ifndef _LOAD_FAMILIES_
-      continue;
-#endif
-
-      MED::TFamilyGroup aFamilyGroup = MED::GetFamilies(aMed,aMeshInfo);
+#ifdef _LOAD_FAMILIES_
+      MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
       
       BuildFamilyMap(aMesh,
-                    aFamilyNbCellsCounterMap,
-                    aFamilyCellsSizeCounterMap,
+                    aFamilyID2CellsSize,
                     aEntityInfo,
-                    anElemGroup,
-                    aFamilyGroup,
+                    anEntity2TGeom2ElemInfo,
+                    aFamilyInfoSet,
                     aMed);
+      
+      BuildGroupMap(aMesh,
+                   aFamilyInfoSet);
+#endif
 
-      BEGMSG(MY_GROUP_DEBUG,"TGroup:\n");
-      TGroupMap& aGroupMap = aMesh->myGroupMap;
-      MED::TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup);
-      MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
-      for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
-       const std::string& aGroupName = aGroupInfoIter->first;
-       const MED::TFamilyGroup& aFamilyGroup = aGroupInfoIter->second;
-       PMEDGroup aGroup(new TMEDGroup());
-       aGroup->myName = aGroupName;
-       aGroup->myMeshName = aMesh->myName;
-       
-       INITMSG(MY_GROUP_DEBUG,"aGroup->myName = '"<<aGroup->myName<<"'\n");
-       
-       MED::TFamilyGroup::const_iterator aFamilyIter = aFamilyGroup.begin();
-       for(; aFamilyIter != aFamilyGroup.end(); aFamilyIter++){
-         const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
-         const std::string& aFamilyName = aFamilyInfo->GetName();
-         
-         TEntity aVEntity = TEntity(-1);
-         PMEDFamily aFamily;
-         
-         // Find aVisuEntity
-         const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-         TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
-         for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
-           const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
-           const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
-           TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
-           for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
-             const std::string& aName = aFamilyMapIter->first;
-             aFamily = aFamilyMapIter->second;
-             if(aName == aFamilyName){
-               aVEntity = aFamily->myEntity;
-               goto exit_lable;
-             }
-           }
-         }
-       exit_lable:
-         if(aFamily && aVEntity >= 0){
-           aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
-           INITMSG(MY_GROUP_DEBUG,
-                   "aFamilyName = '"<<aFamilyName<<"'"<<
-                   "; '"<<aFamily->myName<<"'"<<
-                   "; aVEntity = "<<aVEntity<<
-                   "\n");
-           
-           aGroup->myNbCells += aFamily->myNbCells;
-           aGroup->myCellsSize += aFamily->myCellsSize;
-         }
-       }
-       if(!aGroup->myFamilyAndEntitySet.empty() && aGroup->myNbCells > 0){
-         BEGMSG(MY_GROUP_DEBUG,
-                "myNbCells = "<<aGroup->myNbCells<<
-                "; myCellsSize = "<<aGroup->myCellsSize<<
-                "\n");
-         aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
-       }
-      }
 #ifndef _DEXCEPT_
     }catch(std::exception& exc){
       MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());