0028626: Boolean CUT operation fails due to exception while intersecting two conical...
authorjgv <jgv@opencascade.com>
Fri, 7 Apr 2017 14:37:38 +0000 (17:37 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 12 Apr 2017 14:54:45 +0000 (17:54 +0300)
1. Modification in static function IntersectionWithAnArc of IntPatch_ImpImpIntersection :
  small offset <du> was hardcoded as 1.e-9, now it is adapted to parametric step.

2. Removal of duplicated points of IntPatch_WLine is corrected.

src/IntPatch/IntPatch_ALineToWLine.cxx
src/IntPatch/IntPatch_ImpImpIntersection_0.gxx
src/IntPatch/IntPatch_PrmPrmIntersection.cxx
src/IntPatch/IntPatch_WLine.cxx
tests/bugs/modalg_6/bug28626_1 [new file with mode: 0644]
tests/bugs/modalg_6/bug28626_2 [new file with mode: 0644]
tests/bugs/modalg_6/bug28626_3 [new file with mode: 0644]

index f0b6991..ed54dd9 100644 (file)
@@ -561,7 +561,7 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
                                   theALine->SituationS1(),
                                   theALine->SituationS2());
     }
-    if(theALine->TransitionOnS1() == IntSurf_Undecided)  { 
+    else if(theALine->TransitionOnS1() == IntSurf_Undecided)  { 
       aWLine = new IntPatch_WLine(aLinOn2S, theALine->IsTangent());
     }
     else { 
@@ -578,10 +578,14 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
 
     aWLine->SetPeriod(anArrPeriods[0],anArrPeriods[1],anArrPeriods[2],anArrPeriods[3]);
 
+    //the method ComputeVertexParameters can reduce the number of points in <aWLine>
     aWLine->ComputeVertexParameters(myTol3D);
 
-    aWLine->EnablePurging(Standard_False);
-    theLines.Append(aWLine);
+    if (aWLine->NbPnts() > 1)
+    {
+      aWLine->EnablePurging(Standard_False);
+      theLines.Append(aWLine);
+    }
   }//while(aParameter < theLPar)
 }
 
index 1b906fb..ce58a2c 100644 (file)
@@ -111,6 +111,8 @@ Standard_Boolean IntersectionWithAnArc(gp_Pnt& PSurf,
   //-- recherche bete du point le plus proche de thearc->Value(...)
   dtheta = (u1alin-u0alin)*0.01;
   Standard_Real du=0.000000001;
+  if (du >= dtheta)
+    du = dtheta/2;
   Standard_Real distmin = RealLast();
 
   Standard_Real thetamin = 0.;
index 571c700..e588b43 100644 (file)
@@ -591,8 +591,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
                     Standard_Real TolTang = TolTangency;
                     Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                    //the method PutVertexOnLine can reduce the number of points in <wline>
                     IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                    if (wline->NbPnts() < 2)
+                      continue;
                     IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                    if (wline->NbPnts() < 2)
+                      continue;
 
                     if(wline->NbVertex() == 0) {
                       IntPatch_Point vtx;
@@ -735,8 +740,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
 
                 Standard_Real TolTang = TolTangency;
                 Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+                //the method PutVertexOnLine can reduce the number of points in <wline>
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
 
                 if(wline->NbVertex() == 0) {
                   IntPatch_Point vtx;
@@ -999,7 +1009,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                         vtx.SetParameter(wline->NbPnts());
                         wline->SetPoint(wline->NbPnts(),vtx);
                       }
+                      //the method PutVertexOnLine can reduce the number of points in <wline>
                       IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
+                      if (wline->NbPnts() < 2)
+                        continue;
                       if(wline->NbVertex() == 0) {
                         IntPatch_Point vtx;
                         IntSurf_PntOn2S POn2S = PW.Line()->Value(1);
@@ -1173,7 +1186,10 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
                       wline->SetPoint(wline->NbPnts(),vtx);
                     }
 
+                    //the method PutVertexOnLine can reduce the number of points in <wline>
                     IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf1,Standard_True,TolTang);
+                    if (wline->NbPnts() < 2)
+                      continue;
 
                     if(wline->NbVertex() == 0) {
                       IntPatch_Point vtx;
@@ -1773,8 +1789,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)&
               Standard_Real TolTang = TolTangency;
               Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
               if (RestrictLine){
+                //the method PutVertexOnLine can reduce the number of points in <wline>
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
               }
 
               if(wline->NbVertex() == 0) {
@@ -1921,8 +1942,13 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
 
         Standard_Real TolTang = TolTangency;
         Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+        //the method PutVertexOnLine can reduce the number of points in <wline>
         IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+        if (wline->NbPnts() < 2)
+          return;
         IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+        if (wline->NbPnts() < 2)
+          return;
 
         //---------------
         if(wline->NbVertex() == 0) {
@@ -1945,9 +1971,9 @@ void IntPatch_PrmPrmIntersection::Perform(const Handle(Adaptor3d_HSurface)&    S
         //---------------
         SLin.Append(wline);
         empt = Standard_False;
-      }
-    }
-  }
+      } //if(PW.NbPoints()>2)
+    } //if(PW.IsDone())
+  } //if(HasStartPoint)
 }
 //==================================================================================
 // function : AdjustOnPeriodic
@@ -2450,8 +2476,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
                       Standard_Real TolTang = TolTangency;
                       Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
                       wline->EnablePurging(!hasBeenAdded);
+                      //the method PutVertexOnLine can reduce the number of points in <wline>
                       IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                      if (wline->NbPnts() < 2)
+                        continue;
                       IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                      if (wline->NbPnts() < 2)
+                        continue;
                       if(wline->NbVertex() == 0)
                       {
                         IntPatch_Point vtx;
@@ -2659,8 +2690,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
                 Standard_Real TolTang = TolTangency;
                 Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
                 wline->EnablePurging(!hasBeenAdded);
+                //the method PutVertexOnLine can reduce the number of points in <wline>
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
                 IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+                if (wline->NbPnts() < 2)
+                  continue;
 
                 //---------------
                 if(wline->NbVertex() == 0)
@@ -2850,8 +2886,13 @@ void IntPatch_PrmPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
 
               Standard_Real TolTang = TolTangency;
               Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
+              //the method PutVertexOnLine can reduce the number of points in <wline>
               IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+              if (wline->NbPnts() < 2)
+                continue;
               IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+              if (wline->NbPnts() < 2)
+                continue;
 
               //---------------
               if(wline->NbVertex() == 0)
index 2600d72..b79d125 100644 (file)
@@ -580,7 +580,7 @@ void IntPatch_WLine::ComputeVertexParameters( const Standard_Real RTol)
       if (Substitution)
       {
         Standard_Integer ind_point;
-        for(ind_point = 2; (ind_point <= nbponline && nbponline > 2); ind_point++) { 
+        for(ind_point = 2; (ind_point <= nbponline && nbponline > 1); ind_point++) { 
           Standard_Real d = (curv->Value(ind_point-1).Value()).SquareDistance((curv->Value(ind_point).Value()));
           if(d < dmini) { 
             curv->RemovePoint(ind_point);
diff --git a/tests/bugs/modalg_6/bug28626_1 b/tests/bugs/modalg_6/bug28626_1
new file mode 100644 (file)
index 0000000..0811f01
--- /dev/null
@@ -0,0 +1,20 @@
+puts "========"
+puts "OCC28626"
+puts "========"
+puts ""
+####################################################################################
+## Boolean CUT operation fails due to exception while intersecting two conical faces
+####################################################################################
+
+restore [locate_data_file bug28626_case1_shapes.brep] b
+explode b
+
+bcut result b_1 b_2
+
+checkshape result
+
+checknbshapes result -solid 1 -shell 1 -face 10 -wire 10 -edge 20 -vertex 12
+
+checkmaxtol result -ref 8.00001e-007
+
+checkprops result -v 1.35999e+006
diff --git a/tests/bugs/modalg_6/bug28626_2 b/tests/bugs/modalg_6/bug28626_2
new file mode 100644 (file)
index 0000000..a0aadb5
--- /dev/null
@@ -0,0 +1,27 @@
+puts "========"
+puts "OCC28626"
+puts "========"
+puts ""
+####################################################################################
+## Boolean CUT operation fails due to exception while intersecting two conical faces
+####################################################################################
+
+cone c1 0 0 0  0 -1 0  45  0
+cone c2 -23 -20 10  1 0 0  45  0
+trimv tc1 c1 0 42.4264068711929
+trimv tc2 c2 0 42.4264068711929
+mkface f1 tc1
+mkface f2 tc2
+donly f1 f2
+fit
+
+bop f1 f2
+bopsection result
+
+checkshape result
+
+checknbshapes result -edge 2 -vertex 3
+
+checkmaxtol result -ref 5.21731e-007
+
+checkprops result -l 88.9692
diff --git a/tests/bugs/modalg_6/bug28626_3 b/tests/bugs/modalg_6/bug28626_3
new file mode 100644 (file)
index 0000000..c207d42
--- /dev/null
@@ -0,0 +1,27 @@
+puts "========"
+puts "OCC28626"
+puts "========"
+puts ""
+####################################################################################
+## Boolean CUT operation fails due to exception while intersecting two conical faces
+####################################################################################
+
+cone c1 0 0 0  0 -1 0  45  0
+cone c2 -22 -20 10  1 0 0  45  0
+trimv tc1 c1 0 42.4264068711929
+trimv tc2 c2 0 42.4264068711929
+mkface f1 tc1
+mkface f2 tc2
+donly f1 f2
+fit
+
+bop f1 f2
+bopsection result
+
+checkshape result
+
+checknbshapes result -edge 5 -vertex 6
+
+checkmaxtol result -ref 6.02982e-007
+
+checkprops result -l 94.3164