Salome HOME
021382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)
authoreap <eap@opencascade.com>
Mon, 24 Sep 2012 11:20:01 +0000 (11:20 +0000)
committereap <eap@opencascade.com>
Mon, 24 Sep 2012 11:20:01 +0000 (11:20 +0000)
+  SMESH_ComputeErrorPtr GMFToMesh(const char* theFileName);
+  void ExportGMF(const char * file, const SMESHDS_Mesh* mesh);

src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx

index da8e83e2ce7e8485798b9f76e09b8abaadeb809d..0b171a6efbb293fddecff2e4c8f44059ca114d11 100644 (file)
 
 #include "utilities.h"
 
-#include "DriverMED_W_SMESHDS_Mesh.h"
 #include "DriverDAT_W_SMDS_Mesh.h"
-#include "DriverUNV_W_SMDS_Mesh.h"
-#include "DriverSTL_W_SMDS_Mesh.h"
-
+#include "DriverGMF_Read.hxx"
+#include "DriverGMF_Write.hxx"
 #include "DriverMED_R_SMESHDS_Mesh.h"
-#include "DriverUNV_R_SMDS_Mesh.h"
+#include "DriverMED_W_SMESHDS_Mesh.h"
 #include "DriverSTL_R_SMDS_Mesh.h"
+#include "DriverSTL_W_SMDS_Mesh.h"
+#include "DriverUNV_R_SMDS_Mesh.h"
+#include "DriverUNV_W_SMDS_Mesh.h"
 #ifdef WITH_CGNS
 #include "DriverCGNS_Read.hxx"
 #include "DriverCGNS_Write.hxx"
@@ -538,6 +539,26 @@ int SMESH_Mesh::CGNSToMesh(const char*  theFileName,
   return res;
 }
 
+//================================================================================
+/*!
+ * \brief Fill its data by reading a GMF file
+ */
+//================================================================================
+
+SMESH_ComputeErrorPtr SMESH_Mesh::GMFToMesh(const char* theFileName)
+{
+  DriverGMF_Read myReader;
+  myReader.SetMesh(_myMeshDS);
+  myReader.SetFile(theFileName);
+  myReader.Perform();
+  //theMeshName = myReader.GetMeshName();
+
+  // create groups
+  SynchronizeGroups();
+
+  return myReader.GetError();
+}
+
 //=============================================================================
 /*!
  * 
@@ -1391,6 +1412,21 @@ void SMESH_Mesh::ExportCGNS(const char *        file,
     throw SALOME_Exception("Export failed");
 }
 
+//================================================================================
+/*!
+ * \brief Export the mesh to a GMF file
+ */
+//================================================================================
+
+void SMESH_Mesh::ExportGMF(const char *        file,
+                           const SMESHDS_Mesh* meshDS)
+{
+  DriverGMF_Write myWriter;
+  myWriter.SetFile( file );
+  myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
+  myWriter.Perform();
+}
+
 //================================================================================
 /*!
  * \brief Return number of nodes in the mesh
index 272bcea7d6f454b0f322d6061d52a74bd6223cd2..5bd9b9c14476db90d122ac265088b584205e1460 100644 (file)
 
 #include "SMESH_SMESH.hxx"
 
-#include "SMESH_Hypothesis.hxx"
-#include "SMESH_Controls.hxx"
-
-#include "SMESHDS_Mesh.hxx"
-#include "SMESHDS_Command.hxx"
 #include "SMDSAbs_ElementType.hxx"
+#include "SMESHDS_Command.hxx"
+#include "SMESHDS_Mesh.hxx"
+#include "SMESH_ComputeError.hxx"
+#include "SMESH_Controls.hxx"
+#include "SMESH_Hypothesis.hxx"
 
 #include "Utils_SALOME_Exception.hxx"
 
@@ -44,6 +44,7 @@
 #include <map>
 #include <list>
 
+
 #ifdef WNT
 #pragma warning(disable:4251) // Warning DLL Interface ...
 #pragma warning(disable:4290) // Warning Exception ...
@@ -121,6 +122,8 @@ public:
 
   int CGNSToMesh(const char* theFileName, const int theMeshIndex, std::string& theMeshName);
   
+  SMESH_ComputeErrorPtr GMFToMesh(const char* theFileName);
+
   SMESH_Hypothesis::Hypothesis_Status
   AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
     throw(SALOME_Exception);
@@ -240,6 +243,8 @@ public:
                  const SMESHDS_Mesh* meshPart = 0) throw(SALOME_Exception);
   void ExportCGNS(const char *        file,
                   const SMESHDS_Mesh* mesh);
+  void ExportGMF(const char *        file,
+                 const SMESHDS_Mesh* mesh);
   void ExportSAUV(const char *file, 
                   const char* theMeshName = NULL, 
                   bool theAutoGroups = true) throw(SALOME_Exception);