mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-25 17:00:34 +05:00
PAL10173. Protect computeParamByFunc() against divisionby zero when f(0)=0 and against infinite loop
This commit is contained in:
parent
773894ff04
commit
2df8c2d513
@ -426,6 +426,11 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
|
|||||||
{
|
{
|
||||||
if (!func.IsReady())
|
if (!func.IsReady())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// ########## TMP until pb division by zero when func(0.0)==0 is fixed #########
|
||||||
|
if (::Abs(func(0.0)) <= ::RealSmall() ) return false;
|
||||||
|
// ########## TMP until pb division by zero when func(0.0)==0 is fixed #########
|
||||||
|
|
||||||
vector<double> xxx[2];
|
vector<double> xxx[2];
|
||||||
int nbPnt = 1 + nbSeg;
|
int nbPnt = 1 + nbSeg;
|
||||||
int rev, i;
|
int rev, i;
|
||||||
@ -465,6 +470,8 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
|
|||||||
// Decrease x1 ...
|
// Decrease x1 ...
|
||||||
x1_too_large = x1;
|
x1_too_large = x1;
|
||||||
x1 = (x1_too_small+x1_too_large)/2;
|
x1 = (x1_too_small+x1_too_large)/2;
|
||||||
|
if ( x1 <= ::RealSmall() )
|
||||||
|
return false; // break infinite loop
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +523,7 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last,
|
|||||||
return false;
|
return false;
|
||||||
prevU = U;
|
prevU = U;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user