ENH: improve mesh boolean

1. Don't use mcut on splitable volumes
2. If MCut fails, try again with CGAL.

Change-Id: I55d352b166633db9e4548b5c9e6913cf931f5f8f
(cherry picked from commit c1bde5358524d2291db6efa584ff072308ed9d20)
This commit is contained in:
Arthur 2023-06-21 15:30:04 +08:00 committed by Lane.Wei
parent 1fe741b7f0
commit 40b8d9b87f
3 changed files with 22 additions and 11 deletions

View file

@ -19,7 +19,7 @@ enum ModelParts {
};
template<class OutIt>
void model_to_csgmesh(const ModelObject &mo,
bool model_to_csgmesh(const ModelObject &mo,
const Transform3d &trafo, // Applies to all exported parts
OutIt out, // Output iterator
// values of ModelParts OR-ed
@ -30,6 +30,7 @@ void model_to_csgmesh(const ModelObject &mo,
bool do_negatives = parts_to_include & mpartsNegative;
bool do_drillholes = parts_to_include & mpartsDrillHoles;
bool do_splits = parts_to_include & mpartsDoSplits;
bool has_splitable_volume = false;
for (const ModelVolume *vol : mo.volumes) {
if (vol && vol->mesh_ptr() &&
@ -58,6 +59,7 @@ void model_to_csgmesh(const ModelObject &mo,
part_end.stack_operation = CSGStackOp::Pop;
*out = std::move(part_end);
++out;
has_splitable_volume = true;
} else {
CSGPart part{&(vol->mesh().its),
vol->is_model_part() ? CSGType::Union : CSGType::Difference,
@ -81,6 +83,8 @@ void model_to_csgmesh(const ModelObject &mo,
// ++out;
// }
//}
return has_splitable_volume;
}
}} // namespace Slic3r::csg