From 46156a2b60024a0429080f1428260f2256637038 Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Tue, 2 Nov 2010 22:12:07 +0000
Subject: [PATCH] initial test with swig

---
 CMakeLists.txt           | 12 ++++++++++++
 Geo/GModel.h             |  4 ++--
 Geo/GModel.i             |  9 +++++++++
 Geo/GModelIO_Fourier.cpp |  6 ++++++
 4 files changed, 29 insertions(+), 2 deletions(-)
 create mode 100644 Geo/GModel.i

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c0d63b418..ab54efc27f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,6 +50,7 @@ option(ENABLE_QT "Build QT GUI" OFF)
 option(ENABLE_READLINE "Enable Readline in Lua prompt" ON)
 option(ENABLE_SLEPC "Enable SLEPc eigensolvers" ON)
 option(ENABLE_SOLVER "Enable solver components" ON)
+option(ENABLE_SWIG_EXPERIMENTAL "Enable swig (in developement, totally unusable)" OFF)
 option(ENABLE_TAUCS "Enable Taucs linear algebra solver" ON)
 option(ENABLE_TETGEN "Enable Tetgen mesh generator" ON)
 option(ENABLE_TETGEN_NEW "Enable experimental version of Tetgen" OFF)
@@ -1119,3 +1120,14 @@ message("")
 mark_as_advanced(BISON FLEX GMP_LIB GMSH_EXTRA_VERSION HDF5_LIB MAKEINFO 
                  MED_LIB OCC_INC SZ_LIB TAUCS_LIB LUA_LIB ACIS_LIB TEXI2PDF
                  READLINE_LIB)
+
+if(ENABLE_SWIG_EXPERIMENTAL)
+  FIND_PACKAGE(SWIG REQUIRED)
+  INCLUDE(${SWIG_USE_FILE})
+  FIND_PACKAGE(PythonLibs)
+  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR};${PYTHON_INCLUDE_DIR};../Common;${CMAKE_CURRENT_BINARY_DIR}/../Common)
+  SET_SOURCE_FILES_PROPERTIES(Geo/GModel.i PROPERTIES CPLUSPLUS ON)
+  #SET_SOURCE_FILES_PROPERTIES(Geo/GModel.i SWIG_FLAGS "-includeall -importall")
+  SWIG_ADD_MODULE(gmshPython python Geo/GModel.i ${GMSH_SRC})
+  SWIG_LINK_LIBRARIES(gmshPython ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES})
+endif(ENABLE_SWIG_EXPERIMENTAL)
diff --git a/Geo/GModel.h b/Geo/GModel.h
index f9e2fd56db..c81703d57f 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -481,9 +481,9 @@ class GModel
   int writePartitionedMSH(const std::string &baseName, bool binary=false,
                           bool saveAll=false, bool saveParametric=false,
                           double scalingFactor=1.0);
-  int writeDistanceMSH(const std::string &name, double version=2.2, bool binary=false,
+  /*int writeDistanceMSH(const std::string &name, double version=2.2, bool binary=false,
                        bool saveAll=false, bool saveParametric=false,
-                       double scalingFactor=1.0);
+                       double scalingFactor=1.0);*/
 
   // Iridium file format
   int writeIR3(const std::string &name, int elementTagType,
diff --git a/Geo/GModel.i b/Geo/GModel.i
new file mode 100644
index 0000000000..83aba859eb
--- /dev/null
+++ b/Geo/GModel.i
@@ -0,0 +1,9 @@
+%module gmshPython
+%include std_string.i
+%{
+  #include "GModel.h"
+  void GmshInitialize(int argc=0, char **argv=NULL);
+%}
+
+void GmshInitialize(int argc=0, char **argv=NULL);
+%include "GModel.h"
diff --git a/Geo/GModelIO_Fourier.cpp b/Geo/GModelIO_Fourier.cpp
index 284fef3546..6f5267db96 100644
--- a/Geo/GModelIO_Fourier.cpp
+++ b/Geo/GModelIO_Fourier.cpp
@@ -142,6 +142,12 @@ void GModel::_deleteFMInternals()
 {
 }
 
+int GModel::readFourier()
+{
+  Msg::Error("Gmsh must be compiled with Fourier Model support toad fourier Model");
+  return 0;
+}
+
 int GModel::readFourier(const std::string &fn)
 {
   Msg::Error("Gmsh must be compiled with Fourier Model support to load '%s'",
-- 
GitLab