test_meshboolean.cpp 786 B

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