From 1406e955b3fe27dea45ce9769d47aa21e0b7e9f0 Mon Sep 17 00:00:00 2001 From: jgv Date: Fri, 7 Apr 2017 17:37:38 +0300 Subject: [PATCH] 0028626: Boolean CUT operation fails due to exception while intersecting two conical faces 1. Modification in static function IntersectionWithAnArc of IntPatch_ImpImpIntersection : small offset 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 | 10 ++-- .../IntPatch_ImpImpIntersection_0.gxx | 2 + src/IntPatch/IntPatch_PrmPrmIntersection.cxx | 47 +++++++++++++++++-- src/IntPatch/IntPatch_WLine.cxx | 2 +- tests/bugs/modalg_6/bug28626_1 | 20 ++++++++ tests/bugs/modalg_6/bug28626_2 | 27 +++++++++++ tests/bugs/modalg_6/bug28626_3 | 27 +++++++++++ 7 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 tests/bugs/modalg_6/bug28626_1 create mode 100644 tests/bugs/modalg_6/bug28626_2 create mode 100644 tests/bugs/modalg_6/bug28626_3 diff --git a/src/IntPatch/IntPatch_ALineToWLine.cxx b/src/IntPatch/IntPatch_ALineToWLine.cxx index f0b69919cf..ed54dd94d1 100644 --- a/src/IntPatch/IntPatch_ALineToWLine.cxx +++ b/src/IntPatch/IntPatch_ALineToWLine.cxx @@ -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->ComputeVertexParameters(myTol3D); - aWLine->EnablePurging(Standard_False); - theLines.Append(aWLine); + if (aWLine->NbPnts() > 1) + { + aWLine->EnablePurging(Standard_False); + theLines.Append(aWLine); + } }//while(aParameter < theLPar) } diff --git a/src/IntPatch/IntPatch_ImpImpIntersection_0.gxx b/src/IntPatch/IntPatch_ImpImpIntersection_0.gxx index 1b906fbec1..ce58a2c42b 100644 --- a/src/IntPatch/IntPatch_ImpImpIntersection_0.gxx +++ b/src/IntPatch/IntPatch_ImpImpIntersection_0.gxx @@ -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.; diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx index 571c700d16..e588b4333d 100644 --- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -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 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 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 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 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 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 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 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 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 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) diff --git a/src/IntPatch/IntPatch_WLine.cxx b/src/IntPatch/IntPatch_WLine.cxx index 2600d72cc9..b79d125907 100644 --- a/src/IntPatch/IntPatch_WLine.cxx +++ b/src/IntPatch/IntPatch_WLine.cxx @@ -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 index 0000000000..0811f01031 --- /dev/null +++ b/tests/bugs/modalg_6/bug28626_1 @@ -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 index 0000000000..a0aadb504a --- /dev/null +++ b/tests/bugs/modalg_6/bug28626_2 @@ -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 index 0000000000..c207d42850 --- /dev/null +++ b/tests/bugs/modalg_6/bug28626_3 @@ -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