Jelajahi Sumber

Fix build for current python bindings.

Jérémie Dumas 6 tahun lalu
induk
melakukan
b0c518a05f
46 mengubah file dengan 111 tambahan dan 25 penghapusan
  1. 0 5
      cmake/libigl.cmake
  2. 14 10
      python/CMakeLists.txt
  3. 2 0
      python/tutorial/001_BasicTypes.py
  4. 2 0
      python/tutorial/101_FileIO.py
  5. 2 0
      python/tutorial/102_DrawMesh.py
  6. 2 0
      python/tutorial/102_DrawMesh_TCP.py
  7. 2 0
      python/tutorial/103_Events.py
  8. 2 0
      python/tutorial/104_Colors.py
  9. 2 0
      python/tutorial/105_Overlays.py
  10. 2 0
      python/tutorial/201_Normals.py
  11. 2 0
      python/tutorial/202_GaussianCurvature.py
  12. 2 0
      python/tutorial/203_CurvatureDirections.py
  13. 2 0
      python/tutorial/204_Gradient.py
  14. 2 0
      python/tutorial/205_Laplacian.py
  15. 2 0
      python/tutorial/301_Slice.py
  16. 2 0
      python/tutorial/302_Sort.py
  17. 2 0
      python/tutorial/303_LaplaceEquation.py
  18. 2 0
      python/tutorial/304_LinearEqualityConstraints.py
  19. 2 0
      python/tutorial/305_QuadraticProgramming.py
  20. 2 0
      python/tutorial/306_EigenDecomposition.py
  21. 2 0
      python/tutorial/401_BiharmonicDeformation.py
  22. 2 0
      python/tutorial/402_PolyharmonicDeformation.py
  23. 2 0
      python/tutorial/403_BoundedBiharmonicWeights.py
  24. 2 0
      python/tutorial/404_DualQuaternionSkinning.py
  25. 2 0
      python/tutorial/405_AsRigidAsPossible.py
  26. 2 0
      python/tutorial/501_HarmonicParam.py
  27. 2 0
      python/tutorial/502_LSCMParam.py
  28. 2 0
      python/tutorial/503_ARAPParam.py
  29. 2 0
      python/tutorial/504_NRosyDesign.py
  30. 2 0
      python/tutorial/505_MIQ.py
  31. 2 0
      python/tutorial/507_Planarization.py
  32. 2 0
      python/tutorial/604_Triangle.py
  33. 2 0
      python/tutorial/605_Tetgen.py
  34. 2 0
      python/tutorial/606_AmbientOcclusion.py
  35. 2 0
      python/tutorial/607_ScreenCapture.py
  36. 2 0
      python/tutorial/609_Boolean.py
  37. 2 0
      python/tutorial/701_Statistics.py
  38. 2 0
      python/tutorial/702_WindingNumber.py
  39. 2 0
      python/tutorial/704_SignedDistance.py
  40. 2 0
      python/tutorial/705_MarchingCubes.py
  41. 2 0
      python/tutorial/706_FacetOrientation.py
  42. 2 0
      python/tutorial/707_SweptVolume.py
  43. 2 0
      python/tutorial/708_Picking.py
  44. 3 1
      python/tutorial/709_VectorFieldVisualizer.py
  45. 1 1
      python/tutorial/shared.py
  46. 11 8
      tutorial/CMakeLists.txt

+ 0 - 5
cmake/libigl.cmake

@@ -88,11 +88,6 @@ if(BUILD_SHARED_LIBS)
   set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
 endif()
 
-if(UNIX)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
-endif()
-
 # Eigen
 if(TARGET Eigen3::Eigen)
   # If an imported target already exists, use it

+ 14 - 10
python/CMakeLists.txt

@@ -1,6 +1,19 @@
 cmake_minimum_required(VERSION 2.8.12)
 project(pyigl)
 
+### Adding libIGL: choose the path to your local copy libIGL
+if(NOT TARGET igl::core)
+  ### Prefer header-only mode for compiling Python bindings
+  if(NOT LIBIGL_WITH_PYTHON OR NOT LIBIGL_USE_STATIC_LIBRARY)
+    message(FATAL_ERROR
+      "Trying to compile Python bindings without -DLIBIGL_WITH_PYTHON=ON. "
+      "Either enable manually all the necessary options, or compile from "
+      "the root folder with -DLIBIGL_USE_STATIC_LIBRARY=OFF")
+  endif()
+  list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake")
+  include(libigl)
+endif()
+
 # Force a specific python version
 # set(PYTHON_LIBRARIES "D:/Python34/libs/python34.lib")
 # set(PYTHON_INCLUDE_DIR "D:/Python34/include")
@@ -13,22 +26,13 @@ set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6)
 find_package(PythonInterp REQUIRED)
 find_package(PythonLibs REQUIRED)
 
-
 string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
 if(UNIX)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
   if(NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -flto")
   endif()
 endif()
 
-## libigl		
-if(NOT TARGET igl::core)		
-  list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake")		
-  include(libigl)		
-endif()
-
 ## include pybind
 set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/../external/pybind11 CACHE PATH "Path to pybind11")
 add_subdirectory(${PYBIND11_DIR} pybind11)
@@ -42,7 +46,7 @@ pybind11_add_module(pyigl
 )
 
 ## Add dependencies
-target_include_directories(pyigl PUBLIC igl::core)
+target_link_libraries(pyigl PUBLIC igl::core)
 
 ## Optional modules
 if(LIBIGL_WITH_OPENGL_GLFW)

+ 2 - 0
python/tutorial/001_BasicTypes.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/101_FileIO.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/102_DrawMesh.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/102_DrawMesh_TCP.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/103_Events.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/104_Colors.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/105_Overlays.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/201_Normals.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/202_GaussianCurvature.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/203_CurvatureDirections.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/204_Gradient.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/205_Laplacian.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/301_Slice.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/302_Sort.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/303_LaplaceEquation.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/304_LinearEqualityConstraints.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/305_QuadraticProgramming.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/306_EigenDecomposition.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/401_BiharmonicDeformation.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/402_PolyharmonicDeformation.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/403_BoundedBiharmonicWeights.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/404_DualQuaternionSkinning.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/405_AsRigidAsPossible.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/501_HarmonicParam.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/502_LSCMParam.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/503_ARAPParam.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/504_NRosyDesign.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/505_MIQ.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/507_Planarization.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/604_Triangle.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/605_Tetgen.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/606_AmbientOcclusion.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/607_ScreenCapture.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/609_Boolean.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/701_Statistics.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/702_WindingNumber.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/704_SignedDistance.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/705_MarchingCubes.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/706_FacetOrientation.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/707_SweptVolume.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 2 - 0
python/tutorial/708_Picking.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>

+ 3 - 1
python/tutorial/709_VectorFieldVisualizer.py

@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
 # This file is part of libigl, a simple c++ geometry processing library.
 #
 # Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@gmail.com>
@@ -130,4 +132,4 @@ def main():
     viewer.launch()
 
 if __name__ == "__main__":
-    main()
+    main()

+ 1 - 1
python/tutorial/shared.py

@@ -9,7 +9,7 @@ import pyigl as igl
 import sys
 import os
 
-TUTORIAL_SHARED_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../tutorial/shared/")
+TUTORIAL_SHARED_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../tutorial/data/")
 
 def check_dependencies(deps):
     available = [hasattr(igl, m) for m in deps]

+ 11 - 8
tutorial/CMakeLists.txt

@@ -1,14 +1,17 @@
 cmake_minimum_required(VERSION 3.1)
 project(libigl_tutorials)
 
-### conditionally compile certain modules depending on libraries found on the system		
-list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)		
-	
-### Adding libIGL: choose the path to your local copy libIGL		
-if(NOT TARGET igl_common)		
-  include(libigl)		
-else()		
-  include(LibiglDownloadExternal)		
+### Conditionally compile certain modules depending on libraries found on the system
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
+
+### Compile libigl in header-only mode for Python bindings
+option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
+
+### Adding libIGL: choose the path to your local copy libIGL
+if(NOT TARGET igl_common)
+  include(libigl)
+else()
+  include(LibiglDownloadExternal)
 endif()
 
 ### Download data