]> OCCT Git - occt-copy.git/commitdiff
0028856: Extrema between two curves gives wrong result
authorifv <ifv@opencascade.com>
Thu, 15 Jun 2017 08:53:29 +0000 (11:53 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 13 Jul 2017 14:29:42 +0000 (17:29 +0300)
Treatment for large Lipschitz constant is added
Test case is added

src/Extrema/Extrema_GenExtCC.gxx
src/math/math_GlobOptMin.cxx
tests/bugs/modalg_7/bug28856 [new file with mode: 0644]

index a03e33d116a549e3b1b58c92119845ee5647055c..250f610c1500c34aca10f813873bc98301dda1c8 100644 (file)
@@ -211,6 +211,7 @@ void Extrema_GenExtCC::Perform()
   C2.Intervals(anIntervals2, aContinuity);
 
   // Lipchitz constant computation.
+  const Standard_Real aMaxLC = 10000.;
   Standard_Real aLC = 9.0; // Default value.
   const Standard_Real aMaxDer1 = 1.0 / C1.Resolution(1.0);
   const Standard_Real aMaxDer2 = 1.0 / C2.Resolution(1.0);
@@ -226,6 +227,11 @@ void Extrema_GenExtCC::Perform()
   {
     isConstLockedFlag = Standard_True;
   }
+  if (aMaxDer > aMaxLC)
+  {
+    aLC = aMaxLC;
+    isConstLockedFlag = Standard_True;
+  }
   if (C1.GetType() == GeomAbs_Line)
   {
     aMaxDer = 1.0 / C2.Resolution(1.0);
index ace855134a44448c55baebfb0914f7082b97a972..15107354c23afaf490e9a803d1115d10fb26198b 100644 (file)
@@ -343,6 +343,10 @@ Standard_Boolean math_GlobOptMin::computeLocalExtremum(const math_Vector& thePnt
 //=======================================================================
 void math_GlobOptMin::computeInitialValues()
 {
+  const Standard_Real aMinLC = 0.01;
+  const Standard_Real aMaxLC = 1000.;
+  const Standard_Real aMinEps = 0.1;
+  const Standard_Real aMaxEps = 100.;
   Standard_Integer i;
   math_Vector aCurrPnt(1, myN);
   math_Vector aBestPnt(1, myN);
@@ -374,10 +378,10 @@ void math_GlobOptMin::computeInitialValues()
 
   myC = myInitC;
   aLipConst *= Sqrt(myN) / aStep;
-  if (aLipConst < myC * 0.1)
-    myC = Max(aLipConst * 0.1, 0.01);
-  else if (aLipConst > myC * 5)
-    myC = Min(myC * 5, 50.0);
+  if (aLipConst < myC * aMinEps)
+    myC = Max(aLipConst * aMinEps, aMinLC);
+  else if (aLipConst > myC * aMaxEps)
+    myC = Min(myC * aMaxEps, aMaxLC);
 
   // Clear all solutions except one.
   if (myY.Size() != myN)
diff --git a/tests/bugs/modalg_7/bug28856 b/tests/bugs/modalg_7/bug28856
new file mode 100644 (file)
index 0000000..29a1c61
--- /dev/null
@@ -0,0 +1,13 @@
+puts "========"
+puts "OCC28856"
+puts "========"
+puts ""
+########################################
+#  Extrema between two curves gives wrong result
+########################################
+
+# Restore the initial shape
+restore [locate_data_file bug28856_shapes.brep] e
+explode e
+distmini dd e_1 e_2
+checkprops dd -l 0.101881