2019-12-13 14:08:44 +00:00
|
|
|
#ifndef libslic3r_MeshBoolean_hpp_
|
|
|
|
#define libslic3r_MeshBoolean_hpp_
|
|
|
|
|
2020-01-16 12:20:17 +00:00
|
|
|
#include <memory>
|
2020-02-05 16:39:56 +00:00
|
|
|
#include <exception>
|
2019-12-13 14:08:44 +00:00
|
|
|
|
2020-02-05 16:39:56 +00:00
|
|
|
#include <libslic3r/TriangleMesh.hpp>
|
|
|
|
#include <Eigen/Geometry>
|
2019-12-13 14:08:44 +00:00
|
|
|
|
2020-02-05 16:39:56 +00:00
|
|
|
namespace Slic3r {
|
2019-12-13 14:08:44 +00:00
|
|
|
|
|
|
|
namespace MeshBoolean {
|
|
|
|
|
2020-02-05 16:39:56 +00:00
|
|
|
using EigenMesh = std::pair<Eigen::MatrixXd, Eigen::MatrixXi>;
|
|
|
|
|
|
|
|
TriangleMesh eigen_to_triangle_mesh(const EigenMesh &emesh);
|
|
|
|
EigenMesh triangle_mesh_to_eigen(const TriangleMesh &mesh);
|
|
|
|
|
|
|
|
void minus(EigenMesh &A, const EigenMesh &B);
|
|
|
|
void self_union(EigenMesh &A);
|
|
|
|
|
2019-12-13 14:08:44 +00:00
|
|
|
void minus(TriangleMesh& A, const TriangleMesh& B);
|
|
|
|
void self_union(TriangleMesh& mesh);
|
|
|
|
|
2020-01-16 12:20:17 +00:00
|
|
|
namespace cgal {
|
|
|
|
|
|
|
|
struct CGALMesh;
|
2020-02-05 16:39:56 +00:00
|
|
|
struct CGALMeshDeleter { void operator()(CGALMesh *ptr); };
|
|
|
|
|
2021-03-10 17:21:36 +00:00
|
|
|
std::unique_ptr<CGALMesh, CGALMeshDeleter>
|
|
|
|
triangle_mesh_to_cgal(const std::vector<stl_vertex> &V,
|
|
|
|
const std::vector<stl_triangle_vertex_indices> &F);
|
|
|
|
|
|
|
|
inline std::unique_ptr<CGALMesh, CGALMeshDeleter> triangle_mesh_to_cgal(const indexed_triangle_set &M)
|
|
|
|
{
|
|
|
|
return triangle_mesh_to_cgal(M.vertices, M.indices);
|
|
|
|
}
|
|
|
|
inline std::unique_ptr<CGALMesh, CGALMeshDeleter> triangle_mesh_to_cgal(const TriangleMesh &M)
|
|
|
|
{
|
|
|
|
return triangle_mesh_to_cgal(M.its);
|
|
|
|
}
|
|
|
|
|
2020-02-05 16:39:56 +00:00
|
|
|
TriangleMesh cgal_to_triangle_mesh(const CGALMesh &cgalmesh);
|
2020-01-16 12:20:17 +00:00
|
|
|
|
|
|
|
// Do boolean mesh difference with CGAL bypassing igl.
|
|
|
|
void minus(TriangleMesh &A, const TriangleMesh &B);
|
2020-02-05 16:39:56 +00:00
|
|
|
void plus(TriangleMesh &A, const TriangleMesh &B);
|
|
|
|
void intersect(TriangleMesh &A, const TriangleMesh &B);
|
2020-01-16 12:20:17 +00:00
|
|
|
|
|
|
|
void minus(CGALMesh &A, CGALMesh &B);
|
2020-02-05 16:39:56 +00:00
|
|
|
void plus(CGALMesh &A, CGALMesh &B);
|
|
|
|
void intersect(CGALMesh &A, CGALMesh &B);
|
|
|
|
|
|
|
|
bool does_self_intersect(const TriangleMesh &mesh);
|
|
|
|
bool does_self_intersect(const CGALMesh &mesh);
|
2020-01-16 12:20:17 +00:00
|
|
|
|
2021-06-17 13:04:47 +00:00
|
|
|
bool does_bound_a_volume(const CGALMesh &mesh);
|
|
|
|
|
2020-01-16 12:20:17 +00:00
|
|
|
}
|
2019-12-13 14:08:44 +00:00
|
|
|
|
|
|
|
} // namespace MeshBoolean
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif // libslic3r_MeshBoolean_hpp_
|