Some variations of shell mapping in occt

This commit is contained in:
Thomas Krijnen
2023-10-24 20:56:39 +02:00
parent 85b3509ce3
commit f911bbd931
+11 -6
View File
@@ -23,6 +23,7 @@
#include <BRepBuilderAPI_MakeFace.hxx> #include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepPrimAPI_MakePrism.hxx> #include <BRepPrimAPI_MakePrism.hxx>
#include <BRepAlgoAPI_Common.hxx> #include <BRepAlgoAPI_Common.hxx>
#include <ShapeFix_Solid.hxx>
using namespace ifcopenshell::geometry; using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels; using namespace ifcopenshell::geometry::kernels;
@@ -31,7 +32,7 @@ using namespace IfcGeom::util;
bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) { bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) {
BRep_Builder BB; BRep_Builder BB;
TopoDS_Solid S; TopoDS_Shape S;
if (solid->instance->declaration().is("IfcHalfSpaceSolid")) { if (solid->instance->declaration().is("IfcHalfSpaceSolid")) {
// halfspace // halfspace
@@ -67,12 +68,16 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape&
} }
for (auto& s : solid->children) { for (auto& s : solid->children) {
if (S.IsNull()) { TopoDS_Shape shl;
BB.MakeSolid(S); 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()) { if (!S.IsNull()) {
result = S; result = S;