Skip to content

mesh boolean difference - works until it does not #9282

@petrasvestartas

Description

@petrasvestartas

Issues with multiple times applying in invalid meshes. I know you did some new developments in cgal. Can you suggest any solutions? These issues remains for many years with our compas cgal binding.

It would be really nice that the mesh booleans would be more robust for more than a few boolean difference runs due to triangulations.

Issue Details

The issue is that the more booleans I do the more detailed mesh becomes and at one point it just crashes.
In "real life" I am trying to cut out drilled screws from a piece of block.

Source Code

std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
pmp_boolean_difference(
    Eigen::Ref<const compas::RowMatrixXd> vertices_a,
    Eigen::Ref<const compas::RowMatrixXi> faces_a,
    Eigen::Ref<const compas::RowMatrixXd> vertices_b,
    Eigen::Ref<const compas::RowMatrixXi> faces_b)
{
    compas::Mesh mesh_a = compas::mesh_from_vertices_and_faces(vertices_a, faces_a);
    compas::Mesh mesh_b = compas::mesh_from_vertices_and_faces(vertices_b, faces_b);
    compas::Mesh mesh_out;

    CGAL::Polygon_mesh_processing::corefine_and_compute_difference(mesh_a, mesh_b, mesh_out);

    std::tuple<compas::RowMatrixXd, compas::RowMatrixXi> result = compas::mesh_to_vertices_and_faces(mesh_out);
    return result;
};

Environment

Ubuntu, mac and windows

This booleand difference fails.

mesh.zip

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions