py_arap.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Sebastian Koch <s.koch@tu-berlin.de> and Daniele Panozzo <daniele.panozzo@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. py::class_<igl::ARAPData> ARAPData(m, "ARAPData");
  9. ARAPData
  10. .def(py::init<>())
  11. .def_readwrite("n", &igl::ARAPData::n)
  12. .def_readwrite("energy", &igl::ARAPData::energy)
  13. .def_property("G",
  14. [](const igl::ARAPData& data) {return Eigen::MatrixXi(data.G);},
  15. [](igl::ARAPData& data, const Eigen::MatrixXi& G)
  16. {
  17. assert_is_VectorX("G",G);
  18. data.G = Eigen::VectorXi(G.cast<int>());
  19. })
  20. .def_readwrite("with_dynamics", &igl::ARAPData::with_dynamics)
  21. .def_readwrite("f_ext", &igl::ARAPData::f_ext)
  22. .def_readwrite("h", &igl::ARAPData::h)
  23. .def_readwrite("vel", &igl::ARAPData::vel)
  24. .def_readwrite("ym", &igl::ARAPData::ym)
  25. .def_readwrite("max_iter", &igl::ARAPData::max_iter)
  26. .def_readwrite("K", &igl::ARAPData::K)
  27. .def_readwrite("M", &igl::ARAPData::M)
  28. .def_readwrite("CSM", &igl::ARAPData::CSM)
  29. // .def_readwrite("solver_data", &igl::ARAPData::solver_data)
  30. .def_readwrite("dim", &igl::ARAPData::dim)
  31. .def_property("b",
  32. [](const igl::ARAPData& data) {return Eigen::MatrixXi(data.b);},
  33. [](igl::ARAPData& data, const Eigen::MatrixXi& b)
  34. {
  35. assert_is_VectorX("b",b);
  36. data.b = Eigen::VectorXi(b.cast<int>());
  37. })
  38. ;
  39. m.def("arap_precomputation", []
  40. (
  41. const Eigen::MatrixXd & V,
  42. const Eigen::MatrixXi & F,
  43. const int dim,
  44. const Eigen::MatrixXi& b,
  45. igl::ARAPData & data
  46. )
  47. {
  48. assert_is_VectorX("b",b);
  49. Eigen::VectorXi bt;
  50. if (b.size() != 0)
  51. bt = b;
  52. return igl::arap_precomputation(V,F,dim,bt,data);
  53. }, __doc_igl_arap_precomputation,
  54. py::arg("V"), py::arg("F"), py::arg("dim"), py::arg("b"), py::arg("data"));
  55. m.def("arap_solve", []
  56. (
  57. const Eigen::MatrixXd & bc,
  58. igl::ARAPData & data,
  59. Eigen::MatrixXd& U
  60. )
  61. {
  62. return igl::arap_solve(bc,data,U);
  63. }, __doc_igl_arap_solve,
  64. py::arg("bc"), py::arg("data"), py::arg("U"));