0026484: BRepExtrema_DistShapeShape hangs
[occt.git] / src / math / math_GlobOptMin.cxx
index 57dd45f..7261b63 100644 (file)
@@ -407,11 +407,17 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
   math_Vector aStepBestPoint(1, myN);
   Standard_Boolean isInside = Standard_False;
   Standard_Real r;
   math_Vector aStepBestPoint(1, myN);
   Standard_Boolean isInside = Standard_False;
   Standard_Real r;
+  Standard_Boolean isReached = Standard_False;
 
 
-  for(myX(j) = myA(j) + myE1; myX(j) < myB(j) + myE1; myX(j) += myV(j))
+  for(myX(j) = myA(j) + myE1; 
+     (myX(j) < myB(j) + myE1) && (!isReached);
+      myX(j) += myV(j))
   {
     if (myX(j) > myB(j))
   {
     if (myX(j) > myB(j))
+    {
       myX(j) = myB(j);
       myX(j) = myB(j);
+      isReached = Standard_True;
+    }
 
     if (j == 1)
     {
 
     if (j == 1)
     {