From e93e42300aa8561f6566e7f60a1f751c94fda427 Mon Sep 17 00:00:00 2001 From: aml Date: Thu, 9 Jul 2015 14:12:21 +0300 Subject: [PATCH] 0026356: Wrong result done by projection algorithm Changed internal one dimension search algorithm in case of fast changing curve. Test-case for issue #26356 --- src/math/math_FunctionSetRoot.cxx | 68 +++++++++++++++++++++++-------- tests/bugs/modalg_6/bug26356 | 37 +++++++++++++++++ 2 files changed, 88 insertions(+), 17 deletions(-) create mode 100644 tests/bugs/modalg_6/bug26356 diff --git a/src/math/math_FunctionSetRoot.cxx b/src/math/math_FunctionSetRoot.cxx index a57b5177b2..03510af9e4 100644 --- a/src/math/math_FunctionSetRoot.cxx +++ b/src/math/math_FunctionSetRoot.cxx @@ -125,18 +125,16 @@ Standard_Boolean MyDirFunction::Value(const Standard_Real x, p = Dir->Value(i); P->Value(i) = p * x + P0->Value(i); } - if( F->Value(*P, *FV) ) { + if( F->Value(*P, *FV) ) + { - Standard_Real aVal = 0.; + Standard_Real aVal = 0.0; - for(Standard_Integer i = FV->Lower(); i <= FV->Upper(); i++) { + for(Standard_Integer i = FV->Lower(); i <= FV->Upper(); i++) + { aVal = FV->Value(i); - if(aVal < 0.) { - if(aVal <= -1.e+100) // Precision::HalfInfinite() later - // if(Precision::IsInfinite(Abs(FV->Value(i)))) { - // fval = Precision::Infinite(); - return Standard_False; - } + if(aVal <= -1.e+100) // Precision::HalfInfinite() later + return Standard_False; else if(aVal >= 1.e+100) // Precision::HalfInfinite() later return Standard_False; } @@ -317,7 +315,8 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P, // (2) Si l'on a pas assez progresser on realise une recherche // en bonne et due forme, a partir des inits precedents - if ((fsol > 0.2*PValue) && (tol1d < 0.5)) { + if ((fsol > 0.2*PValue) && (tol1d < 0.5)) + { if (tsol <0) { ax = tsol; bx = 0.0; cx = 1.0; @@ -328,17 +327,52 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P, FSR_DEBUG(" minimisation dans la direction"); math_BrentMinimum Sol(tol1d, 100, tol1d); - Sol.Perform(F, ax, bx, cx); - if(Sol.IsDone()) { - if (Sol.Minimum() <= Result) { + // Base invocation. + Sol.Perform(F, ax, bx, cx); + if(Sol.IsDone()) + { + if (Sol.Minimum() <= Result) + { tsol = Sol.Location(); good = Standard_True; - FSR_DEBUG("t= "<