0025898: Wrong result obtained by intersection algorithm.
authornbv <nbv@opencascade.com>
Thu, 19 Mar 2015 12:45:54 +0000 (15:45 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 19 Mar 2015 12:46:32 +0000 (15:46 +0300)
The reason of the exception has been eliminated.

Test case for issue CR25898

src/IntWalk/IntWalk_PWalking.cxx
tests/bugs/modalg_5/bug25898 [new file with mode: 0755]

index 2081798..539b1ee 100644 (file)
@@ -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(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 (Abs(PrevToParamOnS1.Angle(PrevToCurOnS1)) > MaxAngle &&
-                            Abs(PrevToParamOnS2.Angle(PrevToCurOnS2)) > MaxAngle)
+                          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 (executable)
index 0000000..c19f776
--- /dev/null
@@ -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