Salome HOME
Merge br_enable_import_mesh. Enable import mesh and save/load SMESH study.
[modules/smesh.git] / src / SMESH / SMESH_Gen.cxx
index ec40c71ff9a7d3335fdee3cb5a09e6687dd55897..5be63b4a9ff765c419be4e622b352a438bb957d2 100644 (file)
@@ -30,6 +30,7 @@
 #include "SMESH_subMesh.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 #include "SMESH_subMesh.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
+#include "SMESHDriver.h"
 
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
 
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
@@ -126,7 +127,8 @@ throw(SALOME_Exception)
 
 //=============================================================================
 /*!
 
 //=============================================================================
 /*!
- * 
+ * @TODO Doing a full update after computation is not optimal when doing a local
+ * remeshing.
  */
 //=============================================================================
 
  */
 //=============================================================================
 
@@ -138,7 +140,7 @@ throw(SALOME_Exception)
 /* 
 Algo : s'appuie ou non sur une geometrie
 Si geometrie:
 /* 
 Algo : s'appuie ou non sur une geometrie
 Si geometrie:
-Vertex : rien à faire (range le point)
+Vertex : rien faire (range le point)
 Edge, Wire, collection d'edge et wire : 1D
 Face, Shell, collection de Face et Shells : 2D
 Solid, Collection de Solid : 3D
 Edge, Wire, collection d'edge et wire : 1D
 Face, Shell, collection de Face et Shells : 2D
 Solid, Collection de Solid : 3D
@@ -183,6 +185,8 @@ Solid, Collection de Solid : 3D
                smToCompute = sm->GetFirstToCompute();
        }
 
                smToCompute = sm->GetFirstToCompute();
        }
 
+       aMesh.GetMeshDS()->logFullUpdate();
+
        return ret;
 }
 
        return ret;
 }
 
@@ -404,3 +408,40 @@ int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
 //   SCRUTE(shapeDim);
        return shapeDim;
 }
 //   SCRUTE(shapeDim);
        return shapeDim;
 }
+
+/**
+ * Import a mesh from a file
+ * @param fileName file name to be imported
+ * @param fileType Currently it could be either "DAT", "UNV" or "MED".
+ * @todo
+ */
+SMESH_Mesh * SMESH_Gen::Import(int studyId, const char * fileName,
+       const char * fileType)
+{
+       MESSAGE("SMESH_Gen::Import("<<studyId<<","<<fileName<<","<<fileType<<")");
+
+       // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+       StudyContextStruct *myStudyContext = GetStudyContext(studyId);
+
+       // will be used with document
+       /*Document_Reader * reader = SMESHDriver::GetDocumentReader(string(fileType));
+       reader->SetDocument(myStudyContext->myDocument);
+       reader->SetFile(string(fileName));
+       reader->Read();*/
+       // currently we only read one mesh from a file (limitation on MED files).
+
+       // create a new SMESH_mesh object 
+       SMESH_Mesh *mesh = new SMESH_Mesh(_localId++, studyId, this,
+               myStudyContext->myDocument);
+       myStudyContext->mapMesh[_localId] = mesh;
+       
+       Mesh_Reader * reader = SMESHDriver::GetMeshReader(string(fileType));
+       reader->SetMesh(mesh->GetMeshDS());
+       reader->SetFile(string(fileName));
+       reader->Read();
+       
+       mesh->GetMeshDS()->logFullUpdate();
+       
+       return mesh;
+}
+