]> OCCT Git - occt.git/commitdiff
0029099: Extra shapes in result of General Cut (box by ellipsoid)
authoremv <emv@opencascade.com>
Wed, 13 Sep 2017 05:28:04 +0000 (08:28 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 22 Sep 2017 08:51:47 +0000 (11:51 +0300)
Boolean Operations - when looking for the splitting parameters on the degenerated edges try not only the intersection of the 2D curve of degenerated edge with 2D curves of other edges bounded by the vertex of degenerated edge, but also the projection of the end points of the edges corresponding to the vertex on the 2d curve of degenerated edge.

src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx
tests/bugs/modalg_7/bug29099 [new file with mode: 0644]

index 495c640479ecb4f22c7d6e59aa48413922da0af1..08f515a92460c8723e6c02855fe4f3009d9835a3 100644 (file)
@@ -32,6 +32,7 @@
 #include <Geom2d_Line.hxx>
 #include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
 #include <Geom2dInt_GInter.hxx>
 #include <gp_Lin2d.hxx>
 #include <gp_Pnt.hxx>
@@ -52,6 +53,11 @@ static
                        const Standard_Real  aP2,
                        TopoDS_Edge& aNewEdge);
 
+static
+  Standard_Boolean AddSplitPoint(const Handle(BOPDS_PaveBlock)& thePBD,
+                                 const BOPDS_Pave& thePave,
+                                 const Standard_Real theTol);
+
 //=======================================================================
 //function : ProcessDE
 //purpose  : 
@@ -304,25 +310,30 @@ void BOPAlgo_PaveFiller::ProcessDE()
     }
     // Intersection
     Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInt, aTolInt);
-    if (!aGInter.IsDone()) {
-      continue;
-    }
-    //
-    // Analyze intersection points
-    Standard_Integer i, aNbPoints = aGInter.NbPoints();
-    for (i = 1; i <= aNbPoints; ++i) {
-      Standard_Real aX = aGInter.Point(i).ParamOnFirst();
-      if (aX - aTD1 < aTolCmp || aTD2 - aX < aTolCmp) {
-        continue;
+    if (aGInter.IsDone() && aGInter.NbPoints())
+    {
+      // Analyze intersection points
+      Standard_Integer i, aNbPoints = aGInter.NbPoints();
+      for (i = 1; i <= aNbPoints; ++i) {
+        Standard_Real aX = aGInter.Point(i).ParamOnFirst();
+        aPave.SetParameter(aX);
+        AddSplitPoint(aPBD, aPave, aTolCmp);
       }
-      //
-      Standard_Integer anInd;
-      if (aPBD->ContainsParameter(aX, aTolCmp, anInd)) {
-        continue;
+    }
+    else
+    {
+      // If the intersection did not succeed, try the projection of the end point
+      // of the curve corresponding to the vertex of degenerated edge
+      Standard_Real aT = (nVD == aPB->Pave1().Index() ?
+        aPB->Pave1().Parameter() : aPB->Pave2().Parameter());
+      gp_Pnt2d aP2d = aC2D->Value(aT);
+      Geom2dAPI_ProjectPointOnCurve aProj2d(aP2d, aC2DDE, aTD1, aTD2);
+      if (aProj2d.NbPoints())
+      {
+        Standard_Real aX = aProj2d.LowerDistanceParameter();
+        aPave.SetParameter(aX);
+        AddSplitPoint(aPBD, aPave, aTolCmp);
       }
-      //
-      aPave.SetParameter(aX);
-      aPBD->AppendExtPave1(aPave);
     }
   }
 }
@@ -354,3 +365,34 @@ void BOPAlgo_PaveFiller::ProcessDE()
   BB.UpdateEdge(E, aTol);
   aNewEdge=E;
 }
+
+//=======================================================================
+// function: AddSplitPoint
+// purpose: Validates the point represented by the pave <thePave>
+//          for the Pave Block <thePBD>.
+//          In case the point passes the checks it is added as an
+//          Extra Pave to the Pave Block for further splitting of the latter.
+//          Returns TRUE if the point is added, otherwise returns FALSE.
+//=======================================================================
+Standard_Boolean AddSplitPoint(const Handle(BOPDS_PaveBlock)& thePBD,
+                               const BOPDS_Pave& thePave,
+                               const Standard_Real theTol)
+{
+  Standard_Real aTD1, aTD2;
+  thePBD->Range(aTD1, aTD2);
+
+  Standard_Real aT = thePave.Parameter();
+  // Check that the parameter is inside the Pave Block
+  if (aT - aTD1 < theTol || aTD2 - aT < theTol)
+    return Standard_False;
+
+  // Check that the pave block does not contain the same parameter
+  Standard_Integer anInd;
+  if (thePBD->ContainsParameter(aT, theTol, anInd))
+    return Standard_False;
+
+  // Add the point as an Extra pave to the Pave Block for further
+  // splitting of the latter
+  thePBD->AppendExtPave1(thePave);
+  return Standard_True;
+}
diff --git a/tests/bugs/modalg_7/bug29099 b/tests/bugs/modalg_7/bug29099
new file mode 100644 (file)
index 0000000..f4bbf91
--- /dev/null
@@ -0,0 +1,23 @@
+puts "======="
+puts "0029099"
+puts "======="
+puts ""
+##################################################
+# Extra shapes in result of General Cut (box by ellipsoid)
+##################################################
+
+brestore [locate_data_file bug29099_Box.brep] b1
+brestore [locate_data_file bug29099_Rotation.brep] b2
+
+bclearobjects
+bcleartools
+baddobjects b1
+baddtools b2
+bfillds
+bbuild result
+
+checkshape result
+checknbshapes result -wire 11 -face 10 -shell 3 -solid 3
+checkprops result -s 12651.3 -v 52187.5
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file