From f911bbd9315c8dd1185571493b3168fe61e551a8 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 24 Oct 2023 20:56:39 +0200 Subject: [PATCH] Some variations of shell mapping in occt --- src/ifcgeom/kernels/opencascade/solid.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ifcgeom/kernels/opencascade/solid.cpp b/src/ifcgeom/kernels/opencascade/solid.cpp index 7692c2ea17..6a697d885e 100644 --- a/src/ifcgeom/kernels/opencascade/solid.cpp +++ b/src/ifcgeom/kernels/opencascade/solid.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace ifcopenshell::geometry; using namespace ifcopenshell::geometry::kernels; @@ -31,7 +32,7 @@ using namespace IfcGeom::util; bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) { BRep_Builder BB; - TopoDS_Solid S; + TopoDS_Shape S; if (solid->instance->declaration().is("IfcHalfSpaceSolid")) { // halfspace @@ -67,12 +68,16 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& } for (auto& s : solid->children) { - if (S.IsNull()) { - BB.MakeSolid(S); + TopoDS_Shape shl; + convert(s, shl); + if (shl.ShapeType() == TopAbs_SHELL) { + ShapeFix_Solid solid; + S = solid.SolidFromShell(TopoDS::Shell(shl)); + } else if (solid->children.size() == 1) { + S = shl; + } else { + throw std::runtime_error("Unexpected configuration of subshapes"); } - TopoDS_Shell shl; - convert(((taxonomy::shell::ptr)s), shl); - BB.Add(S, shl); } if (!S.IsNull()) { result = S;