ears.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <test_common.h>
  2. #include <igl/ears.h>
  3. #include <igl/triangulated_grid.h>
  4. #include <igl/is_boundary_edge.h>
  5. void test_F(const Eigen::MatrixXi & F)
  6. {
  7. Eigen::VectorXi ear,ear_opp;
  8. igl::ears(F,ear,ear_opp);
  9. Eigen::Array<bool,Eigen::Dynamic,1> B;
  10. Eigen::MatrixXi E;
  11. Eigen::VectorXi EMAP;
  12. igl::is_boundary_edge(F,B,E,EMAP);
  13. for(int e = 0;e<ear.size();e++)
  14. {
  15. int ue1 = EMAP(ear(e) + F.rows()*((ear_opp(e)+1)%3));
  16. int ue2 = EMAP(ear(e) + F.rows()*((ear_opp(e)+2)%3));
  17. REQUIRE(B(ue1));
  18. REQUIRE(B(ue2));
  19. }
  20. }
  21. TEST_CASE("ears: grid", "[igl]" )
  22. {
  23. Eigen::MatrixXi F;
  24. igl::triangulated_grid(3,3,F);
  25. test_F(F);
  26. }
  27. TEST_CASE("ears: two-boundary", "[igl]" )
  28. {
  29. const auto test_case = [](const std::string &param)
  30. {
  31. Eigen::MatrixXd V;
  32. Eigen::MatrixXi F;
  33. // Load example mesh: GetParam() will be name of mesh file
  34. igl::read_triangle_mesh(test_common::data_path(param), V, F);
  35. test_F(F);
  36. };
  37. test_common::run_test_cases(
  38. {
  39. "bunny.off",
  40. "elephant.off",
  41. "hemisphere.obj"
  42. }, test_case);
  43. }