facet_components.cpp 813 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <test_common.h>
  2. #include <igl/facet_components.h>
  3. TEST_CASE("facet_components: two_triangles", "[igl]")
  4. {
  5. const Eigen::MatrixXi F1 =
  6. (Eigen::MatrixXi(2,3)<<
  7. 0,1,3,
  8. 0,3,2).finished();
  9. Eigen::VectorXi C1;
  10. igl::facet_components(F1,C1);
  11. REQUIRE(C1(0) == 0);
  12. REQUIRE(C1(0) == C1(1));
  13. const Eigen::MatrixXi F2 =
  14. (Eigen::MatrixXi(2,3)<<
  15. 0,1,2,
  16. 3,4,5).finished();
  17. Eigen::VectorXi C2;
  18. igl::facet_components(F2,C2);
  19. REQUIRE(C2(0) != C2(1));
  20. REQUIRE(C2.minCoeff() == 0);
  21. REQUIRE(C2.maxCoeff() == 1);
  22. }
  23. TEST_CASE("facet_components: truck", "[igl]")
  24. {
  25. Eigen::MatrixXi F;
  26. {
  27. Eigen::MatrixXd V;
  28. igl::read_triangle_mesh(test_common::data_path("truck.obj"), V, F);
  29. }
  30. Eigen::VectorXi C;
  31. igl::facet_components(F,C);
  32. REQUIRE(C.maxCoeff()+1 == 59);
  33. }