diff --git a/python/504_NRosyDesign.py b/python/504_NRosyDesign.py index 08f6a4862..f5992f9d4 100755 --- a/python/504_NRosyDesign.py +++ b/python/504_NRosyDesign.py @@ -75,7 +75,7 @@ def plot_mesh_nrosy(viewer, V, F, N, PD1, S, b): def key_down(viewer, key, modifier): global N if key >= ord('1') and key <= ord('9'): - N = key - '0' + N = key - ord('0') R = igl.eigen.MatrixXd() S = igl.eigen.MatrixXd() @@ -95,7 +95,7 @@ bc = igl.eigen.MatrixXd([[1,1,1]]) viewer = igl.viewer.Viewer() # Interpolate the field and plot -key_down(viewer, '4', 0) +key_down(viewer, ord('4'), 0) # Plot the mesh viewer.data.set_mesh(V, F) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 359b9c2dd..3ff8e17c1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -26,8 +26,8 @@ find_package(OPENGL REQUIRED) # SET(PYTHON_INCLUDE_DIR "D:/Python34/include") # Force a specific python version -# SET(PYTHON_LIBRARIES "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib") -# SET(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m") +SET(PYTHON_LIBRARIES "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib") +SET(PYTHON_INCLUDE_DIR "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m") set(Python_ADDITIONAL_VERSIONS 3.4.3 3.5 3.6) find_package(PythonLibs REQUIRED) @@ -78,6 +78,30 @@ include_directories("../external/nanogui/ext/glfw/include") include_directories("../external/nanogui/ext/nanovg/src") list(APPEND SHARED_LIBRARIES "nanogui" "glfw" ${OPENGL_LIBRARIES}) +# include comiso if available + +find_package(LIBCOMISOH QUIET) +#Compile CoMISo (if found) +# NOTE: this cmakefile works only with the +# comiso available here: https://github.com/libigl/CoMISo +IF(LIBCOMISO_FOUND) + + add_definitions(-DPY_COMISO) + + include_directories("../../CoMISo/ext/gmm-4.2/include") + include_directories("../../") + add_subdirectory("../../CoMISo/" "CoMISo") + + list(APPEND SHARED_SOURCES "py_igl_comiso.cpp") + + if(APPLE) + find_library(accelerate_library Accelerate) + list(APPEND SHARED_LIBRARIES "CoMISo" ${accelerate_library}) + else(APPLE) #APPLE + list(APPEND SHARED_LIBRARIES "CoMISo") + endif(APPLE) + +ENDIF(LIBCOMISO_FOUND) add_library(igl SHARED python.cpp diff --git a/python/py_igl.cpp b/python/py_igl.cpp index 60a6d9241..d02db00bb 100644 --- a/python/py_igl.cpp +++ b/python/py_igl.cpp @@ -40,6 +40,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include + void python_export_igl(py::module &m) { @@ -81,4 +89,12 @@ void python_export_igl(py::module &m) #include "py_igl/py_map_vertices_to_circle.cpp" #include "py_igl/py_lscm.cpp" #include "py_igl/py_local_basis.cpp" +#include "py_igl/py_rotate_vectors.cpp" +#include "py_igl/py_compute_frame_field_bisectors.cpp" +#include "py_igl/py_comb_cross_field.cpp" +#include "py_igl/py_cross_field_missmatch.cpp" +#include "py_igl/py_find_cross_field_singularities.cpp" +#include "py_igl/py_cut_mesh_from_singularities.cpp" +#include "py_igl/py_comb_frame_field.cpp" + } diff --git a/python/py_igl/comiso/py_nrosy.cpp b/python/py_igl/comiso/py_nrosy.cpp index 60a0db8aa..4a717f02d 100644 --- a/python/py_igl/comiso/py_nrosy.cpp +++ b/python/py_igl/comiso/py_nrosy.cpp @@ -16,9 +16,23 @@ m.def("nrosy", [] assert_is_VectorX("b",b); assert_is_VectorX("b_soft",b_soft); assert_is_VectorX("w_soft",w_soft); + + Eigen::VectorXi bt; + if (b.size() != 0) + bt = b; + + Eigen::VectorXi b_softt; + if (b_soft.size() != 0) + b_softt = b_soft; + + Eigen::VectorXd w_softt; + if (w_soft.size() != 0) + w_softt = w_soft; + Eigen::VectorXd St; - igl::comiso::nrosy(V,F,b,bc,b_soft,w_soft,bc_soft,N,soft,R,St); + igl::comiso::nrosy(V,F,bt,bc,b_softt,w_softt,bc_soft,N,soft,R,St); S = St; + }, __doc_igl_comiso_nrosy, py::arg("V"), py::arg("F"), py::arg("b"), py::arg("bc"), py::arg("b_soft"), py::arg("w_soft"), py::arg("bc_soft"), py::arg("N"), py::arg("soft"), py::arg("R"), py::arg("S")); @@ -34,8 +48,13 @@ m.def("nrosy", [] ) { assert_is_VectorX("b",b); + + Eigen::VectorXi bt; + if (b.size() != 0) + bt = b; + Eigen::VectorXd St; - igl::comiso::nrosy(V,F,b,bc,N,R,St); + igl::comiso::nrosy(V,F,bt,bc,N,R,St); S = St; }, __doc_igl_comiso_nrosy, py::arg("V"), py::arg("F"), py::arg("b"), py::arg("bc"), py::arg("N"), py::arg("R"), py::arg("S")); diff --git a/python/py_igl_comiso.cpp b/python/py_igl_comiso.cpp new file mode 100644 index 000000000..f8a25d834 --- /dev/null +++ b/python/py_igl_comiso.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + + +#include "python.h" + +#include +#include + +void python_export_igl_comiso(py::module &me) { + + py::module m = me.def_submodule( + "comiso", "Wrappers for libigl functions that use comiso"); + + #include "py_igl/comiso/py_nrosy.cpp" + #include "py_igl/comiso/py_miq.cpp" + +} diff --git a/python/python.cpp b/python/python.cpp index 2141ec027..f81fa6c34 100644 --- a/python/python.cpp +++ b/python/python.cpp @@ -7,6 +7,10 @@ extern void python_export_vector(py::module &); extern void python_export_igl(py::module &); extern void python_export_igl_viewer(py::module &); +#ifdef PY_COMISO +extern void python_export_igl_comiso(py::module &); +#endif + PYTHON_PLUGIN(igl) { py::init_threading(); py::module m("igl", "Python wrappers for libigl"); @@ -15,5 +19,9 @@ PYTHON_PLUGIN(igl) { python_export_igl(m); python_export_igl_viewer(m); + #ifdef PY_COMISO + python_export_igl_comiso(m); + #endif + return m.ptr(); }