From 8c0c216a1d7af37de3b15992243649be6f59413a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 8 Dec 2018 10:37:54 +0100 Subject: [PATCH 1/2] Check boolean result manifoldness for shells individually. Fixes #516. --- src/ifcgeom/IfcGeomFunctions.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 7ae87d9954..53013da932 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -235,16 +235,26 @@ namespace { } bool is_manifold(const TopoDS_Shape& a) { - TopTools_IndexedDataMapOfShapeListOfShape map; - TopExp::MapShapesAndAncestors(a, TopAbs_EDGE, TopAbs_FACE, map); - - for (int i = 1; i <= map.Extent(); ++i) { - if (map.FindFromIndex(i).Extent() != 2) { - return false; + if (a.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator it(a); + for (; it.More(); it.Next()) { + if (!is_manifold(it.Value())) { + return false; + } } - } + return true; + } else { + TopTools_IndexedDataMapOfShapeListOfShape map; + TopExp::MapShapesAndAncestors(a, TopAbs_EDGE, TopAbs_FACE, map); - return true; + for (int i = 1; i <= map.Extent(); ++i) { + if (map.FindFromIndex(i).Extent() != 2) { + return false; + } + } + + return true; + } } bool is_manifold(const TopTools_ListOfShape& l) { From f849434f24e41e8a5e7d280687cfe8cae9b3208c Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 9 Dec 2018 11:59:49 +0100 Subject: [PATCH 2/2] More defensive IfcCurveBoundedPlane processing --- src/ifcgeom/IfcGeomShapes.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ifcgeom/IfcGeomShapes.cpp b/src/ifcgeom/IfcGeomShapes.cpp index 81a8af14ca..17acda26e7 100644 --- a/src/ifcgeom/IfcGeomShapes.cpp +++ b/src/ifcgeom/IfcGeomShapes.cpp @@ -832,24 +832,32 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCsgSolid* l, TopoDS_Shape& sha bool IfcGeom::Kernel::convert(const IfcSchema::IfcCurveBoundedPlane* l, TopoDS_Shape& face) { gp_Pln pln; - IfcGeom::Kernel::convert(l->BasisSurface(), pln); + if (!IfcGeom::Kernel::convert(l->BasisSurface(), pln)) { + return false; + } gp_Trsf trsf; trsf.SetTransformation(pln.Position(), gp::XOY()); TopoDS_Wire outer; - convert_wire(l->OuterBoundary(), outer); + if (!convert_wire(l->OuterBoundary(), outer)) { + return false; + } - BRepBuilderAPI_MakeFace mf (outer); - mf.Add(outer); + BRepBuilderAPI_MakeFace mf(outer); + if (!mf.IsDone() || mf.Shape().IsNull()) { + Logger::Error("Invalid outer boundary:", l->OuterBoundary()->entity); + return false; + } + IfcSchema::IfcCurve::list::ptr boundaries = l->InnerBoundaries(); for (IfcSchema::IfcCurve::list::it it = boundaries->begin(); it != boundaries->end(); ++it) { TopoDS_Wire inner; - convert_wire(*it, inner); - - mf.Add(inner); + if (convert_wire(*it, inner)) { + mf.Add(inner); + } } ShapeFix_Shape sfs(mf.Face());