Salome HOME
lot 14: cut tool : cut mode -> fuse mode
authorisn <isn@opencascade.com>
Thu, 13 Sep 2018 18:12:50 +0000 (21:12 +0300)
committerisn <isn@opencascade.com>
Thu, 13 Sep 2018 18:57:25 +0000 (21:57 +0300)
Signed-off-by: isn <isn@opencascade.com>
src/HYDROData/HYDROData_BoundaryPolygonTools.cxx

index 0f40c3662c6f7c8ec85386633e9a13f460fb35ec..e9f44e44a961ce876f9f199bd09dea1b56009b97 100644 (file)
@@ -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;
 }