]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Add swig to ShapeRecogn
authorEl Hadi Moussi <moussi@phimeca.com>
Mon, 5 Aug 2024 13:22:39 +0000 (15:22 +0200)
committerEl Hadi Moussi <moussi@phimeca.com>
Mon, 5 Aug 2024 13:22:39 +0000 (15:22 +0200)
src/ShapeRecogn/CMakeLists.txt
src/ShapeRecogn/Swig/CMakeLists.txt [new file with mode: 0644]
src/ShapeRecogn/Swig/ShapeRecognMesh.i [new file with mode: 0644]

index 5dac83f40ba027db2b49fc1df80f4f8f04672209..e1797d591954c5f2464035a5bf6408237c3785ed 100644 (file)
@@ -23,9 +23,9 @@ IF (NOT DEFINED MSVC)
   ADD_DEFINITIONS(-Wsign-compare -Wconversion)
 ENDIF()
 
-IF(MEDCOUPLING_ENABLE_PYTHON)
-  ADD_SUBDIRECTORY(Swig)
-ENDIF(MEDCOUPLING_ENABLE_PYTHON)
+IF(MEDCOUPLING_ENABLE_PYTHON)
+  ADD_SUBDIRECTORY(Swig)
+ENDIF(MEDCOUPLING_ENABLE_PYTHON)
 
 # IF(MEDCOUPLING_BUILD_TESTS)
 #   ADD_SUBDIRECTORY(Test)
diff --git a/src/ShapeRecogn/Swig/CMakeLists.txt b/src/ShapeRecogn/Swig/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e03cbea
--- /dev/null
@@ -0,0 +1,80 @@
+# Copyright (C) 2012-2024  CEA, EDF
+#
+# 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, or (at your option) any later version.
+#
+# 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
+#
+
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
+
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+
+SET_SOURCE_FILES_PROPERTIES(ShapeRecognMesh.i PROPERTIES CPLUSPLUS ON)
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+  SET_SOURCE_FILES_PROPERTIES(ShapeRecognMesh.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+  SET_SOURCE_FILES_PROPERTIES(ShapeRecognMesh.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
+IF(MEDCOUPLING_USE_64BIT_IDS)
+  STRING(APPEND SWIG_MODULE_ShapeRecogn_EXTRA_FLAGS ";-DMEDCOUPLING_USE_64BIT_IDS")
+ENDIF(MEDCOUPLING_USE_64BIT_IDS)
+
+SET (ShapeRecogn_SWIG_DPYS_FILES
+  ShapeRecognMesh.i
+)
+
+INCLUDE_DIRECTORIES(
+  ${PYTHON_INCLUDE_DIRS}
+  ${MEDFILE_INCLUDE_DIRS}
+  ${HDF5_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/..
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDCoupling_Swig
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDCoupling
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/Bases
+)
+
+SET (SWIG_MODULE_ShapeRecogn_EXTRA_DEPS ${ShapeRecogn_SWIG_DPYS_FILES}
+    ${shaperecogn_HEADERS_HXX}
+    ${medcoupling_HEADERS_HXX} ${medcoupling_HEADERS_TXX}
+    ${interpkernel_HEADERS_HXX} ${interpkernel_HEADERS_TXX})
+
+IF(WIN32)
+  SET_PROPERTY(SOURCE ShapeRecognMesh.i PROPERTY COMPILE_DEFINITIONS WIN32)
+ENDIF()
+
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0")   
+  SWIG_ADD_MODULE(ShapeRecognMesh python ShapeRecognMesh.i)
+ELSE()
+  SWIG_ADD_LIBRARY(ShapeRecognMesh LANGUAGE python SOURCES ShapeRecognMesh.i)
+ENDIF()
+
+SWIG_LINK_LIBRARIES(ShapeRecognMesh ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} shaperecogn medloader medcouplingcpp)
+SWIG_CHECK_GENERATION(ShapeRecognMesh)
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_ShapeRecognMesh PROPERTIES DEBUG_OUTPUT_NAME _ShapeRecogn_d)
+  # To increase the size of the .obj file on Windows because ShapeRecognPYTHON_wrap.cxx, generated by SWIG, is too big
+  TARGET_COMPILE_OPTIONS(_ShapeRecognMesh PRIVATE /bigobj) 
+ENDIF(WIN32)
+
+INSTALL(TARGETS _ShapeRecognMesh DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
+INSTALL(FILES ShapeRecognMesh.i DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
+
+SALOME_INSTALL_SCRIPTS(
+  ${CMAKE_CURRENT_BINARY_DIR}/ShapeRecogn.py 
+  ${MEDCOUPLING_INSTALL_PYTHON} 
+  EXTRA_DPYS "${SWIG_MODULE_ShapeRecogn_REAL_NAME}")
diff --git a/src/ShapeRecogn/Swig/ShapeRecognMesh.i b/src/ShapeRecogn/Swig/ShapeRecognMesh.i
new file mode 100644 (file)
index 0000000..7522ff8
--- /dev/null
@@ -0,0 +1,13 @@
+%module ShapeRecogn
+
+%include "std_string.i"
+
+
+%{
+#include "ShapeRecognMesh.hxx"
+%}
+
+%ignore getAreas() const; 
+%ignore getNodes() const; 
+%ignore recognize(); 
+%include "ShapeRecognMesh.hxx"