Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / VISU_I / VISU_CorbaMedConvertor.cxx
index 2c1d3a0f55a8a0677c70636a47a51234a32cf672..56c39876d4d2fea091de8ace7501fd8a9826bde7 100644 (file)
 //  Copyright (C) 2003  CEA/DEN, EDF R&D
 
 #include "VISU_CorbaMedConvertor.hxx"
-#include "VISU_ConvertorUtils.hxx"
 
-#include <valarray>    
 #include <vtkCellType.h>
 
-using namespace VISU;
+#include <boost/tuple/tuple.hpp>
+
 using namespace std;
+using namespace VISU;
 
 #define USER_INTERLACE MED_FULL_INTERLACE
 
@@ -43,270 +43,348 @@ static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
-static med_err ret = 0;
 
 extern "C" {
-  VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) {
+  VISU_Convertor* 
+  CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) 
+  {
     return new VISU_MEDConvertor(theMedSObject);
   }
-  VISU_Convertor* CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) {
+
+  VISU_Convertor* 
+  CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) 
+  {
     return new VISU_MEDFieldConvertor(theField);
   }
 }
 
-typedef map<VISU::TEntity,SALOME_MED::medEntityMesh> TVisu2MedEntity;
-static TVisu2MedEntity aVisu2MedEntity;
-typedef map<SALOME_MED::medEntityMesh,VISU::TEntity> TMed2VisuEntity;
-static TMed2VisuEntity aMed2VisuEntity;
-static int INIT = (
-                  aVisu2MedEntity[VISU::CELL_ENTITY] = SALOME_MED::MED_CELL,
-                  aVisu2MedEntity[VISU::FACE_ENTITY] = SALOME_MED::MED_FACE,
-                  aVisu2MedEntity[VISU::EDGE_ENTITY] = SALOME_MED::MED_EDGE,
-                  aVisu2MedEntity[VISU::NODE_ENTITY] = SALOME_MED::MED_NODE,
-
-                  aMed2VisuEntity[SALOME_MED::MED_CELL] = VISU::CELL_ENTITY,
-                  aMed2VisuEntity[SALOME_MED::MED_FACE] = VISU::FACE_ENTITY,
-                  aMed2VisuEntity[SALOME_MED::MED_EDGE] = VISU::EDGE_ENTITY,
-                  aMed2VisuEntity[SALOME_MED::MED_NODE] = VISU::NODE_ENTITY,
-
-                  1);
-
-static int CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
-  SALOME_MED::MED_POINT1,
-  SALOME_MED::MED_SEG2,
-  SALOME_MED::MED_SEG3,
-  SALOME_MED::MED_TRIA3,
-  SALOME_MED::MED_QUAD4,
-  SALOME_MED::MED_TRIA6,
-  SALOME_MED::MED_QUAD8,
-  SALOME_MED::MED_TETRA4,
-  SALOME_MED::MED_PYRA5,
-  SALOME_MED::MED_PENTA6,
-  SALOME_MED::MED_HEXA8,
-  SALOME_MED::MED_TETRA10,
-  SALOME_MED::MED_PYRA13,
-  SALOME_MED::MED_PENTA15,
-  SALOME_MED::MED_HEXA20
-};
-
-static const int VTKCELLGEOMEND = 8;
-static int VTKCELLGEOM[VTKCELLGEOMEND] = {
-  SALOME_MED::MED_POINT1,
-  SALOME_MED::MED_SEG2,
-  SALOME_MED::MED_TRIA3,
-  SALOME_MED::MED_QUAD4,
-  SALOME_MED::MED_TETRA4,
-  SALOME_MED::MED_PYRA5,
-  SALOME_MED::MED_PENTA6,
-  SALOME_MED::MED_HEXA8
-};
-
-static int FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
-  SALOME_MED::MED_TRIA3,
-  SALOME_MED::MED_QUAD4,
-  SALOME_MED::MED_TRIA6,
-  SALOME_MED::MED_QUAD8
-};
-
-static int EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
-  SALOME_MED::MED_SEG2,
-  SALOME_MED::MED_SEG3
-};
-
-static int NODEGEOM[1] = {
-  SALOME_MED::MED_POINT1,
-};
-
-void GetEntity2Geom(const VISU::TEntity& theEntity, int*& theVector, int* theEnd)
-{
-  switch(theEntity){
-  case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break;
-  case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break;
-  case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break;
-  case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break;
-  default:
-    throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect !!!");
+namespace{
+  using namespace SALOME_MED;
+  
+  const int MED_NBR_GEOMETRIE_MAILLE = 15;
+  
+  medGeometryElement 
+  CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
+    MED_POINT1,
+    MED_SEG2,
+    MED_SEG3,
+    MED_TRIA3,
+    MED_QUAD4,
+    MED_TRIA6,
+    MED_QUAD8,
+    MED_TETRA4,
+    MED_PYRA5,
+    MED_PENTA6,
+    MED_HEXA8,
+    MED_TETRA10,
+    MED_PYRA13,
+    MED_PENTA15,
+    MED_HEXA20
+  };
+  
+  const int MED_NBR_GEOMETRIE_FACE = 4;
+  
+  medGeometryElement
+  FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
+    MED_TRIA3,
+    MED_QUAD4,
+    MED_TRIA6,
+    MED_QUAD8
+  };
+  
+  const int MED_NBR_GEOMETRIE_ARETE = 2;
+  
+  medGeometryElement
+  EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
+    MED_SEG2,
+    MED_SEG3
+  };
+  
+  const int MED_NBR_GEOMETRIE_NODE = 1;
+  
+  medGeometryElement
+  NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
+    MED_POINT1,
+  };
+  
+  int GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
+  {
+    switch(theEntity){
+    case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break;
+    case FACE_ENTITY: theVector = FACEGEOM; return MED_NBR_GEOMETRIE_FACE; break;
+    case EDGE_ENTITY: theVector = EDGEGEOM; return MED_NBR_GEOMETRIE_ARETE; break;
+    case NODE_ENTITY: theVector = NODEGEOM; return MED_NBR_GEOMETRIE_NODE; break;
+    }
+    return -1;
   }
-}
-
-struct SalomeMed2vtk {
-  SALOME_MED::medGeometryElement medType;
-  char *medName;
-  int medNbNodes;
-  int vtkType;
-  char *vtkName;
-  int vtkNbNodes;
-};
-
-#define CORBAMED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \
- {SALOME_MED::MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES}
-static SalomeMed2vtk salome_med2vtk[SALOME_MED::MED_ALL_ELEMENTS] = {
-  {SALOME_MED::MED_NONE,"MED_NONE",0,VTK_EMPTY_CELL,"VTK_EMPTY_CELL",0},
-  CORBAMED2VTK(MED_POINT1,VTK_VERTEX,1),
-  CORBAMED2VTK(MED_SEG2,VTK_LINE,2),
-  CORBAMED2VTK(MED_SEG3,VTK_LINE,2),
-  CORBAMED2VTK(MED_TRIA3,VTK_TRIANGLE,3),
-  CORBAMED2VTK(MED_QUAD4,VTK_QUAD,4),
-  CORBAMED2VTK(MED_TRIA6,VTK_TRIANGLE,3),
-  CORBAMED2VTK(MED_QUAD8,VTK_QUAD,4),
-  CORBAMED2VTK(MED_TETRA4,VTK_TETRA,4),
-  CORBAMED2VTK(MED_PYRA5,VTK_PYRAMID,5),
-  CORBAMED2VTK(MED_PENTA6,VTK_WEDGE,6),
-  CORBAMED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8),
-  CORBAMED2VTK(MED_TETRA10,VTK_TETRA,4),
-  CORBAMED2VTK(MED_PYRA13,VTK_PYRAMID,5),
-  CORBAMED2VTK(MED_PENTA15,VTK_WEDGE,6),
-  CORBAMED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8)
-};
-#undef CORBAMED2VTK
-
-int GetIdMEDType(int medType){
-  for(int i = 0; i < SALOME_MED::MED_ALL_ELEMENTS; i++)
-    if(salome_med2vtk[i].medType == medType) return i;
-  return -1;
-}
-
-string GetName(SALOMEDS::SObject_ptr aSObject){
-  SALOMEDS::GenericAttribute_var anAttr;
-  if (aSObject->FindAttribute(anAttr,"AttributeName")) {
-    SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    CORBA::String_var aString = aName->Value();
-    return aString.in();
+  
+  int MEDGeom2NbNodes(int theMEDGeomType)
+  { 
+    switch(theMEDGeomType){
+    case MED_NONE: return 0;
+    case MED_POINT1: return 1;
+    case MED_SEG2: return 2;
+    case MED_SEG3: return 3;
+    case MED_TRIA3: return 3;
+    case MED_TRIA6: return 6;
+    case MED_QUAD4: return 4;
+    case MED_QUAD8: return 8;
+    case MED_TETRA4: return 4;
+    case MED_TETRA10: return 10;
+    case MED_HEXA8: return 8;
+    case MED_HEXA20: return 20;
+    case MED_PENTA6: return 6;
+    case MED_PENTA15: return 15;
+    case MED_PYRA5: return 5;
+    case MED_PYRA13: return 13;
+    }
+    return -1;
   }
-  return "";
-}
-
-
-static void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
-                        SALOME_MED::MESH_ptr theMEDMesh,
-                        const VISU::TEntity& theEntity)
-{
-  int iGeomElemEnd;
-  int* aGeomElemVector;
-  GetEntity2Geom(theEntity,aGeomElemVector,&iGeomElemEnd);
-  theNbCells = theCellsSize = 0;
-  const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[theEntity];
-  if(MYDEBUG) MESSAGE("GetCellsSize - theEntity = "<<theEntity);
-  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 = theMEDMesh->getNumberOfElements(aMedEntity,aMedType);
-    if(iNumElemEnd > 0){
-      if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
-      theNbCells += iNumElemEnd;
-      theCellsSize += iNumElemEnd*(salome_med2vtk[medId].vtkNbNodes + 1);
+  
+  int MEDGeomToVTK(medGeometryElement theMEDGeomType)
+  { 
+    switch(theMEDGeomType){
+    case MED_NONE: return VTK_EMPTY_CELL;
+    case MED_POINT1: return VTK_VERTEX;
+    case MED_SEG2: return VTK_LINE;
+    case MED_SEG3: return VTK_LINE;
+    case MED_TRIA3: return VTK_TRIANGLE;
+    case MED_TRIA6: return VTK_TRIANGLE;
+    case MED_QUAD4: return VTK_QUAD;
+    case MED_QUAD8: return VTK_QUAD;
+    case MED_TETRA4: return VTK_TETRA;
+    case MED_TETRA10: return VTK_TETRA;
+    case MED_HEXA8: return VTK_HEXAHEDRON;
+    case MED_HEXA20: return VTK_HEXAHEDRON;
+    case MED_PENTA6: return VTK_WEDGE;
+    case MED_PENTA15: return VTK_WEDGE;
+    case MED_PYRA5: return VTK_PYRAMID;
+    case MED_PYRA13: return VTK_PYRAMID;
     }
+    return -1;
   }
-}
-
-
-static void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
-                        SALOME_MED::FAMILY_ptr theMEDFamily)
-{
-  SALOME_MED::medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
-  med_int iGeomElemEnd = aGeom->length();
-  theNbCells = theCellsSize = 0;
-  if(MYDEBUG) MESSAGE("GetCellsSize - iGeomElemEnd = "<<iGeomElemEnd);
-  for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
-    SALOME_MED::medGeometryElement aGeomType = aGeom[iGeomElem];
-    SALOME_MED::long_array_var aCellNumForType = theMEDFamily->getNumber(aGeomType);
-    int medId = GetIdMEDType(aGeomType);
-    med_int iNumElemEnd = aCellNumForType->length();
-    if(iNumElemEnd > 0){
-      if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
-      theNbCells += iNumElemEnd;
-      theCellsSize += iNumElemEnd*(salome_med2vtk[medId].vtkNbNodes + 1);
+  
+  int VTKGeom2NbNodes(int theVTKGeomType)
+  { 
+    switch(theVTKGeomType){
+    case VTK_VERTEX: return 1;
+    case VTK_LINE: return 2;
+    case VTK_TRIANGLE: return 3;
+    case VTK_QUAD: return 4;
+    case VTK_TETRA: return 4;
+    case VTK_HEXAHEDRON: return 8;
+    case VTK_WEDGE: return 6;
+    case VTK_PYRAMID: return 5;
     }
+    return -1;
   }
-}
-
-
-static void GetCellsSize(VISU::TMesh& theMesh, 
-                        SALOME_MED::MESH_ptr theMEDMesh, 
-                        const VISU::TEntity& theEntity)
-{
-  VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[theEntity];
-  if(theEntity == VISU::NODE_ENTITY){
-    theMesh.myNbPoints = theMEDMesh->getNumberOfNodes();
-    aMeshOnEntity.myNbCells = theMesh.myNbPoints;
-    aMeshOnEntity.myCellsSize = 2*theMesh.myNbPoints;
-    vtkIdType aNbCells, aCellsSize;
-    GetCellsSize(aNbCells,aCellsSize,theMEDMesh,VISU::CELL_ENTITY);
-    if(aNbCells > 0){
-      VISU::TMeshOnEntity& aMeshOnCells = theMesh.myMeshOnEntityMap[VISU::CELL_ENTITY];
-      aMeshOnCells.myEntity = VISU::CELL_ENTITY;
-      aMeshOnCells.myMeshName = theMesh.myName;
-      aMeshOnCells.myNbCells = aNbCells;
-      aMeshOnCells.myCellsSize = aCellsSize;
+  
+  medGeometryElement VTKGeomToMED(int theVTKGeomType)
+  { 
+    switch(theVTKGeomType){
+    case VTK_VERTEX: return MED_POINT1;
+    case VTK_LINE: return MED_SEG2;
+    case VTK_TRIANGLE: return MED_TRIA3;
+    case VTK_QUAD: return MED_QUAD4;
+    case VTK_TETRA: return MED_TETRA4;
+    case VTK_HEXAHEDRON: return MED_HEXA8;
+    case VTK_WEDGE: return MED_PENTA6;
+    case VTK_PYRAMID: return MED_PYRA5;
+    }
+    return medGeometryElement(-1);
+  }
+  
+  VISU::TEntity MEDEntityToVTK(medEntityMesh theMEDEntity)
+  {
+    switch(theMEDEntity){
+    case MED_NODE: return NODE_ENTITY;
+    case MED_EDGE: return EDGE_ENTITY;
+    case MED_FACE: return FACE_ENTITY;
+    case MED_CELL: return CELL_ENTITY;
     }
-  }else
-    GetCellsSize(aMeshOnEntity.myNbCells,aMeshOnEntity.myCellsSize,theMEDMesh,theEntity);
+    return VISU::TEntity(-1);
+  }
+  
+  medEntityMesh VTKEntityToMED(VISU::TEntity theVTKEntity)
+  {
+    switch(theVTKEntity){
+    case NODE_ENTITY: return MED_NODE;
+    case EDGE_ENTITY: return MED_EDGE;
+    case FACE_ENTITY: return MED_FACE;
+    case CELL_ENTITY: return MED_CELL;
+    }
+    return medEntityMesh(-1);
+  }
+  
+  string GetSObjectName(SALOMEDS::SObject_ptr aSObject){
+    SALOMEDS::GenericAttribute_var anAttr;
+    if (aSObject->FindAttribute(anAttr,"AttributeName")) {
+      SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+      CORBA::String_var aString = aName->Value();
+      return aString.in();
+    }
+    return "";
+  }
+  
+  void 
+  GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
+              SALOME_MED::MESH_ptr theMEDMesh,
+              const VISU::TEntity& theVEntity)
+  {
+    medGeometryElement* aGeomElems;
+    theNbCells = theCellsSize = 0;
+    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;
+       }
+      }
+  }
+  
+  
+  void 
+  GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
+              SALOME_MED::FAMILY_ptr theMEDFamily)
+  {
+    medGeometryElement_array_var aGeom = theMEDFamily->getTypes();
+    int iGeomEnd = aGeom->length();
+    theNbCells = theCellsSize = 0;
+    if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+      medGeometryElement aMEDGeom = aGeom[iGeom];
+      long_array_var aCellNumForType = theMEDFamily->getNumber(aMEDGeom);
+      int iNumElemEnd = aCellNumForType->length();
+      if(iNumElemEnd > 0){
+       if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
+       theNbCells += iNumElemEnd;
+       theCellsSize += iNumElemEnd*(MEDGeom2NbNodes(aMEDGeom) + 1);
+      }
+    }
+  }
+  
+  
+  void
+  GetCellsSize(VISU::PCMesh theMesh, 
+              SALOME_MED::MESH_ptr theMEDMesh, 
+              const VISU::TEntity& theEntity)
+  {
+    TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+    VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
+    if(theEntity == NODE_ENTITY){
+      theMesh->myNbPoints = theMEDMesh->getNumberOfNodes();
+      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);
+    }
+  }
+  
 }
 
 
-VISU_Convertor* VISU_MEDFieldConvertor::Build() {
+VISU_Convertor* 
+VISU_MEDFieldConvertor::Build()
+{
   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::medEntityMesh aMEntity = aMEDSupport->getEntity();
+  TEntity aVEntity = MEDEntityToVTK(aMEntity);
   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.myPointsDim.resize(aMesh.myDim);
-  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)
-    aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
-  GetCellsSize(aMesh,aMEDMesh,anEntity);
-
-  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.myNbValField = 1;
-  aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp;
-  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;
+  PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+  aMesh->myDim = aMEDMesh->getSpaceDimension();
+  aMesh->myPointsDim.resize(aMesh->myDim);
+  aMesh->myName = aMeshName.in();
+  aMesh->myMesh = aMEDMesh;
+
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+  TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+  PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+  aMeshOnEntity->myEntity = aVEntity;
+  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);
+
+  TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+  PCField aField = aFieldMap[aFieldName.in()](new TCField());
+  aField->myId = myField->getOrderNumber();
+  aField->myName = aFieldName.in();
+  aField->myEntity = aVEntity;
+  aField->myMeshName = aMeshName.in();
+  aField->myNbComp = myField->getNumberOfComponents();
+  aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+  aField->myCompNames.resize(aField->myNbComp);
+  aField->myUnitNames.resize(aField->myNbComp);
+
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+  TValField& aValField = aField->myValField;
+  int anId = myField->getIterationNumber();
+  PCValForTime aValForTime = aValField[anId](new TCValForTime());
+  aValForTime->myId = anId;
+  CORBA::Double aDT = myField->getTime();
+  aValForTime->myTime = TTime(aDT,"");
+  aValForTime->myField = myField;
+
   if(MYDEBUG) 
-    MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<"'; myId = "<<aField.myId<<"; myTime = "<<dt);
+    MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
+           "'; myId = "<<anId<<"; myTime = "<<aDT);
+
   return this;
 }
 
-VISU_Convertor* VISU_MEDConvertor::Build() {
+
+VISU_Convertor* 
+VISU_MEDConvertor::Build() 
+{
   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);
+  CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject);
   if(!CORBA::is_nil(aMedObject)){
     SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
     return Build(aMED);
@@ -316,194 +394,362 @@ VISU_Convertor* VISU_MEDConvertor::Build() {
   return Build(aTimeStampIterator);
 }
 
+namespace{
+
+  using namespace boost;
+
+  struct TSObjectByName{
+    std::string myName;
+    typedef tuple<SALOMEDS::SObject_var> TRet;
+
+    TSObjectByName(const std::string& theName):
+      myName(theName)
+    {}
+
+    TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
+    {
+      SALOMEDS::GenericAttribute_var anAttr;
+      if(theSObj->FindAttribute(anAttr,"AttributeName")){
+       SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+       CORBA::String_var aValue = aName->Value();
+       theIsSuccess = (myName == aValue.in());
+       if(theIsSuccess)
+         return TRet(SALOMEDS::SObject::_duplicate(theSObj));
+      }
+      return TRet();
+    }
+
+  };
+
+  struct TMeshByName{
+    std::string myName;
+    typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
 
-VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
+    TMeshByName(const std::string& theName):
+      myName(theName)
+    {}
+
+    TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
+    {
+      CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);
+      if(!CORBA::is_nil(anObj)){
+       SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
+       if(!CORBA::is_nil(aMesh)){
+         CORBA::String_var aName = aMesh->getName();
+         theIsSuccess = (myName == aName.in());
+         if(theIsSuccess)
+           return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));
+       }
+      }
+      return TRet();
+    }
+  };
+
+  template<typename TFun>
+  typename TFun::TRet
+  Find(SALOMEDS::SObject_ptr theStartSObj, 
+       SALOMEDS::Study_ptr theStudy,
+       TFun theFun,
+       bool& theIsSuccess,
+       bool theIsAllLevels = true)
+  {
+    SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj);
+    anIter->InitEx(theIsAllLevels);
+    for(; anIter->More(); anIter->Next()){
+      SALOMEDS::SObject_var aSObj = anIter->Value();
+      typename TFun::TRet aRet = theFun(aSObj,theIsSuccess);
+      if(theIsSuccess)
+       return aRet;
+    }
+    return typename TFun::TRet();
+  }
+
+}
+
+VISU_Convertor* 
+VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
 {
-  if(theMED->_is_nil()) return NULL;
-  CORBA::Short aTag = mySObject->Tag();
-  SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
-  SALOMEDS::SObject_var aMeshSObj;
-  if(!aMedCompSObj->FindSubObject(aTag+1,aMeshSObj)) 
-    throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!");
-  if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found.");
+  if(CORBA::is_nil(theMED)) 
+    return NULL;
+
+  CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();
+  SALOME_MED::string_array_var aMeshNames = theMED->getMeshNames();
+  if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);
+
   SALOMEDS::Study_var aStudy = mySObject->GetStudy();
-  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();
-    aMesh.myPointsDim.resize(aMesh.myDim);
-    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::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
-      SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
-      VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
-      CORBA::String_var aSupportName = aMEDSupport->getName();
-      if(aMEDSupport->isOnAllElements()){
-       if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' anEntity = "<<anEntity);
-       int aNbCells, aCellsSize;
-       //Check, if there is any data on the support?
-       if(anEntity == VISU::NODE_ENTITY){
-         aMesh.myNbPoints = aMeshOnSupport->getNumberOfNodes();
-         aNbCells = aMesh.myNbPoints;
-         aCellsSize = 2*aMesh.myNbPoints;
-       }else{
-         GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,anEntity);
+  SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
+
+  bool anIsSuccess = false;
+  TSObjectByName::TRet aSObjectByNameRet = 
+    Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);
+  if(MYDEBUG) 
+    MESSAGE("VISU_MEDConvertor::Build - Find ('"<<"MEDMESH"<<"') = "<<anIsSuccess);
+  if(anIsSuccess){
+    SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(aSObjectByNameRet);
+    for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
+      anIsSuccess = false;
+      CORBA::String_var aMeshName = aMeshNames[iMesh];
+      TMeshByName::TRet aMeshByNameRet = 
+       Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess);
+      if(MYDEBUG) 
+       MESSAGE("VISU_MEDConvertor::Build - Find aMeshName('"<<aMeshName.in()<<"') = "<<anIsSuccess);
+      if(!anIsSuccess)
+       continue;
+
+      PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+      SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
+      aMesh->myDim = aMEDMesh->getSpaceDimension();
+      aMesh->myName = aMeshName.in();
+      aMesh->myPointsDim.resize(aMesh->myDim);
+      aMesh->myMesh = aMEDMesh;
+
+      if(MYDEBUG) 
+       MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
+
+      std::string aName = aMeshName.in();
+      std::replace(aName.begin(),aName.end(),' ','_');
+
+      anIsSuccess = false;
+      std::ostringstream aStream;
+      aStream<<"MEDSUPPORTS_OF_"<<aName;
+      std::string aSupportsName(aStream.str());
+      TSObjectByName::TRet aSObjectByNameRet = 
+       Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);
+      if(MYDEBUG) 
+       MESSAGE("VISU_MEDConvertor::Build - Find aSupportsName('"<<aSupportsName<<"') = "<<anIsSuccess);
+      if(!anIsSuccess)
+       continue;
+
+      TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);
+      SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);
+
+      // Fill all MeshOnEntity
+      aSupportIterator->InitEx(true);
+      for(; aSupportIterator->More(); aSupportIterator->Next()){
+       SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
+       
+       CORBA::Object_var aMedSupport = VISU::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::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
+       SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
+       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+       CORBA::String_var aSupportName = aMEDSupport->getName();
+       
+       if(aMEDSupport->isOnAllElements() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<
+                   "' aVEntity = "<<aVEntity);
+         int aNbCells, aCellsSize;
+         //Check, if there is any data on the support?
+         if(aVEntity == NODE_ENTITY){
+           aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
+           aNbCells = aMesh->myNbPoints;
+           aCellsSize = 2*aMesh->myNbPoints;
+         }else
+           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;
+         }
        }
-       if(aNbCells == 0) continue;
-       VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
-       aMeshOnEntity.myMeshName = aMeshName.in();
-       aMeshOnEntity.myEntity = anEntity;
-       aMeshOnEntity.myNbCells = aNbCells;
-       aMeshOnEntity.myCellsSize = aCellsSize;
+      }
+
+      // Fill all Family
+      aSupportIterator->InitEx(true);
+      for(; aSupportIterator->More(); aSupportIterator->Next()){
+       SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
+       
+       CORBA::Object_var aMedSupport = VISU::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::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
+       SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
+       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+       CORBA::String_var aSupportName = aMEDSupport->getName();
        
-       VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
-       aMeshOnEntity2.mySupport = aMEDSupport;
-      }else{
        SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
        if(!aMEDFamily->_is_nil()) {
-         int aNbCells, aCellsSize;
-         GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
+         TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+         if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+           continue;
+         PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+         int aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
+         CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
+         if(!anIsOnAllElements)
+           GetCellsSize(aNbCells,aCellsSize,aMEDFamily);
+
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<
+                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+                   "; aVEntity = "<<aVEntity<<
+                   "; aNbCells = "<<aNbCells);
+
          if(aNbCells > 0){
-           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.myNbCells = aNbCells;
-           aFamily.myCellsSize = aCellsSize;
-           aFamily.myId = aMEDFamily->getIdentifier();
-           
-           VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
-           VISUMED::TFamily& aFamily2 = aMeshOnEntity2.myFamilyMap[aSupportName.in()];
-           aFamily2.myFamily = aMEDFamily;
+           TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+           PCFamily aFamily = aFamilyMap[aSupportName.in()](new TCFamily());
+           aFamily->myName = aSupportName.in();
+           aFamily->myEntity = aVEntity;
+           aFamily->myNbCells = aNbCells;
+           aFamily->myCellsSize = aCellsSize;
+           aFamily->myId = aMEDFamily->getIdentifier();
+           aFamily->myFamily = aMEDFamily;
          }
        }
+      }
+       
+      // Fill all Groups
+      aSupportIterator->InitEx(true);
+      for(; aSupportIterator->More(); aSupportIterator->Next()){
+       SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
+       
+       CORBA::Object_var aMedSupport = VISU::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::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
+       SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
+       VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+       CORBA::String_var aSupportName = aMEDSupport->getName();
+       
        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;
+       if(!aMEDGroup->_is_nil()){
+         CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
+
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<
+                   "'; anIsOnAllElements = "<<anIsOnAllElements<<
+                   "; aVEntity = "<<aVEntity);
+
+         PCGroup aGroup(new TCGroup());
+         aGroup->myGroup = aMEDGroup;
+         aGroup->myName = aSupportName.in();
+         aGroup->myMeshName = aMeshName.in();
+         VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
+         
          SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
          int iFamilyEnd = aFamilies->length();
          for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
-           aMEDFamily = aFamilies[iFamaily];
+           SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
            CORBA::String_var aFamilyName = aMEDFamily->getName();
-           VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
-           if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"'");
-           VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyName.in()];
-           VISU::TBindGroups& aBindGroups = aFamily.myGroups;
-           aBindGroups.insert(aSupportName.in());
+           PFamily aFamily = FindFamily(aMesh,aFamilyName.in());
+           if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
+           if(aFamily){
+             TFamilyAndEntity aFamilyAndEntity(aFamilyName.in(),aFamily->myEntity);
+             aFamilyAndEntitySet.insert(aFamilyAndEntity);
+             
+             aGroup->myNbCells += aFamily->myNbCells;
+             aGroup->myCellsSize += aFamily->myCellsSize;
+             
+             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;
-         aGroup.myNbCells += aFamily.myNbCells;
-         aGroup.myCellsSize += aFamily.myCellsSize;
-         VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity);
-         aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity);
+         
+         if(!aGroup->myFamilyAndEntitySet.empty()){
+           TGroupMap& aGroupMap = aMesh->myGroupMap;
+           aGroupMap[aSupportName.in()] = aGroup;
+         }
+
        }
       }
     }
   }
-  SALOMEDS::SObject_var aFieldSObj;
-  if(aMedCompSObj->FindSubObject(aTag+2,aFieldSObj)){
+
+  anIsSuccess = false;
+  aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);
+  if(anIsSuccess){
+    SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);
     if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");
-    SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldSObj);
+    SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);
     for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
-      aFieldSObj = aFieldIterator->Value();
-      if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'");
+      SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
+      if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");
       SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);
-      for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){
+      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;
+       if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
+       CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
+       if(CORBA::is_nil(aMedField)) 
+         continue;
+
        SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
-       if(aMEDField->_is_nil()) continue;
+       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];
+       if(aMEDSupport->_is_nil()) 
+         continue;
+
+       SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
+       VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
        SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
-       if(aMEDMesh->_is_nil()) continue;
+       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)
-         aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
-       GetCellsSize(aMesh,aMEDMesh,anEntity);
-       
-       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.myNbValField = iTimeStamp;
-       aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp;
-       if(MYDEBUG && !iTimeStamp) 
-         MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity.myNbCells = "<<aMeshOnEntity.myNbCells);
-       aField.myCompNames.resize(aField.myNbComp);
-       aField.myUnitNames.resize(aField.myNbComp);
-       
+       TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
+       if(aMeshMapIter == myMeshMap.end())
+         continue;
+
+       PCMesh aMesh = aMeshMapIter->second;
+       TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+       TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
+       if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+         continue;
+
+       PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+       TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+       TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+       PCField aField;
+       if(aFieldMapIter == aFieldMap.end()){
+         aField = aFieldMap[aFieldName.in()](new TCField());
+         aField->myId = iField;
+         aField->myName = aFieldName.in();
+         aField->myEntity = anEntity;
+         aField->myMeshName = aMeshName.in();
+         aField->myNbComp = aMEDField->getNumberOfComponents();
+         aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+         if(MYDEBUG) 
+           MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
+         aField->myCompNames.resize(aField->myNbComp);
+         aField->myUnitNames.resize(aField->myNbComp);
+       }else
+         aField = aFieldMapIter->second;
+
+       TValField& aValField = aField->myValField;
        int anId = aMEDField->getIterationNumber();
-       VISU::TField::TValForTime& aValForTime = aField.myValField[anId];
-       aValForTime.myId = anId;
-       aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),"");
-       VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
-       VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId];
-       aValForTime2.myField = aMEDField;
+       PCValForTime aValForTime = aValField[anId](new TCValForTime());
+       aValForTime->myId = anId;
+       CORBA::Double aDT = aMEDField->getTime();
+       aValForTime->myTime = TTime(aDT,"");
+       aValForTime->myField = aMEDField;
        if(MYDEBUG) 
          MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
-                 "'; myEntity = "<<anEntity<<"; myTime = "<<aValForTime.myTime.first);
+                 "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
       }      
     }
   }
@@ -511,91 +757,112 @@ VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
 }
  
 
-VISU_Convertor* VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
+VISU_Convertor* 
+VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
 {
   if(theTimeStampIterator->_is_nil()) return NULL;
-  for(int iTimeStamp = 1; theTimeStampIterator->More(); theTimeStampIterator->Next(), iTimeStamp++){
+  for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
     SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
-    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'");
-    CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj);
-    if(CORBA::is_nil(aMedField)) continue;
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");
+
+    CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);
+    if(CORBA::is_nil(aMedField)) 
+      continue;
+
     SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);
-    if(aMEDField->_is_nil()) continue;
+    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];
+    if(aMEDSupport->_is_nil()) 
+      continue;
+
+    SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
+    TEntity aVEntity = MEDEntityToVTK(aMEntity);
     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.myPointsDim.resize(aMesh.myDim);
-    aMesh.myName = aMeshName.in();
-    aMesh.myNbPoints = aMEDMesh->getNumberOfNodes();
-    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)
-      aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport;
-    GetCellsSize(aMesh,aMEDMesh,anEntity);
-
-    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.myNbValField = iTimeStamp;
-    aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp;
-    if(MYDEBUG && !iTimeStamp) 
-      MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity.myNbCells = "<<aMeshOnEntity.myNbCells);
-    aField.myCompNames.resize(aField.myNbComp);
-    aField.myUnitNames.resize(aField.myNbComp);
+    PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+    aMesh->myDim = aMEDMesh->getSpaceDimension();
+    aMesh->myPointsDim.resize(aMesh->myDim);
+    aMesh->myName = aMeshName.in();
+    aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
+    aMesh->myMesh = aMEDMesh;
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
 
+    TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+    PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+    aMeshOnEntity->myEntity = aVEntity;
+    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);
+    TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+    TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+    PCField aField;
+    if(aFieldMapIter == aFieldMap.end()){
+      aField = aFieldMap[aFieldName.in()](new TCField());
+      CORBA::Short iField = mySObject->Tag();
+      aField->myId = iField;
+      aField->myName = aFieldName.in();
+      aField->myEntity = aVEntity;
+      aField->myMeshName = aMeshName.in();
+      aField->myNbComp = aMEDField->getNumberOfComponents();
+      aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+      if(MYDEBUG) 
+       MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
+      aField->myCompNames.resize(aField->myNbComp);
+      aField->myUnitNames.resize(aField->myNbComp);
+    }
+    TValField& aValField = aField->myValField;
     int anId = aMEDField->getIterationNumber();
-    VISU::TField::TValForTime& aValForTime = aField.myValField[anId];
-    aValForTime.myId = anId;
-    aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),"");
-    VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()];
-    VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId];
-    aValForTime2.myField = aMEDField;
+    PCValForTime aValForTime = aValField[anId](new TCValForTime());
+    aValForTime->myId = anId;
+    CORBA::Double aDT = aMEDField->getTime();
+    aValForTime->myTime = TTime(aDT,"");
+    aValForTime->myField = aMEDField;
     if(MYDEBUG) 
       MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
-             "'; myEntity = "<<anEntity<<"; myTime = "<<aValForTime.myTime.first);
+             "'; myEntity = "<<aVEntity<<"; myTime = "<<aDT);
   }
   return this; 
 }
 
 
-int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, 
-                                       const string& theFamilyName)
+int
+VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                                   const string& theFamilyName)
 {
   //Main part of code
-  const string& aMeshName = theMeshOnEntity.myMeshName;
-  const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
-  VISU::TMesh& aMesh = myMeshMap[aMeshName];
+  const string& aMeshName = theMeshOnEntity->myMeshName;
+  const TEntity& aVEntity = theMeshOnEntity->myEntity;
+  PCMesh aMesh = myMeshMap[aMeshName];
   int isPointsUpdated;
-  if(anEntity == VISU::NODE_ENTITY) 
+  if(aVEntity == NODE_ENTITY) 
     isPointsUpdated = LoadPoints(aMesh,theFamilyName);
   else 
     isPointsUpdated = LoadPoints(aMesh);
-  int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity,theFamilyName);
+  int isCellsOnEntityUpdated = LoadCellsOnEntity(aMesh,theMeshOnEntity,theFamilyName);
 
   return (isPointsUpdated || isCellsOnEntityUpdated);
 }
-  
-int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh, 
-                                      const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
+int 
+VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
+                                  const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
 {
   //Main part of code
   int isPointsUpdated = 0;
@@ -603,143 +870,158 @@ int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh,
   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){
+    const VISU::TEntity& aVEntity = aFamilyAndEntitySetIter->second;
+    PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+    if(aVEntity == VISU::NODE_ENTITY){
       isPointsUpdated += LoadPoints(theMesh,aFamilyName);
-      isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity);
+      isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity);
     }else{
       isPointsUpdated += LoadPoints(theMesh);
-      isCellsOnEntityUpdated += LoadCellsOnEntity(aMeshOnEntity,aFamilyName);
+      isCellsOnEntityUpdated += LoadCellsOnEntity(theMesh,aMeshOnEntity,aFamilyName);
     }
   }
 
   return (isPointsUpdated || isCellsOnEntityUpdated);
 }
 
-int VISU_MEDConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, 
-                                      VISU::TMeshOnEntity& theMeshOnEntity, 
-                                      VISU::TField& theField, 
-                                      VISU::TField::TValForTime& theValForTime)
+
+int 
+VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
+                                  VISU::PMeshOnEntityImpl theMeshOnEntity, 
+                                  VISU::PFieldImpl theField, 
+                                  VISU::PValForTimeImpl theValForTime)
 {
   //Main part of code
   int isPointsUpdated = LoadPoints(theMesh);
-  int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity);
-  int isFieldUpdated = LoadField(theMeshOnEntity,theField,theValForTime);
+  int isCellsOnEntityUpdated = LoadCellsOnEntity(theMesh,theMeshOnEntity);
+  int isFieldUpdated = LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
   
   return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
 }
 
-int VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName)
+int 
+VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh, 
+                             const string& theFamilyName)
 {
   //Check on existing family
-  VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY];
-  aMeshOnEntity.myEntity = VISU::NODE_ENTITY;
-  aMeshOnEntity.myMeshName = theMesh.myName;
-  VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName);
-  bool isFamilyPresent = (pFamily != NULL);
-  VISU::TFamily& aFamily = *pFamily;
+  PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+  PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
   //Check on loading already done
-  bool isPointsLoaded = !theMesh.myPointsCoord.empty();
+  bool isPointsLoaded = !theMesh->myPointsCoord.empty();
   if(isPointsLoaded) 
-    if(!isFamilyPresent) return 0;
-    else if(!aFamily.mySubMesh.empty()) return 0;
-  VISUMED::TMesh& aMesh2 = myMeshMap2[theMesh.myName];
-  SALOME_MED::MESH_var& aMedMesh = aMesh2.myMesh;
-  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[VISU::NODE_ENTITY];
+    if(!aFamily) 
+      return 0;
+    else if(!aFamily->mySubMesh.empty()) 
+      return 0;
+
   if(MYDEBUG) 
     MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
-  theMesh.myDim = aMedMesh->getSpaceDimension();
+
+  SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
   int iNumElemEnd = aMedMesh->getNumberOfNodes();
-  VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord;
+  TMeshImpl::TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
+
   if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
-  if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
-  aPointsCoord.resize(theMesh.myDim*iNumElemEnd,0.0);
-   SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
+
+  if (iNumElemEnd <= 0) 
+    throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
+
+  aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0);
+  SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
   if(!isPointsLoaded){
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
-      for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
+      for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++)
        aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
+
     if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
-    VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX];
+
+    TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aMeshOnEntity->myCellsConn[VTK_VERTEX];
     aConnForCellType.resize(iNumElemEnd);
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
-      aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem);
+      aConnForCellType[iNumElem] = TMeshOnEntityImpl::TConnect(1,iNumElem);
   }
-  if(isFamilyPresent){
+  if(aFamily){
     if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh");
-    VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName];
-    SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily;
-    VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX];
-    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
-    SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
-    int iNumElemEndTmp = iNumElemEnd;
-    iNumElemEnd = aCellNumForType->length();
-    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
-      int tmp = aCellNumForType[iNumElem]-1;
-      if(0 > tmp || tmp >= iNumElemEndTmp) {
-       static QString aString;
-       aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
-       throw std::runtime_error(aString.latin1());
+
+    SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
+    CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
+    TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
+
+    if(!anIsOnAllElements){
+      SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+      SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
+      int iNumElemEndTmp = iNumElemEnd;
+      iNumElemEnd = aCellNumForType->length();
+      for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+       int tmp = aCellNumForType[iNumElem]-1;
+       if(0 > tmp || tmp >= iNumElemEndTmp) {
+         static QString aString;
+         aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
+         throw std::runtime_error(aString.latin1());
+       }
+       aSubMeshOnCellType.insert(tmp);
+      }
+    }else{
+      for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){
+       aSubMeshOnCellType.insert(iNumElem);
       }
-      aSubMeshOnCellType.insert(tmp);
     }
   }
   return 1;
 }
 
-int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName)
+
+int 
+VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
+                                    VISU::PCMeshOnEntity theMeshOnEntity, 
+                                    const string& theFamilyName)
 {
   //Check on existing family
-  VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
-  bool isFamilyPresent = (pFamily != NULL);
-  VISU::TFamily& aFamily = *pFamily;
+  PCFamily aFamily = GetFamily(theMeshOnEntity,theFamilyName);
   //Check on loading already done
-  bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty();
+  bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
   if(isCellsLoaded) 
-    if(!isFamilyPresent) return 0;
-    else if(!aFamily.mySubMesh.empty()) return 0;
-  VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName];
-  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity];
-  SALOME_MED::SUPPORT_var& aMedSupport = aMeshOnEntity2.mySupport;
+    if(!aFamily) 
+      return 0;
+    else if(!aFamily->mySubMesh.empty()) 
+      return 0;
+
+  SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
   SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
   if(MYDEBUG) {
     MESSAGE("LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'");
-    MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<isFamilyPresent);
+    MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<bool(aFamily));
   }
+
   //Main part of code
-  int iGeomElemEnd;
-  int* aGeomElemVector;
-  const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
-  GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
-  const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[anEntity];
-  VISU::TMesh &aMesh = myMeshMap[theMeshOnEntity.myMeshName];
-  int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
+  SALOME_MED::medGeometryElement* aGeomElems;
+  const TEntity& aVEntity = theMeshOnEntity->myEntity;
+  int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
+  const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
+  int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
   if(!isCellsLoaded){
-    for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
-      int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
-      int nbMedNodes = salome_med2vtk[medId].medNbNodes;
-      int nbVtkNodes = salome_med2vtk[medId].vtkNbNodes;
-      int aVtkType = salome_med2vtk[medId].vtkType;
-      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
-      med_int iNumElemEnd = aMedMesh->getNumberOfElements(aMedEntity,aMedType);
+    for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
+      SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
+      int aMNbNodes = MEDGeom2NbNodes(aGeom);
+      int aVGeom = MEDGeomToVTK(aGeom);
+      int aVNbNodes = VTKGeom2NbNodes(aVGeom);
+      int iNumElemEnd = aMedMesh->getNumberOfElements(aMEntity,aGeom);
       if (iNumElemEnd > 0) {
        SALOME_MED::long_array_var conn = 
-         aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMedEntity,aMedType);
-       VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType];
+         aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMEntity,aGeom);
+       TMeshOnEntityImpl::TConnForCellType& aConnForCellType = theMeshOnEntity->myCellsConn[aVGeom];
        //APO - aConnForCellType.resize(iNumElemEnd);
-       valarray<med_int> aConnect(nbMedNodes);
+       vector<int> aConnect(aMNbNodes);
        int aNbConnForElem = conn->length()/iNumElemEnd;
-       if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<<salome_med2vtk[medId].medName<<
-                           "; iNumElemEnd = "<<iNumElemEnd<<"; aNbConnForElem = "<<aNbConnForElem);
+       if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
+                           "; iNumElemEnd = "<<iNumElemEnd<<
+                           "; aNbConnForElem = "<<aNbConnForElem);
        for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
-         //APO - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem];
-         //APO - anArray.resize(nbVtkNodes);
-         VISU::TMeshOnEntity::TConnect anArray(nbVtkNodes);
-         for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) {
+         VISU::TMeshOnEntityImpl::TConnect anArray(aVNbNodes);
+         for (int k = 0, kj = iNumElem*aNbConnForElem; k < aMNbNodes; k++) {
            aConnect[k] = conn[kj+k] - 1;
          }
-         switch(aMedType){
+         switch(aGeom){
          case SALOME_MED::MED_TETRA4 :
          case SALOME_MED::MED_TETRA10 :
            anArray[0] = aConnect[0];
@@ -756,10 +1038,10 @@ int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, c
            anArray[4] = aConnect[4];
            break;
          default:
-           for (int k = 0; k < nbVtkNodes; k++) 
+           for (int k = 0; k < aVNbNodes; k++) 
              anArray[k] = aConnect[k];
          }
-         for (int k = 0; k < nbVtkNodes; k++) 
+         for (int k = 0; k < aVNbNodes; k++) 
            if(anArray[k] < 0 || aNbPoints <= anArray[k]){
              static QString aString;
              aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]);
@@ -769,113 +1051,122 @@ int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, c
        }
        //Workaround for MED Component data structure
        int aSize = aConnForCellType.size();
-       aMeshOnEntity2.myCellsFirstIndex[aMedType] = VISUMED::TMeshOnEntity::TIndexAndSize(aCounter,aSize);
+       theMeshOnEntity->myCellsFirstIndex[aGeom] = TCMeshOnEntity::TIndexAndSize(aCounter,aSize);
        aCounter += aSize;
       }
     }
   }
   //Filling aFamily SubMesh
-  if(isFamilyPresent){
-    VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName];
-    SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily;
-    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
-    iGeomElemEnd = aGeom->length();
-    if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomElemEnd = "<<iGeomElemEnd);
-    for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
-      SALOME_MED::medGeometryElement aGeomType = aGeom[iGeomElem];
-      SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeomType);
-      int medId = GetIdMEDType(aGeomType);
-      int aVtkType = salome_med2vtk[medId].vtkType;
-      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
-      VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; 
-      med_int iNumElemEndTmp = theMeshOnEntity.myCellsConn[aVtkType].size();
-      med_int iNumElemEnd = aCellNumForType->length();
-      int aCounter = aMeshOnEntity2.myCellsFirstIndex[aMedType].first;
-      if(MYDEBUG) 
-       MESSAGE("LoadCellsOnEntity - medName = "<<salome_med2vtk[medId].medName<<
-               "; iNumElemEnd = "<<iNumElemEnd<<"; aCounter = "<<aCounter);
-      for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
-       int tmp = aCellNumForType[iNumElem]-aCounter-1;
-       if(0 > tmp || tmp >= iNumElemEndTmp) {
-         static QString aString;
-         aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
-         throw std::runtime_error(aString.latin1());
+  if(aFamily){
+    SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
+    CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
+    if(!anIsOnAllElements){
+      SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
+      iGeomEnd = aGeoms->length();
+      if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomEnd = "<<iGeomEnd);
+      for (int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
+       SALOME_MED::medGeometryElement aGeom = aGeoms[iGeom];
+       SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom);
+       int aVGeom = MEDGeomToVTK(aGeom);
+       TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom]; 
+       int iNumElemEndTmp = theMeshOnEntity->myCellsConn[aVGeom].size();
+       int iNumElemEnd = aCellNumForType->length();
+       int aCounter = theMeshOnEntity->myCellsFirstIndex[aGeom].first;
+       if(MYDEBUG) 
+         MESSAGE("LoadCellsOnEntity - aGeom = "<<aGeom<<
+                 "; iNumElemEnd = "<<iNumElemEnd<<
+                 "; aCounter = "<<aCounter);
+       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+         int tmp = aCellNumForType[iNumElem]-aCounter-1;
+         if(0 > tmp || tmp >= iNumElemEndTmp) {
+           static QString aString;
+           aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
+           throw std::runtime_error(aString.latin1());
+         }
+         aSubMeshOnCellType.insert(tmp);
        }
-       aSubMeshOnCellType.insert(tmp);
+      }
+    }else{
+      const TMeshOnEntityImpl::TCellsConn& aCellsConn = theMeshOnEntity->myCellsConn;
+      TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
+      for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
+       int aVGeom = aCellsConnIter->first;
+       const TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConnIter->second;
+       TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVGeom];
+       int iNumElemEnd = aConnForCellType.size();
+       for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+         aSubMeshOnCellType.insert(iNumElem);
       }
     }
   }
   return 1;
 }
 
-template<class TArray> int ImportField(TArray& theArray, 
-                                      const VISU::TMesh& theMesh,
-                                      const VISU::TField& theField,
-                                      VISU::TField::TValForTime& theValForTime,
-                                      const VISU::TMeshOnEntity& theMeshOnEntity,
-                                      const VISUMED::TMeshOnEntity& theMeshOnEntity2)
+template<class TArray> 
+int 
+ImportField(TArray& theArray, 
+           VISU::PCMesh theMesh,
+           VISU::PCField theField,
+           VISU::PCValForTime theValForTime,
+           VISU::PCMeshOnEntity theMeshOnEntity)
 {
-  if(theField.myEntity == VISU::NODE_ENTITY){
-    VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[VTK_VERTEX];
-    int iNumElemEnd = theMesh.myPointsCoord.size()/theMesh.myDim*theField.myNbComp;
+  if(theField->myEntity == NODE_ENTITY){
+    TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = 
+      theValForTime->myValForCells[VTK_VERTEX];
+    int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
     if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
     aValForCellsWithType.resize(iNumElemEnd);
     for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
       aValForCellsWithType[iNumElem] = theArray[iNumElem];
   }else{
-    int iGeomElemEnd;
-    int* aGeomElemVector;
-    const VISU::TEntity& anEntity = theField.myEntity;
-    GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
-    for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
-      int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
-      int aVtkType = salome_med2vtk[medId].vtkType;
-      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
-      const VISUMED::TMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity2.myCellsFirstIndex;
-      VISUMED::TMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMedType);
+    SALOME_MED::medGeometryElement* aGeomElems;
+    const TEntity& aVEntity = theField->myEntity;
+    int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+      SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
+      int aVGeom = MEDGeomToVTK(aGeom);
+      const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
+      TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aGeom);
       if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
-       const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn;
-       VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType);
-       const VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aCellsConnIter->second;
-       const VISUMED::TMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
+       const TCMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
        int iNumElemEnd = aIndexAndSize.second;
        if(MYDEBUG) 
-         MESSAGE("ImportField - medName = "<<salome_med2vtk[medId].medName<<
-                 "; aIndexAndSize = {"<<aIndexAndSize.first<<","<<aIndexAndSize.second<<"}");
-       VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[aVtkType];
-       aValForCellsWithType.resize(iNumElemEnd*theField.myNbComp);
-       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
-         for (int k = 0, kj = iNumElem*theField.myNbComp; k < theField.myNbComp; k++)
-           aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField.myNbComp+kj+k];
+         MESSAGE("ImportField - aGeom = "<<aGeom<<
+                 "; aIndexAndSize = {"<<aIndexAndSize.first<<
+                 ","<<aIndexAndSize.second<<"}");
+       TValForTimeImpl::TValForCellsWithType& aValForCellsWithType = theValForTime->myValForCells[aVGeom];
+       aValForCellsWithType.resize(iNumElemEnd*theField->myNbComp);
+       for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+         for(int k = 0, kj = iNumElem*theField->myNbComp; k < theField->myNbComp; k++)
+           aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField->myNbComp+kj+k];
       }
     }
   }
   return 1;
 }
 
-int VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity,
-                                const VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
+int
+VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh,
+                            VISU::PCMeshOnEntity theMeshOnEntity,
+                            VISU::PField theField, 
+                            VISU::PCValForTime theValForTime)
 {
   //Check on loading already done
-  if(!theValForTime.myValForCells.empty()) return 0;
-  VISU::TMesh& aMesh = myMeshMap[theMeshOnEntity.myMeshName];
-  VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName];
-  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity];
-  VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[theField.myName];
-  VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[theValForTime.myId];
-  SALOME_MED::FIELD_var aMEDField = aValForTime2.myField;
-  //Main part of code
+  if(!theValForTime->myValForCells.empty()) 
+    return 0;
+  SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
   SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
   if(!aFieldDouble->_is_nil()){
     SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
     if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
-    ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2);
+    ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
   }
   SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
   if(!aFieldInt->_is_nil()){
     SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
     if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
-    ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2);
+    ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
   }
   return 1;
 }