From: isn Date: Thu, 13 Sep 2018 18:12:50 +0000 (+0300) Subject: lot 14: cut tool : cut mode -> fuse mode X-Git-Tag: HYDRO_V2_0_0~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f65881919639b9d8195a69c8c23768527409ee48;p=modules%2Fhydro.git lot 14: cut tool : cut mode -> fuse mode Signed-off-by: isn --- 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; }