diff --git a/src/IntWalk/IntWalk_PWalking.cxx b/src/IntWalk/IntWalk_PWalking.cxx index 208179835e..539b1ee2c4 100644 --- a/src/IntWalk/IntWalk_PWalking.cxx +++ b/src/IntWalk/IntWalk_PWalking.cxx @@ -1374,6 +1374,9 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, if (previoustg) { + //There are three consecutive points: + //previousPointSave -> ParamPnt -> curPnt. + Standard_Real prevU1, prevV1, prevU2, prevV2; previousPointSave.Parameters(prevU1, prevV1, prevU2, prevV2); gp_Pnt2d prevPntOnS1(prevU1, prevV1), prevPntOnS2(prevU2, prevV2); @@ -1383,9 +1386,49 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, gp_Vec2d PrevToParamOnS2(prevPntOnS2, ParamPntOnS2); gp_Vec2d PrevToCurOnS2(prevPntOnS2, curPntOnS2); Standard_Real MaxAngle = 3*M_PI/4; + Standard_Real anAngleS1 = 0.0, anAngleS2 = 0.0; + const Standard_Real aSQMParS1 = PrevToParamOnS1.SquareMagnitude(); + const Standard_Real aSQMParS2 = PrevToParamOnS2.SquareMagnitude(); + const Standard_Real aSQMCurS1 = PrevToCurOnS1.SquareMagnitude(); + const Standard_Real aSQMCurS2 = PrevToCurOnS2.SquareMagnitude(); - if (Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)) > MaxAngle && - Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle) + if(aSQMCurS1 < gp::Resolution()) + { + //We came back to the one of previos point. + //Therefore, we must break; + + anAngleS1 = M_PI; + } + else if(aSQMParS1 < gp::Resolution()) + { + //We are walking along tangent zone. + //It should be continued. + anAngleS1 = 0.0; + } + else + { + anAngleS1 = Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)); + } + + if(aSQMCurS2 < gp::Resolution()) + { + //We came back to the one of previos point. + //Therefore, we must break; + + anAngleS2 = M_PI; + } + else if(aSQMParS2 < gp::Resolution()) + { + //We are walking along tangent zone. + //It should be continued; + anAngleS2 = 0.0; + } + else + { + anAngleS2 = Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)); + } + + if ((anAngleS1 > MaxAngle) && (anAngleS2 > MaxAngle)) { Arrive = Standard_True; break; diff --git a/tests/bugs/modalg_5/bug25898 b/tests/bugs/modalg_5/bug25898 new file mode 100755 index 0000000000..c19f776465 --- /dev/null +++ b/tests/bugs/modalg_5/bug25898 @@ -0,0 +1,25 @@ +puts "================" +puts "OCC25898" +puts "================" +puts "" +####################################################################### +# Wrong result obtained by intersection algorithm. +####################################################################### + +# Before fix intersection algorithm threw an exception. + +restore [locate_data_file bug25898_x001_1.draw] s1 +restore [locate_data_file bug25898_x001_2.draw] s2 + +set CurveNumb [intersect i s1 s2] + +if { [llength ${CurveNumb}] != 2 } { + puts "Error : Wrong result obtained by intersection algorithm." +} else { + puts "OK : Good result obtained by intersection algorithm." +} + +smallview +fit + +set only_screen_axo 1