From ee75abc427987a37d59d87395fd13842e0d804f3 Mon Sep 17 00:00:00 2001 From: El Hadi Moussi Date: Mon, 5 Aug 2024 15:22:39 +0200 Subject: [PATCH] Add swig to ShapeRecogn --- src/ShapeRecogn/CMakeLists.txt | 6 +- src/ShapeRecogn/Swig/CMakeLists.txt | 80 ++++++++++++++++++++++++++ src/ShapeRecogn/Swig/ShapeRecognMesh.i | 13 +++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 src/ShapeRecogn/Swig/CMakeLists.txt create mode 100644 src/ShapeRecogn/Swig/ShapeRecognMesh.i diff --git a/src/ShapeRecogn/CMakeLists.txt b/src/ShapeRecogn/CMakeLists.txt index 5dac83f40..e1797d591 100644 --- a/src/ShapeRecogn/CMakeLists.txt +++ b/src/ShapeRecogn/CMakeLists.txt @@ -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 index 000000000..e03cbeaf4 --- /dev/null +++ b/src/ShapeRecogn/Swig/CMakeLists.txt @@ -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 index 000000000..7522ff83c --- /dev/null +++ b/src/ShapeRecogn/Swig/ShapeRecognMesh.i @@ -0,0 +1,13 @@ +%module ShapeRecogn + +%include "std_string.i" + + +%{ +#include "ShapeRecognMesh.hxx" +%} + +%ignore getAreas() const; +%ignore getNodes() const; +%ignore recognize(); +%include "ShapeRecognMesh.hxx" -- 2.39.2