]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Porting MED3 (continued)
authorgdd <gdd>
Wed, 16 Mar 2011 12:19:15 +0000 (12:19 +0000)
committergdd <gdd>
Wed, 16 Mar 2011 12:19:15 +0000 (12:19 +0000)
src/VISU_I/VISU_CorbaMedConvertor.cxx

index 72c88f690966088af0fc4e507e544ac1b4019add..8b36f676cff6b84ceabd350efd9f79a1cef67ffc 100644 (file)
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-//  VISU OBJECT : interactive object for VISU entities implementation
-//  File   : VISU_CorbaMedConvertor.cxx
-//  Author : Alexey PETROV
-//  Module : VISU
-//  $Header$
-//
-#include "VISU_CorbaMedConvertor.hxx"
-#include "VISU_ConvertorUtils.hxx"
-
-#include <vtkCellType.h>
-
-#include <boost/tuple/tuple.hpp>
-
-#include "ReceiverFactory.hxx"
-#include "MED_SliceArray.hxx"
-
-#include "utilities.h"
-
-#define USER_INTERLACE MED_FULL_INTERLACE
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
-extern "C" {
-  VISU_Convertor* 
-  CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) 
-  {
-    return new VISU_MEDConvertor(theMedSObject);
-  }
-
-  VISU_Convertor* 
-  CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) 
-  {
-    return new VISU_MEDFieldConvertor(theField);
-  }
-}
-
-namespace
-{
-  const int MED_NBR_GEOMETRIE_MAILLE = 17;
-  
-  SALOME_MED::medGeometryElement 
-  CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
-    SALOME_MED::MEDMEM_POINT1,
-    SALOME_MED::MEDMEM_SEG2,
-    SALOME_MED::MEDMEM_SEG3,
-    SALOME_MED::MEDMEM_TRIA3,
-    SALOME_MED::MEDMEM_QUAD4,
-    SALOME_MED::MEDMEM_TRIA6,
-    SALOME_MED::MEDMEM_QUAD8,
-    SALOME_MED::MEDMEM_TETRA4,
-    SALOME_MED::MEDMEM_PYRA5,
-    SALOME_MED::MEDMEM_PENTA6,
-    SALOME_MED::MEDMEM_HEXA8,
-    SALOME_MED::MEDMEM_TETRA10,
-    SALOME_MED::MEDMEM_PYRA13,
-    SALOME_MED::MEDMEM_PENTA15,
-    SALOME_MED::MEDMEM_HEXA20,
-    SALOME_MED::MEDMEM_POLYGON,
-    SALOME_MED::MEDMEM_POLYHEDRA
-  };
-  
-  const int MED_NBR_GEOMETRIE_FACE = 5;
-  
-  SALOME_MED::medGeometryElement
-  FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
-    SALOME_MED::MEDMEM_TRIA3,
-    SALOME_MED::MEDMEM_QUAD4,
-    SALOME_MED::MEDMEM_TRIA6,
-    SALOME_MED::MEDMEM_QUAD8,
-    SALOME_MED::MEDMEM_POLYGON
-  };
-  
-  const int MED_NBR_GEOMETRIE_ARETE = 2;
-  
-  SALOME_MED::medGeometryElement
-  EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
-    SALOME_MED::MEDMEM_SEG2,
-    SALOME_MED::MEDMEM_SEG3
-  };
-  
-  const int MED_NBR_GEOMETRIE_NODE = 1;
-  
-  SALOME_MED::medGeometryElement
-  NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
-    SALOME_MED::MEDMEM_POINT1,
-  };
-  
-
-  //---------------------------------------------------------------
-  int
-  GetEntity2Geom(const VISU::TEntity& theEntity, 
-                 SALOME_MED::medGeometryElement*& theVector)
-  {
-    switch(theEntity){
-    case VISU::CELL_ENTITY: 
-      theVector = CELLGEOM; 
-      return MED_NBR_GEOMETRIE_MAILLE; 
-    case VISU::FACE_ENTITY: 
-      theVector = FACEGEOM; 
-      return MED_NBR_GEOMETRIE_FACE; 
-    case VISU::EDGE_ENTITY: 
-      theVector = EDGEGEOM; 
-      return MED_NBR_GEOMETRIE_ARETE; 
-    case VISU::NODE_ENTITY: 
-      theVector = NODEGEOM; 
-      return MED_NBR_GEOMETRIE_NODE; 
-    }
-    return -1;
-  }
-  
-
-  //---------------------------------------------------------------
-  int
-  MEDGeom2NbNodes(int theMEDGeomType)
-  { 
-    switch(theMEDGeomType){
-    case SALOME_MED::MEDMEM_NONE: 
-      return 0;
-    case SALOME_MED::MEDMEM_POINT1: 
-      return 1;
-    case SALOME_MED::MEDMEM_SEG2: 
-      return 2;
-    case SALOME_MED::MEDMEM_SEG3: 
-      return 3;
-    case SALOME_MED::MEDMEM_TRIA3: 
-      return 3;
-    case SALOME_MED::MEDMEM_TRIA6: 
-      return 6;
-    case SALOME_MED::MEDMEM_QUAD4: 
-      return 4;
-    case SALOME_MED::MEDMEM_QUAD8: 
-      return 8;
-    case SALOME_MED::MEDMEM_TETRA4: 
-      return 4;
-    case SALOME_MED::MEDMEM_TETRA10: 
-      return 10;
-    case SALOME_MED::MEDMEM_HEXA8: 
-      return 8;
-    case SALOME_MED::MEDMEM_HEXA20: 
-      return 20;
-    case SALOME_MED::MEDMEM_PENTA6: 
-      return 6;
-    case SALOME_MED::MEDMEM_PENTA15: 
-      return 15;
-    case SALOME_MED::MEDMEM_PYRA5: 
-      return 5;
-    case SALOME_MED::MEDMEM_PYRA13: 
-      return 13;
-    }
-    return -1;
-  }
-  
-
-  //---------------------------------------------------------------
-  VISU::EGeometry
-  MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)
-  { 
-    switch(theGeom){
-    case SALOME_MED::MEDMEM_POINT1:
-      return VISU::ePOINT1;
-    case SALOME_MED::MEDMEM_SEG2: 
-      return VISU::eSEG2;
-    case SALOME_MED::MEDMEM_SEG3: 
-      return VISU::eSEG3;
-    case SALOME_MED::MEDMEM_TRIA3: 
-      return VISU::eTRIA3;
-    case SALOME_MED::MEDMEM_TRIA6: 
-      return VISU::eTRIA6;
-    case SALOME_MED::MEDMEM_QUAD4: 
-      return VISU::eQUAD4;
-    case SALOME_MED::MEDMEM_QUAD8: 
-      return VISU::eQUAD8;
-    case SALOME_MED::MEDMEM_TETRA4: 
-      return VISU::eTETRA4;
-    case SALOME_MED::MEDMEM_TETRA10: 
-      return VISU::eTETRA10;
-    case SALOME_MED::MEDMEM_HEXA8: 
-      return VISU::eHEXA8;
-    case SALOME_MED::MEDMEM_HEXA20: 
-      return VISU::eHEXA20;
-    case SALOME_MED::MEDMEM_PENTA6: 
-      return VISU::ePENTA6;
-    case SALOME_MED::MEDMEM_PENTA15: 
-      return VISU::ePENTA15;
-    case SALOME_MED::MEDMEM_PYRA5: 
-      return VISU::ePYRA5;
-    case SALOME_MED::MEDMEM_PYRA13: 
-      return VISU::ePYRA13;
-    case SALOME_MED::MEDMEM_POLYGON: 
-      return VISU::ePOLYGONE;
-    case SALOME_MED::MEDMEM_POLYHEDRA: 
-      return VISU::ePOLYEDRE;
-    }
-    return VISU::eNONE;
-  }
-  
-  //---------------------------------------------------------------
-  SALOME_MED::medGeometryElement 
-  VISUGeomToMED(int theGeom)
-  { 
-    switch(theGeom){
-    case VISU::ePOINT1: 
-      return SALOME_MED::MEDMEM_POINT1;
-    case VISU::eSEG2: 
-      return SALOME_MED::MEDMEM_SEG2;
-    case VISU::eTRIA3: 
-      return SALOME_MED::MEDMEM_TRIA3;
-    case VISU::eQUAD4: 
-      return SALOME_MED::MEDMEM_QUAD4;
-    case VISU::eTETRA4: 
-      return SALOME_MED::MEDMEM_TETRA4;
-    case VISU::eHEXA8: 
-      return SALOME_MED::MEDMEM_HEXA8;
-    case VISU::ePENTA6: 
-      return SALOME_MED::MEDMEM_PENTA6;
-    case VISU::ePYRA5: 
-      return SALOME_MED::MEDMEM_PYRA5;
-
-    case VISU::eSEG3: 
-      return SALOME_MED::MEDMEM_SEG3;
-    case VISU::eTRIA6: 
-      return SALOME_MED::MEDMEM_TRIA6;
-    case VISU::eQUAD8: 
-      return SALOME_MED::MEDMEM_QUAD8;
-    case VISU::eTETRA10: 
-      return SALOME_MED::MEDMEM_TETRA10;
-    case VISU::eHEXA20: 
-      return SALOME_MED::MEDMEM_HEXA20;
-    case VISU::ePENTA15: 
-      return SALOME_MED::MEDMEM_PENTA15;
-    case VISU::ePYRA13: 
-      return SALOME_MED::MEDMEM_PYRA13;
-    case VISU::ePOLYGONE: 
-      return SALOME_MED::MEDMEM_POLYGON;
-    case VISU::ePOLYEDRE: 
-      return  SALOME_MED::MEDMEM_POLYHEDRA;
-    }
-    return SALOME_MED::medGeometryElement(-1);
-  }
-
-  //---------------------------------------------------------------
-  SALOME_MED::medGeometryElement 
-  VTKGeomToMED(int theVTKGeomType)
-  { 
-    switch(theVTKGeomType){
-    case VTK_VERTEX: 
-      return SALOME_MED::MEDMEM_POINT1;
-    case VTK_LINE: 
-      return SALOME_MED::MEDMEM_SEG2;
-    case VTK_TRIANGLE:
-      return SALOME_MED::MEDMEM_TRIA3;
-    case VTK_QUAD: 
-      return SALOME_MED::MEDMEM_QUAD4;
-    case VTK_TETRA: 
-      return SALOME_MED::MEDMEM_TETRA4;
-    case VTK_HEXAHEDRON: 
-      return SALOME_MED::MEDMEM_HEXA8;
-    case VTK_WEDGE:
-      return SALOME_MED::MEDMEM_PENTA6;
-    case VTK_PYRAMID: 
-      return SALOME_MED::MEDMEM_PYRA5;
-    case VTK_POLYGON: 
-      return SALOME_MED::MEDMEM_POLYGON;
-    }
-    return SALOME_MED::medGeometryElement(-1);
-  }
-  
-  //---------------------------------------------------------------
-  VISU::TEntity
-  MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)
-  {
-    switch(theMEDEntity){
-    case SALOME_MED::MED_NODE: 
-      return VISU::NODE_ENTITY;
-    case SALOME_MED::MED_EDGE: 
-      return VISU::EDGE_ENTITY;
-    case SALOME_MED::MED_FACE: 
-      return VISU::FACE_ENTITY;
-    case SALOME_MED::MED_CELL: 
-      return VISU::CELL_ENTITY;
-    }
-    return VISU::TEntity(-1);
-  }
-  
-  //---------------------------------------------------------------
-  SALOME_MED::medEntityMesh 
-  VTKEntityToMED(VISU::TEntity theVTKEntity)
-  {
-    switch(theVTKEntity){
-    case VISU::NODE_ENTITY: 
-      return SALOME_MED::MED_NODE;
-    case VISU::EDGE_ENTITY: 
-      return SALOME_MED::MED_EDGE;
-    case VISU::FACE_ENTITY: 
-      return SALOME_MED::MED_FACE;
-    case VISU::CELL_ENTITY: 
-      return SALOME_MED::MED_CELL;
-    }
-    return SALOME_MED::medEntityMesh(-1);
-  }
-
-  
-  //---------------------------------------------------------------
-  std::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)
-  {
-    theNbCells = theCellsSize = 0;
-    if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
-    const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
-    SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);
-    int iGeomEnd = connInfo->meshTypes.length();
-    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
-      int iNumElemEnd = connInfo->numberOfElements[iGeom];
-      if(iNumElemEnd > 0){
-        if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
-        theCellsSize += iNumElemEnd + connInfo->nodalConnectivityLength[iGeom];
-        theNbCells += iNumElemEnd;
-      }
-    }
-  }
-  
-  
-  //---------------------------------------------------------------
-  void 
-  GetCellsSize(vtkIdType& theNbCells, 
-               vtkIdType& theCellsSize,
-               SALOME_MED::FAMILY_ptr theMEDFamily)
-  {
-    theNbCells = theCellsSize = 0;
-    SALOME_MED::SUPPORT::supportInfos_var suppInfo=theMEDFamily->getSupportGlobal();
-    int iGeomEnd = suppInfo->types.length();
-    if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);
-    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {
-      int iNumElemEnd = suppInfo->nbEltTypes[iGeom];
-      if(iNumElemEnd > 0){
-        if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);
-        theNbCells += iNumElemEnd;
-        theCellsSize += iNumElemEnd + suppInfo->nodalConnectivityLength[iGeom];
-      }
-    }
-  }
-  
-  
-  //---------------------------------------------------------------
-  void
-  GetCellsSize(VISU::PCMesh theMesh, 
-               SALOME_MED::MESH_ptr theMEDMesh, 
-               const VISU::TEntity& theEntity)
-  {
-    VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
-    VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
-    if(theEntity == VISU::NODE_ENTITY){
-      aMeshOnEntity->myNbCells = theMesh->myNbPoints;
-      aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
-    }else{
-      GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);
-    }
-  }
-
-  //---------------------------------------------------------------
-  VISU::PCMeshOnEntity 
-  InitMeshOnEntity(const VISU::PCMesh& theMesh,
-                   const VISU::TEntity& theEntity,
-                   const VISU::PCMeshOnEntity& theMeshOnEntity)
-  {
-    VISU::PCMeshOnEntity aMeshOnEntity;
-    VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
-    VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
-    if(anIter == aMeshOnEntityMap.end()){
-      aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
-      *aMeshOnEntity = *theMeshOnEntity;
-      aMeshOnEntity->myEntity = theEntity;
-      aMeshOnEntityMap[theEntity] = aMeshOnEntity;
-    }else
-      aMeshOnEntity = anIter->second;
-
-    GetCellsSize(theMesh,theMesh->myMesh,theEntity);
-
-    return aMeshOnEntity;
-  }
-
-  
-  VISU::PCSubProfile
-  CrSubProfile(const VISU::PCMesh theMesh,
-               const VISU::PCField theField,
-               const VISU::TCMeshOnEntity& theMeshOnEntity,
-               SALOME_MED::medGeometryElement theMGeom,
-               int theNbElems)
-  {
-    if (MYDEBUG) MESSAGE("CrSubProfile");
-    VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
-    vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
-
-    VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());
-    aSubProfile->myGeom = aEGeom;
-    aSubProfile->myMGeom = theMGeom;
-    aSubProfile->myStatus = VISU::eAddAll;
-    if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);
-    const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;
-    VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);
-    if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() && 
-       theMGeom != SALOME_MED::MEDMEM_POINT1)
-      aSubProfile->myStatus = VISU::eRemoveAll;
-    else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MEDMEM_POINT1){
-      if(theNbElems > 0){
-        aSubProfile->myName = "";
-        aSubProfile->myStatus = VISU::eAddPart;
-        
-        aSubProfile->myNbCells = theNbElems;
-        aSubProfile->myCellsSize = aSubProfile->myNbCells;
-      }
-    }else{
-        if(theNbElems > 0){
-          aSubProfile->myName = "";
-          aSubProfile->myStatus = VISU::eAddPart;
-          
-          aSubProfile->myNbCells = theNbElems;
-          aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
-        }
-      }
-    
-    if (MYDEBUG) MESSAGE("CrSubProfile done");
-    return aSubProfile;
-  }
-
-  VISU::TProfileKey
-  GetProfileKey(const VISU::PCMesh theMesh,
-                const VISU::PCField theField,
-                const VISU::PCValForTime theValForTime,
-                const VISU::TCMeshOnEntity& theMeshOnEntity)
-  {
-    if (MYDEBUG) MESSAGE("GetProfileKey");
-
-    VISU::TProfileKey aProfileKey;
-
-    const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
-    VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
-    SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
-    int aNbElems = 0;
-    if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){
-      SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MEDMEM_POINT1;
-      try{
-        aNbElems = aSupport->getNumberOfElements(SALOME_MED::MEDMEM_NONE);
-        if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<"   aNbElems="<<aNbElems);
-      }catch(...){
-        MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
-      }
-        
-      VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
-                                                    theField,
-                                                    theMeshOnEntity,
-                                                    aMGeom,
-                                                    aNbElems);
-      aProfileKey.insert(aSubProfile);
-    }
-    
-    for(; anIter != aFirstIndex.end(); anIter++){
-      SALOME_MED::medGeometryElement aMGeom = anIter->first;
-      try{
-        aNbElems = aSupport->getNumberOfElements(aMGeom);
-        if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<"   aNbElems="<<aNbElems);
-      } catch(...){
-        MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
-        continue;
-      }
-      VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
-                                                    theField,
-                                                    theMeshOnEntity,
-                                                    aMGeom,
-                                                    aNbElems);
-      aProfileKey.insert(aSubProfile);
-    }
-
-    if (MYDEBUG) MESSAGE("GetProfileKey done");
-    return aProfileKey;
-  }
-  
-  void
-  InitProfile(VISU::PCMesh theMesh,
-              VISU::PCField theField,
-              VISU::PCValForTime theValForTime,
-              VISU::TCMeshOnEntity& theMeshOnEntity)
-  {
-    if (MYDEBUG) MESSAGE("InitProfile");
-    
-    VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
-
-    VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,
-                                                  theField,
-                                                  theValForTime,
-                                                  theMeshOnEntity);
-    
-    VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
-    if(anIter != aProfileMap.end()){
-      theValForTime->myProfile = anIter->second;
-      if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");
-    }else{
-      VISU::PCProfile aProfile(new VISU::TCProfile());
-      VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-      
-      VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
-      for(; anIter != aProfileKey.end(); anIter++){
-        VISU::PCSubProfile aSubProfile(*anIter);
-        
-        if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
-          aProfile->myIsAll = false;
-        
-        VISU::EGeometry aEGeom = aSubProfile->myGeom;
-        aGeom2SubProfile[aEGeom] = aSubProfile;
-      }
-      
-      aProfileMap[aProfileKey] = aProfile;
-      theValForTime->myProfile = aProfile;
-    }
-    if (MYDEBUG) MESSAGE("InitProfile done");
-  }
-
-  void
-  LoadProfile(VISU::PCMesh theMesh,
-              VISU::PCField theField,
-              VISU::PCValForTime theValForTime,
-              VISU::PCMeshOnEntity theMeshOnEntity)
-  {
-    VISU::PCProfile aProfile = theValForTime->myProfile;
-    if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<<aProfile->myIsDone);
-    if(aProfile->myIsDone)
-      return;
-    
-    const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-    VISU::TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();
-    if(aGeom2SubProfileIter == aGeom2SubProfile.end()){
-      MESSAGE("Warning! No geom 2 sub profile");
-    }
-    SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
-    for(; aGeom2SubProfileIter != aGeom2SubProfile.end(); aGeom2SubProfileIter++){
-      VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;
-      SALOME_MED::medGeometryElement aMGeom = VISUGeomToMED(aEGeom);
-      VISU::PCSubProfile aSubProfile = aGeom2SubProfileIter->second;
-      SALOME_TYPES::ListOfLong_var aGeom2ProfileIds;
-      std::vector<int> aGeom2Profile;
-      if(!aSupport->isOnAllElements()){
-        try{
-          if(aMGeom == SALOME_MED::MEDMEM_POINT1)
-            aGeom2ProfileIds = aSupport->getNumberFromFile(SALOME_MED::MEDMEM_NONE);
-          else
-            aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom);
-          int aLen = aGeom2ProfileIds->length();
-          if(MYDEBUG) MESSAGE_BEGIN(" - aMGeom="<<aMGeom<<"; aNbCells="<<aLen);
-          for(int i = 0; i < aLen; i++){
-            int anId = aGeom2ProfileIds[i];
-            aGeom2Profile.push_back(anId);
-            if(MYDEBUG) MESSAGE_ADD(std::endl << "------------------------------->" << anId);
-          }
-          if(MYDEBUG) MESSAGE_END(" ");
-        } catch(...) {
-          continue;
-        }
-      } else {
-        SALOME_MED::medEntityMesh aMEntity = aSupport->getEntity();
-        int aNbElems = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);
-        for(int i = 0; i < aNbElems; i++) 
-          aGeom2Profile.push_back(i+1);
-      }
-      if(aGeom2Profile.size()>0){
-        VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
-        int aSize = aGeom2Profile.size();
-        aSubMeshID.resize(aSize);
-        for(int anId = 0; anId < aSize; anId++){
-          aSubMeshID[anId] = aGeom2Profile[anId] - 1;
-        }
-      }
-    }
-    
-    aProfile->myIsDone = true;
-    if (MYDEBUG) MESSAGE("LoadProfile done");
-  }
-}
-
-
-//---------------------------------------------------------------
-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 aMEntity = aMEDSupport->getEntity();
-  VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
-  SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
-  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::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
-  aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
-  aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
-  aMesh->myDim = aMEDMesh->getSpaceDimension();
-  aMesh->myName = aMeshName.in();
-  aMesh->myMesh = aMEDMesh;
-
-  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
-
-  VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-  VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new VISU::TCMeshOnEntity());
-  aMeshOnEntity->myEntity = aVEntity;
-  aMeshOnEntity->myMeshName = aMeshName.in();
-  aMeshOnEntity->mySupport = aMEDSupport;
-
-  if(aVEntity == VISU::NODE_ENTITY)
-    ::InitMeshOnEntity(aMesh, VISU::CELL_ENTITY, aMeshOnEntity);
-  else
-    ::InitMeshOnEntity(aMesh, VISU::NODE_ENTITY, aMeshOnEntity);
-
-  ::GetCellsSize(aMesh, aMEDMesh, aVEntity);
-
-  VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-  VISU::PCField aField = aFieldMap[aFieldName.in()](new VISU::TCField());
-  aField->myId = myField->getOrderNumber();
-  aField->myName = aFieldName.in();
-  aField->myEntity = aVEntity;
-  aField->myMeshName = aMeshName.in();
-  aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
-
-  vtkIdType aDataType = VTK_DOUBLE;
-  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);
-  if(aFieldDouble->_is_nil()) {
-    // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
-    if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
-      aDataType = VTK_LONG;
-    else if (sizeof(int) == 4)
-      aDataType = VTK_INT;
-    else {
-      throw std::runtime_error("Can't map CORBA::Long to a VTK type");
-    }
-  }
-  aField->Init(myField->getNumberOfComponents(), aDataType);
-
-  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
-
-  VISU::TValField& aValField = aField->myValField;
-  int anId = myField->getIterationNumber();
-  VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
-  aValForTime->myId = anId;
-  CORBA::Double aDT = myField->getTime();
-  aValForTime->myTime = VISU::TTime(aDT,"");
-  aValForTime->myField = myField;
-
-  if(MYDEBUG) 
-    MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<
-            "'; myId = "<<anId<<"; myTime = "<<aDT);
-
-  return this;
-}
-
-
-//---------------------------------------------------------------
-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 = VISU::SObjectToObject(mySObject);
-  if(!CORBA::is_nil(aMedObject)){
-    SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);
-    return Build(aMED);
-  }
-
-  SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
-  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;
-
-    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(CORBA::is_nil(theMED)) 
-    return NULL;
-
-  CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();
-  SALOME_TYPES::ListOfString_var aMeshNames = theMED->getMeshNames();
-  if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);
-
-  SALOMEDS::Study_var aStudy = mySObject->GetStudy();
-  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;
-
-      VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
-      SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
-      aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
-      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
-      aMesh->myDim = aMEDMesh->getSpaceDimension();
-      aMesh->myName = aMeshName.in();
-      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;
-
-      VISU::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()->convertInMESH();
-        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);
-          vtkIdType aNbCells, aCellsSize;
-          //Check, if there is any data on the support?
-          if(aVEntity == VISU::NODE_ENTITY){
-            aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
-            aNbCells = aMesh->myNbPoints;
-            aCellsSize = 2*aMesh->myNbPoints;
-          }else
-            ::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
-          
-          if(aNbCells > 0){
-            if(aMeshOnEntityMap.find(aVEntity) == aMeshOnEntityMap.end()){
-              VISU::PCMeshOnEntity aMeshOnEntity(new VISU::TCMeshOnEntity());
-              aMeshOnEntity->myMeshName = aMeshName.in();
-              aMeshOnEntity->myEntity = aVEntity;
-              aMeshOnEntity->myNbCells = aNbCells;
-              aMeshOnEntity->myCellsSize = aCellsSize;
-              aMeshOnEntity->mySupport = aMEDSupport;
-              aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
-            }
-          }
-        }
-      }
-
-      // 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()->convertInMESH();
-        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
-        VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
-        CORBA::String_var aSupportName = aMEDSupport->getName();
-        
-        SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
-        if(!aMEDFamily->_is_nil()) {
-          VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
-          if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
-            continue;
-          VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
-
-          vtkIdType 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){
-            VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
-            VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
-            if(aFamilyMapIter == aFamilyMap.end()){
-              VISU::PCFamily aFamily(new VISU::TCFamily());
-              aFamily->myEntity = aVEntity;
-              aFamily->myNbCells = aNbCells;
-              aFamily->myCellsSize = aCellsSize;
-              aFamily->myId = aMEDFamily->getIdentifier();
-              aFamily->myName = aSupportName.in();
-              aFamily->myFamily = aMEDFamily;
-              aFamilyMap[aSupportName.in()] = aFamily;
-            }
-          }
-        }
-      }
-        
-      // 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()->convertInMESH();
-        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()){
-          CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
-
-          if(MYDEBUG) 
-            MESSAGE("VISU_MEDConvertor::Build "<<
-                    "- aGroup = '"<<aSupportName<<"'"<<
-                    "; anIsOnAllElements = "<<anIsOnAllElements<<
-                    "; aVEntity = "<<aVEntity);
-
-          VISU::PCGroup aGroup(new VISU::TCGroup());
-          aGroup->myGroup = aMEDGroup;
-          VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
-          
-          SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
-          int iFamilyEnd = aFamilies->length();
-          for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
-            SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
-            CORBA::String_var aFamilyName = aMEDFamily->getName();
-            TFindFamilyOnEntity aFindFamilyOnEntity = 
-              FindFamilyOnEntity(aMeshName.in(), aVEntity, aFamilyName.in());
-            VISU::PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);
-            if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
-            if(aFamily){
-              aFamilySet.insert(VISU::TEnity2Family(aVEntity, aFamily));
-            }
-          }
-          
-          if(!aFamilySet.empty()){
-            VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
-            aGroupMap[aSupportName.in()] = aGroup;
-          }
-
-        }
-      }
-    }
-  }
-
-  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(aFieldsSObj);
-    for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){
-      SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();
-      if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(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 = '"<<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;
-
-        SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
-        if(aMEDSupport->_is_nil()) 
-          continue;
-
-        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
-        VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);
-        SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
-        if(aMEDMesh->_is_nil()) 
-          continue;
-
-        CORBA::String_var aMeshName = aMEDMesh->getName();
-        CORBA::String_var aFieldName = aMEDField->getName();
-        
-        VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
-        if(aMeshMapIter == myMeshMap.end())
-          continue;
-
-        VISU::PCMesh aMesh = aMeshMapIter->second;
-        VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-        VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
-        if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
-          continue;
-
-        VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
-        VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-        VISU::TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
-        VISU::PCField aField;
-        if(aFieldMapIter == aFieldMap.end()){
-          aField = aFieldMap[aFieldName.in()](new VISU::TCField());
-          aField->myId = iField;
-          aField->myName = aFieldName.in();
-          aField->myEntity = anEntity;
-          aField->myMeshName = aMeshName.in();
-          aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
-
-          vtkIdType aDataType = VTK_DOUBLE;
-          SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
-          if(aFieldDouble->_is_nil()) {
-            // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
-            if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
-              aDataType = VTK_LONG;
-            else if (sizeof(int) == 4)
-              aDataType = VTK_INT;
-            else {
-              MESSAGE("Can't map CORBA::Long to a VTK type, for Field " << aFieldName);
-              continue;
-            }
-          }
-          aField->Init(aMEDField->getNumberOfComponents(), aDataType);
-
-          if(MYDEBUG) 
-            MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
-        }else
-          aField = aFieldMapIter->second;
-
-        VISU::TValField& aValField = aField->myValField;
-        int anId = aMEDField->getIterationNumber();
-        VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
-        aValForTime->myId = anId;
-        CORBA::Double aDT = aMEDField->getTime();
-        aValForTime->myTime = VISU::TTime(aDT,"");
-        aValForTime->myField = aMEDField;
-        if(MYDEBUG) 
-          MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
-                  "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);
-      }      
-    }
-  }
-  return this; 
-}
-
-//---------------------------------------------------------------
-VISU_Convertor* 
-VISU_MEDConvertor
-::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
-{
-  if(theTimeStampIterator->_is_nil()) return NULL;
-  for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
-    SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();
-    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;
-
-    SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
-    if(aMEDSupport->_is_nil()) 
-      continue;
-
-    SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
-    VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
-    SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();
-    if(aMEDMesh->_is_nil()) continue;
-    CORBA::String_var aMeshName = aMEDMesh->getName();
-    CORBA::String_var aFieldName = aMEDField->getName();
-
-    VISU::PCMesh aMesh;
-    VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
-    if(aMeshMapIter == myMeshMap.end()){
-      aMesh.reset(new VISU::TCMesh());
-      aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
-      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
-      aMesh->myDim = aMEDMesh->getSpaceDimension();
-      aMesh->myName = aMeshName.in();
-      aMesh->myMesh = aMEDMesh;
-      
-      myMeshMap[aMeshName.in()] = aMesh;
-
-      if(MYDEBUG) 
-        MESSAGE("VISU_MEDConvertor::Build "<<
-                "- aMeshName = '"<<aMeshName<<"'"<<
-                "; aDim = "<<aMesh->myDim);
-    }else
-      aMesh = aMeshMapIter->second;
-
-    VISU::PCMeshOnEntity aMeshOnEntity;
-    VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-    VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
-    if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
-      aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
-      aMeshOnEntity->myEntity = aVEntity;
-      aMeshOnEntity->myMeshName = aMeshName.in();
-      aMeshOnEntity->mySupport = aMEDSupport;
-      aMeshOnEntityMap[aVEntity] = aMeshOnEntity;
-    }else
-      aMeshOnEntity = aMeshOnEntityMapIter->second;
-
-    if(aVEntity == VISU::NODE_ENTITY)
-      ::InitMeshOnEntity(aMesh,VISU::CELL_ENTITY,aMeshOnEntity);
-    else
-      ::InitMeshOnEntity(aMesh,VISU::NODE_ENTITY,aMeshOnEntity);
-
-    ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
-
-    VISU::PCField aField;
-    VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
-    VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
-    if(aFieldMapIter == aFieldMap.end()){
-      aField.reset(new VISU::TCField());
-      aField->myId = mySObject->Tag();
-      aField->myName = aFieldName.in();
-      aField->myEntity = aVEntity;
-      aField->myMeshName = aMeshName.in();
-      aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
-      
-      vtkIdType aDataType = VTK_DOUBLE;
-      SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
-      if(aFieldDouble->_is_nil()){
-        if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
-          //Fix for IPAL20325 Crash on create presentation for imported field 
-          aDataType = VTK_LONG;
-        else if (sizeof(int) == 4)
-          aDataType = VTK_INT;
-        else {
-          throw std::runtime_error("Can't map CORBA::Long to a VTK type");
-        }
-      }
-      aField->Init(aMEDField->getNumberOfComponents(), aDataType);
-
-      aFieldMap[aFieldName.in()] = aField;
-
-      if(MYDEBUG) 
-        MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
-    }else
-      aField = aFieldMapIter->second;
-
-    VISU::TValField& aValField = aField->myValField;
-    int anId = aMEDField->getIterationNumber();
-    VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
-    aValForTime->myId = anId;
-    CORBA::Double aDT = aMEDField->getTime();
-    aValForTime->myTime = VISU::TTime(aDT,"");
-    aValForTime->myField = aMEDField;
-    if(MYDEBUG) 
-      MESSAGE("VISU_MEDConvertor::Build "<<
-              "- aMeshName = '"<<aMeshName<<"'"<<
-              "; myEntity = "<<aVEntity<<
-              "; myTime = "<<aDT<<
-              "; anId = "<<anId);
-  }
-  return this; 
-}
-
-
-//---------------------------------------------------------------
-int
-VISU_MEDConvertor
-::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
-                   VISU::PMeshOnEntityImpl theMeshOnEntity)
-{
-  int anIsUpdated = LoadPoints(theMesh);
-  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
-  if(aVEntity != VISU::NODE_ENTITY)
-    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
-
-  return anIsUpdated;
-}
-//---------------------------------------------------------------
-int
-VISU_MEDConvertor
-::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
-                     VISU::PMeshOnEntityImpl theMeshOnEntity, 
-                     VISU::PFamilyImpl theFamily)
-{
-  int anIsUpdated = LoadPoints(theMesh);
-  const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
-  if(anEntity == VISU::NODE_ENTITY){
-    anIsUpdated |= LoadPointsOnFamily(theMesh,theFamily);
-  }else{
-    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
-    anIsUpdated |= LoadCellsOnFamily(theMesh,theMeshOnEntity,theFamily);
-  }
-
-  return anIsUpdated;
-}
-
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
-                  const VISU::TFamilySet& theFamilySet)
-{
-  //Main part of code
-  int anIsUpdated = LoadPoints(theMesh);
-  VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
-  for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
-    VISU::PCFamily aFamily = (*aFamilyIter).second;
-    const VISU::TEntity& aVEntity = aFamily->myEntity;
-    VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
-    if(aVEntity == VISU::NODE_ENTITY){
-      anIsUpdated |= LoadPointsOnFamily(theMesh,aFamily);
-    }else{
-      anIsUpdated |= LoadCellsOnEntity(theMesh,aMeshOnEntity);
-      anIsUpdated |= LoadCellsOnFamily(theMesh,aMeshOnEntity,aFamily);
-    }
-  }
-
-  return anIsUpdated;
-}
-
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
-                       VISU::PMeshOnEntityImpl theMeshOnEntity, 
-                       VISU::PFieldImpl theField, 
-                       VISU::PValForTimeImpl theValForTime)
-{
-  //Main part of code
-  int anIsUpdated = LoadPoints(theMesh);
-  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
-  if(aVEntity != VISU::NODE_ENTITY)
-    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
-
-  anIsUpdated |= LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
-  
-  return anIsUpdated;
-}
-
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadPoints(VISU::PCMesh theMesh)
-{
-  //Check on existing family
-  VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
-  
-  //Check on loading already done
-  if(theMesh->myIsDone) 
-    return 0;
-  
-  SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
-  vtkIdType aDim = theMesh->GetDim();
-  vtkIdType aNbElem = theMesh->GetNbPoints();
-
-  if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
-
-  if(aNbElem <= 0) 
-    throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
-
-  SALOME_TYPES::ListOfDouble_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
-  VISU::TCMEDCoordHolder* aCoordHolder = new VISU::TCMEDCoordHolder();
-  aCoordHolder->Init(aNbElem, aDim, aCCoord);
-
-  VISU::TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
-  aCoords.Init(VISU::PCoordHolder(aCoordHolder));
-  
-  if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
-  
-  VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
-  VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TCSubMesh());
-
-  aSubMesh->myNbCells = theMesh->myNbPoints;
-  aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
-
-  VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-  aCell2Connect.resize(aNbElem);
-  if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<<aNbElem);
-  for(int iElem = 0; iElem < aNbElem; iElem++)
-    aCell2Connect[iElem] = VISU::TConnect(1,iElem);
-  
-  theMesh->myIsDone = true;
-
-  return 1;
-}
-
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadPointsOnFamily(VISU::PCMesh theMesh, 
-                     VISU::PCFamily theFamily)
-{
-  VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
-
-  if(theFamily->myIsDone) 
-    return 0;
-
-  vtkIdType aNbElem = theMesh->GetNbPoints();
-  SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
-  CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
-  VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
-  
-  if(!anIsOnAllElements){
-    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
-    SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
-    int aSize = aNbElem;
-    aNbElem = aCellNumForType->length();
-    for(int iElem = 0; iElem < aNbElem; iElem++){
-      int anID = aCellNumForType[iElem] - 1;
-      if(0 > anID || anID >= aSize){
-        static QString aString;
-        aString.sprintf("LoadPointsOnFamily - aSize(%d) <= aCellNumForType[%d] = %d < 0",aSize,iElem,anID);
-        throw std::runtime_error((const char*)aString.toLatin1());
-      }
-      aSubMeshID.push_back(anID);
-    }
-  }else{
-    for(int iElem = 0; iElem < aNbElem; iElem++){
-      aSubMeshID.push_back(iElem);
-    }
-  }
-  
-  theFamily->myIsDone = true;
-  
-  return 1;
-}
-
-//---------------------------------------------------------------
-namespace 
-{
-  typedef MED::TCSlice<int> TA;
-  //---------------------------------------------------------------
-  typedef std::set<int> TConnSet;
-  typedef std::vector<int> TIntArray;
-  typedef MED::TCSlice<int> TConnSlice;
-
-  //---------------------------------------------------------------
-  class MEDPolygonConnectivity //! retriver of polygon connectivity
-  {
-    TIntArray myConn;
-    TIntArray myConnIndex;
-  public:
-
-    MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,
-                           SALOME_MED::medEntityMesh theEntity) 
-    {
-      {
-        SALOME::SenderInt_var aSender = 
-          theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYGON);
-        long int aSize;
-        int* aValuePtr = ReceiverFactory::getValue(aSender.in(), aSize);
-        myConn.assign(aValuePtr, aValuePtr + aSize);
-      }
-      {
-        SALOME::SenderInt_var aSender = 
-          theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYGON);
-        long int aSize;
-        int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
-        myConnIndex.assign(aValuePtr, aValuePtr + aSize);
-      }
-    }
-
-    TConnSlice 
-    GetConn(int theId) const 
-    {
-      int anOffSet = myConnIndex[theId] - 1;
-      int aSize = myConnIndex[theId + 1] - myConnIndex[ theId ];
-      return TConnSlice(&myConn[0], myConn.size(), std::slice(anOffSet, aSize, 1));
-    }
-
-    int 
-    GetNbElem() const 
-    {
-      return myConnIndex.size() - 1;
-    }
-
-    int
-    GetCellSize() const
-    {
-      return myConn.size() + GetNbElem();
-    }
-  };
-
-
-  //---------------------------------------------------------------
-  class MEDPolyhedraConnectivity //! retriver of polyhedron connectivity
-  {
-    TIntArray myConn;
-    TIntArray myConnIndex;
-    TIntArray myFaceIndex;
-  public:
-
-    MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh,
-                             SALOME_MED::medEntityMesh theEntity)
-    {
-      {
-        SALOME::SenderInt_var aSender = 
-          theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYHEDRA);
-        long int aSize;
-        int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
-        myConn.assign(aValuePtr, aValuePtr + aSize);
-      }
-      {
-        SALOME::SenderInt_var aSender = 
-          theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYHEDRA);
-        long int aSize;
-        int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
-        myConnIndex.assign(aValuePtr, aValuePtr + aSize);
-      }
-      {
-        SALOME::SenderInt_var aSender = 
-          theMesh->getSenderForPolyhedronFacesIndex();
-        long int aSize;
-        int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
-        myFaceIndex.assign(aValuePtr, aValuePtr + aSize);
-      }
-    }
-
-    int
-    GetUniqueConn(int theId, 
-                  TConnSet& theConnSet) const 
-    {
-      theConnSet.clear();
-      int aStartFaceId = myConnIndex[theId] - 1;
-      int anEndFaceId = myConnIndex[theId + 1] - 2;
-      int aStartConnId = myFaceIndex[aStartFaceId] - 1;
-      int anEndConnId = myFaceIndex[anEndFaceId + 1] - 1;
-      for(int aConnId = aStartConnId; aConnId < anEndConnId; aConnId++)
-        theConnSet.insert(myConn[aConnId]);
-      return theConnSet.size();
-    }
-
-    int
-    GetNbElem() const
-    {
-      return myConnIndex.size() - 1;
-    }
-
-    int
-    GetCellSize() const
-    {
-      TConnSet aConnSet;
-      int aCellSize = 0;
-      for(int anElemId = 0; anElemId < GetNbElem(); anElemId++)
-        aCellSize += GetUniqueConn(anElemId, aConnSet);
-      return aCellSize;
-    }
-  };
-}
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadCellsOnEntity(VISU::PCMesh theMesh,
-                    VISU::PCMeshOnEntity theMeshOnEntity)
-{
-  if(theMeshOnEntity->myIsDone) 
-    return 0;
-
-  SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;
-  SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh()->convertInMESH();
-
-  //Main part of code
-  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
-  const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
-  VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity->myCellsFirstIndex;
-
-  SALOME_MED::MESH::connectivityInfos_var anInfo = aMedMesh->getConnectGlobal(aMEntity);
-  int iGeomEnd = anInfo->meshTypes.length();
-
-  VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
-  vtkIdType aNbPoints = theMesh->GetNbPoints();
-
-  for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++) {
-    SALOME_MED::medGeometryElement aMGeom = anInfo->meshTypes[iGeom];
-    VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
-    switch (aMGeom) {
-    case SALOME_MED::MEDMEM_POLYGON:
-    {
-      MEDPolygonConnectivity aConn(aMedMesh, aMEntity);
-      int aNbElem = aConn.GetNbElem();
-      if (aNbElem > 0) {
-        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
-        aSubMesh->myNbCells   = aNbElem;
-        aSubMesh->myCellsSize = aConn.GetCellSize();
-
-        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-        aCell2Connect.resize(aNbElem);
-
-        for(int iElem = 0; iElem < aNbElem; iElem++) {
-          TConnSlice aConnSlice = aConn.GetConn(iElem);
-          VISU::TConnect& anArray = aCell2Connect[iElem];
-          anArray.resize(aConnSlice.size());
-          for(int iConn = 0; iConn < aConnSlice.size(); iConn++)
-            anArray[iConn] = aConnSlice[iConn] - 1;
-        }
-      }
-    }
-    break;
-    case SALOME_MED::MEDMEM_POLYHEDRA:
-    {
-      MEDPolyhedraConnectivity aConn( aMedMesh, aMEntity );
-      int aNbElem = aConn.GetNbElem();
-      if (aNbElem > 0) {
-        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
-        aSubMesh->myNbCells = aNbElem;
-        aSubMesh->myCellsSize = aConn.GetCellSize();
-
-        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-        aCell2Connect.resize(aNbElem);
-
-        TConnSet aConnectSet;
-        for(int iElem = 0; iElem < aNbElem; iElem++){
-          if(aConn.GetUniqueConn(iElem, aConnectSet)){
-            int aNbConn = aConnectSet.size();
-            VISU::TConnect& anArray = aCell2Connect[iElem];
-            anArray.resize(aNbConn);
-            std::set<int>::iterator anIter = aConnectSet.begin();
-            for(int i = 0; anIter != aConnectSet.end(); anIter++, i++)
-              anArray[i] = *anIter - 1;
-          }
-        }
-      }
-    }
-    break;
-    default:
-    {        
-      int aMNbNodes = MEDGeom2NbNodes(aMGeom);
-      int aVNbNodes = VISUGeom2NbNodes(aEGeom);
-      int aNbElem = anInfo->numberOfElements[iGeom];
-      if (aNbElem > 0) {
-        SALOME_TYPES::ListOfLong_var aConn = 
-          aMedMesh->getConnectivity(SALOME_MED::MED_NODAL,
-                                    aMEntity,
-                                    aMGeom);
-        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
-
-        aSubMesh->myNbCells = aNbElem;
-        aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
-
-        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-        std::vector<int> aConnect(aMNbNodes);
-        int aNbConnForElem = aConn->length() / aNbElem;
-
-        if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aMGeom = "<<aMGeom<<
-                            "; aNbElem = "<<aNbElem<<
-                            "; aMNbNodes = "<<aMNbNodes<<
-                            "; aVNbNodes = "<<aVNbNodes<<
-                            "; aNbConnForElem = "<<aNbConnForElem);
-
-        for(int iElem = 0; iElem < aNbElem; iElem++) {
-          VISU::TConnect anArray(aVNbNodes);
-          for(int k = 0, kj = iElem*aNbConnForElem; k < aMNbNodes; k++)
-            aConnect[k] = aConn[kj+k] - 1;
-
-          switch(aMGeom){
-#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
-          case SALOME_MED::MEDMEM_SEG3:
-            anArray[0] = aConnect[0];
-            anArray[2] = aConnect[1];  
-
-            anArray[1] = aConnect[2];
-            break;
-#endif
-#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
-          case SALOME_MED::MEDMEM_TRIA6:
-            anArray[0] = aConnect[0];
-            anArray[2] = aConnect[1];  
-            anArray[4] = aConnect[2];  
-
-            anArray[1] = aConnect[3];
-            anArray[3] = aConnect[4];  
-            anArray[5] = aConnect[5];  
-            break;
-#endif
-#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
-          case SALOME_MED::MEDMEM_QUAD8:
-            anArray[0] = aConnect[0];
-            anArray[2] = aConnect[1];  
-            anArray[4] = aConnect[2];  
-            anArray[6] = aConnect[3];  
-
-            anArray[1] = aConnect[4];
-            anArray[3] = aConnect[5];  
-            anArray[5] = aConnect[6];  
-            anArray[7] = aConnect[7];  
-            break;
-#endif
-#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
-          case SALOME_MED::MEDMEM_TETRA10 :
-#endif
-          case SALOME_MED::MEDMEM_TETRA4 :
-            anArray[0] = aConnect[0];
-            anArray[1] = aConnect[1];
-            anArray[2] = aConnect[3];  
-            anArray[3] = aConnect[2];  
-            break;
-#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
-          case SALOME_MED::MEDMEM_PYRA13:
-#endif
-          case SALOME_MED::MEDMEM_PYRA5 :
-            anArray[0] = aConnect[0];
-            anArray[1] = aConnect[3];  
-            anArray[2] = aConnect[2];
-            anArray[3] = aConnect[1];  
-            anArray[4] = aConnect[4];
-            break;
-          default:
-            for (int k = 0; k < aVNbNodes; k++) 
-              anArray[k] = aConnect[k];
-          }
-          for (int k = 0; k < aVNbNodes; k++) 
-            if(anArray[k] < 0 || aNbPoints <= anArray[k]){
-              static QString aString;
-              aString.sprintf("LoadCellsOnEntity >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",int(aNbPoints),iElem,k,anArray[k]);
-              throw std::runtime_error((const char*)aString.toLatin1());
-            }
-          aCell2Connect.push_back(anArray);
-        } // loop on elements
-      }
-    }} // switch( aMGeom )
-    VISU::TGeom2SubMesh::iterator anIter = aGeom2SubMesh.find(aEGeom);
-    if(anIter != aGeom2SubMesh.end()){
-      const VISU::PSubMeshImpl& aSubMesh = anIter->second;
-      const VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-      int aSize = aCell2Connect.size();
-      if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);
-      aFirstIndex[aMGeom] = VISU::TIndexAndSize(aCounter, aSize);
-      aCounter += aSize;
-    }
-  } //loop on types
-
-  // Dump result connectivity
-// #ifdef _DEBUG_
-//   TGeom2SubMesh::iterator geom_sm = aGeom2SubMesh.begin();
-//   for ( ; geom_sm!=aGeom2SubMesh.end(); ++geom_sm ) {
-//     cout << "TYPE: " << geom_sm->first << endl;
-//     PSubMeshImpl aSubMesh = geom_sm->second;
-//     TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
-//     TCell2Connect::iterator id_conn = aCell2Connect.begin();
-//     for ( int i = 0; id_conn !=aCell2Connect.end(); ++id_conn ) {
-//       cout << "\t" << i++ << ": [";
-//       TConnect& anArray = *id_conn;
-//       TConnect::iterator n = anArray.begin();
-//       for ( ; n != anArray.end(); ++n )
-//         cout << " " << *n + 1;
-//       cout << " ]"<< endl;
-//     }
-//   }
-// #endif
-
-  theMeshOnEntity->myIsDone = true;
-
-  return 1;
-}
-
-
-//---------------------------------------------------------------
-int 
-VISU_MEDConvertor
-::LoadCellsOnFamily(VISU::PCMesh theMesh,
-                    VISU::PCMeshOnEntity theMeshOnEntity, 
-                    VISU::PCFamily theFamily)
-{
-  if(theFamily->myIsDone) 
-    return 0;
-
-  SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
-  CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
-  if(!anIsOnAllElements){
-    SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();
-    int iGeomEnd = aGeoms->length();
-    if(MYDEBUG) MESSAGE("LoadCellsOnFamily - iGeomEnd = "<<iGeomEnd);
-    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
-      SALOME_MED::medGeometryElement aMGeom = aGeoms[iGeom];
-      SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aMGeom);
-      VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
-
-      int aNbElem = aCellNumForType->length();
-      int aCounter = theMeshOnEntity->myCellsFirstIndex[aMGeom].first;
-      int aSize = theMeshOnEntity->myCellsFirstIndex[aMGeom].second;
-      VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom]; 
-      
-      if(MYDEBUG) 
-        MESSAGE("LoadCellsOnFamily "<<
-                "- aMGeom = "<<aMGeom<<
-                "; aNbElem = "<<aNbElem<<
-                "; aSize = "<<aSize<<
-                "; aCounter = "<<aCounter);
-      
-      for(int iElem = 0; iElem < aNbElem; iElem++){
-        int anID = aCellNumForType[iElem] - aCounter - 1;
-        if(0 > anID || anID >= aSize){
-          static QString aString;
-          aString.sprintf("LoadCellsOnFamily - aNbElem(%d) <= aCellNumForType[%d] = %d < 0 !!!",aNbElem,iElem,anID);
-          throw std::runtime_error((const char*)aString.toLatin1());
-        }
-        aSubMeshID.push_back(anID);
-      }
-    }
-  }else{
-    const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
-    VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
-    for(; anIter != aGeom2SubMesh.end(); anIter++){
-      VISU::EGeometry aEGeom = anIter->first;
-      const VISU::TSubMeshImpl& aSubMesh = anIter->second;
-      const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
-      VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
-      int iNumElemEnd = aCell2Connect.size();
-      for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
-        aSubMeshID.push_back(iNumElem);
-    }
-  }
-  
-  theFamily->myIsDone = true;
-
-  return 1;
-}
-
-
-template<class TValueType,
-         class TContainerType> 
-void 
-ImportField(TContainerType& theContainer, 
-            VISU::PCMesh theMesh,
-            VISU::PCField theField,
-            VISU::PCValForTime theValForTime,
-            VISU::PCMeshOnEntity theMeshOnEntity)
-{
-  typedef VISU::TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;
-  vtkIdType aNbComp = theField->myNbComp;
-  if(theField->myEntity == VISU::NODE_ENTITY){
-    VISU::EGeometry aEGeom = VISU::ePOINT1;
-    vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
-    vtkIdType aNbElem = theMesh->GetNbPoints();
-
-    if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
-
-    VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);
-    TVMeshValue* aMeshValue = new TVMeshValue();
-    aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, 0);
-    aVMeshValue.reset(aMeshValue);
-  }else{
-    SALOME_MED::medGeometryElement* aGeomElems;
-    const VISU::TEntity& aVEntity = theField->myEntity;
-    int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
-    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
-      SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
-      VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
-      vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
-      const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
-      VISU::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
-      if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
-        const VISU::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
-        if(MYDEBUG) 
-          MESSAGE("ImportField - aMGeom = "<<aMGeom<<
-                  "; aIndexAndSize = {"<<aIndexAndSize.first<<
-                  ","<<aIndexAndSize.second<<"}");
-
-        vtkIdType aNbElem = aIndexAndSize.second;
-        vtkIdType aStart = aIndexAndSize.first * aNbComp;
-        VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
-        TVMeshValue* aMeshValue = new TVMeshValue();
-        aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);
-        aVMeshValue.reset(aMeshValue);
-      }
-    }
-  }
-}
-
-int
-VISU_MEDConvertor
-::LoadField(VISU::PCMesh theMesh,
-            VISU::PCMeshOnEntity theMeshOnEntity,
-            VISU::PField theField, 
-            VISU::PCValForTime theValForTime)
-{
-  MESSAGE("VISU_MEDConvertor::LoadField");
-  //Check on loading already done
-  VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
-  if(anUnstructuredGridIDMapper->myIsVTKDone) 
-    return 0;
-  
-  VISU::PCProfile aProfile(new VISU::TCProfile());
-  aProfile->myIsAll = true;
-  theValForTime->myProfile = aProfile;
-
-  SALOME_MED::FIELD_var aMEDField = theValForTime->myField;
-
-  SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();
-
-  if(aMEDSupport->isOnAllElements()) aProfile->myIsDone = true;
-  
-  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
-  if(!aFieldDouble->_is_nil()){
-    SALOME_TYPES::ListOfDouble_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
-    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
-    ImportField<CORBA::Double>(anArray,
-                               theMesh,
-                               theField,
-                               theValForTime,
-                               theMeshOnEntity);
-  }
-
-  SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
-  if(!aFieldInt->_is_nil()){
-    SALOME_TYPES::ListOfLong_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
-    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
-    ImportField<CORBA::Long>(anArray,
-                             theMesh,
-                             theField,
-                             theValForTime,
-                             theMeshOnEntity);
-  }
-
-  anUnstructuredGridIDMapper->myIsVTKDone = true;
-
-  MESSAGE("VISU_MEDConvertor::LoadField done");
-  return 1;
-}
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+//  This library is free software; you can redistribute it and/or\r
+//  modify it under the terms of the GNU Lesser General Public\r
+//  License as published by the Free Software Foundation; either\r
+//  version 2.1 of the License.\r
+//\r
+//  This library is distributed in the hope that it will be useful,\r
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+//  Lesser General Public License for more details.\r
+//\r
+//  You should have received a copy of the GNU Lesser General Public\r
+//  License along with this library; if not, write to the Free Software\r
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
+//\r
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+//  VISU OBJECT : interactive object for VISU entities implementation\r
+//  File   : VISU_CorbaMedConvertor.cxx\r
+//  Author : Alexey PETROV\r
+//  Module : VISU\r
+//  $Header$\r
+//\r
+#include "VISU_CorbaMedConvertor.hxx"\r
+#include "VISU_ConvertorUtils.hxx"\r
+\r
+#include <vtkCellType.h>\r
+\r
+#include <boost/tuple/tuple.hpp>\r
+\r
+#include "ReceiverFactory.hxx"\r
+#include "MED_SliceArray.hxx"\r
+\r
+#include "utilities.h"\r
+\r
+#define USER_INTERLACE MED_FULL_INTERLACE\r
+\r
+#ifdef _DEBUG_\r
+static int MYDEBUG = 0;\r
+#else\r
+static int MYDEBUG = 0;\r
+#endif\r
+\r
+extern "C" {\r
+  VISU_Convertor* \r
+  CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) \r
+  {\r
+    return new VISU_MEDConvertor(theMedSObject);\r
+  }\r
+\r
+  VISU_Convertor* \r
+  CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) \r
+  {\r
+    return new VISU_MEDFieldConvertor(theField);\r
+  }\r
+}\r
+\r
+namespace\r
+{\r
+  const int MED_NBR_GEOMETRIE_MAILLE = 17;\r
+  \r
+  SALOME_MED::medGeometryElement \r
+  CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {\r
+    SALOME_MED::MEDMEM_POINT1,\r
+    SALOME_MED::MEDMEM_SEG2,\r
+    SALOME_MED::MEDMEM_SEG3,\r
+    SALOME_MED::MEDMEM_TRIA3,\r
+    SALOME_MED::MEDMEM_QUAD4,\r
+    SALOME_MED::MEDMEM_TRIA6,\r
+    SALOME_MED::MEDMEM_QUAD8,\r
+    SALOME_MED::MEDMEM_TETRA4,\r
+    SALOME_MED::MEDMEM_PYRA5,\r
+    SALOME_MED::MEDMEM_PENTA6,\r
+    SALOME_MED::MEDMEM_HEXA8,\r
+    SALOME_MED::MEDMEM_TETRA10,\r
+    SALOME_MED::MEDMEM_PYRA13,\r
+    SALOME_MED::MEDMEM_PENTA15,\r
+    SALOME_MED::MEDMEM_HEXA20,\r
+    SALOME_MED::MEDMEM_POLYGON,\r
+    SALOME_MED::MEDMEM_POLYHEDRA\r
+  };\r
+  \r
+  const int MED_NBR_GEOMETRIE_FACE = 5;\r
+  \r
+  SALOME_MED::medGeometryElement\r
+  FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {\r
+    SALOME_MED::MEDMEM_TRIA3,\r
+    SALOME_MED::MEDMEM_QUAD4,\r
+    SALOME_MED::MEDMEM_TRIA6,\r
+    SALOME_MED::MEDMEM_QUAD8,\r
+    SALOME_MED::MEDMEM_POLYGON\r
+  };\r
+  \r
+  const int MED_NBR_GEOMETRIE_ARETE = 2;\r
+  \r
+  SALOME_MED::medGeometryElement\r
+  EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {\r
+    SALOME_MED::MEDMEM_SEG2,\r
+    SALOME_MED::MEDMEM_SEG3\r
+  };\r
+  \r
+  const int MED_NBR_GEOMETRIE_NODE = 1;\r
+  \r
+  SALOME_MED::medGeometryElement\r
+  NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {\r
+    SALOME_MED::MEDMEM_POINT1,\r
+  };\r
+  \r
+\r
+  //---------------------------------------------------------------\r
+  int\r
+  GetEntity2Geom(const VISU::TEntity& theEntity, \r
+                 SALOME_MED::medGeometryElement*& theVector)\r
+  {\r
+    switch(theEntity){\r
+    case VISU::CELL_ENTITY: \r
+      theVector = CELLGEOM; \r
+      return MED_NBR_GEOMETRIE_MAILLE; \r
+    case VISU::FACE_ENTITY: \r
+      theVector = FACEGEOM; \r
+      return MED_NBR_GEOMETRIE_FACE; \r
+    case VISU::EDGE_ENTITY: \r
+      theVector = EDGEGEOM; \r
+      return MED_NBR_GEOMETRIE_ARETE; \r
+    case VISU::NODE_ENTITY: \r
+      theVector = NODEGEOM; \r
+      return MED_NBR_GEOMETRIE_NODE; \r
+    }\r
+    return -1;\r
+  }\r
+  \r
+\r
+  //---------------------------------------------------------------\r
+  int\r
+  MEDGeom2NbNodes(int theMEDGeomType)\r
+  { \r
+    switch(theMEDGeomType){\r
+    case SALOME_MED::MEDMEM_NONE: \r
+      return 0;\r
+    case SALOME_MED::MEDMEM_POINT1: \r
+      return 1;\r
+    case SALOME_MED::MEDMEM_SEG2: \r
+      return 2;\r
+    case SALOME_MED::MEDMEM_SEG3: \r
+      return 3;\r
+    case SALOME_MED::MEDMEM_TRIA3: \r
+      return 3;\r
+    case SALOME_MED::MEDMEM_TRIA6: \r
+      return 6;\r
+    case SALOME_MED::MEDMEM_QUAD4: \r
+      return 4;\r
+    case SALOME_MED::MEDMEM_QUAD8: \r
+      return 8;\r
+    case SALOME_MED::MEDMEM_TETRA4: \r
+      return 4;\r
+    case SALOME_MED::MEDMEM_TETRA10: \r
+      return 10;\r
+    case SALOME_MED::MEDMEM_HEXA8: \r
+      return 8;\r
+    case SALOME_MED::MEDMEM_HEXA20: \r
+      return 20;\r
+    case SALOME_MED::MEDMEM_PENTA6: \r
+      return 6;\r
+    case SALOME_MED::MEDMEM_PENTA15: \r
+      return 15;\r
+    case SALOME_MED::MEDMEM_PYRA5: \r
+      return 5;\r
+    case SALOME_MED::MEDMEM_PYRA13: \r
+      return 13;\r
+    }\r
+    return -1;\r
+  }\r
+  \r
+\r
+  //---------------------------------------------------------------\r
+  VISU::EGeometry\r
+  MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)\r
+  { \r
+    switch(theGeom){\r
+    case SALOME_MED::MEDMEM_POINT1:\r
+      return VISU::ePOINT1;\r
+    case SALOME_MED::MEDMEM_SEG2: \r
+      return VISU::eSEG2;\r
+    case SALOME_MED::MEDMEM_SEG3: \r
+      return VISU::eSEG3;\r
+    case SALOME_MED::MEDMEM_TRIA3: \r
+      return VISU::eTRIA3;\r
+    case SALOME_MED::MEDMEM_TRIA6: \r
+      return VISU::eTRIA6;\r
+    case SALOME_MED::MEDMEM_QUAD4: \r
+      return VISU::eQUAD4;\r
+    case SALOME_MED::MEDMEM_QUAD8: \r
+      return VISU::eQUAD8;\r
+    case SALOME_MED::MEDMEM_TETRA4: \r
+      return VISU::eTETRA4;\r
+    case SALOME_MED::MEDMEM_TETRA10: \r
+      return VISU::eTETRA10;\r
+    case SALOME_MED::MEDMEM_HEXA8: \r
+      return VISU::eHEXA8;\r
+    case SALOME_MED::MEDMEM_HEXA20: \r
+      return VISU::eHEXA20;\r
+    case SALOME_MED::MEDMEM_PENTA6: \r
+      return VISU::ePENTA6;\r
+    case SALOME_MED::MEDMEM_PENTA15: \r
+      return VISU::ePENTA15;\r
+    case SALOME_MED::MEDMEM_PYRA5: \r
+      return VISU::ePYRA5;\r
+    case SALOME_MED::MEDMEM_PYRA13: \r
+      return VISU::ePYRA13;\r
+    case SALOME_MED::MEDMEM_POLYGON: \r
+      return VISU::ePOLYGONE;\r
+    case SALOME_MED::MEDMEM_POLYHEDRA: \r
+      return VISU::ePOLYEDRE;\r
+    }\r
+    return VISU::eNONE;\r
+  }\r
+  \r
+  //---------------------------------------------------------------\r
+  SALOME_MED::medGeometryElement \r
+  VISUGeomToMED(int theGeom)\r
+  { \r
+    switch(theGeom){\r
+    case VISU::ePOINT1: \r
+      return SALOME_MED::MEDMEM_POINT1;\r
+    case VISU::eSEG2: \r
+      return SALOME_MED::MEDMEM_SEG2;\r
+    case VISU::eTRIA3: \r
+      return SALOME_MED::MEDMEM_TRIA3;\r
+    case VISU::eQUAD4: \r
+      return SALOME_MED::MEDMEM_QUAD4;\r
+    case VISU::eTETRA4: \r
+      return SALOME_MED::MEDMEM_TETRA4;\r
+    case VISU::eHEXA8: \r
+      return SALOME_MED::MEDMEM_HEXA8;\r
+    case VISU::ePENTA6: \r
+      return SALOME_MED::MEDMEM_PENTA6;\r
+    case VISU::ePYRA5: \r
+      return SALOME_MED::MEDMEM_PYRA5;\r
+\r
+    case VISU::eSEG3: \r
+      return SALOME_MED::MEDMEM_SEG3;\r
+    case VISU::eTRIA6: \r
+      return SALOME_MED::MEDMEM_TRIA6;\r
+    case VISU::eQUAD8: \r
+      return SALOME_MED::MEDMEM_QUAD8;\r
+    case VISU::eTETRA10: \r
+      return SALOME_MED::MEDMEM_TETRA10;\r
+    case VISU::eHEXA20: \r
+      return SALOME_MED::MEDMEM_HEXA20;\r
+    case VISU::ePENTA15: \r
+      return SALOME_MED::MEDMEM_PENTA15;\r
+    case VISU::ePYRA13: \r
+      return SALOME_MED::MEDMEM_PYRA13;\r
+    case VISU::ePOLYGONE: \r
+      return SALOME_MED::MEDMEM_POLYGON;\r
+    case VISU::ePOLYEDRE: \r
+      return  SALOME_MED::MEDMEM_POLYHEDRA;\r
+    }\r
+    return SALOME_MED::medGeometryElement(-1);\r
+  }\r
+\r
+  //---------------------------------------------------------------\r
+  SALOME_MED::medGeometryElement \r
+  VTKGeomToMED(int theVTKGeomType)\r
+  { \r
+    switch(theVTKGeomType){\r
+    case VTK_VERTEX: \r
+      return SALOME_MED::MEDMEM_POINT1;\r
+    case VTK_LINE: \r
+      return SALOME_MED::MEDMEM_SEG2;\r
+    case VTK_TRIANGLE:\r
+      return SALOME_MED::MEDMEM_TRIA3;\r
+    case VTK_QUAD: \r
+      return SALOME_MED::MEDMEM_QUAD4;\r
+    case VTK_TETRA: \r
+      return SALOME_MED::MEDMEM_TETRA4;\r
+    case VTK_HEXAHEDRON: \r
+      return SALOME_MED::MEDMEM_HEXA8;\r
+    case VTK_WEDGE:\r
+      return SALOME_MED::MEDMEM_PENTA6;\r
+    case VTK_PYRAMID: \r
+      return SALOME_MED::MEDMEM_PYRA5;\r
+    case VTK_POLYGON: \r
+      return SALOME_MED::MEDMEM_POLYGON;\r
+    }\r
+    return SALOME_MED::medGeometryElement(-1);\r
+  }\r
+  \r
+  //---------------------------------------------------------------\r
+  VISU::TEntity\r
+  MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)\r
+  {\r
+    switch(theMEDEntity){\r
+    case SALOME_MED::MED_NODE: \r
+      return VISU::NODE_ENTITY;\r
+    case SALOME_MED::MED_EDGE: \r
+      return VISU::EDGE_ENTITY;\r
+    case SALOME_MED::MED_FACE: \r
+      return VISU::FACE_ENTITY;\r
+    case SALOME_MED::MED_CELL: \r
+      return VISU::CELL_ENTITY;\r
+    }\r
+    return VISU::TEntity(-1);\r
+  }\r
+  \r
+  //---------------------------------------------------------------\r
+  SALOME_MED::medEntityMesh \r
+  VTKEntityToMED(VISU::TEntity theVTKEntity)\r
+  {\r
+    switch(theVTKEntity){\r
+    case VISU::NODE_ENTITY: \r
+      return SALOME_MED::MED_NODE;\r
+    case VISU::EDGE_ENTITY: \r
+      return SALOME_MED::MED_EDGE;\r
+    case VISU::FACE_ENTITY: \r
+      return SALOME_MED::MED_FACE;\r
+    case VISU::CELL_ENTITY: \r
+      return SALOME_MED::MED_CELL;\r
+    }\r
+    return SALOME_MED::medEntityMesh(-1);\r
+  }\r
+\r
+  \r
+  //---------------------------------------------------------------\r
+  std::string \r
+  GetSObjectName(SALOMEDS::SObject_ptr aSObject)\r
+  {\r
+    SALOMEDS::GenericAttribute_var anAttr;\r
+    if (aSObject->FindAttribute(anAttr,"AttributeName")) {\r
+      SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);\r
+      CORBA::String_var aString = aName->Value();\r
+      return aString.in();\r
+    }\r
+    return "";\r
+  }\r
+  \r
+\r
+  //---------------------------------------------------------------\r
+  void \r
+  GetCellsSize(vtkIdType& theNbCells, \r
+               vtkIdType& theCellsSize,\r
+               SALOME_MED::MESH_ptr theMEDMesh,\r
+               const VISU::TEntity& theVEntity)\r
+  {\r
+    theNbCells = theCellsSize = 0;\r
+    if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);\r
+    const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);\r
+    SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);\r
+    int iGeomEnd = connInfo->meshTypes.length();\r
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){\r
+      int iNumElemEnd = connInfo->numberOfElements[iGeom];\r
+      if(iNumElemEnd > 0){\r
+        if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);\r
+        theCellsSize += iNumElemEnd + connInfo->nodalConnectivityLength[iGeom];\r
+        theNbCells += iNumElemEnd;\r
+      }\r
+    }\r
+  }\r
+  \r
+  \r
+  //---------------------------------------------------------------\r
+  void \r
+  GetCellsSize(vtkIdType& theNbCells, \r
+               vtkIdType& theCellsSize,\r
+               SALOME_MED::FAMILY_ptr theMEDFamily)\r
+  {\r
+    theNbCells = theCellsSize = 0;\r
+    SALOME_MED::SUPPORT::supportInfos_var suppInfo=theMEDFamily->getSupportGlobal();\r
+    int iGeomEnd = suppInfo->types.length();\r
+    if(MYDEBUG) MESSAGE("GetCellsSize - iGeomEnd = "<<iGeomEnd);\r
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++) {\r
+      int iNumElemEnd = suppInfo->nbEltTypes[iGeom];\r
+      if(iNumElemEnd > 0){\r
+        if(MYDEBUG) MESSAGE("GetCellsSize - iNumElemEnd = "<<iNumElemEnd);\r
+        theNbCells += iNumElemEnd;\r
+        theCellsSize += iNumElemEnd + suppInfo->nodalConnectivityLength[iGeom];\r
+      }\r
+    }\r
+  }\r
+  \r
+  \r
+  //---------------------------------------------------------------\r
+  void\r
+  GetCellsSize(VISU::PCMesh theMesh, \r
+               SALOME_MED::MESH_ptr theMEDMesh, \r
+               const VISU::TEntity& theEntity)\r
+  {\r
+    VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;\r
+    VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];\r
+    if(theEntity == VISU::NODE_ENTITY){\r
+      aMeshOnEntity->myNbCells = theMesh->myNbPoints;\r
+      aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;\r
+    }else{\r
+      GetCellsSize(aMeshOnEntity->myNbCells,aMeshOnEntity->myCellsSize,theMEDMesh,theEntity);\r
+    }\r
+  }\r
\r
+\r
+  //---------------------------------------------------------------\r
+  VISU::PCMeshOnEntity \r
+  InitMeshOnEntity(const VISU::PCMesh& theMesh,\r
+                   const VISU::TEntity& theEntity,\r
+                   const VISU::PCMeshOnEntity& theMeshOnEntity)\r
+  {\r
+    VISU::PCMeshOnEntity aMeshOnEntity;\r
+    VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;\r
+    VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);\r
+    if(anIter == aMeshOnEntityMap.end()){\r
+      aMeshOnEntity.reset(new VISU::TCMeshOnEntity());\r
+      *aMeshOnEntity = *theMeshOnEntity;\r
+      aMeshOnEntity->myEntity = theEntity;\r
+      aMeshOnEntityMap[theEntity] = aMeshOnEntity;\r
+    }else\r
+      aMeshOnEntity = anIter->second;\r
+\r
+    GetCellsSize(theMesh,theMesh->myMesh,theEntity);\r
+\r
+    return aMeshOnEntity;\r
+  }\r
+\r
+  \r
+  VISU::PCSubProfile\r
+  CrSubProfile(const VISU::PCMesh theMesh,\r
+               const VISU::PCField theField,\r
+               const VISU::TCMeshOnEntity& theMeshOnEntity,\r
+               SALOME_MED::medGeometryElement theMGeom,\r
+               int theNbElems)\r
+  {\r
+    if (MYDEBUG) MESSAGE("CrSubProfile");\r
+    VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);\r
+    vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);\r
+\r
+    VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());\r
+    aSubProfile->myGeom = aEGeom;\r
+    aSubProfile->myMGeom = theMGeom;\r
+    aSubProfile->myStatus = VISU::eAddAll;\r
+    if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);\r
+    const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;\r
+    VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);\r
+    if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() && \r
+       theMGeom != SALOME_MED::MEDMEM_POINT1)\r
+      aSubProfile->myStatus = VISU::eRemoveAll;\r
+    else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MEDMEM_POINT1){\r
+      if(theNbElems > 0){\r
+        aSubProfile->myName = "";\r
+        aSubProfile->myStatus = VISU::eAddPart;\r
+        \r
+        aSubProfile->myNbCells = theNbElems;\r
+        aSubProfile->myCellsSize = aSubProfile->myNbCells;\r
+      }\r
+    }else{\r
+        if(theNbElems > 0){\r
+          aSubProfile->myName = "";\r
+          aSubProfile->myStatus = VISU::eAddPart;\r
+          \r
+          aSubProfile->myNbCells = theNbElems;\r
+          aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;\r
+        }\r
+      }\r
+    \r
+    if (MYDEBUG) MESSAGE("CrSubProfile done");\r
+    return aSubProfile;\r
+  }\r
+\r
+  VISU::TProfileKey\r
+  GetProfileKey(const VISU::PCMesh theMesh,\r
+                const VISU::PCField theField,\r
+                const VISU::PCValForTime theValForTime,\r
+                const VISU::TCMeshOnEntity& theMeshOnEntity)\r
+  {\r
+    if (MYDEBUG) MESSAGE("GetProfileKey");\r
+\r
+    VISU::TProfileKey aProfileKey;\r
+\r
+    const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;\r
+    VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();\r
+    SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();\r
+    int aNbElems = 0;\r
+    if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){\r
+      SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MEDMEM_POINT1;\r
+      try{\r
+        aNbElems = aSupport->getNumberOfElements(SALOME_MED::MEDMEM_NONE);\r
+        if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<"   aNbElems="<<aNbElems);\r
+      }catch(...){\r
+        MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");\r
+      }\r
+        \r
+      VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,\r
+                                                    theField,\r
+                                                    theMeshOnEntity,\r
+                                                    aMGeom,\r
+                                                    aNbElems);\r
+      aProfileKey.insert(aSubProfile);\r
+    }\r
+    \r
+    for(; anIter != aFirstIndex.end(); anIter++){\r
+      SALOME_MED::medGeometryElement aMGeom = anIter->first;\r
+      try{\r
+        aNbElems = aSupport->getNumberOfElements(aMGeom);\r
+        if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<"   aNbElems="<<aNbElems);\r
+      } catch(...){\r
+        MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");\r
+        continue;\r
+      }\r
+      VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,\r
+                                                    theField,\r
+                                                    theMeshOnEntity,\r
+                                                    aMGeom,\r
+                                                    aNbElems);\r
+      aProfileKey.insert(aSubProfile);\r
+    }\r
+\r
+    if (MYDEBUG) MESSAGE("GetProfileKey done");\r
+    return aProfileKey;\r
+  }\r
+  \r
+  void\r
+  InitProfile(VISU::PCMesh theMesh,\r
+              VISU::PCField theField,\r
+              VISU::PCValForTime theValForTime,\r
+              VISU::TCMeshOnEntity& theMeshOnEntity)\r
+  {\r
+    if (MYDEBUG) MESSAGE("InitProfile");\r
+    \r
+    VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;\r
+\r
+    VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,\r
+                                                  theField,\r
+                                                  theValForTime,\r
+                                                  theMeshOnEntity);\r
+    \r
+    VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);\r
+    if(anIter != aProfileMap.end()){\r
+      theValForTime->myProfile = anIter->second;\r
+      if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");\r
+    }else{\r
+      VISU::PCProfile aProfile(new VISU::TCProfile());\r
+      VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;\r
+      \r
+      VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();\r
+      for(; anIter != aProfileKey.end(); anIter++){\r
+        VISU::PCSubProfile aSubProfile(*anIter);\r
+        \r
+        if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)\r
+          aProfile->myIsAll = false;\r
+        \r
+        VISU::EGeometry aEGeom = aSubProfile->myGeom;\r
+        aGeom2SubProfile[aEGeom] = aSubProfile;\r
+      }\r
+      \r
+      aProfileMap[aProfileKey] = aProfile;\r
+      theValForTime->myProfile = aProfile;\r
+    }\r
+    if (MYDEBUG) MESSAGE("InitProfile done");\r
+  }\r
+\r
+  void\r
+  LoadProfile(VISU::PCMesh theMesh,\r
+              VISU::PCField theField,\r
+              VISU::PCValForTime theValForTime,\r
+              VISU::PCMeshOnEntity theMeshOnEntity)\r
+  {\r
+    VISU::PCProfile aProfile = theValForTime->myProfile;\r
+    if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<<aProfile->myIsDone);\r
+    if(aProfile->myIsDone)\r
+      return;\r
+    \r
+    const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;\r
+    VISU::TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();\r
+    if(aGeom2SubProfileIter == aGeom2SubProfile.end()){\r
+      MESSAGE("Warning! No geom 2 sub profile");\r
+    }\r
+    SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();\r
+    for(; aGeom2SubProfileIter != aGeom2SubProfile.end(); aGeom2SubProfileIter++){\r
+      VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;\r
+      SALOME_MED::medGeometryElement aMGeom = VISUGeomToMED(aEGeom);\r
+      VISU::PCSubProfile aSubProfile = aGeom2SubProfileIter->second;\r
+      SALOME_TYPES::ListOfLong_var aGeom2ProfileIds;\r
+      std::vector<int> aGeom2Profile;\r
+      if(!aSupport->isOnAllElements()){\r
+        try{\r
+          if(aMGeom == SALOME_MED::MEDMEM_POINT1)\r
+            aGeom2ProfileIds = aSupport->getNumberFromFile(SALOME_MED::MEDMEM_NONE);\r
+          else\r
+            aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom);\r
+          int aLen = aGeom2ProfileIds->length();\r
+          if(MYDEBUG) MESSAGE_BEGIN(" - aMGeom="<<aMGeom<<"; aNbCells="<<aLen);\r
+          for(int i = 0; i < aLen; i++){\r
+            int anId = aGeom2ProfileIds[i];\r
+            aGeom2Profile.push_back(anId);\r
+            if(MYDEBUG) MESSAGE_ADD(std::endl << "------------------------------->" << anId);\r
+          }\r
+          if(MYDEBUG) MESSAGE_END(" ");\r
+        } catch(...) {\r
+          continue;\r
+        }\r
+      } else {\r
+        SALOME_MED::medEntityMesh aMEntity = aSupport->getEntity();\r
+        int aNbElems = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);\r
+        for(int i = 0; i < aNbElems; i++) \r
+          aGeom2Profile.push_back(i+1);\r
+      }\r
+      if(aGeom2Profile.size()>0){\r
+        VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;\r
+        int aSize = aGeom2Profile.size();\r
+        aSubMeshID.resize(aSize);\r
+        for(int anId = 0; anId < aSize; anId++){\r
+          aSubMeshID[anId] = aGeom2Profile[anId] - 1;\r
+        }\r
+      }\r
+    }\r
+    \r
+    aProfile->myIsDone = true;\r
+    if (MYDEBUG) MESSAGE("LoadProfile done");\r
+  }\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+VISU_Convertor* \r
+VISU_MEDFieldConvertor\r
+::Build()\r
+{\r
+  if(myField->_is_nil()) \r
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");\r
+  \r
+  SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport();\r
+  if(aMEDSupport->_is_nil()) \r
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");\r
+\r
+  SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+  VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);\r
+  SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();\r
+  if(aMEDMesh->_is_nil()) \r
+    throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");\r
+\r
+  CORBA::String_var aMeshName = aMEDMesh->getName();\r
+  CORBA::String_var aFieldName = myField->getName();\r
+\r
+  VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());\r
+  aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());\r
+  aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();\r
+  aMesh->myDim = aMEDMesh->getSpaceDimension();\r
+  aMesh->myName = aMeshName.in();\r
+  aMesh->myMesh = aMEDMesh;\r
+\r
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);\r
+\r
+  VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;\r
+  VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new VISU::TCMeshOnEntity());\r
+  aMeshOnEntity->myEntity = aVEntity;\r
+  aMeshOnEntity->myMeshName = aMeshName.in();\r
+  aMeshOnEntity->mySupport = aMEDSupport;\r
+\r
+  if(aVEntity == VISU::NODE_ENTITY)\r
+    ::InitMeshOnEntity(aMesh, VISU::CELL_ENTITY, aMeshOnEntity);\r
+  else\r
+    ::InitMeshOnEntity(aMesh, VISU::NODE_ENTITY, aMeshOnEntity);\r
+\r
+  ::GetCellsSize(aMesh, aMEDMesh, aVEntity);\r
+\r
+  VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;\r
+  VISU::PCField aField = aFieldMap[aFieldName.in()](new VISU::TCField());\r
+  aField->myId = myField->getOrderNumber();\r
+  aField->myName = aFieldName.in();\r
+  aField->myEntity = aVEntity;\r
+  aField->myMeshName = aMeshName.in();\r
+  aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;\r
+\r
+  vtkIdType aDataType = VTK_DOUBLE;\r
+  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);\r
+  if(aFieldDouble->_is_nil()) {\r
+    // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".\r
+    if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)\r
+      aDataType = VTK_LONG;\r
+    else if (sizeof(int) == 4)\r
+      aDataType = VTK_INT;\r
+    else {\r
+      throw std::runtime_error("Can't map CORBA::Long to a VTK type");\r
+    }\r
+  }\r
+  aField->Init(myField->getNumberOfComponents(), aDataType);\r
+\r
+  if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);\r
+\r
+  VISU::TValField& aValField = aField->myValField;\r
+  int anId = myField->getIterationNumber();\r
+  VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());\r
+  aValForTime->myId = anId;\r
+  CORBA::Double aDT = myField->getTime();\r
+  aValForTime->myTime = VISU::TTime(aDT,"");\r
+  aValForTime->myField = myField;\r
+\r
+  if(MYDEBUG) \r
+    MESSAGE("VISU_MEDFieldConvertor::Build - aFieldName = '"<<aFieldName<<\r
+            "'; myId = "<<anId<<"; myTime = "<<aDT);\r
+\r
+  return this;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+VISU_Convertor* \r
+VISU_MEDConvertor\r
+::Build() \r
+{\r
+  if(mySObject->_is_nil()) \r
+    throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");\r
+  SALOMEDS::Study_var aStudy = mySObject->GetStudy();\r
+\r
+  CORBA::Object_var aMedObject = VISU::SObjectToObject(mySObject);\r
+  if(!CORBA::is_nil(aMedObject)){\r
+    SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject);\r
+    return Build(aMED);\r
+  }\r
+\r
+  SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);\r
+  return Build(aTimeStampIterator);\r
+}\r
+\r
+\r
+namespace\r
+{\r
+  using namespace boost;\r
+\r
+  //---------------------------------------------------------------\r
+  struct TSObjectByName\r
+  {\r
+    std::string myName;\r
+    typedef tuple<SALOMEDS::SObject_var> TRet;\r
+\r
+    TSObjectByName(const std::string& theName):\r
+      myName(theName)\r
+    {}\r
+\r
+    TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)\r
+    {\r
+      SALOMEDS::GenericAttribute_var anAttr;\r
+      if(theSObj->FindAttribute(anAttr,"AttributeName")){\r
+        SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);\r
+        CORBA::String_var aValue = aName->Value();\r
+        theIsSuccess = (myName == aValue.in());\r
+        if(theIsSuccess)\r
+          return TRet(SALOMEDS::SObject::_duplicate(theSObj));\r
+      }\r
+      return TRet();\r
+    }\r
+\r
+  };\r
+\r
+\r
+  //---------------------------------------------------------------\r
+  struct TMeshByName\r
+  {\r
+    std::string myName;\r
+    typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;\r
+\r
+    TMeshByName(const std::string& theName):\r
+      myName(theName)\r
+    {}\r
+\r
+    TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)\r
+    {\r
+      CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);\r
+      if(!CORBA::is_nil(anObj)){\r
+        SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);\r
+        if(!CORBA::is_nil(aMesh)){\r
+          CORBA::String_var aName = aMesh->getName();\r
+          theIsSuccess = (myName == aName.in());\r
+          if(theIsSuccess)\r
+            return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));\r
+        }\r
+      }\r
+      return TRet();\r
+    }\r
+  };\r
+\r
+\r
+  //---------------------------------------------------------------\r
+  template<typename TFun>\r
+  typename TFun::TRet\r
+  Find(SALOMEDS::SObject_ptr theStartSObj, \r
+       SALOMEDS::Study_ptr theStudy,\r
+       TFun theFun,\r
+       bool& theIsSuccess,\r
+       bool theIsAllLevels = true)\r
+  {\r
+    SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theStartSObj);\r
+    anIter->InitEx(theIsAllLevels);\r
+    for(; anIter->More(); anIter->Next()){\r
+      SALOMEDS::SObject_var aSObj = anIter->Value();\r
+      typename TFun::TRet aRet = theFun(aSObj,theIsSuccess);\r
+      if(theIsSuccess)\r
+        return aRet;\r
+    }\r
+    return typename TFun::TRet();\r
+  }\r
+\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+VISU_Convertor* \r
+VISU_MEDConvertor\r
+::Build(SALOME_MED::MED_ptr theMED)\r
+{\r
+  if(CORBA::is_nil(theMED)) \r
+    return NULL;\r
+\r
+  CORBA::Long aNbMeshes = theMED->getNumberOfMeshes();\r
+  SALOME_TYPES::ListOfString_var aMeshNames = theMED->getMeshNames();\r
+  if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aNbMeshes = "<<aNbMeshes);\r
+\r
+  SALOMEDS::Study_var aStudy = mySObject->GetStudy();\r
+  SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();\r
+\r
+  bool anIsSuccess = false;\r
+  TSObjectByName::TRet aSObjectByNameRet = \r
+    Find(aMedCompSObj,aStudy,TSObjectByName("MEDMESH"),anIsSuccess);\r
+  if(MYDEBUG) \r
+    MESSAGE("VISU_MEDConvertor::Build - Find ('"<<"MEDMESH"<<"') = "<<anIsSuccess);\r
+  if(anIsSuccess){\r
+    SALOMEDS::SObject_var aMeshesSObj = boost::get<0>(aSObjectByNameRet);\r
+    for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){\r
+      anIsSuccess = false;\r
+      CORBA::String_var aMeshName = aMeshNames[iMesh];\r
+      TMeshByName::TRet aMeshByNameRet = \r
+        Find(aMeshesSObj,aStudy,TMeshByName(aMeshName.in()),anIsSuccess);\r
+      if(MYDEBUG) \r
+        MESSAGE("VISU_MEDConvertor::Build - Find aMeshName('"<<aMeshName.in()<<"') = "<<anIsSuccess);\r
+      if(!anIsSuccess)\r
+        continue;\r
+\r
+      VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());\r
+      SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);\r
+      aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());\r
+      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();\r
+      aMesh->myDim = aMEDMesh->getSpaceDimension();\r
+      aMesh->myName = aMeshName.in();\r
+      aMesh->myMesh = aMEDMesh;\r
+\r
+      if(MYDEBUG) \r
+        MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);\r
+\r
+      std::string aName = aMeshName.in();\r
+      std::replace(aName.begin(),aName.end(),' ','_');\r
+\r
+      anIsSuccess = false;\r
+      std::ostringstream aStream;\r
+      aStream<<"MEDSUPPORTS_OF_"<<aName;\r
+      std::string aSupportsName(aStream.str());\r
+      TSObjectByName::TRet aSObjectByNameRet = \r
+        Find(aMeshesSObj,aStudy,TSObjectByName(aSupportsName.c_str()),anIsSuccess);\r
+      if(MYDEBUG) \r
+        MESSAGE("VISU_MEDConvertor::Build - Find aSupportsName('"<<aSupportsName<<"') = "<<anIsSuccess);\r
+      if(!anIsSuccess)\r
+        continue;\r
+\r
+      VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;\r
+      SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);\r
+      SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);\r
+\r
+      // Fill all MeshOnEntity\r
+      aSupportIterator->InitEx(true);\r
+      for(; aSupportIterator->More(); aSupportIterator->Next()){\r
+        SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();\r
+        \r
+        CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);\r
+        if(CORBA::is_nil(aMedSupport)) \r
+          continue;\r
+        \r
+        SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport); \r
+        if(aMEDSupport->_is_nil()) \r
+          continue;\r
+        \r
+        SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();\r
+        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+        VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);\r
+        CORBA::String_var aSupportName = aMEDSupport->getName();\r
+        \r
+        if(aMEDSupport->isOnAllElements() && strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){\r
+          if(MYDEBUG) \r
+            MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<\r
+                    "' aVEntity = "<<aVEntity);\r
+          vtkIdType aNbCells, aCellsSize;\r
+          //Check, if there is any data on the support?\r
+          if(aVEntity == VISU::NODE_ENTITY){\r
+            aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();\r
+            aNbCells = aMesh->myNbPoints;\r
+            aCellsSize = 2*aMesh->myNbPoints;\r
+          }else\r
+            ::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);\r
+          \r
+          if(aNbCells > 0){\r
+            if(aMeshOnEntityMap.find(aVEntity) == aMeshOnEntityMap.end()){\r
+              VISU::PCMeshOnEntity aMeshOnEntity(new VISU::TCMeshOnEntity());\r
+              aMeshOnEntity->myMeshName = aMeshName.in();\r
+              aMeshOnEntity->myEntity = aVEntity;\r
+              aMeshOnEntity->myNbCells = aNbCells;\r
+              aMeshOnEntity->myCellsSize = aCellsSize;\r
+              aMeshOnEntity->mySupport = aMEDSupport;\r
+              aMeshOnEntityMap[aVEntity] = aMeshOnEntity;\r
+            }\r
+          }\r
+        }\r
+      }\r
+\r
+      // Fill all Family\r
+      aSupportIterator->InitEx(true);\r
+      for(; aSupportIterator->More(); aSupportIterator->Next()){\r
+        SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();\r
+        \r
+        CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);\r
+        if(CORBA::is_nil(aMedSupport)) \r
+          continue;\r
+        \r
+        SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport); \r
+        if(aMEDSupport->_is_nil()) \r
+          continue;\r
+        \r
+        SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();\r
+        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+        VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);\r
+        CORBA::String_var aSupportName = aMEDSupport->getName();\r
+        \r
+        SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);\r
+        if(!aMEDFamily->_is_nil()) {\r
+          VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);\r
+          if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())\r
+            continue;\r
+          VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;\r
+\r
+          vtkIdType aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;\r
+          CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();\r
+          if(!anIsOnAllElements)\r
+            ::GetCellsSize(aNbCells,aCellsSize,aMEDFamily);\r
+\r
+          if(MYDEBUG) \r
+            MESSAGE("VISU_MEDConvertor::Build "<<\r
+                    "- aFamily = '"<<aSupportName<<"'"<<\r
+                    "; anIsOnAllElements = "<<anIsOnAllElements<<\r
+                    "; aVEntity = "<<aVEntity<<\r
+                    "; aNbCells = "<<aNbCells);\r
+\r
+          if(aNbCells > 0){\r
+            VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;\r
+            VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());\r
+            if(aFamilyMapIter == aFamilyMap.end()){\r
+              VISU::PCFamily aFamily(new VISU::TCFamily());\r
+              aFamily->myEntity = aVEntity;\r
+              aFamily->myNbCells = aNbCells;\r
+              aFamily->myCellsSize = aCellsSize;\r
+              aFamily->myId = aMEDFamily->getIdentifier();\r
+              aFamily->myName = aSupportName.in();\r
+              aFamily->myFamily = aMEDFamily;\r
+              aFamilyMap[aSupportName.in()] = aFamily;\r
+            }\r
+          }\r
+        }\r
+      }\r
+        \r
+      // Fill all Groups\r
+      aSupportIterator->InitEx(true);\r
+      for(; aSupportIterator->More(); aSupportIterator->Next()){\r
+        SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();\r
+        \r
+        CORBA::Object_var aMedSupport = VISU::SObjectToObject(aSupportSObj);\r
+        if(CORBA::is_nil(aMedSupport)) \r
+          continue;\r
+        \r
+        SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport); \r
+        if(aMEDSupport->_is_nil()) \r
+          continue;\r
+        \r
+        SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh()->convertInMESH();\r
+        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+        VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);\r
+        CORBA::String_var aSupportName = aMEDSupport->getName();\r
+        \r
+        SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);\r
+        if(!aMEDGroup->_is_nil()){\r
+          CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();\r
+\r
+          if(MYDEBUG) \r
+            MESSAGE("VISU_MEDConvertor::Build "<<\r
+                    "- aGroup = '"<<aSupportName<<"'"<<\r
+                    "; anIsOnAllElements = "<<anIsOnAllElements<<\r
+                    "; aVEntity = "<<aVEntity);\r
+\r
+          VISU::PCGroup aGroup(new VISU::TCGroup());\r
+          aGroup->myGroup = aMEDGroup;\r
+          VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;\r
+          \r
+          SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();\r
+          int iFamilyEnd = aFamilies->length();\r
+          for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){\r
+            SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];\r
+            CORBA::String_var aFamilyName = aMEDFamily->getName();\r
+            TFindFamilyOnEntity aFindFamilyOnEntity = \r
+              FindFamilyOnEntity(aMeshName.in(), aVEntity, aFamilyName.in());\r
+            VISU::PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);\r
+            if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));\r
+            if(aFamily){\r
+              aFamilySet.insert(VISU::TEnity2Family(aVEntity, aFamily));\r
+            }\r
+          }\r
+          \r
+          if(!aFamilySet.empty()){\r
+            VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;\r
+            aGroupMap[aSupportName.in()] = aGroup;\r
+          }\r
+\r
+        }\r
+      }\r
+    }\r
+  }\r
+\r
+  anIsSuccess = false;\r
+  aSObjectByNameRet = Find(aMedCompSObj,aStudy,TSObjectByName("MEDFIELD"),anIsSuccess);\r
+  if(anIsSuccess){\r
+    SALOMEDS::SObject_var aFieldsSObj = boost::get<0>(aSObjectByNameRet);\r
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found.");\r
+    SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldsSObj);\r
+    for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){\r
+      SALOMEDS::SObject_var aFieldSObj = aFieldIterator->Value();\r
+      if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<GetSObjectName(aFieldSObj)<<"'");\r
+      SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj);\r
+      for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){\r
+        SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value();\r
+        if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");\r
+        CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);\r
+        if(CORBA::is_nil(aMedField)) \r
+          continue;\r
+\r
+        SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);\r
+        if(aMEDField->_is_nil()) \r
+          continue;\r
+\r
+        SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();\r
+        if(aMEDSupport->_is_nil()) \r
+          continue;\r
+\r
+        SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+        VISU::TEntity anEntity = MEDEntityToVTK(aMEntity);\r
+        SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();\r
+        if(aMEDMesh->_is_nil()) \r
+          continue;\r
+\r
+        CORBA::String_var aMeshName = aMEDMesh->getName();\r
+        CORBA::String_var aFieldName = aMEDField->getName();\r
+        \r
+        VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());\r
+        if(aMeshMapIter == myMeshMap.end())\r
+          continue;\r
+\r
+        VISU::PCMesh aMesh = aMeshMapIter->second;\r
+        VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;\r
+        VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);\r
+        if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())\r
+          continue;\r
+\r
+        VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;\r
+        VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;\r
+        VISU::TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());\r
+        VISU::PCField aField;\r
+        if(aFieldMapIter == aFieldMap.end()){\r
+          aField = aFieldMap[aFieldName.in()](new VISU::TCField());\r
+          aField->myId = iField;\r
+          aField->myName = aFieldName.in();\r
+          aField->myEntity = anEntity;\r
+          aField->myMeshName = aMeshName.in();\r
+          aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;\r
+\r
+          vtkIdType aDataType = VTK_DOUBLE;\r
+          SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);\r
+          if(aFieldDouble->_is_nil()) {\r
+            // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".\r
+            if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)\r
+              aDataType = VTK_LONG;\r
+            else if (sizeof(int) == 4)\r
+              aDataType = VTK_INT;\r
+            else {\r
+              MESSAGE("Can't map CORBA::Long to a VTK type, for Field " << aFieldName);\r
+              continue;\r
+            }\r
+          }\r
+          aField->Init(aMEDField->getNumberOfComponents(), aDataType);\r
+\r
+          if(MYDEBUG) \r
+            MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);\r
+        }else\r
+          aField = aFieldMapIter->second;\r
+\r
+        VISU::TValField& aValField = aField->myValField;\r
+        int anId = aMEDField->getIterationNumber();\r
+        VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());\r
+        aValForTime->myId = anId;\r
+        CORBA::Double aDT = aMEDField->getTime();\r
+        aValForTime->myTime = VISU::TTime(aDT,"");\r
+        aValForTime->myField = aMEDField;\r
+        if(MYDEBUG) \r
+          MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<\r
+                  "'; myEntity = "<<anEntity<<"; myTime = "<<aDT);\r
+      }      \r
+    }\r
+  }\r
+  return this; \r
+}\r
\r
+\r
+//---------------------------------------------------------------\r
+VISU_Convertor* \r
+VISU_MEDConvertor\r
+::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)\r
+{\r
+  if(theTimeStampIterator->_is_nil()) return NULL;\r
+  for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){\r
+    SALOMEDS::SObject_var aTimeStampSObj = theTimeStampIterator->Value();\r
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<GetSObjectName(aTimeStampSObj)<<"'");\r
+\r
+    CORBA::Object_var aMedField = VISU::SObjectToObject(aTimeStampSObj);\r
+    if(CORBA::is_nil(aMedField)) \r
+      continue;\r
+\r
+    SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField);\r
+    if(aMEDField->_is_nil()) \r
+      continue;\r
+\r
+    SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();\r
+    if(aMEDSupport->_is_nil()) \r
+      continue;\r
+\r
+    SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();\r
+    VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);\r
+    SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh()->convertInMESH();\r
+    if(aMEDMesh->_is_nil()) continue;\r
+    CORBA::String_var aMeshName = aMEDMesh->getName();\r
+    CORBA::String_var aFieldName = aMEDField->getName();\r
+\r
+    VISU::PCMesh aMesh;\r
+    VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());\r
+    if(aMeshMapIter == myMeshMap.end()){\r
+      aMesh.reset(new VISU::TCMesh());\r
+      aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());\r
+      aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();\r
+      aMesh->myDim = aMEDMesh->getSpaceDimension();\r
+      aMesh->myName = aMeshName.in();\r
+      aMesh->myMesh = aMEDMesh;\r
+      \r
+      myMeshMap[aMeshName.in()] = aMesh;\r
+\r
+      if(MYDEBUG) \r
+        MESSAGE("VISU_MEDConvertor::Build "<<\r
+                "- aMeshName = '"<<aMeshName<<"'"<<\r
+                "; aDim = "<<aMesh->myDim);\r
+    }else\r
+      aMesh = aMeshMapIter->second;\r
+\r
+    VISU::PCMeshOnEntity aMeshOnEntity;\r
+    VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;\r
+    VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);\r
+    if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){\r
+      aMeshOnEntity.reset(new VISU::TCMeshOnEntity());\r
+      aMeshOnEntity->myEntity = aVEntity;\r
+      aMeshOnEntity->myMeshName = aMeshName.in();\r
+      aMeshOnEntity->mySupport = aMEDSupport;\r
+      aMeshOnEntityMap[aVEntity] = aMeshOnEntity;\r
+    }else\r
+      aMeshOnEntity = aMeshOnEntityMapIter->second;\r
+\r
+    if(aVEntity == VISU::NODE_ENTITY)\r
+      ::InitMeshOnEntity(aMesh,VISU::CELL_ENTITY,aMeshOnEntity);\r
+    else\r
+      ::InitMeshOnEntity(aMesh,VISU::NODE_ENTITY,aMeshOnEntity);\r
+\r
+    ::GetCellsSize(aMesh,aMEDMesh,aVEntity);\r
+\r
+    VISU::PCField aField;\r
+    VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;\r
+    VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());\r
+    if(aFieldMapIter == aFieldMap.end()){\r
+      aField.reset(new VISU::TCField());\r
+      aField->myId = mySObject->Tag();\r
+      aField->myName = aFieldName.in();\r
+      aField->myEntity = aVEntity;\r
+      aField->myMeshName = aMeshName.in();\r
+      aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;\r
+      \r
+      vtkIdType aDataType = VTK_DOUBLE;\r
+      SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);\r
+      if(aFieldDouble->_is_nil()){\r
+        if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)\r
+          //Fix for IPAL20325 Crash on create presentation for imported field \r
+          aDataType = VTK_LONG;\r
+        else if (sizeof(int) == 4)\r
+          aDataType = VTK_INT;\r
+        else {\r
+          throw std::runtime_error("Can't map CORBA::Long to a VTK type");\r
+        }\r
+      }\r
+      aField->Init(aMEDField->getNumberOfComponents(), aDataType);\r
+\r
+      aFieldMap[aFieldName.in()] = aField;\r
+\r
+      if(MYDEBUG) \r
+        MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);\r
+    }else\r
+      aField = aFieldMapIter->second;\r
+\r
+    VISU::TValField& aValField = aField->myValField;\r
+    int anId = aMEDField->getIterationNumber();\r
+    VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());\r
+    aValForTime->myId = anId;\r
+    CORBA::Double aDT = aMEDField->getTime();\r
+    aValForTime->myTime = VISU::TTime(aDT,"");\r
+    aValForTime->myField = aMEDField;\r
+    if(MYDEBUG) \r
+      MESSAGE("VISU_MEDConvertor::Build "<<\r
+              "- aMeshName = '"<<aMeshName<<"'"<<\r
+              "; myEntity = "<<aVEntity<<\r
+              "; myTime = "<<aDT<<\r
+              "; anId = "<<anId);\r
+  }\r
+  return this; \r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int\r
+VISU_MEDConvertor\r
+::LoadMeshOnEntity(VISU::PMeshImpl theMesh,\r
+                   VISU::PMeshOnEntityImpl theMeshOnEntity)\r
+{\r
+  int anIsUpdated = LoadPoints(theMesh);\r
+  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;\r
+  if(aVEntity != VISU::NODE_ENTITY)\r
+    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);\r
+\r
+  return anIsUpdated;\r
+}\r
\r
\r
+//---------------------------------------------------------------\r
+int\r
+VISU_MEDConvertor\r
+::LoadFamilyOnEntity(VISU::PMeshImpl theMesh,\r
+                     VISU::PMeshOnEntityImpl theMeshOnEntity, \r
+                     VISU::PFamilyImpl theFamily)\r
+{\r
+  int anIsUpdated = LoadPoints(theMesh);\r
+  const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;\r
+  if(anEntity == VISU::NODE_ENTITY){\r
+    anIsUpdated |= LoadPointsOnFamily(theMesh,theFamily);\r
+  }else{\r
+    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);\r
+    anIsUpdated |= LoadCellsOnFamily(theMesh,theMeshOnEntity,theFamily);\r
+  }\r
+\r
+  return anIsUpdated;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadMeshOnGroup(VISU::PMeshImpl theMesh, \r
+                  const VISU::TFamilySet& theFamilySet)\r
+{\r
+  //Main part of code\r
+  int anIsUpdated = LoadPoints(theMesh);\r
+  VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();\r
+  for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){\r
+    VISU::PCFamily aFamily = (*aFamilyIter).second;\r
+    const VISU::TEntity& aVEntity = aFamily->myEntity;\r
+    VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];\r
+    if(aVEntity == VISU::NODE_ENTITY){\r
+      anIsUpdated |= LoadPointsOnFamily(theMesh,aFamily);\r
+    }else{\r
+      anIsUpdated |= LoadCellsOnEntity(theMesh,aMeshOnEntity);\r
+      anIsUpdated |= LoadCellsOnFamily(theMesh,aMeshOnEntity,aFamily);\r
+    }\r
+  }\r
+\r
+  return anIsUpdated;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, \r
+                       VISU::PMeshOnEntityImpl theMeshOnEntity, \r
+                       VISU::PFieldImpl theField, \r
+                       VISU::PValForTimeImpl theValForTime)\r
+{\r
+  //Main part of code\r
+  int anIsUpdated = LoadPoints(theMesh);\r
+  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;\r
+  if(aVEntity != VISU::NODE_ENTITY)\r
+    anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);\r
+\r
+  anIsUpdated |= LoadField(theMesh,theMeshOnEntity,theField,theValForTime);\r
+  \r
+  return anIsUpdated;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadPoints(VISU::PCMesh theMesh)\r
+{\r
+  //Check on existing family\r
+  VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];\r
+  \r
+  //Check on loading already done\r
+  if(theMesh->myIsDone) \r
+    return 0;\r
+  \r
+  SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;\r
+  vtkIdType aDim = theMesh->GetDim();\r
+  vtkIdType aNbElem = theMesh->GetNbPoints();\r
+\r
+  if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);\r
+\r
+  if(aNbElem <= 0) \r
+    throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");\r
+\r
+  SALOME_TYPES::ListOfDouble_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);\r
+  VISU::TCMEDCoordHolder* aCoordHolder = new VISU::TCMEDCoordHolder();\r
+  aCoordHolder->Init(aNbElem, aDim, aCCoord);\r
+\r
+  VISU::TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;\r
+  aCoords.Init(VISU::PCoordHolder(aCoordHolder));\r
+  \r
+  if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");\r
+  \r
+  VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;\r
+  VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TCSubMesh());\r
+\r
+  aSubMesh->myNbCells = theMesh->myNbPoints;\r
+  aSubMesh->myCellsSize = 2*theMesh->myNbPoints;\r
+\r
+  VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+  aCell2Connect.resize(aNbElem);\r
+  if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<<aNbElem);\r
+  for(int iElem = 0; iElem < aNbElem; iElem++)\r
+    aCell2Connect[iElem] = VISU::TConnect(1,iElem);\r
+  \r
+  theMesh->myIsDone = true;\r
+\r
+  return 1;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadPointsOnFamily(VISU::PCMesh theMesh, \r
+                     VISU::PCFamily theFamily)\r
+{\r
+  VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];\r
+\r
+  if(theFamily->myIsDone) \r
+    return 0;\r
+\r
+  vtkIdType aNbElem = theMesh->GetNbPoints();\r
+  SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;\r
+  CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();\r
+  VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];\r
+  \r
+  if(!anIsOnAllElements){\r
+    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();\r
+    SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);\r
+    int aSize = aNbElem;\r
+    aNbElem = aCellNumForType->length();\r
+    for(int iElem = 0; iElem < aNbElem; iElem++){\r
+      int anID = aCellNumForType[iElem] - 1;\r
+      if(0 > anID || anID >= aSize){\r
+        static QString aString;\r
+        aString.sprintf("LoadPointsOnFamily - aSize(%d) <= aCellNumForType[%d] = %d < 0",aSize,iElem,anID);\r
+        throw std::runtime_error((const char*)aString.toLatin1());\r
+      }\r
+      aSubMeshID.push_back(anID);\r
+    }\r
+  }else{\r
+    for(int iElem = 0; iElem < aNbElem; iElem++){\r
+      aSubMeshID.push_back(iElem);\r
+    }\r
+  }\r
+  \r
+  theFamily->myIsDone = true;\r
+  \r
+  return 1;\r
+}\r
+\r
+//---------------------------------------------------------------\r
+namespace \r
+{\r
+  typedef MED::TCSlice<int> TA;\r
+  //---------------------------------------------------------------\r
+  typedef std::set<int> TConnSet;\r
+  typedef std::vector<int> TIntArray;\r
+  typedef MED::TCSlice<int> TConnSlice;\r
+\r
+  //---------------------------------------------------------------\r
+  class MEDPolygonConnectivity //! retriver of polygon connectivity\r
+  {\r
+    TIntArray myConn;\r
+    TIntArray myConnIndex;\r
+  public:\r
+\r
+    MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,\r
+                           SALOME_MED::medEntityMesh theEntity) \r
+    {\r
+      {\r
+        SALOME::SenderInt_var aSender = \r
+          theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYGON);\r
+        long int aSize;\r
+        int* aValuePtr = ReceiverFactory::getValue(aSender.in(), aSize);\r
+        myConn.assign(aValuePtr, aValuePtr + aSize);\r
+      }\r
+      {\r
+        SALOME::SenderInt_var aSender = \r
+          theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYGON);\r
+        long int aSize;\r
+        int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);\r
+        myConnIndex.assign(aValuePtr, aValuePtr + aSize);\r
+      }\r
+    }\r
+\r
+    TConnSlice \r
+    GetConn(int theId) const \r
+    {\r
+      int anOffSet = myConnIndex[theId] - 1;\r
+      int aSize = myConnIndex[theId + 1] - myConnIndex[ theId ];\r
+      return TConnSlice(&myConn[0], myConn.size(), std::slice(anOffSet, aSize, 1));\r
+    }\r
+\r
+    int \r
+    GetNbElem() const \r
+    {\r
+      return myConnIndex.size() - 1;\r
+    }\r
+\r
+    int\r
+    GetCellSize() const\r
+    {\r
+      return myConn.size() + GetNbElem();\r
+    }\r
+  };\r
+\r
+\r
+  //---------------------------------------------------------------\r
+  class MEDPolyhedraConnectivity //! retriver of polyhedron connectivity\r
+  {\r
+    TIntArray myConn;\r
+    TIntArray myConnIndex;\r
+    TIntArray myFaceIndex;\r
+  public:\r
+\r
+    MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh,\r
+                             SALOME_MED::medEntityMesh theEntity)\r
+    {\r
+      {\r
+        SALOME::SenderInt_var aSender = \r
+          theMesh->getSenderForConnectivity(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYHEDRA);\r
+        long int aSize;\r
+        int* pt = ReceiverFactory::getValue(aSender, aSize);\r
+        //\r
+        SALOME::SenderInt_var aSender2 = \r
+          theMesh->getSenderForConnectivityIndex(SALOME_MED::MED_NODAL, theEntity, SALOME_MED::MEDMEM_POLYHEDRA);\r
+        long int aSizeI;\r
+        int* ptI = ReceiverFactory::getValue(aSender, aSize);\r
+        //\r
+        int nbOfPolyHCells=aSizeI-1;\r
+        std::vector<int> polh1v(aSizeI);\r
+        polh1v[0]=1;\r
+        std::vector<int> polh2v,polh3v;\r
+        for(int i=0;i<nbOfPolyHCells;i++)\r
+          {\r
+            int nbOfFaces=std::count(pt+ptI[i]-1,pt+ptI[i+1]-1,-1)+1;\r
+            polh1v[i+1]=polh1v[i]+nbOfFaces;\r
+            int *work=pt+ptI[i]-1;\r
+            for(int j=0;j<nbOfFaces;j++)\r
+              {\r
+                int *work2=std::find(work,pt+ptI[i+1]-1,-1);\r
+                int connLgthOfFace=std::distance(work,work2);\r
+                polh2v.push_back(connLgthOfFace);\r
+                polh3v.insert(polh3v.end(),work,work2);\r
+                work=work2+1;\r
+              }\r
+          }\r
+        //\r
+        myConn.assign(polh3v.begin(),polh3v.end());\r
+        myFaceIndex.assign(polh2v.begin(),polh2v.end());\r
+        myConnIndex.assign(polh1v.begin(),polh1v.end());\r
+      }\r
+    }\r
+\r
+    int\r
+    GetUniqueConn(int theId, \r
+                  TConnSet& theConnSet) const \r
+    {\r
+      theConnSet.clear();\r
+      int aStartFaceId = myConnIndex[theId] - 1;\r
+      int anEndFaceId = myConnIndex[theId + 1] - 2;\r
+      int aStartConnId = myFaceIndex[aStartFaceId] - 1;\r
+      int anEndConnId = myFaceIndex[anEndFaceId + 1] - 1;\r
+      for(int aConnId = aStartConnId; aConnId < anEndConnId; aConnId++)\r
+        theConnSet.insert(myConn[aConnId]);\r
+      return theConnSet.size();\r
+    }\r
+\r
+    int\r
+    GetNbElem() const\r
+    {\r
+      return myConnIndex.size() - 1;\r
+    }\r
+\r
+    int\r
+    GetCellSize() const\r
+    {\r
+      TConnSet aConnSet;\r
+      int aCellSize = 0;\r
+      for(int anElemId = 0; anElemId < GetNbElem(); anElemId++)\r
+        aCellSize += GetUniqueConn(anElemId, aConnSet);\r
+      return aCellSize;\r
+    }\r
+  };\r
+}\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadCellsOnEntity(VISU::PCMesh theMesh,\r
+                    VISU::PCMeshOnEntity theMeshOnEntity)\r
+{\r
+  if(theMeshOnEntity->myIsDone) \r
+    return 0;\r
+\r
+  SALOME_MED::SUPPORT_var& aMedSupport = theMeshOnEntity->mySupport;\r
+  SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh()->convertInMESH();\r
+\r
+  //Main part of code\r
+  const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;\r
+  const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);\r
+  VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity->myCellsFirstIndex;\r
+\r
+  SALOME_MED::MESH::connectivityInfos_var anInfo = aMedMesh->getConnectGlobal(aMEntity);\r
+  int iGeomEnd = anInfo->meshTypes.length();\r
+\r
+  VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;\r
+  vtkIdType aNbPoints = theMesh->GetNbPoints();\r
+\r
+  for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++) {\r
+    SALOME_MED::medGeometryElement aMGeom = anInfo->meshTypes[iGeom];\r
+    VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);\r
+    switch (aMGeom) {\r
+    case SALOME_MED::MEDMEM_POLYGON:\r
+    {\r
+      MEDPolygonConnectivity aConn(aMedMesh, aMEntity);\r
+      int aNbElem = aConn.GetNbElem();\r
+      if (aNbElem > 0) {\r
+        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());\r
+        aSubMesh->myNbCells   = aNbElem;\r
+        aSubMesh->myCellsSize = aConn.GetCellSize();\r
+\r
+        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+        aCell2Connect.resize(aNbElem);\r
+\r
+        for(int iElem = 0; iElem < aNbElem; iElem++) {\r
+          TConnSlice aConnSlice = aConn.GetConn(iElem);\r
+          VISU::TConnect& anArray = aCell2Connect[iElem];\r
+          anArray.resize(aConnSlice.size());\r
+          for(int iConn = 0; iConn < aConnSlice.size(); iConn++)\r
+            anArray[iConn] = aConnSlice[iConn] - 1;\r
+        }\r
+      }\r
+    }\r
+    break;\r
+    case SALOME_MED::MEDMEM_POLYHEDRA:\r
+    {\r
+      MEDPolyhedraConnectivity aConn( aMedMesh, aMEntity );\r
+      int aNbElem = aConn.GetNbElem();\r
+      if (aNbElem > 0) {\r
+        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());\r
+        aSubMesh->myNbCells = aNbElem;\r
+        aSubMesh->myCellsSize = aConn.GetCellSize();\r
+\r
+        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+        aCell2Connect.resize(aNbElem);\r
+\r
+        TConnSet aConnectSet;\r
+        for(int iElem = 0; iElem < aNbElem; iElem++){\r
+          if(aConn.GetUniqueConn(iElem, aConnectSet)){\r
+            int aNbConn = aConnectSet.size();\r
+            VISU::TConnect& anArray = aCell2Connect[iElem];\r
+            anArray.resize(aNbConn);\r
+            std::set<int>::iterator anIter = aConnectSet.begin();\r
+            for(int i = 0; anIter != aConnectSet.end(); anIter++, i++)\r
+              anArray[i] = *anIter - 1;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    break;\r
+    default:\r
+    {        \r
+      int aMNbNodes = MEDGeom2NbNodes(aMGeom);\r
+      int aVNbNodes = VISUGeom2NbNodes(aEGeom);\r
+      int aNbElem = anInfo->numberOfElements[iGeom];\r
+      if (aNbElem > 0) {\r
+        SALOME_TYPES::ListOfLong_var aConn = \r
+          aMedMesh->getConnectivity(SALOME_MED::MED_NODAL,\r
+                                    aMEntity,\r
+                                    aMGeom);\r
+        VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());\r
+\r
+        aSubMesh->myNbCells = aNbElem;\r
+        aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);\r
+\r
+        VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+        std::vector<int> aConnect(aMNbNodes);\r
+        int aNbConnForElem = aConn->length() / aNbElem;\r
+\r
+        if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aMGeom = "<<aMGeom<<\r
+                            "; aNbElem = "<<aNbElem<<\r
+                            "; aMNbNodes = "<<aMNbNodes<<\r
+                            "; aVNbNodes = "<<aVNbNodes<<\r
+                            "; aNbConnForElem = "<<aNbConnForElem);\r
+\r
+        for(int iElem = 0; iElem < aNbElem; iElem++) {\r
+          VISU::TConnect anArray(aVNbNodes);\r
+          for(int k = 0, kj = iElem*aNbConnForElem; k < aMNbNodes; k++)\r
+            aConnect[k] = aConn[kj+k] - 1;\r
+\r
+          switch(aMGeom){\r
+#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)\r
+          case SALOME_MED::MEDMEM_SEG3:\r
+            anArray[0] = aConnect[0];\r
+            anArray[2] = aConnect[1];  \r
+\r
+            anArray[1] = aConnect[2];\r
+            break;\r
+#endif\r
+#if !(defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)\r
+          case SALOME_MED::MEDMEM_TRIA6:\r
+            anArray[0] = aConnect[0];\r
+            anArray[2] = aConnect[1];  \r
+            anArray[4] = aConnect[2];  \r
+\r
+            anArray[1] = aConnect[3];\r
+            anArray[3] = aConnect[4];  \r
+            anArray[5] = aConnect[5];  \r
+            break;\r
+#endif\r
+#if !(defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)\r
+          case SALOME_MED::MEDMEM_QUAD8:\r
+            anArray[0] = aConnect[0];\r
+            anArray[2] = aConnect[1];  \r
+            anArray[4] = aConnect[2];  \r
+            anArray[6] = aConnect[3];  \r
+\r
+            anArray[1] = aConnect[4];\r
+            anArray[3] = aConnect[5];  \r
+            anArray[5] = aConnect[6];  \r
+            anArray[7] = aConnect[7];  \r
+            break;\r
+#endif\r
+#if (defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)\r
+          case SALOME_MED::MEDMEM_TETRA10 :\r
+#endif\r
+          case SALOME_MED::MEDMEM_TETRA4 :\r
+            anArray[0] = aConnect[0];\r
+            anArray[1] = aConnect[1];\r
+            anArray[2] = aConnect[3];  \r
+            anArray[3] = aConnect[2];  \r
+            break;\r
+#if (defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)\r
+          case SALOME_MED::MEDMEM_PYRA13:\r
+#endif\r
+          case SALOME_MED::MEDMEM_PYRA5 :\r
+            anArray[0] = aConnect[0];\r
+            anArray[1] = aConnect[3];  \r
+            anArray[2] = aConnect[2];\r
+            anArray[3] = aConnect[1];  \r
+            anArray[4] = aConnect[4];\r
+            break;\r
+          default:\r
+            for (int k = 0; k < aVNbNodes; k++) \r
+              anArray[k] = aConnect[k];\r
+          }\r
+          for (int k = 0; k < aVNbNodes; k++) \r
+            if(anArray[k] < 0 || aNbPoints <= anArray[k]){\r
+              static QString aString;\r
+              aString.sprintf("LoadCellsOnEntity >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",int(aNbPoints),iElem,k,anArray[k]);\r
+              throw std::runtime_error((const char*)aString.toLatin1());\r
+            }\r
+          aCell2Connect.push_back(anArray);\r
+        } // loop on elements\r
+      }\r
+    }} // switch( aMGeom )\r
+    VISU::TGeom2SubMesh::iterator anIter = aGeom2SubMesh.find(aEGeom);\r
+    if(anIter != aGeom2SubMesh.end()){\r
+      const VISU::PSubMeshImpl& aSubMesh = anIter->second;\r
+      const VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+      int aSize = aCell2Connect.size();\r
+      if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);\r
+      aFirstIndex[aMGeom] = VISU::TIndexAndSize(aCounter, aSize);\r
+      aCounter += aSize;\r
+    }\r
+  } //loop on types\r
+\r
+  // Dump result connectivity\r
+// #ifdef _DEBUG_\r
+//   TGeom2SubMesh::iterator geom_sm = aGeom2SubMesh.begin();\r
+//   for ( ; geom_sm!=aGeom2SubMesh.end(); ++geom_sm ) {\r
+//     cout << "TYPE: " << geom_sm->first << endl;\r
+//     PSubMeshImpl aSubMesh = geom_sm->second;\r
+//     TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;\r
+//     TCell2Connect::iterator id_conn = aCell2Connect.begin();\r
+//     for ( int i = 0; id_conn !=aCell2Connect.end(); ++id_conn ) {\r
+//       cout << "\t" << i++ << ": [";\r
+//       TConnect& anArray = *id_conn;\r
+//       TConnect::iterator n = anArray.begin();\r
+//       for ( ; n != anArray.end(); ++n )\r
+//         cout << " " << *n + 1;\r
+//       cout << " ]"<< endl;\r
+//     }\r
+//   }\r
+// #endif\r
+\r
+  theMeshOnEntity->myIsDone = true;\r
+\r
+  return 1;\r
+}\r
+\r
+\r
+//---------------------------------------------------------------\r
+int \r
+VISU_MEDConvertor\r
+::LoadCellsOnFamily(VISU::PCMesh theMesh,\r
+                    VISU::PCMeshOnEntity theMeshOnEntity, \r
+                    VISU::PCFamily theFamily)\r
+{\r
+  if(theFamily->myIsDone) \r
+    return 0;\r
+\r
+  SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;\r
+  CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();\r
+  if(!anIsOnAllElements){\r
+    SALOME_MED::medGeometryElement_array_var aGeoms = aMedFamily->getTypes();\r
+    int iGeomEnd = aGeoms->length();\r
+    if(MYDEBUG) MESSAGE("LoadCellsOnFamily - iGeomEnd = "<<iGeomEnd);\r
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){\r
+      SALOME_MED::medGeometryElement aMGeom = aGeoms[iGeom];\r
+      SALOME_TYPES::ListOfLong_var aCellNumForType = aMedFamily->getNumber(aMGeom);\r
+      VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);\r
+\r
+      int aNbElem = aCellNumForType->length();\r
+      int aCounter = theMeshOnEntity->myCellsFirstIndex[aMGeom].first;\r
+      int aSize = theMeshOnEntity->myCellsFirstIndex[aMGeom].second;\r
+      VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom]; \r
+      \r
+      if(MYDEBUG) \r
+        MESSAGE("LoadCellsOnFamily "<<\r
+                "- aMGeom = "<<aMGeom<<\r
+                "; aNbElem = "<<aNbElem<<\r
+                "; aSize = "<<aSize<<\r
+                "; aCounter = "<<aCounter);\r
+      \r
+      for(int iElem = 0; iElem < aNbElem; iElem++){\r
+        int anID = aCellNumForType[iElem] - aCounter - 1;\r
+        if(0 > anID || anID >= aSize){\r
+          static QString aString;\r
+          aString.sprintf("LoadCellsOnFamily - aNbElem(%d) <= aCellNumForType[%d] = %d < 0 !!!",aNbElem,iElem,anID);\r
+          throw std::runtime_error((const char*)aString.toLatin1());\r
+        }\r
+        aSubMeshID.push_back(anID);\r
+      }\r
+    }\r
+  }else{\r
+    const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;\r
+    VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();\r
+    for(; anIter != aGeom2SubMesh.end(); anIter++){\r
+      VISU::EGeometry aEGeom = anIter->first;\r
+      const VISU::TSubMeshImpl& aSubMesh = anIter->second;\r
+      const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;\r
+      VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];\r
+      int iNumElemEnd = aCell2Connect.size();\r
+      for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)\r
+        aSubMeshID.push_back(iNumElem);\r
+    }\r
+  }\r
+  \r
+  theFamily->myIsDone = true;\r
+\r
+  return 1;\r
+}\r
+\r
+\r
+template<class TValueType,\r
+         class TContainerType> \r
+void \r
+ImportField(TContainerType& theContainer, \r
+            VISU::PCMesh theMesh,\r
+            VISU::PCField theField,\r
+            VISU::PCValForTime theValForTime,\r
+            VISU::PCMeshOnEntity theMeshOnEntity)\r
+{\r
+  typedef VISU::TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;\r
+  vtkIdType aNbComp = theField->myNbComp;\r
+  if(theField->myEntity == VISU::NODE_ENTITY){\r
+    VISU::EGeometry aEGeom = VISU::ePOINT1;\r
+    vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);\r
+    vtkIdType aNbElem = theMesh->GetNbPoints();\r
+\r
+    if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);\r
+\r
+    VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);\r
+    TVMeshValue* aMeshValue = new TVMeshValue();\r
+    aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, 0);\r
+    aVMeshValue.reset(aMeshValue);\r
+  }else{\r
+    SALOME_MED::medGeometryElement* aGeomElems;\r
+    const VISU::TEntity& aVEntity = theField->myEntity;\r
+    int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);\r
+    for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){\r
+      SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];\r
+      VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);\r
+      vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);\r
+      const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;\r
+      VISU::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);\r
+      if(aCellsFirstIndexIter != aCellsFirstIndex.end()){\r
+        const VISU::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;\r
+        if(MYDEBUG) \r
+          MESSAGE("ImportField - aMGeom = "<<aMGeom<<\r
+                  "; aIndexAndSize = {"<<aIndexAndSize.first<<\r
+                  ","<<aIndexAndSize.second<<"}");\r
+\r
+        vtkIdType aNbElem = aIndexAndSize.second;\r
+        vtkIdType aStart = aIndexAndSize.first * aNbComp;\r
+        VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);\r
+        TVMeshValue* aMeshValue = new TVMeshValue();\r
+        aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);\r
+        aVMeshValue.reset(aMeshValue);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+int\r
+VISU_MEDConvertor\r
+::LoadField(VISU::PCMesh theMesh,\r
+            VISU::PCMeshOnEntity theMeshOnEntity,\r
+            VISU::PField theField, \r
+            VISU::PCValForTime theValForTime)\r
+{\r
+  MESSAGE("VISU_MEDConvertor::LoadField");\r
+  //Check on loading already done\r
+  VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;\r
+  if(anUnstructuredGridIDMapper->myIsVTKDone) \r
+    return 0;\r
+  \r
+  VISU::PCProfile aProfile(new VISU::TCProfile());\r
+  aProfile->myIsAll = true;\r
+  theValForTime->myProfile = aProfile;\r
+\r
+  SALOME_MED::FIELD_var aMEDField = theValForTime->myField;\r
+\r
+  SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport();\r
+\r
+  if(aMEDSupport->isOnAllElements()) aProfile->myIsDone = true;\r
+  \r
+  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);\r
+  if(!aFieldDouble->_is_nil()){\r
+    SALOME_TYPES::ListOfDouble_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);\r
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());\r
+    ImportField<CORBA::Double>(anArray,\r
+                               theMesh,\r
+                               theField,\r
+                               theValForTime,\r
+                               theMeshOnEntity);\r
+  }\r
+\r
+  SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);\r
+  if(!aFieldInt->_is_nil()){\r
+    SALOME_TYPES::ListOfLong_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);\r
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());\r
+    ImportField<CORBA::Long>(anArray,\r
+                             theMesh,\r
+                             theField,\r
+                             theValForTime,\r
+                             theMeshOnEntity);\r
+  }\r
+\r
+  anUnstructuredGridIDMapper->myIsVTKDone = true;\r
+\r
+  MESSAGE("VISU_MEDConvertor::LoadField done");\r
+  return 1;\r
+}\r