From: eap Date: Thu, 15 Nov 2012 13:29:43 +0000 (+0000) Subject: 0021980: [CEA 708] Import/export GMF does work only if the file extension is ".mesh" X-Git-Tag: V6_6_0rc1~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=094043665ca1ba82757ae82f3dfcad19e122af33;p=modules%2Fsmesh.git 0021980: [CEA 708] Import/export GMF does work only if the file extension is ".mesh" Notify on a wrong file extesion --- diff --git a/src/DriverGMF/DriverGMF_Read.cxx b/src/DriverGMF/DriverGMF_Read.cxx index 02f4a0a29..9cf599fee 100644 --- a/src/DriverGMF/DriverGMF_Read.cxx +++ b/src/DriverGMF/DriverGMF_Read.cxx @@ -24,7 +24,7 @@ // Author : Edward AGAPOV (eap) #include "DriverGMF_Read.hxx" -#include "DriverGMF_Write.hxx" +#include "DriverGMF.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_Mesh.hxx" @@ -39,13 +39,6 @@ extern "C" #include -// -------------------------------------------------------------------------------- -// Closing GMF mesh at destruction -DriverGMF_MeshCloser::~DriverGMF_MeshCloser() -{ - if ( _gmfMeshID ) - GmfCloseMesh( _gmfMeshID ); -} // -------------------------------------------------------------------------------- DriverGMF_Read::DriverGMF_Read(): Driver_SMESHDS_Mesh(), @@ -74,9 +67,13 @@ Driver_Mesh::Status DriverGMF_Read::Perform() // open the file int meshID = GmfOpenMesh( myFile.c_str(), GmfRead, &version, &dim ); if ( !meshID ) - return addMessage( SMESH_Comment("Can't open for reading ") << myFile, /*fatal=*/true ); - - DriverGMF_MeshCloser aMeshCloser( meshID ); // An object closing GMF mesh at destruction + { + if ( DriverGMF::isExtensionCorrect( myFile )) + return addMessage( SMESH_Comment("Can't open for reading ") << myFile, /*fatal=*/true ); + else + return addMessage( SMESH_Comment("Not '.mesh' or '.meshb' extension of file ") << myFile, /*fatal=*/true ); + } + DriverGMF::MeshCloser aMeshCloser( meshID ); // An object closing GMF mesh at destruction // Read nodes diff --git a/src/DriverGMF/DriverGMF_Write.cxx b/src/DriverGMF/DriverGMF_Write.cxx index 6dd232d91..926f7f4c3 100644 --- a/src/DriverGMF/DriverGMF_Write.cxx +++ b/src/DriverGMF/DriverGMF_Write.cxx @@ -24,6 +24,7 @@ // Author : Edward AGAPOV (eap) #include "DriverGMF_Write.hxx" +#include "DriverGMF.hxx" #include "SMESHDS_GroupBase.hxx" #include "SMESHDS_Mesh.hxx" @@ -74,9 +75,14 @@ Driver_Mesh::Status DriverGMF_Write::Perform() int meshID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim ); if ( !meshID ) - return addMessage( SMESH_Comment("Can't open for writing ") << myFile, /*fatal=*/true ); + { + if ( DriverGMF::isExtensionCorrect( myFile )) + return addMessage( SMESH_Comment("Can't open for writing ") << myFile, /*fatal=*/true ); + else + return addMessage( SMESH_Comment("Not '.mesh' or '.meshb' extension of file ") << myFile, /*fatal=*/true ); + } - DriverGMF_MeshCloser aMeshCloser( meshID ); // An object closing GMF mesh at destruction + DriverGMF::MeshCloser aMeshCloser( meshID ); // An object closing GMF mesh at destruction // nodes std::map< const SMDS_MeshNode* , int > node2IdMap;