Salome HOME
Integration of PAL/SALOME V2.1.0c from OCC
[modules/smesh.git] / src / DriverMED / DriverMED_R_SMESHDS_Mesh.cxx
index c37f1e60adddd7e446dc350fafc35d799db410ed..36f07fd7f628d49acde7195c6b1af6e828f19c15 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "DriverMED_R_SMESHDS_Mesh.h"
 #include "DriverMED_R_SMDS_Mesh.h"
+#include "SMESHDS_Mesh.hxx"
 #include "utilities.h"
 
 #include "DriverMED_Family.h"
 
 #include <stdlib.h>
 
-DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh()
-     :
-       myMesh (NULL),
-       myFile (""),
-       myFileId (-1),
-       myMeshId (-1)
-{
-}
-
-DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh()
-{
-//  map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
-//  for (; aFamsIter != myFamilies.end(); aFamsIter++)
-//  {
-//    delete (*aFamsIter).second;
-//  }
-}
-
-void DriverMED_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
-{
-  myMesh = aMesh;
-}
-
-void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile)
-{
-  myFile = aFile;
-}
-
-void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId)
-{
-  myFileId = aFileId;
-}
-
-void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId)
-{
-  myMeshId = aMeshId;
-}
+#define _EDF_NODE_IDS_
 
 void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
 {
   myMeshName = theMeshName;
 }
 
-void DriverMED_R_SMESHDS_Mesh::Read()
-{
-
-  string myClass = string("SMDS_Mesh");
-  string myExtension = string("MED");
-
-  DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
-
-  myReader->SetMesh(myMesh);
-  myReader->SetMeshId(myMeshId);
-  myReader->SetFile(myFile);
-  myReader->SetFileId(-1);
-
-  myReader->Read();
+static const SMDS_MeshNode* 
+FindNode(const SMDS_Mesh* theMesh, med_int theId){
+  const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
+  if(aNode) return aNode;
+  EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
 }
 
-void DriverMED_R_SMESHDS_Mesh::Add()
-{
-  string myClass = string("SMDS_Mesh");
-  string myExtension = string("MED");
-
-  DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh;
 
-  myReader->SetMesh(myMesh);
-  myReader->SetMeshId(myMeshId);
+enum ECoordName{eX, eY, eZ, eNone};
+typedef med_float (*TGetCoord)(MEDA::PNodeInfo&, med_int);
 
-  SCRUTE(myFileId);
-  myReader->SetFileId(myFileId);
+template<ECoordName TheCoordId>
+med_float GetCoord(MEDA::PNodeInfo& thePNodeInfo, med_int theElemId){
+  return thePNodeInfo->GetNodeCoord(theElemId,TheCoordId);
+}
 
-  myReader->Read();
+template<>
+med_float GetCoord<eNone>(MEDA::PNodeInfo& thePNodeInfo, med_int theElemId){
+  return 0.0;
 }
 
 
-static const SMDS_MeshNode* 
-FindNode(const SMDS_Mesh* theMesh, med_int theId){
-  const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
-  if(aNode) return aNode;
-  EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
-}
+static TGetCoord aXYZGetCoord[3] = {
+  &GetCoord<eX>, 
+  &GetCoord<eY>, 
+  &GetCoord<eZ>
+};
+
+
+static TGetCoord aXYGetCoord[3] = {
+  &GetCoord<eX>, 
+  &GetCoord<eY>, 
+  &GetCoord<eNone>
+};
+
+static TGetCoord aYZGetCoord[3] = {
+  &GetCoord<eNone>,
+  &GetCoord<eX>, 
+  &GetCoord<eY>
+};
+
+static TGetCoord aXZGetCoord[3] = {
+  &GetCoord<eX>, 
+  &GetCoord<eNone>,
+  &GetCoord<eY>
+};
+
+
+static TGetCoord aXGetCoord[3] = {
+  &GetCoord<eX>, 
+  &GetCoord<eNone>,
+  &GetCoord<eNone>
+};
+
+static TGetCoord aYGetCoord[3] = {
+  &GetCoord<eNone>,
+  &GetCoord<eX>, 
+  &GetCoord<eNone>
+};
+
+static TGetCoord aZGetCoord[3] = {
+  &GetCoord<eNone>,
+  &GetCoord<eNone>,
+  &GetCoord<eX>
+};
+
+
+class TCoordHelper{
+  MEDA::PNodeInfo myPNodeInfo;
+  TGetCoord* myGetCoord;
+public:
+  TCoordHelper(const MEDA::PNodeInfo& thePNodeInfo,
+              TGetCoord* theGetCoord):
+    myPNodeInfo(thePNodeInfo),
+    myGetCoord(theGetCoord)
+  {}
+  virtual ~TCoordHelper(){}
+  med_float GetCoord(med_int theElemId, med_int theCoodId){
+    return (*myGetCoord[theCoodId])(myPNodeInfo,theElemId);
+  }
+};
+typedef boost::shared_ptr<TCoordHelper> TCoordHelperPtr;
 
 
-DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
+Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
 {
-  ReadStatus result = DRS_FAIL;
+  Status aResult = DRS_FAIL;
   try{
     using namespace MEDA;
 
     myFamilies.clear();
-    MESSAGE("ReadMySelf - myFile : "<<myFile);
+    MESSAGE("Perform - myFile : "<<myFile);
     TWrapper aMed(myFile);
 
-    result = DRS_EMPTY;
+    aResult = DRS_EMPTY;
     if(med_int aNbMeshes = aMed.GetNbMeshes()){
       for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
        // Reading the MED mesh
@@ -145,9 +153,9 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
         } else {
           aMeshName = myMeshName;
         }
-       MESSAGE("ReadMySelf - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
+       MESSAGE("Perform - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
        if(aMeshName != aMeshInfo->GetName()) continue;
-        result = DRS_OK;
+        aResult = DRS_OK;
        med_int aMeshDim = aMeshInfo->GetDim();
        
         // Reading MED families to the temporary structure
@@ -159,7 +167,6 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
           med_int aFamId = aFamilyInfo->GetId();
           MESSAGE("Family " << aFamId << " :");
 
-//if (aFamId >= FIRST_VALID_FAMILY) {
             DriverMED_FamilyPtr aFamily (new DriverMED_Family);
 
             med_int aNbGrp = aFamilyInfo->GetNbGroup();
@@ -169,21 +176,56 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
               MESSAGE(aGroupName);
               aFamily->AddGroupName(aGroupName);
             }
-//        aFamily->SetId(aFamId);
             myFamilies[aFamId] = aFamily;
-//          }
         }
 
         // Reading MED nodes to the corresponding SMDS structure
        //------------------------------------------------------
        PNodeInfo aNodeInfo = aMed.GetNodeInfo(aMeshInfo);
+
+       TCoordHelperPtr aCoordHelperPtr;
+       {
+         med_int aMeshDimension = aMeshInfo->GetDim();
+         bool anIsDimPresent[3] = {false, false, false};
+          for(med_int iDim = 0; iDim < aMeshDimension; iDim++){
+           string aDimName = aNodeInfo->GetCoordName(iDim);
+           if(aDimName == "x" || aDimName == "X")
+             anIsDimPresent[eX] = true;
+           else if(aDimName == "y" || aDimName == "Y")
+             anIsDimPresent[eY] = true;
+           else if(aDimName == "z" || aDimName == "Z")
+             anIsDimPresent[eZ] = true;
+         }
+         switch(aMeshDimension){
+         case 3:
+           aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYZGetCoord));
+           break;
+         case 2:
+           if(anIsDimPresent[eY] && anIsDimPresent[eZ])
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYZGetCoord));
+           else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXZGetCoord));
+           else
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXYGetCoord));
+           break;
+         case 1:
+           if(anIsDimPresent[eY])
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aYGetCoord));
+           else if(anIsDimPresent[eZ])
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aZGetCoord));
+           else
+             aCoordHelperPtr.reset(new TCoordHelper(aNodeInfo,aXGetCoord));
+           break;
+         }
+       }
+
        med_booleen anIsNodeNum = aNodeInfo->IsElemNum();
        med_int aNbElems = aNodeInfo->GetNbElem();
-       MESSAGE("ReadMySelf - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
+       MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
         for(med_int iElem = 0; iElem < aNbElems; iElem++){
           double aCoords[3] = {0.0, 0.0, 0.0};
-          for(med_int iDim = 0; iDim < aMeshDim; iDim++)
-            aCoords[iDim] = aNodeInfo->GetNodeCoord(iElem,iDim);
+          for(med_int iDim = 0; iDim < 3; iDim++)
+            aCoords[iDim] = aCoordHelperPtr->GetCoord(iElem,iDim);
           const SMDS_MeshNode* aNode;
           if(anIsNodeNum) {
            aNode = myMesh->AddNodeWithID
@@ -221,8 +263,8 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
            PCellInfo aCellInfo = aMed.GetCellInfo(aMeshInfo,anEntity,aGeom);
            med_booleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : MED_FAUX;
            med_int aNbElems = aCellInfo->GetNbElem();
-           MESSAGE("ReadMySelf - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
-           MESSAGE("ReadMySelf - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
+           MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
+           MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
 
            for(int iElem = 0; iElem < aNbElems; iElem++){
              med_int aNbNodes = -1;
@@ -258,22 +300,21 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                break;
              }
              vector<med_int> aNodeIds(aNbNodes);
+#ifdef _EDF_NODE_IDS_
              if(anIsNodeNum) {
                for(int i = 0; i < aNbNodes; i++){
-                 aNodeIds.at(i) = aNodeInfo->GetElemNum(aCellInfo->GetConn(iElem,i)-1);
+                 aNodeIds[i] = aNodeInfo->GetElemNum(aCellInfo->GetConn(iElem,i)-1);
                }
              }else{
                for(int i = 0; i < aNbNodes; i++){
-                 aNodeIds.at(i) = aCellInfo->GetConn(iElem,i);
+                 aNodeIds[i] = aCellInfo->GetConn(iElem,i);
                }
              }
-             //if(anIsElemNum)
-             //        cout<<aCellInfo->GetElemNum(iElem)<<": ";
-             //else
-             //        cout<<iElem<<": ";
-             //for(int i = 0; i < aNbNodes; i++){
-             //        cout<<aNodeIds.at(i)<<", ";
-             //}
+#else
+             for(int i = 0; i < aNbNodes; i++){
+               aNodeIds[i] = aCellInfo->GetConn(iElem,i);
+             }
+#endif
 
              bool isRenum = false;
              SMDS_MeshElement* anElement = NULL;
@@ -283,12 +324,12 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                case MED_SEG2:
                case MED_SEG3:
                  if(anIsElemNum)
-                   anElement = myMesh->AddEdgeWithID(aNodeIds.at(0),
-                                                     aNodeIds.at(1),
+                   anElement = myMesh->AddEdgeWithID(aNodeIds[0],
+                                                     aNodeIds[1],
                                                      aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds.at(0)),
-                                               FindNode(myMesh,aNodeIds.at(1)));
+                   anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
+                                               FindNode(myMesh,aNodeIds[1]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -296,14 +337,14 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                case MED_TRIA6:
                  aNbNodes = 3;
                  if(anIsElemNum)
-                   anElement = myMesh->AddFaceWithID(aNodeIds.at(0),
-                                                     aNodeIds.at(1),
-                                                     aNodeIds.at(2),
+                   anElement = myMesh->AddFaceWithID(aNodeIds[0],
+                                                     aNodeIds[1],
+                                                     aNodeIds[2],
                                                      aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds.at(0)),
-                                               FindNode(myMesh,aNodeIds.at(1)),
-                                               FindNode(myMesh,aNodeIds.at(2)));
+                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
+                                               FindNode(myMesh,aNodeIds[1]),
+                                               FindNode(myMesh,aNodeIds[2]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -312,16 +353,16 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                  aNbNodes = 4;
                  // There is some differnce between SMDS and MED
                  if(anIsElemNum)
-                   anElement = myMesh->AddFaceWithID(aNodeIds.at(0),
-                                                     aNodeIds.at(1),
-                                                     aNodeIds.at(2),
-                                                     aNodeIds.at(3),
+                   anElement = myMesh->AddFaceWithID(aNodeIds[0],
+                                                     aNodeIds[1],
+                                                     aNodeIds[2],
+                                                     aNodeIds[3],
                                                      aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds.at(0)),
-                                               FindNode(myMesh,aNodeIds.at(1)),
-                                               FindNode(myMesh,aNodeIds.at(2)),
-                                               FindNode(myMesh,aNodeIds.at(3)));
+                   anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
+                                               FindNode(myMesh,aNodeIds[1]),
+                                               FindNode(myMesh,aNodeIds[2]),
+                                               FindNode(myMesh,aNodeIds[3]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -329,16 +370,16 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                case MED_TETRA10:
                  aNbNodes = 4;
                  if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
-                                                       aNodeIds.at(1),
-                                                       aNodeIds.at(2),
-                                                       aNodeIds.at(3),
+                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aNodeIds[2],
+                                                       aNodeIds[3],
                                                        aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
-                                                 FindNode(myMesh,aNodeIds.at(1)),
-                                                 FindNode(myMesh,aNodeIds.at(2)),
-                                                 FindNode(myMesh,aNodeIds.at(3)));
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]),
+                                                 FindNode(myMesh,aNodeIds[2]),
+                                                 FindNode(myMesh,aNodeIds[3]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -347,18 +388,18 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                  aNbNodes = 5;
                  // There is some differnce between SMDS and MED
                  if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
-                                                       aNodeIds.at(1),
-                                                       aNodeIds.at(2),
-                                                       aNodeIds.at(3),
-                                                       aNodeIds.at(4),
+                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aNodeIds[2],
+                                                       aNodeIds[3],
+                                                       aNodeIds[4],
                                                        aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
-                                                 FindNode(myMesh,aNodeIds.at(1)),
-                                                 FindNode(myMesh,aNodeIds.at(2)),
-                                                 FindNode(myMesh,aNodeIds.at(3)),
-                                                 FindNode(myMesh,aNodeIds.at(4)));
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]),
+                                                 FindNode(myMesh,aNodeIds[2]),
+                                                 FindNode(myMesh,aNodeIds[3]),
+                                                 FindNode(myMesh,aNodeIds[4]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -366,20 +407,20 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                case MED_PENTA15:
                  aNbNodes = 6;
                  if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
-                                                       aNodeIds.at(1),
-                                                       aNodeIds.at(2),
-                                                       aNodeIds.at(3),
-                                                       aNodeIds.at(4),
-                                                       aNodeIds.at(5),
+                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aNodeIds[2],
+                                                       aNodeIds[3],
+                                                       aNodeIds[4],
+                                                       aNodeIds[5],
                                                        aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
-                                                 FindNode(myMesh,aNodeIds.at(1)),
-                                                 FindNode(myMesh,aNodeIds.at(2)),
-                                                 FindNode(myMesh,aNodeIds.at(3)),
-                                                 FindNode(myMesh,aNodeIds.at(4)),
-                                                 FindNode(myMesh,aNodeIds.at(5)));
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]),
+                                                 FindNode(myMesh,aNodeIds[2]),
+                                                 FindNode(myMesh,aNodeIds[3]),
+                                                 FindNode(myMesh,aNodeIds[4]),
+                                                 FindNode(myMesh,aNodeIds[5]));
                    isRenum = anIsElemNum;
                  }
                  break;
@@ -387,45 +428,45 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
                case MED_HEXA20:
                  aNbNodes = 8;
                  if(anIsElemNum)
-                   anElement = myMesh->AddVolumeWithID(aNodeIds.at(0),
-                                                       aNodeIds.at(1),
-                                                       aNodeIds.at(2),
-                                                       aNodeIds.at(3),
-                                                       aNodeIds.at(4),
-                                                       aNodeIds.at(5),
-                                                       aNodeIds.at(6),
-                                                       aNodeIds.at(7),
+                   anElement = myMesh->AddVolumeWithID(aNodeIds[0],
+                                                       aNodeIds[1],
+                                                       aNodeIds[2],
+                                                       aNodeIds[3],
+                                                       aNodeIds[4],
+                                                       aNodeIds[5],
+                                                       aNodeIds[6],
+                                                       aNodeIds[7],
                                                        aCellInfo->GetElemNum(iElem));
                  if (!anElement) {
-                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds.at(0)),
-                                                 FindNode(myMesh,aNodeIds.at(1)),
-                                                 FindNode(myMesh,aNodeIds.at(2)),
-                                                 FindNode(myMesh,aNodeIds.at(3)),
-                                                 FindNode(myMesh,aNodeIds.at(4)),
-                                                 FindNode(myMesh,aNodeIds.at(5)),
-                                                 FindNode(myMesh,aNodeIds.at(6)),
-                                                 FindNode(myMesh,aNodeIds.at(7)));
+                   anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
+                                                 FindNode(myMesh,aNodeIds[1]),
+                                                 FindNode(myMesh,aNodeIds[2]),
+                                                 FindNode(myMesh,aNodeIds[3]),
+                                                 FindNode(myMesh,aNodeIds[4]),
+                                                 FindNode(myMesh,aNodeIds[5]),
+                                                 FindNode(myMesh,aNodeIds[6]),
+                                                 FindNode(myMesh,aNodeIds[7]));
                    isRenum = anIsElemNum;
                  }
                  break;
                }
              }catch(const std::exception& exc){
                //INFOS("Follow exception was cought:\n\t"<<exc.what());
-               result = DRS_FAIL;
+               aResult = DRS_FAIL;
              }catch(...){
                //INFOS("Unknown exception was cought !!!");
-               result = DRS_FAIL;
+               aResult = DRS_FAIL;
              }
                
               if (!anElement) {
-                result = DRS_WARN_SKIP_ELEM;
+                aResult = DRS_WARN_SKIP_ELEM;
               }
               else {
                 if (isRenum) {
                   anIsElemNum = MED_FAUX;
                   takeNumbers = false;
-                  if (result < DRS_WARN_RENUMBER)
-                    result = DRS_WARN_RENUMBER;
+                  if (aResult < DRS_WARN_RENUMBER)
+                    aResult = DRS_WARN_RENUMBER;
                 }
                 if (myFamilies.find(aFamNum) != myFamilies.end()) {
                   // Save reference to this element from its family
@@ -441,16 +482,16 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf()
     }
   }catch(const std::exception& exc){
     INFOS("Follow exception was cought:\n\t"<<exc.what());
-    result = DRS_FAIL;
+    aResult = DRS_FAIL;
   }catch(...){
     INFOS("Unknown exception was cought !!!");
-    result = DRS_FAIL;
+    aResult = DRS_FAIL;
   }
-  MESSAGE("ReadMySelf - result status = "<<result);
-  return result;
+  MESSAGE("Perform - aResult status = "<<aResult);
+  return aResult;
 }
 
-list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames()
+list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus)
 {
   list<string> aMeshNames;
 
@@ -458,6 +499,7 @@ list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames()
     using namespace MEDA;
 
     MESSAGE("GetMeshNames - myFile : " << myFile);
+    theStatus = DRS_OK;
     TWrapper aMed (myFile);
 
     if (med_int aNbMeshes = aMed.GetNbMeshes()) {
@@ -470,8 +512,10 @@ list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames()
     }
   }catch(const std::exception& exc){
     INFOS("Follow exception was cought:\n\t"<<exc.what());
+    theStatus = DRS_FAIL;
   }catch(...){
     INFOS("Unknown exception was cought !!!");
+    theStatus = DRS_FAIL;
   }
 
   return aMeshNames;
@@ -560,10 +604,6 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh,
 
 void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
 {
-  SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast<SMESHDS_Mesh*>(myMesh);
-  if (!aSMESHDSMesh) {
-    EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh");
-  }
   map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
   for (; aFamsIter != myFamilies.end(); aFamsIter++)
   {
@@ -583,18 +623,28 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
         {
           for (; anElemsIter != anElements.end(); anElemsIter++)
           {
-            const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
-            aSMESHDSMesh->SetNodeInVolume(node, Id);
-//            aSMESHDSMesh->SetNodeOnFace(node, Id);
-//            aSMESHDSMesh->SetNodeOnEdge(node, Id);
-//            aSMESHDSMesh->SetNodeOnVertex(node, Id);
+            SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>
+              ( static_cast<const SMDS_MeshNode*>( *anElemsIter ));
+            // find out a shape type
+            TopoDS_Shape aShape = myMesh->IndexToShape( Id );
+            int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() );
+            switch ( aShapeType ) {
+            case TopAbs_FACE:
+              myMesh->SetNodeOnFace(node, Id); break;
+            case TopAbs_EDGE:
+              myMesh->SetNodeOnEdge(node, Id); break;
+            case TopAbs_VERTEX:
+              myMesh->SetNodeOnVertex(node, Id); break;
+            default:
+              myMesh->SetNodeInVolume(node, Id);
+            }
           }
         }
         else
         {
           for (; anElemsIter != anElements.end(); anElemsIter++)
           {
-            aSMESHDSMesh->SetMeshElementOnShape(*anElemsIter, Id);
+            myMesh->SetMeshElementOnShape(*anElemsIter, Id);
           }
         }
       }