py_heat_geodesics.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Amrollah Seifoddini <a.seif67@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. // Wrap the data class, no properties are exposed since it is not necessary
  9. py::class_<igl::HeatGeodesicsData<double> > heat_geodesics_data(m, "heat_geodesics_data");
  10. heat_geodesics_data.def(py::init<>());
  11. m.def("heat_geodesics_precompute", []
  12. (
  13. const Eigen::MatrixXd &V,
  14. const Eigen::MatrixXi &F,
  15. igl::HeatGeodesicsData<double> &data
  16. )
  17. {
  18. return igl::heat_geodesics_precompute(V, F, data);
  19. }, __doc_igl_heat_geodesics_precompute,
  20. py::arg("V"), py::arg("F"), py::arg("data"));
  21. m.def("heat_geodesics_solve", []
  22. (
  23. const igl::HeatGeodesicsData<double> &data,
  24. const Eigen::MatrixXi &gamma,
  25. Eigen::MatrixXd &D
  26. )
  27. {
  28. assert_is_VectorX("D", D);
  29. assert_is_VectorX("gamma", gamma);
  30. Eigen::VectorXd vD;
  31. igl::heat_geodesics_solve(data, Eigen::VectorXi(gamma), vD);
  32. D.resize(vD.size(), 1);
  33. for (int i = 0; i < vD.size(); i++)
  34. {
  35. D(i, 0) = vD[i];
  36. }
  37. return true;
  38. }, __doc_igl_heat_geodesics_solve,
  39. py::arg("data"), py::arg("gamma"), py::arg("D"));