test_meshboolean.cpp 824 B

1234567891011121314151617181920212223242526
  1. #include <catch2/catch.hpp>
  2. #include <test_utils.hpp>
  3. #include <libslic3r/TriangleMesh.hpp>
  4. #include <libslic3r/MeshBoolean.hpp>
  5. #include <libslic3r/SimplifyMesh.hpp>
  6. using namespace Slic3r;
  7. TEST_CASE("CGAL and TriangleMesh conversions", "[MeshBoolean]") {
  8. TriangleMesh sphere = make_sphere(1.);
  9. auto cgalmesh_ptr = MeshBoolean::cgal::triangle_mesh_to_cgal(sphere);
  10. REQUIRE(cgalmesh_ptr);
  11. REQUIRE(! MeshBoolean::cgal::does_self_intersect(*cgalmesh_ptr));
  12. TriangleMesh M = MeshBoolean::cgal::cgal_to_triangle_mesh(*cgalmesh_ptr);
  13. REQUIRE(M.its.vertices.size() == sphere.its.vertices.size());
  14. REQUIRE(M.its.indices.size() == sphere.its.indices.size());
  15. REQUIRE(M.volume() == Approx(sphere.volume()));
  16. REQUIRE(! MeshBoolean::cgal::does_self_intersect(M));
  17. }