From 9ffc505ab4a918694c5ec17ae462fa58f166443c Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 4 Jun 2026 21:41:06 +0200 Subject: [PATCH] Check for empty result after BOPAlgo_MakerVolume and reset manifoldness state #8140 --- .../kernels/opencascade/OpenCascadeKernel.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp index 7fccb84871..93bf37f38e 100644 --- a/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp +++ b/src/ifcgeom/kernels/opencascade/OpenCascadeKernel.cpp @@ -31,6 +31,8 @@ #include #include +#include + namespace { struct opening_sorter { bool operator()(const std::pair& a, const std::pair& b) const { @@ -152,17 +154,25 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c BOPAlgo_MakerVolume mv; mv.AddArgument(entity_part); mv.SetAvoidInternalShapes(true); + // mv.SetFuzzyValue(settings_.get().get()); + std::optional failure; try { mv.Perform(); + auto entity_part_2 = mv.Shape(); if (mv.HasErrors()) { - logger::warning("Non-manifold first operand, --make-volume failed", entity); + failure = "BOPAlgo_MakerVolume reported errors"; + } else if (IfcGeom::util::count(entity_part_2, TopAbs_FACE) == 0) { + failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE)); } else { - entity_part = mv.Shape(); - is_manifold = util::is_manifold(entity_part); - logger::warning("Successfully detected exterior volume to non-manifold first operand", entity); + is_manifold = util::is_manifold(entity_part_2); + logger::warning(std::string("Successfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")), entity); + entity_part = entity_part_2; } } catch (const Standard_Failure& e) { - logger::warning("MakeVolume failed: " + std::string(e.GetMessageString()), entity); + failure.emplace(e.GetMessageString()); + } + if (failure) { + logger::warning("MakeVolume failed: " + *failure, entity); } } else { logger::warning("Non-manifold first operand, use --make-volume to try and make manifold", entity);