From b59ca5c972822b3ced985bf7302e9a7585fdd298 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 24 Sep 2012 11:20:01 +0000 Subject: [PATCH] 021382: EDF 1985 SMESH: Read/write of .mesh files (GMF format) + SMESH_ComputeErrorPtr GMFToMesh(const char* theFileName); + void ExportGMF(const char * file, const SMESHDS_Mesh* mesh); --- src/SMESH/SMESH_Mesh.cxx | 46 +++++++++++++++++++++++++++++++++++----- src/SMESH/SMESH_Mesh.hxx | 15 ++++++++----- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index da8e83e2c..0b171a6ef 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -40,14 +40,15 @@ #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( meshDS )); + myWriter.Perform(); +} + //================================================================================ /*! * \brief Return number of nodes in the mesh diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 272bcea7d..5bd9b9c14 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -29,12 +29,12 @@ #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 #include + #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); -- 2.39.2