From ea6dd18b5c4711c4685b5266a9e21f121547e7ba Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Mon, 28 Oct 2024 13:28:40 -0400 Subject: [PATCH 01/15] bump libigl and update decimates --- cmake/PyiglDependencies.cmake | 2 +- src/decimate.cpp | 4 +++- src/qslim.cpp | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/PyiglDependencies.cmake b/cmake/PyiglDependencies.cmake index b43e93cb..8229ac05 100644 --- a/cmake/PyiglDependencies.cmake +++ b/cmake/PyiglDependencies.cmake @@ -19,7 +19,7 @@ include(FetchContent) FetchContent_Declare( libigl GIT_REPOSITORY https://github.com/libigl/libigl.git - GIT_TAG v2.5.0 + GIT_TAG f962e4a6b68afe978dc12a63702b7846a3e7a6ed ) FetchContent_GetProperties(libigl) FetchContent_MakeAvailable(libigl) diff --git a/src/decimate.cpp b/src/decimate.cpp index 07b967bb..c957c045 100644 --- a/src/decimate.cpp +++ b/src/decimate.cpp @@ -29,6 +29,7 @@ Parameters V #V by dim list of vertex positions F #F by 3 list of face indices into V. max_m desired number of output faces +block_intersections whether to block intersections Returns ------- @@ -57,6 +58,7 @@ npe_doc(ds_decimate) npe_arg(v, dense_float, dense_double) npe_arg(f, dense_int32, dense_int64) npe_arg(max_m, size_t) +npe_arg(block_intersections, bool) npe_begin_code() @@ -69,7 +71,7 @@ npe_begin_code() Eigen::MatrixXi g; Eigen::VectorXi j; Eigen::VectorXi i; - bool reach = igl::decimate(v_copy, f_copy, max_m, u, g, j, i); + bool reach = igl::decimate(v_copy, f_copy, max_m, block_intersections, u, g, j, i); EigenDenseFloat u_row_major = u; EigenDenseInt g_row_major = g.template cast(); // FIXME: vector not allowing row major, but they should be essentially the same so i feel we can leave it as col major diff --git a/src/qslim.cpp b/src/qslim.cpp index 1ad29e04..b684e0c0 100644 --- a/src/qslim.cpp +++ b/src/qslim.cpp @@ -30,6 +30,7 @@ Parameters V #V by dim list of vertex positions. Assumes that vertices w F #F by 3 list of triangle indices into V max_m desired number of output faces +block_intersections whether to block intersections Returns @@ -60,6 +61,7 @@ npe_doc(ds_qslim) npe_arg(v, dense_float, dense_double) npe_arg(f, dense_int32, dense_int64) npe_arg(max_m, size_t) +npe_arg(block_intersections, bool) npe_begin_code() @@ -72,7 +74,7 @@ npe_begin_code() Eigen::MatrixXi g; Eigen::VectorXi j; Eigen::VectorXi i; - bool success = igl::qslim(v_copy, f_copy, max_m, u, g, j, i); + bool success = igl::qslim(v_copy, f_copy, max_m, block_intersections, u, g, j, i); EigenDenseFloat u_row_major = u; EigenDenseInt g_row_major = g.template cast(); // FIXME: vector not allowing row major, but they should be essentially the same so i feel we can leave it as col major From 6a21fbfffb9da6c5b48d70427dbb15dc5aa03635 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Mon, 28 Oct 2024 14:01:59 -0400 Subject: [PATCH 02/15] fix test --- tests/test_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 226cdd2a..9d17d1ec 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -705,7 +705,7 @@ def test_cylinder(self): self.assertTrue(f.flags.c_contiguous) def test_decimate(self): - success, u, g, j, i = igl.decimate(self.v1, self.f1, 100) + success, u, g, j, i = igl.decimate(self.v1, self.f1, 100, False) self.assertEqual(u.shape[1], self.v1.shape[1]) self.assertEqual(g.shape[1], 3) self.assertEqual(j.shape[0], g.shape[0]) @@ -823,7 +823,7 @@ def test_procrustes(self): self.assertTrue(r.dtype == t.dtype == self.v1.dtype) def test_qslim(self): - success, u, g, j, i = igl.qslim(self.v1, self.f1, 100) + success, u, g, j, i = igl.qslim(self.v1, self.f1, 100, False) self.assertEqual(u.dtype, self.v1.dtype) self.assertTrue(g.dtype == j.dtype == i.dtype == self.f1.dtype) self.assertEqual(u.shape[1], self.v1.shape[1]) From bbf350c4a2eac31223f779e2e79bdd6d449c0596 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 15:17:46 -0400 Subject: [PATCH 03/15] fault handler --- tests/test_basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_basic.py b/tests/test_basic.py index 9d17d1ec..f9cf02be 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -13,6 +13,8 @@ import math import sys from git import Repo +import faulthandler +faulthandler.enable() From 0e48975d3b922cf50aecb42d638319cee40d5175 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 15:18:05 -0400 Subject: [PATCH 04/15] rewrite to use pybind types and maps --- classes/AABB.cpp | 115 +++++++++++++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 38 deletions(-) diff --git a/classes/AABB.cpp b/classes/AABB.cpp index 29cff578..881b8b7a 100644 --- a/classes/AABB.cpp +++ b/classes/AABB.cpp @@ -4,58 +4,97 @@ #include #include #include +#include namespace py = pybind11; + +template +void check_c_contiguity(py::array_t V, const std::string name = "arg") +{ + auto V_buf = V.request(); + if (V_buf.ndim != 2 || V_buf.strides[1] != sizeof(T)) { + throw std::runtime_error(name+" must be C-contiguous with a 2D shape."); + } +}; + template void init_AABB(py::module_ &m) { - using AABB_f64_DIM = igl::AABB; + using MatrixXdRowMajor = Eigen::Matrix; + using MatrixXiRowMajor = Eigen::Matrix; + using MapMatrixXdRowMajor = Eigen::Map; + using MapMatrixXiRowMajor = Eigen::Map; + using DerivedV = MapMatrixXdRowMajor; + using AABB_f64_DIM = igl::AABB; py::class_(m, (std::string("AABB_f64_")+std::to_string(DIM)).c_str() ) .def(py::init([]() { std::unique_ptr self = std::make_unique(); return self; })) - .def("init",[](AABB_f64_DIM & self, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F) - { - self.init(V,F); - }, - py::arg("V"), py::arg("F")) - .def("squared_distance",[]( - AABB_f64_DIM & self, - const Eigen::MatrixXd & V, - const Eigen::MatrixXi & F, - const Eigen::MatrixXd & P, - const bool return_index = false, - const bool return_closest_point = false) -> - std::variant > + .def("init", [](AABB_f64_DIM &self, py::array_t V, py::array_t F) { - Eigen::VectorXd sqrD; - Eigen::VectorXi I; - Eigen::MatrixXd C; - self.squared_distance(V,F,P,sqrD,I,C); - if(return_index && return_closest_point) - { - return std::list({npe::move(sqrD),npe::move(I),npe::move(C)}); - }else if(return_index) - { - return std::list({npe::move(sqrD),npe::move(I)}); - }else if(return_closest_point) - { - return std::list({npe::move(sqrD),npe::move(C)}); - }else - { - return npe::move(sqrD); + auto V_buf = V.request(); + auto F_buf = F.request(); + + if (V_buf.ndim != 2 || F_buf.ndim != 2) { + throw std::runtime_error("Input matrices must be 2-dimensional."); } - }, - py::arg("V"), - py::arg("F"), - py::arg("P"), - py::arg("return_index")=false, - py::arg("return_closest_point")=false - ) - ; + + check_c_contiguity(V,"V"); + check_c_contiguity(F,"F"); + + MapMatrixXdRowMajor V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); + MapMatrixXiRowMajor F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); + + self.init(V_eigen, F_eigen); + }, py::arg("V"), py::arg("F")) + .def("squared_distance",[]( + AABB_f64_DIM & self, + py::array_t V, + py::array_t F, + py::array_t P, + const bool return_index = false, + const bool return_closest_point = false) -> + std::variant > + { + check_c_contiguity(V,"V"); + check_c_contiguity(F,"F"); + check_c_contiguity(P,"P"); + + auto V_buf = V.request(); + auto F_buf = F.request(); + auto P_buf = P.request(); + MapMatrixXdRowMajor V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); + MapMatrixXiRowMajor F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); + MapMatrixXdRowMajor P_eigen(static_cast(P_buf.ptr), P_buf.shape[0], P_buf.shape[1]); + + Eigen::VectorXd sqrD; + Eigen::VectorXi I; + MatrixXdRowMajor C; + self.squared_distance(V_eigen,F_eigen,P_eigen,sqrD,I,C); + if(return_index && return_closest_point) + { + return std::list({npe::move(sqrD),npe::move(I),npe::move(C)}); + }else if(return_index) + { + return std::list({npe::move(sqrD),npe::move(I)}); + }else if(return_closest_point) + { + return std::list({npe::move(sqrD),npe::move(C)}); + }else + { + return npe::move(sqrD); + } + }, + py::arg("V"), + py::arg("F"), + py::arg("P"), + py::arg("return_index")=false, + py::arg("return_closest_point")=false + ) + ; } template void init_AABB<2>(py::module_ &); From da9a273a60fc61729e465e9b3a800aa27f219fa5 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 17:26:41 -0400 Subject: [PATCH 05/15] constraints --- .github/workflows/wheels.yml | 4 ++-- constraints.txt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 constraints.txt diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ce9a2a36..5c93f655 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -37,7 +37,7 @@ jobs: CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py" CIBW_BUILD: "${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }}" CIBW_TEST_SKIP: "*-macosx_arm64" - CIBW_ENVIRONMENT: "MAX_JOBS=${{ matrix.os.runs-on == 'macos-latest' && 3 || 2 }}" + CIBW_ENVIRONMENT: "MAX_JOBS=${{ matrix.os.runs-on == 'macos-latest' && 3 || 2 }} PIP_CONSTRAINT=constraints.txt" # Why universal2 here? It's not included above in CIBW_BUILD CIBW_ARCHS_MACOS: "x86_64 arm64 universal2" CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.13 CMAKE_OSX_ARCHITECTURES=\"${{ matrix.os.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.os.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.os.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}\"" @@ -90,7 +90,7 @@ jobs: - name: Build wheels run: | - python -m cibuildwheel --output-dir wheelhouse + CIBW_ENVIRONMENT="PIP_CONSTRAINT=constraints.txt" python -m cibuildwheel --output-dir wheelhouse # Upload binaries to github - uses: actions/upload-artifact@v4 diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..e55abda1 --- /dev/null +++ b/constraints.txt @@ -0,0 +1,2 @@ +numpy<=1.26.4 + From 02fe3938bb8833dcbf64e24cb3c82bb6e3cae343 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 21:35:26 -0400 Subject: [PATCH 06/15] fix windows --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5c93f655..f0079548 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,7 +90,7 @@ jobs: - name: Build wheels run: | - CIBW_ENVIRONMENT="PIP_CONSTRAINT=constraints.txt" python -m cibuildwheel --output-dir wheelhouse + set "PIP_CONSTRAINT=constraints.txt" && python -m cibuildwheel --output-dir wheelhouse # Upload binaries to github - uses: actions/upload-artifact@v4 From e60a442b20a3dcec3ab6cd1f89638737836f97c0 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 23:42:15 -0400 Subject: [PATCH 07/15] try again --- .github/workflows/wheels.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f0079548..5cde90b3 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,7 +90,11 @@ jobs: - name: Build wheels run: | - set "PIP_CONSTRAINT=constraints.txt" && python -m cibuildwheel --output-dir wheelhouse + if [ "$RUNNER_OS" = "Windows" ]; then \ + set "PIP_CONSTRAINT=constraints.txt" && python -m cibuildwheel --output-dir wheelhouse; \ + else \ + PIP_CONSTRAINT=constraints.txt python -m cibuildwheel --output-dir wheelhouse; \ + fi # Upload binaries to github - uses: actions/upload-artifact@v4 From b4f117a42bdee31e1882942b8a27d7b076bf9894 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 23:44:25 -0400 Subject: [PATCH 08/15] this is excruciating --- .github/workflows/wheels.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5cde90b3..596fc48e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,10 +90,10 @@ jobs: - name: Build wheels run: | - if [ "$RUNNER_OS" = "Windows" ]; then \ - set "PIP_CONSTRAINT=constraints.txt" && python -m cibuildwheel --output-dir wheelhouse; \ - else \ - PIP_CONSTRAINT=constraints.txt python -m cibuildwheel --output-dir wheelhouse; \ + if [[ "$RUNNER_OS" == "Windows" ]]; then + set PIP_CONSTRAINT=constraints.txt && python -m cibuildwheel --output-dir wheelhouse + else + PIP_CONSTRAINT=constraints.txt python -m cibuildwheel --output-dir wheelhouse fi # Upload binaries to github From 18619dd1695e86283c85b2296ecf0c908f56c9ee Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 23:46:27 -0400 Subject: [PATCH 09/15] this continues to be excruciating --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 596fc48e..3ac9b948 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,9 +91,9 @@ jobs: - name: Build wheels run: | if [[ "$RUNNER_OS" == "Windows" ]]; then - set PIP_CONSTRAINT=constraints.txt && python -m cibuildwheel --output-dir wheelhouse + set PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt && python -m cibuildwheel --output-dir wheelhouse else - PIP_CONSTRAINT=constraints.txt python -m cibuildwheel --output-dir wheelhouse + PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt python -m cibuildwheel --output-dir wheelhouse fi # Upload binaries to github From b336de407e22b7ce6644686dbb4821b6a47299db Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 23:55:26 -0400 Subject: [PATCH 10/15] also bashing my head on the wall --- .github/workflows/wheels.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3ac9b948..1027b847 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -89,12 +89,9 @@ jobs: python -m pip install cibuildwheel - name: Build wheels + shell: bash run: | - if [[ "$RUNNER_OS" == "Windows" ]]; then - set PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt && python -m cibuildwheel --output-dir wheelhouse - else - PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt python -m cibuildwheel --output-dir wheelhouse - fi + CIBW_BEFORE_ALL="pip install numpy<=1.26.4" python -m cibuildwheel --output-dir wheelhouse # Upload binaries to github - uses: actions/upload-artifact@v4 From 3dcbcbc3fbf9bb064ecdfce6fe4af091a685d42f Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Tue, 29 Oct 2024 23:57:21 -0400 Subject: [PATCH 11/15] 1 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1027b847..ea6e16bd 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -91,7 +91,7 @@ jobs: - name: Build wheels shell: bash run: | - CIBW_BEFORE_ALL="pip install numpy<=1.26.4" python -m cibuildwheel --output-dir wheelhouse + PIP_CONSTRAINT=$GITHUB_WORKSPACE/constraints.txt python -m cibuildwheel --output-dir wheelhouse # Upload binaries to github - uses: actions/upload-artifact@v4 From 0e2748d4b5a58408dfa2567e6232f26f05f04663 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Wed, 30 Oct 2024 09:28:53 -0400 Subject: [PATCH 12/15] fix aabb template nonsense --- classes/AABB.cpp | 39 +++++++++++++++++++++++++-------------- src/in_element.cpp | 10 ++++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/classes/AABB.cpp b/classes/AABB.cpp index 881b8b7a..59fc7ea4 100644 --- a/classes/AABB.cpp +++ b/classes/AABB.cpp @@ -17,15 +17,26 @@ void check_c_contiguity(py::array_t V, const std::string name = "arg") throw std::runtime_error(name+" must be C-contiguous with a 2D shape."); } }; +template +void check_f_contiguity(py::array_t V, const std::string name = "arg") +{ + auto V_buf = V.request(); + if (V_buf.ndim != 2 || V_buf.strides[1] == sizeof(T)) { + throw std::runtime_error(name+" must be F-contiguous (ColMajor) with a 2D shape."); + } +}; template void init_AABB(py::module_ &m) { + using namespace Eigen; using MatrixXdRowMajor = Eigen::Matrix; using MatrixXiRowMajor = Eigen::Matrix; - using MapMatrixXdRowMajor = Eigen::Map; - using MapMatrixXiRowMajor = Eigen::Map; - using DerivedV = MapMatrixXdRowMajor; + using MapMatrixXdRowMajor = Eigen::Map; + using MapMatrixXiRowMajor = Eigen::Map; + using MapMatrixXd = Eigen::Map; + using MapMatrixXi = Eigen::Map; + using DerivedV = MapMatrixXd; using AABB_f64_DIM = igl::AABB; py::class_(m, (std::string("AABB_f64_")+std::to_string(DIM)).c_str() ) .def(py::init([]() @@ -42,11 +53,11 @@ void init_AABB(py::module_ &m) throw std::runtime_error("Input matrices must be 2-dimensional."); } - check_c_contiguity(V,"V"); - check_c_contiguity(F,"F"); + check_f_contiguity(V,"V"); + check_f_contiguity(F,"F"); - MapMatrixXdRowMajor V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); - MapMatrixXiRowMajor F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); + MapMatrixXd V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); + MapMatrixXi F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); self.init(V_eigen, F_eigen); }, py::arg("V"), py::arg("F")) @@ -59,20 +70,20 @@ void init_AABB(py::module_ &m) const bool return_closest_point = false) -> std::variant > { - check_c_contiguity(V,"V"); - check_c_contiguity(F,"F"); - check_c_contiguity(P,"P"); + check_f_contiguity(V,"V"); + check_f_contiguity(F,"F"); + check_f_contiguity(P,"P"); auto V_buf = V.request(); auto F_buf = F.request(); auto P_buf = P.request(); - MapMatrixXdRowMajor V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); - MapMatrixXiRowMajor F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); - MapMatrixXdRowMajor P_eigen(static_cast(P_buf.ptr), P_buf.shape[0], P_buf.shape[1]); + MapMatrixXd V_eigen(static_cast(V_buf.ptr), V_buf.shape[0], V_buf.shape[1]); + MapMatrixXi F_eigen(static_cast(F_buf.ptr), F_buf.shape[0], F_buf.shape[1]); + MapMatrixXd P_eigen(static_cast(P_buf.ptr), P_buf.shape[0], P_buf.shape[1]); Eigen::VectorXd sqrD; Eigen::VectorXi I; - MatrixXdRowMajor C; + MatrixXd C; self.squared_distance(V_eigen,F_eigen,P_eigen,sqrD,I,C); if(return_index && return_closest_point) { diff --git a/src/in_element.cpp b/src/in_element.cpp index 78a79f80..71dfd96a 100644 --- a/src/in_element.cpp +++ b/src/in_element.cpp @@ -11,7 +11,8 @@ #include #include -using AABB_f64_3 = igl::AABB; +using AABB_f64_3 = igl::AABB,3>; +using AABB_f64_2 = igl::AABB,2>; const char* ds_in_element = R"igl_Qu8mg5v7( Determine whether each point in a list of points is in the elements of a mesh. @@ -36,13 +37,13 @@ npe_arg(aabb, AABB_f64_3) npe_begin_code() Eigen::VectorXi I; - igl::in_element(V,Ele,Q,aabb,I); + Eigen::Map V_map(V.data(),V.rows(),V.cols()); + igl::in_element(V_map,Ele,Q,aabb,I); return npe::move(I); npe_end_code() -using AABB_f64_2 = igl::AABB; npe_function(in_element_2) npe_doc( ds_in_element) npe_arg(V, Eigen::MatrixXd) @@ -52,7 +53,8 @@ npe_arg(aabb, AABB_f64_2) npe_begin_code() Eigen::VectorXi I; - igl::in_element(V,Ele,Q,aabb,I); + Eigen::Map V_map(V.data(),V.rows(),V.cols()); + igl::in_element(V_map,Ele,Q,aabb,I); return npe::move(I); npe_end_code() From 6c2b55c3f0115f1d8727e0a6ff1ab2df5ff618de Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Wed, 30 Oct 2024 09:35:04 -0400 Subject: [PATCH 13/15] fix continguity in tests --- tests/test_basic.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index f9cf02be..e15d45ac 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -2486,20 +2486,22 @@ def test_flip_edge(self): def test_AABB(self): tree = igl.AABB_f64_3() - tree.init(self.v1,self.f1) - bc = igl.barycenter(self.v1,self.f1) - sqrD = tree.squared_distance(self.v1,self.f1,bc) + v1_f = np.asarray(self.v1, order='F') + f1_f = np.asarray(self.f1, order='F') + tree.init(v1_f,f1_f) + bc = igl.barycenter(v1_f,f1_f) + sqrD = tree.squared_distance(v1_f,f1_f,bc) self.assertTrue(sqrD.shape[0] == bc.shape[0]) self.assertTrue(np.max(sqrD) <= 1e-16) - sqrD,I,C = tree.squared_distance(self.v1,self.f1,bc,return_index=True,return_closest_point=True) + sqrD,I,C = tree.squared_distance(v1_f,f1_f,bc,return_index=True,return_closest_point=True) self.assertTrue(sqrD.shape[0] == bc.shape[0]) self.assertTrue(I.shape[0] == bc.shape[0]) self.assertTrue(C.shape == bc.shape) def test_in_element_3(self): - V = np.array([ [0.,0,0], [1,0,0], [0,1,0], [0,0,1], [1,1,1]],dtype='float64') - T = np.array([[0,1,2,3],[4,3,2,1]],dtype='int32') - Q = np.array([[0.1,0.1,0.1],[0.9,0.9,0.9]],dtype='float64') + V = np.array([ [0.,0,0], [1,0,0], [0,1,0], [0,0,1], [1,1,1]],dtype='float64',order='f') + T = np.array([[0,1,2,3],[4,3,2,1]],dtype='int32',order='f') + Q = np.array([[0.1,0.1,0.1],[0.9,0.9,0.9]],dtype='float64',order='f') tree = igl.AABB_f64_3() tree.init(V,T) I = igl.in_element_3(V,T,Q,tree) @@ -2508,9 +2510,9 @@ def test_in_element_3(self): self.assertTrue(I[1] == 1) def test_in_element_2(self): - V = np.array([ [0.,0], [1,0], [0,1], [1,1]],dtype='float64') - F = np.array([[0,1,2],[2,1,3]],'int32') - Q = np.array([[0.1,0.1],[0.9,0.9]],dtype='float64') + V = np.array([ [0.,0], [1,0], [0,1], [1,1]],dtype='float64',order='f') + F = np.array([[0,1,2],[2,1,3]],'int32',order='f') + Q = np.array([[0.1,0.1],[0.9,0.9]],dtype='float64',order='f') tree = igl.AABB_f64_2() tree.init(V,F) I = igl.in_element_2(V,F,Q,tree) @@ -2518,7 +2520,6 @@ def test_in_element_2(self): self.assertTrue(I[0] == 0) self.assertTrue(I[1] == 1) - def test_triangulate(self): V = np.array([[0,0],[1,0],[1,1],[0,1]],dtype='float64') E = np.array([[0,1],[1,2],[2,3],[3,0]]) From 90a8801049f5f547b26acd15e65934f5d4f6db80 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Wed, 30 Oct 2024 09:44:30 -0400 Subject: [PATCH 14/15] fix warning --- tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index e15d45ac..b8f3cb2f 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -2432,7 +2432,7 @@ def test_fast_winding_number_for_meshes(self): def test_flip_avoiding_line_search(self): def fun(v): - return np.random.rand(1) + return np.random.rand(1)[0] energy, vr = igl.flip_avoiding_line_search( self.f1, self.v1[:, :2], self.v1[:, :2], fun, 10.0) From d14044bd90ff3cc8579740b271ca119dad3c2317 Mon Sep 17 00:00:00 2001 From: Alec Jacobson Date: Wed, 30 Oct 2024 09:45:10 -0400 Subject: [PATCH 15/15] version --- igl/_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/igl/_version.py b/igl/_version.py index 79b56048..887b40df 100644 --- a/igl/_version.py +++ b/igl/_version.py @@ -1,8 +1,8 @@ # This file is part of libigl, a simple c++ geometry processing library. # -# Copyright (C) 2023 Alec Jacobson +# Copyright (C) 2024 Alec Jacobson # # This Source Code Form is subject to the terms of the Mozilla Public License # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -__version__ = "2.5.1" +__version__ = "2.5.4dev"