direct_delta_mush.cpp 978 B

12345678910111213141516171819202122232425
  1. #include <test_common.h>
  2. #include <igl/direct_delta_mush.h>
  3. #include <igl/adjacency_list.h>
  4. #include <iostream>
  5. TEST_CASE("direct_delta_mush: cube", "[igl]")
  6. {
  7. Eigen::MatrixXd V, W, U, Omega;
  8. Eigen::MatrixXi F;
  9. // Test that direct delta mush with identity transform reproduces the rest state of the mesh.
  10. // For simplicity, testing on a cube of dimensions 1.0 x 1.0 x 1.0,
  11. // with all vertices bound strictly to one and only one imaginary bone (weight is a column of 1s)
  12. igl::read_triangle_mesh(test_common::data_path("cube.off"), V, F);
  13. W = Eigen::MatrixXd::Ones(V.rows(), 1);
  14. // Parameters such as p, lambda, kappa, alpha do not matter given identity transform
  15. igl::direct_delta_mush_precomputation(V, F, W, 1, 1., 0.5, 0.5, Omega);
  16. std::vector<Eigen::Affine3d, Eigen::aligned_allocator<Eigen::Affine3d>> T_list;
  17. T_list.push_back(Eigen::Affine3d::Identity());
  18. igl::direct_delta_mush(V, T_list, Omega, U);
  19. test_common::assert_near(U, V, 1e-4);
  20. }