heat_geodesics.cpp 703 B

123456789101112131415161718192021222324252627
  1. #include <test_common.h>
  2. #include <igl/heat_geodesics.h>
  3. #include <igl/upsample.h>
  4. #include <igl/avg_edge_length.h>
  5. TEST_CASE("heat_geodesic: upsampled cube", "[igl]")
  6. {
  7. Eigen::MatrixXd V;
  8. Eigen::MatrixXi F;
  9. igl::read_triangle_mesh(test_common::data_path("cube.obj"), V, F);
  10. igl::upsample(V,F,3);
  11. int vid = 0;
  12. igl::HeatGeodesicsData<double> data;
  13. igl::heat_geodesics_precompute(V,F,data);
  14. Eigen::VectorXd dist;
  15. igl::heat_geodesics_solve(data, (Eigen::VectorXi(1,1)<<vid).finished(), dist);
  16. double avg_edge = igl::avg_edge_length(V,F);
  17. // Check the adjacent corners
  18. for (int i=0; i<6; i++) {
  19. REQUIRE((V.row(i)-V.row(0)).norm() == Approx(dist(i)).margin(avg_edge));
  20. }
  21. }