Salome HOME
NRI : Merge from V1_2.
[modules/visu.git] / src / VISU_I / VISU_CorbaMedConvertor.cxx
index 29eab3d08e4e748c1b372e3cb42b1d4465c590b9..b23363dba7efc756ea33c976d554659d7833af46 100644 (file)
@@ -1,10 +1,12 @@
-using namespace std;
-// File:       VISU_CorbaMedConvertor.cxx
-// Created:    Fri Jan 10 12:04:54 2003
-// Author:     Alexey PETROV
-//             <apo@ivanox.nnov.matra-dtv.fr>
-
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : VISU_CorbaMedConvertor.cxx
+//  Author : Alexey PETROV
+//  Module : VISU
 
+using namespace std;
 #include "VISU_CorbaMedConvertor.hxx"
 using namespace VISU;
 #include <valarray>    
@@ -13,12 +15,21 @@ using namespace VISU;
 #define USER_INTERLACE MED_FULL_INTERLACE
 
 #ifdef DEBUG
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
 static med_err ret = 0;
-/*
+
+extern "C" {
+  VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) throw(std::runtime_error&){
+    return new VISU_MEDConvertor(theMedSObject);
+  }
+  VISU_Convertor* CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) throw(std::runtime_error&){
+    return new VISU_MEDFieldConvertor(theField);
+  }
+}
+
 typedef map<VISU::TEntity,SALOME_MED::medEntityMesh> TVisu2MedEntity;
 static TVisu2MedEntity aVisu2MedEntity;
 static int INIT = (
@@ -135,10 +146,363 @@ void VISU_MedMeshConvertor::SetMedMesh(SALOME_MED::MESH_ptr theMedMesh) {
   myMedMesh = SALOME_MED::MESH::_duplicate(theMedMesh);
 }
 
-void VISU_CorbaMedConvertor::SetMedField(SALOME_MED::FIELD_ptr theMedField) {
-  myMedField = SALOME_MED::FIELD::_duplicate(theMedField);
-  if(!myMedField->_is_nil())
-    myMedMesh = myMedField->getSupport()->getMesh();
+VISU_Convertor* VISU_MEDFieldConvertor::Build() throw (std::runtime_error&){
+  if(myField->_is_nil()) 
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");
+  
+  SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport();
+  if(aMEDSupport->_is_nil()) 
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");
+  SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
+  VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
+  SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
+  if(aMEDMesh->_is_nil()) 
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");
+  CORBA::String_var aMeshName = aMEDMesh->getName();
+  CORBA::String_var aFieldName = myField->getName();
+
+  VISU::TMesh &aMesh = myMeshMap[aMeshName.in()];
+  aMesh.myDim = aMEDMesh->getSpaceDimension();
+  aMesh.myName = aMeshName.in();
+  VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()];
+  aMesh2.myMesh = aMEDMesh;
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
+
+  VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+  aMeshOnEntity.myEntity = anEntity;
+  aMeshOnEntity.myMeshName = aMeshName.in();
+  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
+  aMeshOnEntity2.mySupport = aMEDSupport;
+  if(anEntity == VISU::NODE_ENTITY){
+    aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myEntity = VISU::CELL_ENTITY;
+    aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myMeshName = aMeshName.in();
+    aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
+  }
+
+  VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()];
+  aField.myId = myField->getOrderNumber();
+  aField.myName = aFieldName.in();
+  aField.myEntity = anEntity;
+  aField.myMeshName = aMeshName.in();
+  aField.myNbComp = myField->getNumberOfComponents();
+  aField.myCompNames.resize(aField.myNbComp);
+  aField.myUnitNames.resize(aField.myNbComp);
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
+  int iTimeStamp = myField->getIterationNumber();
+  VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp];
+  aValForTime.myId = iTimeStamp;
+  double dt = myField->getTime();
+  aValForTime.myTime = VISU::TField::TTime(dt,"");
+  
+  VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
+  VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp];
+  aValForTime2.myField = myField;
+  if(MYDEBUG) 
+    MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<aFieldName<<"'; myId = "<<aField.myId<<"; myTime = "<<dt);
+  return this;
+}
+
+VISU_Convertor* VISU_MEDConvertor::Build() throw (std::runtime_error&){
+  if(mySObject->_is_nil()) 
+    throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");
+  SALOMEDS::Study_var aStudy = mySObject->GetStudy();
+
+  CORBA::Object_var aMedObject = SObjectToObject(mySObject);
+  if(!CORBA::is_nil(aMedObject)){
+    SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
+    if(!aMED->_is_nil()){
+      CORBA::Short aTag = mySObject->Tag();
+      SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
+      SALOMEDS::SObject_var aMeshSObj;
+      CORBA::Boolean aBool = aMedCompSObj->FindSubObject(aTag+1,aMeshSObj);
+      if(!aBool) throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!");
+      if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found.");
+      SALOMEDS::ChildIterator_var aMeshIterator = aStudy->NewChildIterator(aMeshSObj);
+      for(; aMeshIterator->More(); aMeshIterator->Next()){
+       aMeshSObj = aMeshIterator->Value();
+       if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'");
+       CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj);
+       if(CORBA::is_nil(aMedMesh)) continue;
+       SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh);
+       if(aMEDMesh->_is_nil()) continue;
+       CORBA::String_var aMeshName = aMEDMesh->getName();
+       VISU::TMesh &aMesh = myMeshMap[aMeshName.in()];
+       aMesh.myDim = aMEDMesh->getSpaceDimension();
+       aMesh.myName = aMeshName.in();
+       VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()];
+       aMesh2.myMesh = aMEDMesh;
+       if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
+       SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aMeshSObj);
+       for(; aSupportIterator->More(); aSupportIterator->Next()){
+         SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
+         CORBA::Object_var aMedSupport = SObjectToObject(aSupportSObj);
+         if(CORBA::is_nil(aMedSupport)) continue;
+         SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport); 
+         if(aMEDSupport->_is_nil()) continue;
+         SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
+         VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
+         CORBA::String_var aSupportName = aMEDSupport->getName();
+         bool isDataPresent = false;
+         if(aMEDSupport->isOnAllElements()){
+           if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' anEntity = "<<anEntity);
+           //Check, if there is any data on the support?
+           SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
+           if(anEntity == VISU::NODE_ENTITY){
+             if(aMeshOnSupport->getNumberOfNodes() > 0) 
+               isDataPresent = true;
+           }else{
+             int iGeomElemEnd;
+             int* aGeomElemVector;
+             GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
+             const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[anEntity];
+             for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
+               int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
+               SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
+               med_int iNumElemEnd = aMeshOnSupport->getNumberOfElements(aMedEntity,aMedType);
+               if(iNumElemEnd > 0) {
+                 isDataPresent = true;
+                 break;
+               }
+             }
+           }
+           if(!isDataPresent) continue;
+           VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+           aMeshOnEntity.myEntity = anEntity;
+           aMeshOnEntity.myMeshName = aMeshName.in();
+           VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
+           aMeshOnEntity2.mySupport = aMEDSupport;
+         }else{
+           SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
+           if(!aMEDFamily->_is_nil()) {
+             if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' anEntity = "<<anEntity);
+             VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+             VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aSupportName.in()];
+             aFamily.myName = aSupportName.in();
+             aFamily.myEntity = anEntity;
+             aFamily.myId = aMEDFamily->getIdentifier();
+             VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
+             VISUMED::TFamily& aFamily2 = aMeshOnEntity2.myFamilyMap[aSupportName.in()];
+             aFamily2.myFamily = aMEDFamily;
+           }
+           SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
+           if(!aMEDGroup->_is_nil()) {
+             if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' anEntity = "<<anEntity);
+             VISUMED::TGroupMap& aGroupMap2 = aMesh2.myGroupMap;
+             VISUMED::TGroup& aGroup2 = aGroupMap2[aSupportName.in()];
+             aGroup2.myGroup = aMEDGroup;
+             //VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
+             //VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+             //VISU::TGroup& aGroup = aGroupMap[aSupportName.in()];
+             //aGroup.myName = aSupportName.in();
+             //aGroup.myMeshName = aMesh.myName;
+             SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
+             int iFamilyEnd = aFamilies->length();
+             for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
+               aMEDFamily = aFamilies[iFamaily];
+               CORBA::String_var aFamilyName = aMEDFamily->getName();
+               VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+               VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyName.in()];
+               VISU::TBindGroups& aBindGroups = aFamily.myGroups;
+               aBindGroups.insert(aSupportName.in());
+             }
+           }
+         }
+       }
+       //Correction of TMesh.TGroupMap
+       const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
+       if(aMeshOnEntityMap.empty()) continue;
+       VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
+       VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+         const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+         const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
+         if(aFamilyMap.empty()) continue;
+         VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+         for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+           const VISU::TFamily& aFamily = aFamilyMapIter->second;
+           const VISU::TBindGroups& aBindGroups = aFamily.myGroups;
+           if(aBindGroups.empty()) continue;
+           VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin();
+           for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){
+             const string& aGroupName = *aBindGroupsIter;
+             VISU::TGroup& aGroup = aGroupMap[aGroupName];
+             aGroup.myName = aGroupName;
+             aGroup.myMeshName = aMesh.myName;
+             VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity);
+             aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity);
+           }
+         }
+       }
+      }
+      SALOMEDS::SObject_var aFieldSObj;
+      aBool = aMedCompSObj->FindSubObject(aTag+2,aFieldSObj);
+      if(aBool){
+       if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
+       SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldSObj);
+       for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
+         aFieldSObj = aFieldIterator->Value();
+         if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'");
+         SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
+         for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
+           SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
+           if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'");
+           CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj);
+           if(CORBA::is_nil(aMedField)) continue;
+           SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
+           if(aMEDField->_is_nil()) continue;
+           SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
+           if(aMEDSupport->_is_nil()) continue;
+           SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
+           VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
+           SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
+           if(aMEDMesh->_is_nil()) continue;
+           CORBA::String_var aMeshName = aMEDMesh->getName();
+           CORBA::String_var aFieldName = aMEDField->getName();
+
+           VISU::TMesh &aMesh = myMeshMap[aMeshName.in()];
+           aMesh.myDim = aMEDMesh->getSpaceDimension();
+           aMesh.myName = aMeshName.in();
+           VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()];
+           aMesh2.myMesh = aMEDMesh;
+
+           VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+           aMeshOnEntity.myEntity = anEntity;
+           aMeshOnEntity.myMeshName = aMeshName.in();
+           VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
+           aMeshOnEntity2.mySupport = aMEDSupport;
+           if(anEntity == VISU::NODE_ENTITY){
+             aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myEntity = VISU::CELL_ENTITY;
+             aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myMeshName = aMeshName.in();
+             aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
+           }
+
+           VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()];
+           aField.myId = iField;
+           aField.myName = aFieldName.in();
+           aField.myEntity = anEntity;
+           aField.myMeshName = aMeshName.in();
+           aField.myNbComp = aMEDField->getNumberOfComponents();
+           aField.myCompNames.resize(aField.myNbComp);
+           aField.myUnitNames.resize(aField.myNbComp);
+           //int iTimeStamp = aMEDField->getOrderNumber();
+           int iTimeStamp = aMEDField->getIterationNumber();
+           VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp];
+           aValForTime.myId = iTimeStamp;
+           double dt = aMEDField->getTime();
+           aValForTime.myTime = VISU::TField::TTime(dt,"");
+
+           VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
+           VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp];
+           aValForTime2.myField = aMEDField;
+           if(MYDEBUG) 
+             MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myEntity = "<<anEntity<<"; myTime = "<<dt);
+         }      
+       }
+      }
+      return this; 
+    }
+    return NULL; 
+  }
+  SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
+  for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){
+    SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'");
+    CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj);
+    if(CORBA::is_nil(aMedField)) continue;
+    SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
+    if(aMEDField->_is_nil()) continue;
+    SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
+    if(aMEDSupport->_is_nil()) continue;
+    SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
+    VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
+    SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
+    if(aMEDMesh->_is_nil()) continue;
+    CORBA::String_var aMeshName = aMEDMesh->getName();
+    CORBA::String_var aFieldName = aMEDField->getName();
+
+    VISU::TMesh &aMesh = myMeshMap[aMeshName.in()];
+    aMesh.myDim = aMEDMesh->getSpaceDimension();
+    aMesh.myName = aMeshName.in();
+    VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()];
+    aMesh2.myMesh = aMEDMesh;
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
+
+    VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
+    aMeshOnEntity.myEntity = anEntity;
+    aMeshOnEntity.myMeshName = aMeshName.in();
+    VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
+    aMeshOnEntity2.mySupport = aMEDSupport;
+    if(anEntity == VISU::NODE_ENTITY){
+      aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myEntity = VISU::CELL_ENTITY;
+      aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myMeshName = aMeshName.in();
+      aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
+    }
+
+    VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()];
+    CORBA::Short iField = mySObject->Tag();
+    aField.myId = iField;
+    aField.myName = aFieldName.in();
+    aField.myEntity = anEntity;
+    aField.myMeshName = aMeshName.in();
+    aField.myNbComp = aMEDField->getNumberOfComponents();
+    aField.myCompNames.resize(aField.myNbComp);
+    aField.myUnitNames.resize(aField.myNbComp);
+    //int iTimeStamp = aMEDField->getOrderNumber();
+    int iTimeStamp = aMEDField->getIterationNumber();
+    VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp];
+    aValForTime.myId = iTimeStamp;
+    double dt = aMEDField->getTime();
+    aValForTime.myTime = VISU::TField::TTime(dt,"");
+
+    VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
+    VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp];
+    aValForTime2.myField = aMEDField;
+    if(MYDEBUG) 
+      MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myEntity = "<<anEntity<<"; myTime = "<<dt);
+  }
+  return this; 
+}
+
+int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, 
+                                       const string& theFamilyName)
+     throw (std::runtime_error&) 
+{
+  //Main part of code
+  const string& aMeshName = theMeshOnEntity.myMeshName;
+  const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
+  VISU::TMesh& aMesh = myMeshMap[aMeshName];
+  int isPointsUpdated;
+  if(anEntity == VISU::NODE_ENTITY) 
+    isPointsUpdated = LoadPoints(aMesh,theFamilyName);
+  else 
+    isPointsUpdated = LoadPoints(aMesh);
+  int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity,theFamilyName);
+
+  return (isPointsUpdated || isCellsOnEntityUpdated);
+}
+  
+int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, 
+                                      const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
+     throw (std::runtime_error&)
+{
+  //Main part of code
+  int isPointsUpdated = 0;
+  int isCellsOnEntityUpdated = 0;
+  VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
+  for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
+    const string& aFamilyName = aFamilyAndEntitySetIter->first;
+    const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second;
+    VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity];
+    if(anEntity == VISU::NODE_ENTITY){
+      isPointsUpdated += LoadPoints(theMesh,aFamilyName);
+      isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity);
+    }else{
+      isPointsUpdated += LoadPoints(theMesh);
+      isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity,aFamilyName);
+    }
+  }
+
+  return (isPointsUpdated || isCellsOnEntityUpdated);
 }
 
 void VISU_CorbaMedSupportConvertor::SetSupport(SALOME_MED::SUPPORT_ptr theSupport) {