Browse Source

python bindings for signed_distance with fast_winding_number

Thomas Davies 6 years ago
parent
commit
e2548f971c

+ 2 - 1
include/igl/fast_winding_number.cpp

@@ -438,4 +438,5 @@ template void igl::fast_winding_number<Eigen::CwiseUnaryOp<Eigen::internal::scal
 template Eigen::Matrix<float, 1, 3, 1, 1, 3>::Scalar igl::fast_winding_number<Eigen::Matrix<float, 1, 3, 1, 1, 3> >(igl::FastWindingNumberBVH const&, float, Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&);
 template Eigen::Matrix<float, 1, 3, 1, 1, 3>::Scalar igl::fast_winding_number<Eigen::Matrix<float, 1, 3, 1, 1, 3> >(igl::FastWindingNumberBVH const&, float, Eigen::MatrixBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&);
 template void igl::fast_winding_number<Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, int, igl::FastWindingNumberBVH&);
 template void igl::fast_winding_number<Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, int, igl::FastWindingNumberBVH&);
 template void igl::fast_winding_number<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, int, igl::FastWindingNumberBVH&);
 template void igl::fast_winding_number<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, int, igl::FastWindingNumberBVH&);
-#endif
+template void igl::fast_winding_number<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, igl::FastWindingNumberBVH&);
+#endif

+ 3 - 1
python/py_igl.cpp

@@ -47,6 +47,7 @@
 #include <igl/eigs.h>
 #include <igl/eigs.h>
 #include <igl/exact_geodesic.h>
 #include <igl/exact_geodesic.h>
 #include <igl/heat_geodesics.h>
 #include <igl/heat_geodesics.h>
+#include <igl/fast_winding_number.h>
 #include <igl/find_cross_field_singularities.h>
 #include <igl/find_cross_field_singularities.h>
 #include <igl/fit_rotations.h>
 #include <igl/fit_rotations.h>
 #include <igl/floor.h>
 #include <igl/floor.h>
@@ -146,7 +147,7 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_edge_topology.cpp"
 #include "py_igl/py_edge_topology.cpp"
 #include "py_igl/py_eigs.cpp"
 #include "py_igl/py_eigs.cpp"
 #include "py_igl/py_exact_geodesic.cpp"
 #include "py_igl/py_exact_geodesic.cpp"
-#include "py_igl/py_heat_geodesics.cpp"
+#include "py_igl/py_fast_winding_number.cpp"
 #include "py_igl/py_find_cross_field_singularities.cpp"
 #include "py_igl/py_find_cross_field_singularities.cpp"
 #include "py_igl/py_fit_rotations.cpp"
 #include "py_igl/py_fit_rotations.cpp"
 #include "py_igl/py_floor.cpp"
 #include "py_igl/py_floor.cpp"
@@ -155,6 +156,7 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_get_seconds.cpp"
 #include "py_igl/py_get_seconds.cpp"
 #include "py_igl/py_grad.cpp"
 #include "py_igl/py_grad.cpp"
 #include "py_igl/py_harmonic.cpp"
 #include "py_igl/py_harmonic.cpp"
+#include "py_igl/py_heat_geodesics.cpp"
 #include "py_igl/py_hsv_to_rgb.cpp"
 #include "py_igl/py_hsv_to_rgb.cpp"
 #include "py_igl/py_internal_angles.cpp"
 #include "py_igl/py_internal_angles.cpp"
 #include "py_igl/py_invert_diag.cpp"
 #include "py_igl/py_invert_diag.cpp"

+ 24 - 0
python/py_igl/py_fast_winding_number.cpp

@@ -0,0 +1,24 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2019 Thomas Davies [email protected]
+//
+// 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/.
+
+py::class_<igl::FastWindingNumberBVH> FastWindingNumberBVH(m,"FastWindingNumberBVH");
+FastWindingNumberBVH.def(py::init<>());
+
+//we only expose precomputation of tree 
+// for fast_winding_number signing in signed distance
+m.def("fast_winding_number", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const int order,
+  igl::FastWindingNumberBVH & fwn_bvh
+)
+{
+  igl::fast_winding_number(V.cast<float>(), F, order, fwn_bvh);
+}, __doc_igl_signed_distance,
+py::arg("V"), py::arg("F"), py::arg("order"), py::arg("fwn_bvh"));

+ 16 - 0
python/py_igl/py_signed_distance.cpp

@@ -82,6 +82,22 @@ m.def("signed_distance_pseudonormal", []
 }, __doc_igl_signed_distance_pseudonormal,
 }, __doc_igl_signed_distance_pseudonormal,
 py::arg("P"), py::arg("V"), py::arg("F"), py::arg("tree"), py::arg("FN"), py::arg("VN"), py::arg("EN"), py::arg("EMAP"), py::arg("S"), py::arg("I"), py::arg("C"), py::arg("N"));
 py::arg("P"), py::arg("V"), py::arg("F"), py::arg("tree"), py::arg("FN"), py::arg("VN"), py::arg("EN"), py::arg("EMAP"), py::arg("S"), py::arg("I"), py::arg("C"), py::arg("N"));
 
 
+m.def("signed_distance_fast_winding_number", []
+(
+    const Eigen::MatrixXd& P,
+    const Eigen::MatrixXd& V,
+    const Eigen::MatrixXi & F,
+    const igl::AABB<Eigen::MatrixXd,3> & tree,
+    const igl::FastWindingNumberBVH & fwn_bvh,
+    Eigen::MatrixXd & S
+)
+{
+  Eigen::VectorXd Sv;
+  igl::signed_distance_fast_winding_number(P,V,F,tree,fwn_bvh,Sv);
+  S = Sv;
+}, __doc_igl_signed_distance_pseudonormal,
+py::arg("P"), py::arg("V"), py::arg("F"), py::arg("tree"), py::arg("fwn_bvh"), py::arg("S"));
+
 //m.def("signed_distance_pseudonormal", []
 //m.def("signed_distance_pseudonormal", []
 //(
 //(
 //  const AABB<Eigen::MatrixXd, 3> & tree,
 //  const AABB<Eigen::MatrixXd, 3> & tree,

+ 1 - 0
python/python_shared.cpp

@@ -103,6 +103,7 @@ PYBIND11_PLUGIN(pyigl) {
            find_cross_field_singularities
            find_cross_field_singularities
            fit_rotations
            fit_rotations
            floor
            floor
+           fast_winding_number
            forward_kinematics
            forward_kinematics
            gaussian_curvature
            gaussian_curvature
            get_seconds
            get_seconds