From: eap Date: Thu, 15 Nov 2012 13:30:32 +0000 (+0000) Subject: 0021980: [CEA 708] Import/export GMF does work only if the file extension is ".mesh" X-Git-Tag: V6_6_0rc1~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b35b22be3460654bb8322be1a0d25ad0f8a09f38;p=modules%2Fsmesh.git 0021980: [CEA 708] Import/export GMF does work only if the file extension is ".mesh" --- diff --git a/src/DriverGMF/DriverGMF.cxx b/src/DriverGMF/DriverGMF.cxx new file mode 100644 index 000000000..17ebb5e05 --- /dev/null +++ b/src/DriverGMF/DriverGMF.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : DriverGMF.hxx +// Created : Thu Nov 15 16:45:58 2012 +// Author : Edward AGAPOV (eap) + +#include "DriverGMF.hxx" + +#include + +extern "C" +{ +#include "libmesh5.h" +} + +namespace DriverGMF +{ + + //================================================================================ + /*! + * \brief Closes GMF mesh at destruction + */ + //================================================================================ + + MeshCloser::~MeshCloser() + { + if ( _gmfMeshID ) + GmfCloseMesh( _gmfMeshID ); + } + + //================================================================================ + /*! + * \brief Checks GMF file extension + */ + //================================================================================ + + bool isExtensionCorrect( const std::string& fileName ) + { + std::string ext = boost::filesystem::extension(fileName); + switch ( ext.size() ) { + case 5: return ( ext == ".mesh" || ext == ".solb" ); + case 6: return ( ext == ".meshb" ); + case 4: return ( ext == ".sol" ); + } + return false; + } +} diff --git a/src/DriverGMF/DriverGMF.hxx b/src/DriverGMF/DriverGMF.hxx new file mode 100644 index 000000000..52d560f06 --- /dev/null +++ b/src/DriverGMF/DriverGMF.hxx @@ -0,0 +1,46 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : DriverGMF.hxx +// Created : Thu Nov 15 16:45:58 2012 +// Author : Edward AGAPOV (eap) + +#ifndef __DriverGMF_HXX__ +#define __DriverGMF_HXX__ + +#include + +namespace DriverGMF +{ + /*! + * \brief An object closing GMF mesh at destruction + */ + struct MeshCloser + { + int _gmfMeshID; + MeshCloser( const int gmfMeshID ): _gmfMeshID(gmfMeshID) {} + ~MeshCloser(); + }; + + bool isExtensionCorrect( const std::string& fileName ); +} + +#endif diff --git a/src/DriverGMF/DriverGMF_Write.hxx b/src/DriverGMF/DriverGMF_Write.hxx index 308dcdc00..0e8ee4f70 100644 --- a/src/DriverGMF/DriverGMF_Write.hxx +++ b/src/DriverGMF/DriverGMF_Write.hxx @@ -54,15 +54,4 @@ public: bool _exportRequiredGroups; }; -/*! - * \brief An object closing GMF mesh at destruction - */ -struct DriverGMF_MeshCloser -{ - int _gmfMeshID; - DriverGMF_MeshCloser( const int gmfMeshID ): _gmfMeshID(gmfMeshID) {} - ~DriverGMF_MeshCloser(); -}; - - #endif