edge_flaps.cpp 1.2 KB

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