0027026: Modeling -- Improve AppCont_LeastSquare::AppCont_LeastSquare::FixSingleBorde...
authorabv <abv@opencascade.com>
Mon, 21 Dec 2015 15:46:58 +0000 (18:46 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 23 Dec 2015 09:22:16 +0000 (12:22 +0300)
Update of test-cases according to the new behavior

src/AppCont/AppCont_LeastSquare.cxx
tests/bugs/modalg_6/bug26576_1
tests/bugs/modalg_6/bug26576_3

index 92c18eb..d44d555 100644 (file)
@@ -24,6 +24,7 @@
 #include <AppParCurves_MultiPoint.hxx>
 #include <AppCont_ContMatrices.hxx>
 #include <PLib.hxx>
+#include <Precision.hxx>
 
 
 //=======================================================================
@@ -37,21 +38,25 @@ void AppCont_LeastSquare::FixSingleBorderPoint(const AppCont_Function&       the
                                                NCollection_Array1<gp_Pnt2d>& theFix2d,
                                                NCollection_Array1<gp_Pnt>&   theFix)
 {
-  Standard_Real aMaxIter = 15.0;
+  Standard_Integer aMaxIter = 15;
   Standard_Integer j, i2;
   NCollection_Array1<gp_Pnt>   aTabP(1, Max (myNbP, 1)),     aPrevP(1, Max (myNbP, 1));
   NCollection_Array1<gp_Pnt2d> aTabP2d(1,  Max (myNbP2d, 1)), aPrevP2d(1,  Max (myNbP2d, 1));
   Standard_Real aMult = ((theU - theU0) > (theU1 - theU)) ? 1.0: -1.0;
-  Standard_Real aStartParam = (theU0 + theU1) / 2.0,
+  Standard_Real aStartParam = theU,
                 aCurrParam, aPrevDist = 1.0, aCurrDist = 1.0;
 
-  for (Standard_Real anIter = 1.0; anIter < aMaxIter; anIter += 1.0)
+  Standard_Real du = -(theU1 - theU0) / 2.0 * aMult;
+  Standard_Real eps = Epsilon(1.);
+  Standard_Real dd = du, dec = .1;
+  for (Standard_Integer anIter = 1; anIter < aMaxIter; anIter++)
   {
-    aCurrParam = aStartParam + aMult * (1 - pow(10, -anIter)) * (theU1 - theU0) / 2.0;
+    dd *=  dec;
+    aCurrParam = aStartParam + dd;
     theSSP.Value(aCurrParam, aTabP2d, aTabP);
 
     // from second iteration
-    if (anIter > 1.5)
+    if (anIter > 1)
     {
       aCurrDist = 0.0;
 
@@ -68,12 +73,14 @@ void AppCont_LeastSquare::FixSingleBorderPoint(const AppCont_Function&       the
       }
 
       // from the third iteration
-      if (anIter > 2.5 && aCurrDist / aPrevDist > 10.0)
+      if (anIter > 2 && aCurrDist / aPrevDist > 10.0)
         break;
     }
     aPrevP = aTabP;
     aPrevP2d = aTabP2d;
     aPrevDist = aCurrDist;
+    if(aPrevDist <= eps)
+      break;
   }
   theFix2d = aPrevP2d;
   theFix   = aPrevP;
index a85e65d..2ea4e23 100644 (file)
@@ -26,7 +26,7 @@ regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Tolerance_
 
 set GoodNbCurv 2
 
-set expected_Tolerance_Reached 2.4466119525954045e-008
+set expected_Tolerance_Reached 1.2482990218170969e-007
 set tol_abs_Tolerance_Reached 1.0e-7
 set tol_rel_Tolerance_Reached 0.0
 checkreal "Tolerance Reached" ${Tolerance_Reached} ${expected_Tolerance_Reached} ${tol_abs_Tolerance_Reached} ${tol_rel_Tolerance_Reached}
index 936519d..feb3178 100644 (file)
@@ -31,7 +31,7 @@ regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Tolerance_
 
 set GoodNbCurv 2
 
-set expected_Tolerance_Reached 2.4466119525954045e-008
+set expected_Tolerance_Reached 1.2482990218170969e-007
 set tol_abs_Tolerance_Reached 1.0e-7
 set tol_rel_Tolerance_Reached 0.0
 checkreal "Tolerance Reached" ${Tolerance_Reached} ${expected_Tolerance_Reached} ${tol_abs_Tolerance_Reached} ${tol_rel_Tolerance_Reached}