edge_flaps.cpp 1.1 KB

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