From cbf6b8707467d62b76159bd6fbd9ec64dd089a48 Mon Sep 17 00:00:00 2001 From: msv Date: Tue, 27 Dec 2022 22:19:11 +0300 Subject: [PATCH] 0033304: Modeling Data - Floating point signal when converting a B-spline curve to analytical form Protect the static function ConicDefinition from calling sqrt with negative argument. --- src/GeomConvert/GeomConvert_CurveToAnaCurve.cxx | 6 ++++++ tests/bugs/moddata_3/bug33304 | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/bugs/moddata_3/bug33304 diff --git a/src/GeomConvert/GeomConvert_CurveToAnaCurve.cxx b/src/GeomConvert/GeomConvert_CurveToAnaCurve.cxx index 8e135e1edb..3038e88dfa 100644 --- a/src/GeomConvert/GeomConvert_CurveToAnaCurve.cxx +++ b/src/GeomConvert/GeomConvert_CurveToAnaCurve.cxx @@ -429,6 +429,8 @@ static Standard_Boolean ConicDefinition term2 = -gdet/(cprim*pdet); if (IsEllip) { + if (term1 <= eps || term2 <= eps) + return Standard_False; Xax = cost; Yax = sint; Rmin = sqrt ( term1); @@ -439,12 +441,16 @@ static Standard_Boolean ConicDefinition } } else if (term1 <= eps){ + if (-term1 <= eps || term2 <= eps) + return Standard_False; Xax = -sint; Yax = cost; Rmin = sqrt (-term1); Rmax = sqrt (term2); } else { + if (term1 <= eps || -term2 <= eps) + return Standard_False; Xax = cost; Yax = sint; Rmin = sqrt (-term2); diff --git a/tests/bugs/moddata_3/bug33304 b/tests/bugs/moddata_3/bug33304 new file mode 100644 index 0000000000..ba6e514743 --- /dev/null +++ b/tests/bugs/moddata_3/bug33304 @@ -0,0 +1,9 @@ +puts "===========================================================" +puts "0033304: Modeling Data - Floating point signal when converting a B-spline curve to analytical form" +puts "===========================================================" + +puts "REQUIRED ALL: Conversion failed" + +binrestore [locate_data_file bug33304_bspl_curv.bbrep] a +mkcurve c a +tocanon r c