From: NATHALIE GORE Date: Fri, 15 Dec 2023 07:20:15 +0000 (+0100) Subject: Fix computation height of isocel triangle with base equal zero : NaN X-Git-Tag: V9_13_0a1~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=662a2a2393a25baef77e42f74204b11b70a9646c;p=tools%2Fmedcoupling.git Fix computation height of isocel triangle with base equal zero : NaN --- diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx index 5ba8d86e3..bf370ff3a 100644 --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ b/src/INTERP_KERNEL/VolSurfUser.txx @@ -439,12 +439,19 @@ namespace INTERP_KERNEL template void ComputeTriangleHeight(const double *PA, const double *PB, const double *PC, double *res) { - double AB = getDistanceBtw2Pts(PA,PB); - double BC = getDistanceBtw2Pts(PB,PC); - double CA = getDistanceBtw2Pts(PC,PA); + constexpr double EPS = 1e-12; + double AB = getDistanceBtw2Pts(PA,PB); double maxLength = AB; + double BC = getDistanceBtw2Pts(PB,PC); if (BC > maxLength) maxLength = BC; + double CA = getDistanceBtw2Pts(PC,PA); if (CA > maxLength) maxLength = CA; double perim( (AB+BC+CA)*0.5 ); double num( 2*sqrt(perim*(perim-AB)*(perim-BC)*(perim-CA)) ); res[0] = num/AB; res[1] = num/BC; res[2] = num/CA; + if (AB/maxLength <= EPS) + res[0] = BC; + if (BC/maxLength <= EPS) + res[1] = CA; + if (CA/maxLength <= EPS) + res[3] = AB; } }