From 4cad132160e871ed4f5566ea697514ae7cb685b1 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 9 Apr 2007 07:34:26 +0000 Subject: [PATCH] NPAL15379: EDF386: Fuse error with partitioned shape. Check compounds to prevent returning invalid result. --- src/GEOMImpl/GEOMImpl_BooleanDriver.cxx | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx index 2a7c71386..1ee33f4e1 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -231,6 +232,54 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const // perform FUSE operation else if (aType == BOOLEAN_FUSE) { + // Check arguments + TopTools_ListOfShape listShape1, listShape2; + AddSimpleShapes(aShape1, listShape1); + AddSimpleShapes(aShape2, listShape2); + + if (listShape1.Extent() > 1) { + TopTools_ListIteratorOfListOfShape it1 (listShape1); + for (; it1.More(); it1.Next()) { + TopoDS_Shape aValue1 = it1.Value(); + TopTools_ListIteratorOfListOfShape it2 (listShape1); + for (; it2.More(); it2.Next()) { + TopoDS_Shape aValue2 = it2.Value(); + if (aValue2 != aValue1) { + BRepAlgoAPI_Section BO (aValue1, aValue2); + if (BO.IsDone()) { + TopoDS_Shape aSect = BO.Shape(); + TopExp_Explorer anExp (aSect, TopAbs_VERTEX); + if (anExp.More()) { + StdFail_NotDone::Raise("Bad first shape for Fuse: compound with intersecting sub-shapes"); + } + } + } + } + } + } + + if (listShape2.Extent() > 1) { + TopTools_ListIteratorOfListOfShape it1 (listShape2); + for (; it1.More(); it1.Next()) { + TopoDS_Shape aValue1 = it1.Value(); + TopTools_ListIteratorOfListOfShape it2 (listShape2); + for (; it2.More(); it2.Next()) { + TopoDS_Shape aValue2 = it2.Value(); + if (aValue2 != aValue1) { + BRepAlgoAPI_Section BO (aValue1, aValue2); + if (BO.IsDone()) { + TopoDS_Shape aSect = BO.Shape(); + TopExp_Explorer anExp (aSect, TopAbs_VERTEX); + if (anExp.More()) { + StdFail_NotDone::Raise("Bad second shape for Fuse: compound with intersecting sub-shapes"); + } + } + } + } + } + } + + // Perform BRepAlgoAPI_Fuse BO (aShape1, aShape2); if (!BO.IsDone()) { StdFail_NotDone::Raise("Fuse operation can not be performed on the given shapes"); -- 2.39.2