remesh_self_intersections.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <test_common.h>
  2. #include <Eigen/Dense>
  3. #include <igl/copyleft/cgal/remesh_self_intersections.h>
  4. #include <igl/copyleft/cgal/RemeshSelfIntersectionsParam.h>
  5. #include <igl/copyleft/cgal/assign.h>
  6. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  7. TEST_CASE("remesh_self_intersections: CubeWithFold", "[igl/copyleft/cgal]")
  8. {
  9. Eigen::MatrixXd V;
  10. Eigen::MatrixXi F;
  11. igl::read_triangle_mesh(test_common::data_path("cube_with_fold.ply"), V, F);
  12. typedef CGAL::Exact_predicates_exact_constructions_kernel K;
  13. typedef Eigen::Matrix<K::FT, Eigen::Dynamic, Eigen::Dynamic> MatrixXe;
  14. MatrixXe VV;
  15. Eigen::MatrixXi FF, IF;
  16. Eigen::VectorXi J, IM;
  17. igl::copyleft::cgal::RemeshSelfIntersectionsParam param;
  18. igl::copyleft::cgal::remesh_self_intersections(V, F, param, VV, FF, IF, J, IM);
  19. }
  20. TEST_CASE(
  21. "remesh_self_intersections: exact",
  22. "[igl/copyleft/cgal/]")
  23. {
  24. const auto test_case = [](const std::string & param)
  25. {
  26. using namespace igl::copyleft::cgal;
  27. // Load and cast to exact
  28. typedef CGAL::Epeck::FT EScalar;
  29. typedef Eigen::Matrix<EScalar,Eigen::Dynamic,3> MatrixXE;
  30. Eigen::MatrixXi F;
  31. MatrixXE Ve;
  32. {
  33. Eigen::MatrixXd Vd;
  34. igl::read_triangle_mesh(test_common::data_path(param),Vd,F);
  35. igl::copyleft::cgal::assign(Vd,Ve);
  36. }
  37. MatrixXE Vsu;
  38. Eigen::MatrixXi Fsu;
  39. // resolve intersections
  40. {
  41. RemeshSelfIntersectionsParam params(false,false,true);
  42. Eigen::MatrixXi IF;
  43. Eigen::VectorXi Jsu,IM;
  44. remesh_self_intersections(Ve,F,params,Vsu,Fsu,IF,Jsu,IM);
  45. }
  46. // detect intersections (there should be none)
  47. {
  48. RemeshSelfIntersectionsParam params(true,false,false);
  49. MatrixXE _VV;
  50. Eigen::MatrixXi _FF, IF;
  51. Eigen::VectorXi _J,_IM;
  52. remesh_self_intersections(Vsu,Fsu,params,_VV,_FF,IF,_J,_IM);
  53. REQUIRE(IF.rows() == 0);
  54. }
  55. };
  56. test_common::run_test_cases(test_common::all_meshes(), test_case);
  57. }