From 7aca082cb593ed96db707bdc773e735dee8f5703 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Sun, 1 Apr 2018 14:56:04 +0200 Subject: [PATCH] fix crash when boundary edges are not ordered --- src/Mod/Surface/App/FeatureFilling.cpp | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index 07c031adfa..cc7289612c 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #include #include #include @@ -139,6 +140,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, } if (edge_obj.size() == edge_sub.size()) { + BRepBuilderAPI_MakeWire testWire; for (std::size_t index = 0; index < edge_obj.size(); index++) { // get the part object App::DocumentObject* obj = edge_obj[index]; @@ -156,12 +158,34 @@ void Filling::addConstraints(BRepFill_Filling& builder, // edge doesn't have set an adjacent face if (subFace.empty()) { - builder.Add(TopoDS::Edge(edge), cont, bnd); + if (!bnd) { + builder.Add(TopoDS::Edge(edge), cont, bnd); + } + else { + testWire.Add(TopoDS::Edge(edge)); + if (testWire.IsDone()) { + builder.Add(TopoDS::Edge(edge), cont, bnd); + } + else { + Standard_Failure::Raise("Boundary edges are not ordered"); + } + } } else { TopoDS_Shape face = shape.getSubShape(subFace.c_str()); if (!face.IsNull() && face.ShapeType() == TopAbs_FACE) { - builder.Add(TopoDS::Edge(edge), TopoDS::Face(face), cont, bnd); + if (!bnd) { + builder.Add(TopoDS::Edge(edge), TopoDS::Face(face), cont, bnd); + } + else { + testWire.Add(TopoDS::Edge(edge)); + if (testWire.IsDone()) { + builder.Add(TopoDS::Edge(edge), TopoDS::Face(face), cont, bnd); + } + else { + Standard_Failure::Raise("Boundary edges are not ordered"); + } + } } else { Standard_Failure::Raise("Sub-shape is not a face");