Bladeren bron

Merge pull request #1140 from amrollah/heat_geodesics_python

exposed heat_geodesics in python binding
Jérémie Dumas 6 jaren geleden
bovenliggende
commit
be2e69a35c
4 gewijzigde bestanden met toevoegingen van 69 en 0 verwijderingen
  1. 20 0
      python/py_doc.cpp
  2. 2 0
      python/py_doc.h
  3. 2 0
      python/py_igl.cpp
  4. 45 0
      python/py_igl/py_heat_geodesics.cpp

+ 20 - 0
python/py_doc.cpp

@@ -615,6 +615,26 @@ const char *__doc_igl_exact_geodesic = R"igl_Qu8mg5v7(
     // Note:  
     //      Specifying a face as target/source means its center.  
     //)igl_Qu8mg5v7";
+const char *__doc_igl_heat_geodesics_precompute = R"igl_Qu8mg5v7(
+    // Precompute factorized solvers for computing a fast approximation of
+    // geodesic distances on a mesh (V,F). [Crane et al. 2013]
+    //
+    // Inputs:
+    //   V  #V by dim list of mesh vertex positions
+    //   F  #F by 3 list of mesh face indices into V
+    // Outputs:
+    //   data  precomputation data (see heat_geodesics_solve)
+    //)igl_Qu8mg5v7";
+const char *__doc_igl_heat_geodesics_solve = R"igl_Qu8mg5v7(
+    // Compute fast approximate geodesic distances using precomputed data from a
+    // set of selected source vertices (gamma)
+    //
+    // Inputs:
+    //   data  precomputation data (see heat_geodesics_precompute)
+    //   gamma  #gamma list of indices into V of source vertices
+    // Outputs:
+    //   D  #V list of distances to gamma
+    //)igl_Qu8mg5v7";
 const char *__doc_igl_find_cross_field_singularities = R"igl_Qu8mg5v7(// Inputs:
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F                #F by 3 eigen Matrix of face (quad) indices

+ 2 - 0
python/py_doc.h

@@ -49,6 +49,8 @@ extern const char *__doc_igl_embree_ambient_occlusion;
 extern const char *__doc_igl_embree_line_mesh_intersection;
 extern const char *__doc_igl_embree_reorient_facets_raycast;
 extern const char *__doc_igl_exact_geodesic;
+extern const char *__doc_igl_heat_geodesics_precompute;
+extern const char *__doc_igl_heat_geodesics_solve;
 extern const char *__doc_igl_find_cross_field_singularities;
 extern const char *__doc_igl_fit_rotations;
 extern const char *__doc_igl_fit_rotations_planar;

+ 2 - 0
python/py_igl.cpp

@@ -46,6 +46,7 @@
 #include <igl/edge_topology.h>
 #include <igl/eigs.h>
 #include <igl/exact_geodesic.h>
+#include <igl/heat_geodesics.h>
 #include <igl/find_cross_field_singularities.h>
 #include <igl/fit_rotations.h>
 #include <igl/floor.h>
@@ -145,6 +146,7 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_edge_topology.cpp"
 #include "py_igl/py_eigs.cpp"
 #include "py_igl/py_exact_geodesic.cpp"
+#include "py_igl/py_heat_geodesics.cpp"
 #include "py_igl/py_find_cross_field_singularities.cpp"
 #include "py_igl/py_fit_rotations.cpp"
 #include "py_igl/py_floor.cpp"

+ 45 - 0
python/py_igl/py_heat_geodesics.cpp

@@ -0,0 +1,45 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2018 Amrollah Seifoddini <a.seif67@gmail.com>
+//
+// 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/.
+
+// Wrap the data class, no properties are exposed since it is not necessary
+py::class_<igl::HeatGeodesicsData<double> > heat_geodesics_data(m, "heat_geodesics_data");
+
+heat_geodesics_data.def(py::init<>());
+
+m.def("heat_geodesics_precompute", []
+(
+    const Eigen::MatrixXd &V,
+    const Eigen::MatrixXi &F,
+    igl::HeatGeodesicsData<double> &data
+)
+{
+  return igl::heat_geodesics_precompute(V, F, data);
+}, __doc_igl_heat_geodesics_precompute,
+py::arg("V"), py::arg("F"), py::arg("data"));
+
+
+m.def("heat_geodesics_solve", []
+(
+    const igl::HeatGeodesicsData<double> &data,
+    const Eigen::MatrixXi &gamma,
+    Eigen::MatrixXd &D
+)
+{
+assert_is_VectorX("D", D);
+assert_is_VectorX("gamma", gamma);
+Eigen::VectorXd vD;
+igl::heat_geodesics_solve(data, Eigen::VectorXi(gamma), vD);
+D.resize(vD.size(), 1);
+for (int i = 0; i < vD.size(); i++)
+{
+    D(i, 0) = vD[i];
+}
+return true;
+}, __doc_igl_heat_geodesics_solve,
+py::arg("data"), py::arg("gamma"), py::arg("D"));
+