edge_flaps.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <test_common.h>
  2. #include <igl/edge_flaps.h>
  3. class edge_flaps : public ::testing::TestWithParam<std::string> {};
  4. TEST_CASE("edge_flaps: verify", "[igl]")
  5. {
  6. const auto test_case = [](const std::string &param)
  7. {
  8. Eigen::MatrixXd V, TC;
  9. Eigen::MatrixXi F;
  10. test_common::load_mesh(param, V, F, TC);
  11. Eigen::MatrixXi efE,efEF,efEI;
  12. Eigen::VectorXi efEMAP;
  13. igl::edge_flaps(F,efE,efEMAP,efEF,efEI);
  14. REQUIRE (efEF.rows() == efE.rows());
  15. REQUIRE (2 == efE.cols());
  16. REQUIRE (efEF.cols() == efE.cols());
  17. // for each edge, make sure edge appears in face
  18. for(int e = 0;e<efE.rows();e++)
  19. {
  20. for(int fe = 0;fe<2;fe++)
  21. {
  22. const int f = efEF(e,fe);
  23. // index of corner
  24. const int c = efEI(e,fe);
  25. REQUIRE (f<F.rows());
  26. // only check if not on boundary
  27. if(f >= 0)
  28. {
  29. // Either efE(e,[1 2]) = [i,j] appears after vertex c of face f
  30. // Or efE(e,[2 1]) = [j,i] appears after vertex c of face f
  31. CHECK((
  32. ((efE(e,0) == F(f,(c+1)%3)) && (efE(e,1) == F(f,(c+2)%3))) ||
  33. ((efE(e,1) == F(f,(c+1)%3)) && (efE(e,0) == F(f,(c+2)%3)))));
  34. }
  35. }
  36. }
  37. };
  38. test_common::run_test_cases(test_common::all_meshes(), test_case);
  39. }
  40. INSTANTIATE_TEST_CASE_P
  41. (
  42. all_meshes,
  43. edge_flaps,
  44. ::testing::ValuesIn(test_common::all_meshes()),
  45. test_common::string_test_name
  46. );