triangle_triangle_adjacency.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <test_common.h>
  2. #include <igl/triangle_triangle_adjacency.h>
  3. #include <Eigen/Geometry>
  4. class triangle_triangle_adjacency : public ::testing::TestWithParam<std::string> {};
  5. TEST_CASE("triangle_triangle_adjacency: dot", "[igl]")
  6. {
  7. const auto test_case = [](const std::string &param)
  8. {
  9. Eigen::MatrixXd V, TC;
  10. Eigen::MatrixXi F,TT,TTi;
  11. // Load example mesh: GetParam() will be name of mesh file
  12. test_common::load_mesh(param, V, F, TC);
  13. igl::triangle_triangle_adjacency(F,TT,TTi);
  14. REQUIRE (TT.rows() == F.rows());
  15. REQUIRE (TTi.rows() == F.rows());
  16. REQUIRE (TT.cols() == F.cols());
  17. REQUIRE (TTi.cols() == F.cols());
  18. for(int f = 0;f<F.rows();f++)
  19. {
  20. for(int c = 0;c<3;c++)
  21. {
  22. if(TT(f,c) >= 0)
  23. {
  24. REQUIRE (F.rows() > TT(f,c));
  25. REQUIRE (0 <= TTi(f,c));
  26. REQUIRE (3 > TTi(f,c));
  27. REQUIRE (f == TT(TT(f,c),TTi(f,c)));
  28. }
  29. }
  30. }
  31. // REQUIRE (b == a);
  32. // REQUIRE (a==b);
  33. // REQUIRE(a == Approx(b).margin(1e-15))
  34. // REQUIRE (1e-12 > a);
  35. };
  36. test_common::run_test_cases(test_common::manifold_meshes(), test_case);
  37. }
  38. INSTANTIATE_TEST_CASE_P
  39. (
  40. manifold_meshes,
  41. triangle_triangle_adjacency,
  42. ::testing::ValuesIn(test_common::manifold_meshes()),
  43. test_common::string_test_name
  44. );