0031836: Modeling Algorithms - Boolean cut failed between a Cone and a Torus
authoremv <emv@opencascade.com>
Mon, 12 Oct 2020 12:40:27 +0000 (15:40 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 13 Oct 2020 16:18:02 +0000 (19:18 +0300)
BOPAlgo_PaveFiller::UpdateExistingPaveBlocks: Add check for closed edge when updating pave block.

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

index 9c35a81..0756d6f 100644 (file)
@@ -2838,37 +2838,50 @@ void BOPAlgo_PaveFiller::UpdateExistingPaveBlocks
         else {
           // For the different original edge compute the parameters of paves
           BOPDS_Pave aPave[2];
-          for (Standard_Integer i = 0; i < 2; ++i) {
-            Standard_Integer nV = aPBValuePaves[i].Index();
-            aPave[i].SetIndex(nV);
-            if (nV == aPB2->Pave1().Index()) {
-              aPave[i].SetParameter(aPB2->Pave1().Parameter());
-            }
-            else if (nV == aPB2->Pave2().Index()) {
-              aPave[i].SetParameter(aPB2->Pave2().Parameter());
-            }
-            else {
-              // Compute the parameter by projecting the point
-              const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
-              const TopoDS_Edge& aEOr = TopoDS::Edge(myDS->Shape(nE));
-              Standard_Real aTOut, aDist;
-              Standard_Integer iErr = myContext->ComputeVE(aV, aEOr, aTOut, aDist, myFuzzyValue);
-              if (!iErr) {
-                aPave[i].SetParameter(aTOut);
+
+          if (aPBValuePaves[0].Index() == aPBValuePaves[1].Index() &&
+              aPB2->Pave1().Index() == aPB2->Pave2().Index())
+          {
+            // still closed
+            aPave[0].SetIndex (aPBValuePaves[0].Index());
+            aPave[0].SetParameter (aPB2->Pave1().Parameter());
+            aPave[1].SetIndex (aPBValuePaves[1].Index());
+            aPave[1].SetParameter (aPB2->Pave2().Parameter());
+          }
+          else
+          {
+            for (Standard_Integer i = 0; i < 2; ++i) {
+              Standard_Integer nV = aPBValuePaves[i].Index();
+              aPave[i].SetIndex(nV);
+              if (nV == aPB2->Pave1().Index()) {
+                aPave[i].SetParameter(aPB2->Pave1().Parameter());
+              }
+              else if (nV == aPB2->Pave2().Index()) {
+                aPave[i].SetParameter(aPB2->Pave2().Parameter());
               }
               else {
-                // Unable to project - set the parameter of the closest boundary
-                const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(aPB2->Pave1().Index()));
-                const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(aPB2->Pave2().Index()));
-                //
-                gp_Pnt aP = BRep_Tool::Pnt(aV);
-                gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
-                gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
-                //
-                Standard_Real aDist1 = aP.SquareDistance(aP1);
-                Standard_Real aDist2 = aP.SquareDistance(aP2);
-                //
-                aPave[i].SetParameter(aDist1 < aDist2 ? aPB2->Pave1().Parameter() : aPB2->Pave2().Parameter());
+                // Compute the parameter by projecting the point
+                const TopoDS_Vertex& aV = TopoDS::Vertex(myDS->Shape(nV));
+                const TopoDS_Edge& aEOr = TopoDS::Edge(myDS->Shape(nE));
+                Standard_Real aTOut, aDist;
+                Standard_Integer iErr = myContext->ComputeVE(aV, aEOr, aTOut, aDist, myFuzzyValue);
+                if (!iErr) {
+                  aPave[i].SetParameter(aTOut);
+                }
+                else {
+                  // Unable to project - set the parameter of the closest boundary
+                  const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(aPB2->Pave1().Index()));
+                  const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(aPB2->Pave2().Index()));
+                  //
+                  gp_Pnt aP = BRep_Tool::Pnt(aV);
+                  gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
+                  gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
+                  //
+                  Standard_Real aDist1 = aP.SquareDistance(aP1);
+                  Standard_Real aDist2 = aP.SquareDistance(aP2);
+                  //
+                  aPave[i].SetParameter(aDist1 < aDist2 ? aPB2->Pave1().Parameter() : aPB2->Pave2().Parameter());
+                }
               }
             }
           }
diff --git a/tests/bugs/modalg_7/bug31836 b/tests/bugs/modalg_7/bug31836
new file mode 100644 (file)
index 0000000..bc2a75a
--- /dev/null
@@ -0,0 +1,59 @@
+puts "============================================================================================="
+puts "0031836: regression issue - boolean cut between a cone and a Torus is not done"
+puts "============================================================================================="
+puts ""
+
+pcone c 282.842712474619 100 300
+ttranslate c 100 0 0
+ptorus t 80.2535587508467 19.7464412491533
+ttranslate t 100 0 300
+
+bfuzzyvalue 1.e-6
+brunparallel 1
+bnondestructive 1
+setfillhistory 0
+
+explode s
+
+bclearobjects
+bcleartools
+baddobjects c
+baddtools t
+bfillds
+
+bbop r_0 0
+bbop r_1 1
+bbop r_2 2
+bbop r_3 3
+bbop r_4 4
+bbuild r_5
+
+boptions -default
+
+foreach i {0 1 2 3 4 5} {
+  checkshape r_$i
+  if {![regexp "OK" [bopcheck r_$i]]} {
+    puts "Error: r_$i is self-intersecting shape"
+  }
+}
+
+checkprops r_0 -s 51195.4 -v 308846
+checknbshapes r_0 -wire 3 -face 2 -shell 1 -solid 1 -t
+
+checkprops r_1 -s 716665 -v 3.74689e+07
+checknbshapes r_1 -wire 4 -face 4 -shell 1 -solid 1 -t
+
+checkprops r_2 -s 716665 -v 3.68513e+07
+checknbshapes r_2 -wire 4 -face 4 -shell 1 -solid 1 -t
+
+checkprops r_3 -s 51195.4 -v 308846
+checknbshapes r_3 -wire 3 -face 2 -shell 1 -solid 1 -t
+
+checkprops r_4 -l 1008.5
+checksection r_4 -r 0
+checknbshapes r_4 -edge 2
+
+checkprops r_5 -s 819056 -v 3.74689e+07
+checknbshapes r_5 -wire 7 -face 6 -shell 3 -solid 3 -t
+
+checkview -display r_2 -2d -path ${imagedir}/${test_image}.png