From 3551d209732b6f7bc098181a12653775f059abe4 Mon Sep 17 00:00:00 2001 From: ifv Date: Tue, 21 Feb 2017 17:38:52 +0300 Subject: [PATCH] 0028458: Some faces are missing when loading a specific CAD. This is a regression from OCCT 7.0 and Express Mesh 7.0. Function ACos and ASin are modified to avoid exception when argument is +-(1. + Epsilon(1.)) because of "numerical noise" Conflicts: src/Standard/Standard_Real.cxx --- src/Standard/Standard_Real.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Standard/Standard_Real.cxx b/src/Standard/Standard_Real.cxx index b587af4f82..7c03f07d0a 100644 --- a/src/Standard/Standard_Real.cxx +++ b/src/Standard/Standard_Real.cxx @@ -20,6 +20,8 @@ #include #include +static const Standard_Real ACosLimit = 1. + Epsilon(1.); + // ------------------------------------------------------------------ // Hascode : Computes a hascoding value for a given real // ------------------------------------------------------------------ @@ -44,9 +46,17 @@ Standard_Integer HashCode(const Standard_Real me, const Standard_Integer Upper) //------------------------------------------------------------------- Standard_Real ACos (const Standard_Real Value) { - if ( (Value < -1.) || (Value > 1.) ){ + if ((Value < -ACosLimit) || (Value > ACosLimit)){ Standard_RangeError::Raise(); } + else if (Value > 1.) + { + return 0.; //acos(1.) + } + else if (Value < -1.) + { + return M_PI; //acos(-1.) + } return acos(Value); } @@ -94,9 +104,17 @@ Standard_Real ACosApprox (const Standard_Real Value) //------------------------------------------------------------------- Standard_Real ASin (const Standard_Real Value) { - if ( Value < -1 || Value > 1 ){ + if ((Value < -ACosLimit) || (Value > ACosLimit)){ Standard_RangeError::Raise(); } + else if (Value > 1.) + { + return M_PI_2; //asin(1.) + } + else if (Value < -1.) + { + return -M_PI_2; //asin(-1.) + } return asin(Value); } -- 2.39.5