python.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "python.h"
  2. #include <sstream>
  3. #include <string>
  4. #include <fstream>
  5. void assert_is_VectorXd(const std::string name, const Eigen::MatrixXd& v)
  6. {
  7. if (v.cols() != 1)
  8. throw std::runtime_error(name + " must be a column vector.");
  9. }
  10. void assert_is_RowVectorXd(const std::string name, const Eigen::MatrixXd& v)
  11. {
  12. if (v.rows() != 1)
  13. throw std::runtime_error(name + " must be a row vector.");
  14. }
  15. void assert_is_Vector3d(const std::string name, const Eigen::MatrixXd& v)
  16. {
  17. if ((v.cols() != 1) || (v.rows() != 3))
  18. throw std::runtime_error(name + " must be a column vector with 3 entries.");
  19. }
  20. void assert_is_RowVector3d(const std::string name, const Eigen::MatrixXd& v)
  21. {
  22. if ((v.cols() != 3) || (v.rows() != 1))
  23. throw std::runtime_error(name + " must be a row vector with 3 entries.");
  24. }
  25. void assert_is_Vector4d(const std::string name, const Eigen::MatrixXd& v)
  26. {
  27. if ((v.cols() != 1) || (v.rows() != 4))
  28. throw std::runtime_error(name + " must be a column vector with 4 entries.");
  29. }
  30. void assert_is_RowVector4d(const std::string name, const Eigen::MatrixXd& v)
  31. {
  32. if ((v.cols() != 4) || (v.rows() != 1))
  33. throw std::runtime_error(name + " must be a row vector with 4 entries.");
  34. }
  35. void assert_is_Matrix4d(const std::string name, const Eigen::MatrixXd& v)
  36. {
  37. if ((v.cols() != 4) || (v.rows() != 4))
  38. throw std::runtime_error(name + " must be a 4x4 matrix.");
  39. }
  40. extern void python_export_vector(py::module &);
  41. extern void python_export_igl(py::module &);
  42. extern void python_export_igl_viewer(py::module &);
  43. PYTHON_PLUGIN(igl) {
  44. py::init_threading();
  45. py::module m("igl", "Python wrappers for libigl");
  46. python_export_vector(m);
  47. python_export_igl(m);
  48. python_export_igl_viewer(m);
  49. return m.ptr();
  50. }