]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
NRI : Merge from V1_2.
authornri <nri@opencascade.com>
Thu, 10 Jul 2003 15:41:21 +0000 (15:41 +0000)
committernri <nri@opencascade.com>
Thu, 10 Jul 2003 15:41:21 +0000 (15:41 +0000)
src/VISU_I/VISU_CorbaMedConvertor.cxx

index b23363dba7efc756ea33c976d554659d7833af46..1b8797106c19f36dbebc25faa3d92460d2554672 100644 (file)
@@ -32,13 +32,21 @@ extern "C" {
 
 typedef map<VISU::TEntity,SALOME_MED::medEntityMesh> TVisu2MedEntity;
 static TVisu2MedEntity aVisu2MedEntity;
+typedef map<SALOME_MED::medEntityMesh,VISU::TEntity> TMed2VisuEntity;
+static TMed2VisuEntity aMed2VisuEntity;
 static int INIT = (
                   aVisu2MedEntity[VISU::CELL_ENTITY] = SALOME_MED::MED_CELL,
                   aVisu2MedEntity[VISU::FACE_ENTITY] = SALOME_MED::MED_FACE,
                   aVisu2MedEntity[VISU::EDGE_ENTITY] = SALOME_MED::MED_EDGE,
                   aVisu2MedEntity[VISU::NODE_ENTITY] = SALOME_MED::MED_NODE,
+
+                  aMed2VisuEntity[SALOME_MED::MED_CELL] = VISU::CELL_ENTITY,
+                  aMed2VisuEntity[SALOME_MED::MED_FACE] = VISU::FACE_ENTITY,
+                  aMed2VisuEntity[SALOME_MED::MED_EDGE] = VISU::EDGE_ENTITY,
+                  aMed2VisuEntity[SALOME_MED::MED_NODE] = VISU::NODE_ENTITY,
+
                   1);
-*/
+
 static int CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
   SALOME_MED::MED_POINT1,
   SALOME_MED::MED_SEG2,
@@ -85,26 +93,19 @@ static int NODEGEOM[1] = {
   SALOME_MED::MED_POINT1,
 };
 
-void Entity2Geom(const VISU::TEntity& theEntity, int* theVector, int* theEnd) {
+void GetEntity2Geom(const VISU::TEntity& theEntity, int*& theVector, int* theEnd)
+     throw (std::runtime_error&)
+{
   switch(theEntity){
   case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break;
   case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break;
   case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break;
   case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break;
+  default:
+    throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect !!!");
   }
 }
 
-typedef pair<int*,int> TEntity2Geom;
-typedef map<SALOME_MED::medEntityMesh,TEntity2Geom> TEntity2GeomMap;
-static TEntity2GeomMap anEntity2GeomMap;
-static int INIT = (
-  anEntity2GeomMap[SALOME_MED::MED_CELL] = TEntity2Geom(CELLGEOM,MED_NBR_GEOMETRIE_MAILLE),
-  anEntity2GeomMap[SALOME_MED::MED_FACE] = TEntity2Geom(FACEGEOM,MED_NBR_GEOMETRIE_FACE),
-  anEntity2GeomMap[SALOME_MED::MED_EDGE] = TEntity2Geom(EDGEGEOM,MED_NBR_GEOMETRIE_ARETE),
-  anEntity2GeomMap[SALOME_MED::MED_NODE] = TEntity2Geom(NODEGEOM,1),
-  1
-);
-
 struct SalomeMed2vtk {
   SALOME_MED::medGeometryElement medType;
   char *medName;
@@ -136,14 +137,20 @@ static SalomeMed2vtk salome_med2vtk[SALOME_MED::MED_ALL_ELEMENTS] = {
 };
 #undef CORBAMED2VTK
 
-int FindIdMEDType(int medType){
+int GetIdMEDType(int medType){
   for(int i = 0; i < SALOME_MED::MED_ALL_ELEMENTS; i++)
     if(salome_med2vtk[i].medType == medType) return i;
   return -1;
 }
 
-void VISU_MedMeshConvertor::SetMedMesh(SALOME_MED::MESH_ptr theMedMesh) {
-  myMedMesh = SALOME_MED::MESH::_duplicate(theMedMesh);
+string GetName(SALOMEDS::SObject_ptr aSObject){
+  SALOMEDS::GenericAttribute_var anAttr;
+  if (aSObject->FindAttribute(anAttr,"AttributeName")) {
+    SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+    CORBA::String_var aString = aName->Value();
+    return aString.in();
+  }
+  return "";
 }
 
 VISU_Convertor* VISU_MEDFieldConvertor::Build() throw (std::runtime_error&){
@@ -505,290 +512,269 @@ int VISU_MEDConvertor::LoadMeshOnGroup(VISU::TMesh& theMesh,
   return (isPointsUpdated || isCellsOnEntityUpdated);
 }
 
-void VISU_CorbaMedSupportConvertor::SetSupport(SALOME_MED::SUPPORT_ptr theSupport) {
-  mySupport = SALOME_MED::SUPPORT::_duplicate(theSupport);
-  if(!mySupport->_is_nil())
-    myMedMesh = mySupport->getMesh();
+int VISU_MEDConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, 
+                                      VISU::TMeshOnEntity& theMeshOnEntity, 
+                                      VISU::TField& theField, 
+                                      VISU::TField::TValForTime& theValForTime)
+  throw (std::runtime_error&)
+{
+  //Main part of code
+  int isPointsUpdated = LoadPoints(theMesh);
+  int isCellsOnEntityUpdated = LoadCellsOnEntity(theMeshOnEntity);
+  int isFieldUpdated = LoadField(theMeshOnEntity,theField,theValForTime);
+  
+  return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
 }
 
-int ImportPoints(VISU::TMesh& theMesh, SALOME_MED::MESH_ptr theMESH)
+int VISU_MEDConvertor::LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName)
   throw (std::runtime_error&) 
 {
-/*
-  if(MYDEBUG) MESSAGE("ImportPoints - beginning");
-  theMesh.myDim = theMESH->getMeshDimension();
-  int aNbPoints = theMESH->getNumberOfNodes();
-  VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord;
-  aPointsCoord.resize(theMesh.myDim*aNbPoints,0.0);
-  Engines::double_array_var coord = theMESH->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
-  for (int i = 0 ; i < aNbPoints; i++)
-    for(int j = 0, ij = theMesh.myDim*i; j < theMesh.myDim; j++)
-      aPointsCoord[ij+j] = coord[ij+j];
+  //Check on existing family
+  VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY];
+  aMeshOnEntity.myEntity = VISU::NODE_ENTITY;
+  aMeshOnEntity.myMeshName = theMesh.myName;
+  VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName);
+  bool isFamilyPresent = (pFamily != NULL);
+  VISU::TFamily& aFamily = *pFamily;
+  //Check on loading already done
+  bool isPointsLoaded = !theMesh.myPointsCoord.empty();
+  if(isPointsLoaded) 
+    if(!isFamilyPresent) return 0;
+    else if(!aFamily.mySubMesh.empty()) return 0;
+  VISUMED::TMesh& aMesh2 = myMeshMap2[theMesh.myName];
+  SALOME_MED::MESH_var& aMedMesh = aMesh2.myMesh;
+  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[VISU::NODE_ENTITY];
   if(MYDEBUG) 
-    MESSAGE("ImportPoints - End : theDim = "<<theMesh.myDim<<"; aNbPoints = "<<aNbPoints);
+    MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
+  theMesh.myDim = aMedMesh->getSpaceDimension();
+  int iNumElemEnd = aMedMesh->getNumberOfNodes();
+  VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord;
+  if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
+  if (iNumElemEnd <= 0) throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
+  aPointsCoord.resize(theMesh.myDim*iNumElemEnd,0.0);
+  Engines::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
+  if(!isPointsLoaded){
+    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
+      for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++)
+       aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
+    if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
+    VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX];
+    aConnForCellType.resize(iNumElemEnd);
+    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+      aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem);
+  }
+  if(isFamilyPresent){
+    if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh");
+    VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName];
+    SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily;
+    VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX];
+    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+    Engines::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
+    int iNumElemEndTmp = iNumElemEnd;
+    iNumElemEnd = aCellNumForType->length();
+    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+      int tmp = aCellNumForType[iNumElem]-1;
+      if(0 > tmp || tmp >= iNumElemEndTmp) {
+       static QString aString;
+       aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
+       throw std::runtime_error(aString.latin1());
+      }
+      aSubMeshOnCellType.insert(tmp);
+    }
+  }
   return 1;
-*/
 }
 
-int ImportCells(VISU::TMesh& theMesh, SALOME_MED::MESH_ptr theMESH, 
-               const SALOME_MED::medEntityMesh& theEntity)
+int VISU_MEDConvertor::LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName)
      throw (std::runtime_error&) 
 {
-/*
-  if(MYDEBUG) MESSAGE("ImportCells - theEntity = "<<theEntity);
-  //TEntity2Geom anEntity2Geom = anEntity2GeomMap[theEntity];
-  //int *iVector = anEntity2Geom->first, iEnd = anEntity2Geom->second;
-  int *iArray, iEnd;
-  VISU::TEntity anEntity = MED2VISUEntity(theEntity);
-  Entity2Geom(anEntity,iArray,&iEnd);
-  int aNbPoints = theMesh.myPointsCoord.size();
-  for (int i = 0; i < iEnd; i++) {
-    int medId = FindIdMEDType(iArray[i]);
-    int nbMedNodes = salome_med2vtk[medId].medNbNodes;
-    int nbVtkNodes = salome_med2vtk[medId].vtkNbNodes;
-    int aVtkType = salome_med2vtk[medId].vtkType;
-    SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
-    int jEnd = theMESH->getNumberOfElements(theEntity,aMedType);
-    if(jEnd > 0){
-      VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity];
-      Engines::long_array_var conn = 
-       theMESH->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,theEntity,aMedType);
-      if(MYDEBUG) MESSAGE("ImportCells - medName = "<<salome_med2vtk[medId].medName<<"; jEnd = "<<jEnd);
-      VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[aVtkType];
-      aConnForCellType.resize(jEnd);
-      valarray<med_int> aConnect(nbMedNodes);
-      for (int j = 0; j < jEnd; j++) {
-       VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[j];
-       anArray.resize(nbVtkNodes);
-       for (int k = 0, kj = j*nbMedNodes; k < nbMedNodes; k++) 
-         aConnect[k] = conn[kj+k] - 1;
-       switch(aMedType){
-       case SALOME_MED::MED_TETRA4 :
-       case SALOME_MED::MED_TETRA10 :
-         anArray[0] = aConnect[0];
-         anArray[1] = aConnect[1];
-         anArray[2] = aConnect[3];  
-         anArray[3] = aConnect[2];  
-         break;
-       case SALOME_MED::MED_PYRA5 :
-       case SALOME_MED::MED_PYRA13 :
-         anArray[0] = aConnect[0];
-         anArray[1] = aConnect[3];  
-         anArray[2] = aConnect[2];
-         anArray[3] = aConnect[1];  
-         anArray[4] = aConnect[4];
-         break;
-       default:
+  //Check on existing family
+  VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
+  bool isFamilyPresent = (pFamily != NULL);
+  VISU::TFamily& aFamily = *pFamily;
+  //Check on loading already done
+  bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty();
+  if(isCellsLoaded) 
+    if(!isFamilyPresent) return 0;
+    else if(!aFamily.mySubMesh.empty()) return 0;
+  VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName];
+  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity];
+  SALOME_MED::SUPPORT_var& aMedSupport = aMeshOnEntity2.mySupport;
+  SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
+  if(MYDEBUG) {
+    MESSAGE("LoadCellsOnEntity - theFamilyName = '"<<theFamilyName<<"'");
+    MESSAGE("LoadCellsOnEntity - isCellsLoaded = "<<isCellsLoaded<<"; isFamilyPresent = "<<isFamilyPresent);
+  }
+  //Main part of code
+  int iGeomElemEnd;
+  int* aGeomElemVector;
+  const VISU::TEntity& anEntity = theMeshOnEntity.myEntity;
+  GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
+  const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[anEntity];
+  VISU::TMesh &aMesh = myMeshMap[theMeshOnEntity.myMeshName];
+  int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
+  if(!isCellsLoaded){
+    for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
+      int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
+      int nbMedNodes = salome_med2vtk[medId].medNbNodes;
+      int nbVtkNodes = salome_med2vtk[medId].vtkNbNodes;
+      int aVtkType = salome_med2vtk[medId].vtkType;
+      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
+      med_int iNumElemEnd = aMedMesh->getNumberOfElements(aMedEntity,aMedType);
+      if (iNumElemEnd > 0) {
+       Engines::long_array_var conn = 
+         aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,SALOME_MED::MED_NODAL,aMedEntity,aMedType);
+       VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType];
+       //APO - aConnForCellType.resize(iNumElemEnd);
+       valarray<med_int> aConnect(nbMedNodes);
+       int aNbConnForElem = conn->length()/iNumElemEnd;
+       if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<<salome_med2vtk[medId].medName<<
+                           "; iNumElemEnd = "<<iNumElemEnd<<"; aNbConnForElem = "<<aNbConnForElem);
+       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+         //APO - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem];
+         //APO - anArray.resize(nbVtkNodes);
+         VISU::TMeshOnEntity::TConnect anArray(nbVtkNodes);
+         for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) {
+           aConnect[k] = conn[kj+k] - 1;
+         }
+         switch(aMedType){
+         case SALOME_MED::MED_TETRA4 :
+         case SALOME_MED::MED_TETRA10 :
+           anArray[0] = aConnect[0];
+           anArray[1] = aConnect[1];
+           anArray[2] = aConnect[3];  
+           anArray[3] = aConnect[2];  
+           break;
+         case SALOME_MED::MED_PYRA5 :
+         case SALOME_MED::MED_PYRA13 :
+           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 < nbVtkNodes; k++) 
+             anArray[k] = aConnect[k];
+         }
          for (int k = 0; k < nbVtkNodes; k++) 
-           anArray[k] = aConnect[k];
+           if(anArray[k] < 0 || aNbPoints <= anArray[k]){
+             static QString aString;
+             aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d]=%d < 0 !!!",aNbPoints,iNumElem,k,anArray[k]);
+             throw std::runtime_error(aString.latin1());
+           }
+         aConnForCellType.push_back(anArray);
        }
-       for (int k = 0; k < nbVtkNodes; k++) 
-         if(anArray[k] < 0 || aNbPoints <= anArray[k])
-           throw std::runtime_error("ImportCells >> anArray[k] < 0 || aNbPoints <= anArray[k]");
+       //Workaround for MED Component data structure
+       int aSize = aConnForCellType.size();
+       aMeshOnEntity2.myCellsFirstIndex[aMedType] = VISUMED::TMeshOnEntity::TIndexAndSize(aCounter,aSize);
+       aCounter += aSize;
       }
-      if(MYDEBUG)
-       MESSAGE("ImportCells - aMeshOnEntity.myCellsConn.size() = "<<aMeshOnEntity.myCellsConn.size());
     }
   }
-*/
-}
-
-VISU_Convertor* VISU_MedMeshConvertor::Build() throw (std::runtime_error&) {
-/*
-  if(myMedMesh->_is_nil())
-    throw std::runtime_error("VISU_MedMeshConvertor::Build >> myMesh->_is_nil()");
-  CORBA::String_var aName = myMedMesh->getName();
-  myName = aName;
-  TMesh& aMesh = myMeshMap[myName];
-  if(MYDEBUG) MESSAGE("MedInfo - aMeshName = "<<myMeshMap.begin()->first);
-  ::ImportPoints(aMesh,myMedMesh);
-  TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin();
-  for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++)
-    ::ImportCells(aMesh,myMedMesh,aVisu2MedEntityIter->second);
-  myIsDone = true;
-  return this; 
-*/
+  //Filling aFamily SubMesh
+  if(isFamilyPresent){
+    VISUMED::TFamily aFamily2 = aMeshOnEntity2.myFamilyMap[aFamily.myName];
+    SALOME_MED::FAMILY_var aMedFamily = aFamily2.myFamily;
+    SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+    iGeomElemEnd = aGeom->length();
+    if(MYDEBUG) MESSAGE("LoadCellsOnEntity - iGeomElemEnd = "<<iGeomElemEnd);
+    for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
+      SALOME_MED::medGeometryElement aGeomType = aGeom[iGeomElem];
+      Engines::long_array_var aCellNumForType = aMedFamily->getNumber(aGeomType);
+      int medId = GetIdMEDType(aGeomType);
+      int aVtkType = salome_med2vtk[medId].vtkType;
+      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
+      VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; 
+      med_int iNumElemEndTmp = theMeshOnEntity.myCellsConn[aVtkType].size();
+      med_int iNumElemEnd = aCellNumForType->length();
+      int aCounter = aMeshOnEntity2.myCellsFirstIndex[aMedType].first;
+      if(MYDEBUG) 
+       MESSAGE("LoadCellsOnEntity - medName = "<<salome_med2vtk[medId].medName<<
+               "; iNumElemEnd = "<<iNumElemEnd<<"; aCounter = "<<aCounter);
+      for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
+       int tmp = aCellNumForType[iNumElem]-aCounter-1;
+       if(0 > tmp || tmp >= iNumElemEndTmp) {
+         static QString aString;
+         aString.sprintf("LoadCellsOnEntity >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEndTmp,iNumElem,tmp);
+         throw std::runtime_error(aString.latin1());
+       }
+       aSubMeshOnCellType.insert(tmp);
+      }
+    }
+  }
+  return 1;
 }
 
 template<class TArray> int ImportField(TArray& theArray, 
+                                      const VISU::TMesh& theMesh,
+                                      const VISU::TField& theField,
+                                      VISU::TField::TValForTime& theValForTime,
                                       const VISU::TMeshOnEntity& theMeshOnEntity,
-                                      VISU::TField& theField, 
-                                      const SALOME_MED::medEntityMesh& theEntity,
-                                      const VISU::TField::TTime& theTime)
+                                      const VISUMED::TMeshOnEntity& theMeshOnEntity2)
 {
-/*
-  if(MYDEBUG) MESSAGE("ImportField - IEnd = "<<theArray->length()<<"; myNbComp = "<<theField.myNbComp);
-  VISU::TEntity anEntity = MED2VISUEntity(theEntity);
-  VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity];
-  VISU::TField& aField = aMeshOnEntity.myFieldMap[nomcha]
-  VISU::TField::TValForTime& aValForTime = theField.myValField[theTime];
-  if(theField.myTypeConn == POINT_DATA){
-    VISU::TField::TValForCellsWithType& aValForCellsWithType = aValForTime[VTK_VERTEX];
-    int iEnd = theMesh.myPointsCoord.size()/theMesh.myDim * theField.myNbComp;
-    if(MYDEBUG) MESSAGE("ImportField - iEnd = "<<iEnd);
-    aValForCellsWithType.resize(iEnd);
-    for (int i = 0; i < iEnd; i++)
-      aValForCellsWithType[i] = theArray[i];
+  if(theField.myEntity == VISU::NODE_ENTITY){
+    VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[VTK_VERTEX];
+    int iNumElemEnd = theMesh.myPointsCoord.size()/theMesh.myDim*theField.myNbComp;
+    if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
+    aValForCellsWithType.resize(iNumElemEnd);
+    for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) 
+      aValForCellsWithType[iNumElem] = theArray[iNumElem];
   }else{
-    int iEnd = VTKCELLGEOMEND, *iArray = VTKCELLGEOM, kEnd = theField.myNbComp;
-    for (int i = 0, I = 0; i < iEnd; i++) {
-      int medId = FindIdMEDType(iArray[i]), aVtkType = salome_med2vtk[medId].vtkType;
-      const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMesh.myCellsConn;
-      VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType);
-      if(aCellsConnIter != aCellsConn.end()){
-       const VISU::TMesh::TConnForCellType& aConnForCellType = aCellsConnIter->second;
-       int jEnd = aConnForCellType.size();
-       if(MYDEBUG) MESSAGE("ImportField - medName = "<<salome_med2vtk[medId].medName<<
-                           "; vtkName = "<<salome_med2vtk[medId].vtkName<<"; jEnd = "<<jEnd);
-       VISU::TField::TValForCellsWithType& aValForCellsWithType = aValForTime[aVtkType];
-       aValForCellsWithType.resize(jEnd*kEnd);
-       for (int j = 0; j < jEnd; j++)
-         for (int k = 0, kj = j*kEnd; k < kEnd; k++)
-           aValForCellsWithType[kj+k] = theArray[I++];
+    int iGeomElemEnd;
+    int* aGeomElemVector;
+    const VISU::TEntity& anEntity = theField.myEntity;
+    GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
+    for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
+      int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
+      int aVtkType = salome_med2vtk[medId].vtkType;
+      SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
+      const VISUMED::TMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity2.myCellsFirstIndex;
+      VISUMED::TMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMedType);
+      if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
+       const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn;
+       VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType);
+       const VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aCellsConnIter->second;
+       const VISUMED::TMeshOnEntity::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
+       int iNumElemEnd = aIndexAndSize.second;
+       if(MYDEBUG) 
+         MESSAGE("ImportField - medName = "<<salome_med2vtk[medId].medName<<
+                 "; aIndexAndSize = {"<<aIndexAndSize.first<<","<<aIndexAndSize.second<<"}");
+       VISU::TField::TValForCellsWithType& aValForCellsWithType = theValForTime.myValForCells[aVtkType];
+       aValForCellsWithType.resize(iNumElemEnd*theField.myNbComp);
+       for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
+         for (int k = 0, kj = iNumElem*theField.myNbComp; k < theField.myNbComp; k++)
+           aValForCellsWithType[kj+k] = theArray[aIndexAndSize.first*theField.myNbComp+kj+k];
       }
     }
   }
-*/
+  return 1;
 }
 
-VISU_Convertor* VISU_CorbaMedConvertor::Build() throw (std::runtime_error&){
-/*
-  if(myMedField->_is_nil())
-    throw std::runtime_error("VISU_CorbaMedConvertor::Build >> myField->_is_nil()");
-  if(VISU_MedMeshConvertor::Build() == NULL) return NULL;
-  CORBA::String_var aName = myMedField->getName();
-  myName = aName;
-  TMeshMap::const_iterator aMeshIter = myMeshMap.begin();
-  const TMesh& aMesh = aMeshIter->second;
-  int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim;
-  int aNbCells = aMesh.GetCellsDims().first;
-  aName = myMedField->getName();
-  aMeshOnEntity.myEntity = theEntity;
-  aMeshOnEntity.myMeshName = theMesh.myName;
-  TField& aField = myFieldMap[aName.in()];
-  aField.myMeshName = aMeshIter->first;
-  SALOME_MED::SUPPORT_var aSupport = myMedField->getSupport();
-  SALOME_MED::medEntityMesh anEntity = aSupport->getEntity();
-  int aSize;
-  if(anEntity == SALOME_MED::MED_NODE){
-    aSize = aNbPoints;
-    aField.myTypeConn = POINT_DATA;
-    if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - POINT_DATA = "<<aSize);
-  }else if(anEntity == SALOME_MED::MED_CELL){
-    aSize = aNbCells;
-    aField.myTypeConn = CELL_DATA;
-    if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - CELL_DATA = "<<aSize);
-  }
-  aField.myNbComp = myMedField->getNumberOfComponents();
-  if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - aField.myNbComp = "<<aField.myNbComp);
-  TField::TTime aTime(myMedField->getTime(),"");
-  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myMedField);
+int VISU_MEDConvertor::LoadField(const VISU::TMeshOnEntity& theMeshOnEntity,
+                                const VISU::TField& theField, VISU::TField::TValForTime& theValForTime)
+     throw (std::runtime_error&)
+{
+  //Check on loading already done
+  if(!theValForTime.myValForCells.empty()) return 0;
+  VISU::TMesh& aMesh = myMeshMap[theMeshOnEntity.myMeshName];
+  VISUMED::TMesh& aMesh2 = myMeshMap2[theMeshOnEntity.myMeshName];
+  VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[theMeshOnEntity.myEntity];
+  VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[theField.myName];
+  VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[theValForTime.myId];
+  SALOME_MED::FIELD_var aMEDField = aValForTime2.myField;
+  //Main part of code
+  SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
   if(!aFieldDouble->_is_nil()){
-    if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - There is FIELDDOUBLE");
     Engines::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
-    ::ImportField(anArray,aMesh,aField,anEntity,aTime);
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
+    ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2);
   }
-  SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(myMedField);
+  SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
   if(!aFieldInt->_is_nil()){
-    if(MYDEBUG) MESSAGE("VISU_CorbaMedConvertor::Build - There is FIELDINT");
     Engines::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
-    ::ImportField(anArray,aMesh,aField,anEntity,aTime);
-  }
-  myIsDone = true;
-  return this; 
-*/
-}
-
-int ImportCellsOfSupport(VISU::TMesh& theMesh, SALOME_MED::SUPPORT_ptr theSUPPORT) 
-     throw (std::runtime_error&) 
-{
-/*
-  if(MYDEBUG) MESSAGE("ImportCellsOfSupport - beginning");
-  SALOME_MED::medEntityMesh anEntity = theSUPPORT->getEntity();
-  med_int nmailles[SALOME_MED::MED_ALL_ELEMENTS];
-  if(MYDEBUG) MESSAGE("ImportCellsOfSupport - anEntity = "<<anEntity);
-  if(anEntity == SALOME_MED::MED_NODE){
-    VISU::TMesh::TConnForCellType& aConnForCellType = theMesh.myCellsConn[VTK_VERTEX];
-    if(theSUPPORT->isOnAllElements()){
-      int jEnd = theMesh.myPointsCoord.size()/theMesh.myDim;
-      if(MYDEBUG) MESSAGE("ImportCellsOfSupport - isOnAllElements - "<<jEnd);
-      aConnForCellType.resize(jEnd);
-      for (int j = 0; j < jEnd; j++) 
-       aConnForCellType[j] = vector<int>(1,j);
-    }else{
-      SALOME_MED::medGeometryElement_array_var aGeom = theSUPPORT->getTypes();
-      Engines::long_array_var aCellNumForType = theSUPPORT->getNumber(aGeom[0]);
-      int jEnd = aCellNumForType->length();
-      aConnForCellType.resize(jEnd);
-      for (int j = 0; j < jEnd; j++) 
-       aConnForCellType[j] = vector<int>(1,aCellNumForType[j]-1);
-    }
-  }else{
-    VISU::TMesh aBaseMesh;
-    SALOME_MED::MESH_var aMedMesh = theSUPPORT->getMesh();
-    ::ImportPoints(aBaseMesh,aMedMesh);
-    ::ImportCells(aBaseMesh,aMedMesh,anEntity);
-    if(theSUPPORT->isOnAllElements()){
-      if(MYDEBUG) MESSAGE("ImportCellsOfSupport - isOnAllElements");
-    }else{
-      SALOME_MED::medGeometryElement_array_var aGeom = theSUPPORT->getTypes();
-      int iEnd = aGeom->length();
-      if(MYDEBUG) MESSAGE("ImportCellsOfSupport - aGeom->length() = "<<iEnd);
-      for (int i = 0; i < iEnd; i++) {
-       Engines::long_array_var aCellNumForType = theSUPPORT->getNumber(aGeom[i]);
-       int medId = FindIdMEDType(aGeom[i]);
-       int aVtkType = salome_med2vtk[medId].vtkType;
-       med_int jEnd = aCellNumForType->length();
-       if(MYDEBUG) MESSAGE("ImportCellsOfSupport - medName = "<<salome_med2vtk[medId].medName<<"; jEnd = "<<jEnd);
-       VISU::TMesh::TConnForCellType& aConnForCellType = theMesh.myCellsConn[aVtkType];
-       aConnForCellType.resize(jEnd);
-       VISU::TMesh::TConnForCellType& aBaseConnForCellType = aBaseMesh.myCellsConn[aVtkType];
-       for (int j = 0; j < jEnd; j++) {
-         aConnForCellType[j] = aBaseConnForCellType[aCellNumForType[j]-1];
-       }
-      }
-    }
+    if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
+    ::ImportField(anArray,aMesh,theField,theValForTime,theMeshOnEntity,aMeshOnEntity2);
   }
   return 1;
-*/
-}
-
-VISU_Convertor* VISU_CorbaMedSupportConvertor::Build() throw (std::runtime_error&) {
-/*
-  if(MYDEBUG) MESSAGE("BuildSupport - checking mySupport & mySupport->getMesh()");
-  if(mySupport->_is_nil())
-    throw std::runtime_error("VISU_CorbaMedConvertor::Build >> mySupport->_is_nil()");
-  SALOME_MED::GROUP_var aGroup = SALOME_MED::GROUP::_narrow(mySupport);
-  int aNbCells = 0;
-  if(!aGroup->_is_nil()){
-    CORBA::String_var aName = aGroup->getName();
-    myName = aName;
-    if(MYDEBUG) MESSAGE("BuildSupport aGroup->getName() = "<<myName);
-    SALOME_MED::Family_array_var anArray = aGroup->getFamilies();
-    med_int iEnd = anArray->length();
-    TMesh& aMesh = myMeshMap[myName];
-    if(MYDEBUG) MESSAGE("BuildSupport - aGroup->getFamilies()->length() = "<<iEnd);
-    ::ImportPoints(aMesh,myMedMesh);
-    for(med_int i = 0; i < iEnd; i++){
-      if(MYDEBUG) MESSAGE("BuildSupport - import FAMILY with number = "<<i);
-      SALOME_MED::FAMILY_var aFamily = anArray[i];
-      ::ImportCellsOfSupport(aMesh,aFamily);
-    }
-    aNbCells = aMesh.GetCellsDims().first;
-  }else{
-    CORBA::String_var aName = mySupport->getName();
-    myName = aName;
-    if(MYDEBUG) MESSAGE("mySupport - myName = "<<myName);
-    TMesh& aMesh = myMeshMap[myName];
-    myMedMesh = mySupport->getMesh();
-    ::ImportPoints(aMesh,myMedMesh);
-    ::ImportCellsOfSupport(aMesh,mySupport);
-    aNbCells = aMesh.GetCellsDims().first;
-  }
-  if(aNbCells == 0) 
-    throw std::runtime_error("VISU_MedMeshConvertor::Build >> aNbCells == 0");
-  if(MYDEBUG) MESSAGE("BuildSupport - aNbCells = "<<aNbCells);
-  myIsDone = true;
-  return this; 
-*/
 }