From f65881919639b9d8195a69c8c23768527409ee48 Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 13 Sep 2018 21:12:50 +0300 Subject: [PATCH] lot 14: cut tool : cut mode -> fuse mode Signed-off-by: isn --- .../HYDROData_BoundaryPolygonTools.cxx | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx b/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx index 0f40c366..e9f44e44 100644 --- a/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx +++ b/src/HYDROData/HYDROData_BoundaryPolygonTools.cxx @@ -101,32 +101,60 @@ bool HYDROData_BoundaryPolygonTools::CutTool( const TopTools_SequenceOfShape& Cu BB.MakeCompound(aToolCmp); for (int i=1; i<= EdgesTools.Extent();i++) BB.Add(aToolCmp, EdgesTools(i)); - // + + TopoDS_Compound aObjCmp; + BB.MakeCompound(aObjCmp); for (int i = 1; i <= ObjToRes.Extent(); i++ ) { const TopoDS_Shape& Obj = ObjToRes.FindKey(i); - Standard_Real aTol; - if (!Obj.IsNull()) - { - aTol = Precision::Confusion(); - BOPAlgo_BOP aBOP; - // - aBOP.AddArgument(Obj); - aBOP.AddTool(aToolCmp); - aBOP.SetOperation(BOPAlgo_CUT); - aBOP.SetRunParallel(true); + if (!Obj.IsNull()) + BB.Add(aObjCmp, Obj); + } + + Standard_Real aTol; + + aTol = Precision::Confusion(); + BOPAlgo_BOP aBOP; + // + aBOP.AddArgument(aObjCmp); + aBOP.AddTool(aToolCmp); + aBOP.SetOperation(BOPAlgo_FUSE); + aBOP.SetRunParallel(true); - aBOP.Perform(); + aBOP.Perform(); #if OCC_VERSION_LARGE > 0x07020000 if (aBOP.HasErrors()) return false; #endif - const TopoDS_Shape& aRes=aBOP.Shape(); + for (int i = 1; i <= ObjToRes.Extent(); i++ ) + { + const TopoDS_Shape& Obj = ObjToRes.FindKey(i); + Standard_Real aTol; + if (!Obj.IsNull()) + { + TopTools_ListOfShape ls = aBOP.Modified(Obj); + TopoDS_Shape aRes; + if (ls.IsEmpty()) + aRes = Obj; //no fusing of toolcmp with Obj + else if (ls.Extent() == 1) + aRes = ls.First(); + else + { + BRep_Builder BB; + TopoDS_Compound cmp; + BB.MakeCompound(cmp); + TopTools_ListIteratorOfListOfShape aItLS(ls); + for (; aItLS.More(); aItLS.Next()) + BB.Add(cmp, aItLS.Value()); + aRes = cmp; + } + //const TopoDS_Shape& aRes=aBOP.Shape(); ObjToRes.ChangeFromKey(Obj) = aRes; } } + return true; } -- 2.30.2