From: eap Date: Tue, 15 Nov 2005 08:53:15 +0000 (+0000) Subject: PAL10173. Protect computeParamByFunc() against divisionby zero when f(0)=0 and agains... X-Git-Tag: V3_1_0a3~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2df8c2d513211f05f5bd9660db2ff768daa3e1ba;p=modules%2Fsmesh.git PAL10173. Protect computeParamByFunc() against divisionby zero when f(0)=0 and against infinite loop --- diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index 2bdf91da9..c9765f039 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -426,6 +426,11 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last, { if (!func.IsReady()) 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 xxx[2]; int nbPnt = 1 + nbSeg; int rev, i; @@ -465,6 +470,8 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last, // Decrease x1 ... x1_too_large = x1; x1 = (x1_too_small+x1_too_large)/2; + if ( x1 <= ::RealSmall() ) + return false; // break infinite loop continue; } @@ -516,7 +523,7 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d, double first, double last, return false; prevU = U; } - return false; + return true; } //=============================================================================