]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Fix computation height of isocel triangle with base equal zero : NaN
authorNATHALIE GORE <ng13417n@dsp1077169.postes.calibre.edf.fr>
Fri, 15 Dec 2023 07:20:15 +0000 (08:20 +0100)
committerNATHALIE GORE <ng13417n@dsp1077169.postes.calibre.edf.fr>
Fri, 15 Dec 2023 07:20:15 +0000 (08:20 +0100)
src/INTERP_KERNEL/VolSurfUser.txx

index 5ba8d86e3f2c67a0166e2ab9affeca1cc70ff475..bf370ff3ab7e09833c8a908f40217364445e8340 100644 (file)
@@ -439,12 +439,19 @@ namespace INTERP_KERNEL
   template<int SPACEDIM>
   void ComputeTriangleHeight(const double *PA, const double *PB, const double *PC, double *res)
   {
-    double AB = getDistanceBtw2Pts<SPACEDIM>(PA,PB);
-    double BC = getDistanceBtw2Pts<SPACEDIM>(PB,PC);
-    double CA = getDistanceBtw2Pts<SPACEDIM>(PC,PA);
+    constexpr double EPS = 1e-12;
+    double AB = getDistanceBtw2Pts<SPACEDIM>(PA,PB); double maxLength = AB;
+    double BC = getDistanceBtw2Pts<SPACEDIM>(PB,PC); if (BC > maxLength) maxLength = BC;
+    double CA = getDistanceBtw2Pts<SPACEDIM>(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;
   }
 }