Salome HOME
0021980: [CEA 708] Import/export GMF does work only if the file extension is ".mesh"
authoreap <eap@opencascade.com>
Thu, 15 Nov 2012 13:30:32 +0000 (13:30 +0000)
committereap <eap@opencascade.com>
Thu, 15 Nov 2012 13:30:32 +0000 (13:30 +0000)
src/DriverGMF/DriverGMF.cxx [new file with mode: 0644]
src/DriverGMF/DriverGMF.hxx [new file with mode: 0644]
src/DriverGMF/DriverGMF_Write.hxx

diff --git a/src/DriverGMF/DriverGMF.cxx b/src/DriverGMF/DriverGMF.cxx
new file mode 100644 (file)
index 0000000..17ebb5e
--- /dev/null
@@ -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 <boost/filesystem.hpp>
+
+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 (file)
index 0000000..52d560f
--- /dev/null
@@ -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 <string>
+
+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
index 308dcdc002885567fdebcfc55c02f3802d0f15f2..0e8ee4f70859786bbc7856f788b9069a3800edd2 100644 (file)
@@ -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