py_unproject_onto_mesh.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // COMPLETE BINDINGS ========================
  9. m.def("unproject_onto_mesh", []
  10. (
  11. const Eigen::MatrixXd & pos,
  12. const Eigen::MatrixXd & model,
  13. const Eigen::MatrixXd & proj,
  14. const Eigen::MatrixXd & viewport,
  15. const Eigen::MatrixXd& V,
  16. const Eigen::MatrixXi& F,
  17. Eigen::MatrixXi& fid, // TODO: Can we replace this with integer object reference?
  18. Eigen::MatrixXd& bc
  19. )
  20. {
  21. assert_is_Vector2("pos", pos);
  22. Eigen::Vector2f posv;
  23. if (pos.size() != 0)
  24. posv = Eigen::Vector2f(pos.cast<float>());
  25. assert_is_Matrix4("model", model);
  26. Eigen::Matrix4f modelm;
  27. if (model.size() != 0)
  28. modelm = model.cast<float>();
  29. assert_is_Matrix4("proj", proj);
  30. Eigen::Matrix4f projm;
  31. if (proj.size() != 0)
  32. projm = proj.cast<float>();
  33. assert_is_Vector4("viewport", viewport);
  34. Eigen::Vector4f viewportv;
  35. if (viewport.size() != 0)
  36. viewportv = Eigen::Vector4f(viewport.cast<float>());
  37. Eigen::VectorXd bcv;
  38. int fidi;
  39. bool ret = igl::unproject_onto_mesh(posv, modelm, projm, viewportv, V, F, fidi, bcv);
  40. fid(0, 0) = fidi;
  41. bc = bcv;
  42. return ret;
  43. }, __doc_igl_unproject_onto_mesh,
  44. py::arg("pos"), py::arg("model"), py::arg("proj"), py::arg("viewport"), py::arg("V"), py::arg("F"), py::arg("fid"), py::arg("bc"));
  45. // INCOMPLETE BINDINGS ========================
  46. //m.def("unproject_onto_mesh", []
  47. //(
  48. // Eigen::Vector2f & pos,
  49. // Eigen::Matrix4f & model,
  50. // Eigen::Matrix4f & proj,
  51. // Eigen::Vector4f & viewport,
  52. // std::function<bool (const Eigen::Vector3f &, const Eigen::Vector3f &, igl::Hit &)> & shoot_ray,
  53. // int & fid,
  54. // Eigen::MatrixXd& bc
  55. //)
  56. //{
  57. // return igl::unproject_onto_mesh(pos, model, proj, viewport, shoot_ray, fid, bc);
  58. //}, __doc_igl_unproject_onto_mesh,
  59. //py::arg("pos"), py::arg("model"), py::arg("proj"), py::arg("viewport"), py::arg("shoot_ray"), py::arg("fid"), py::arg("bc"));