From d75aa7f81d8c979912ab879382f4bba02b4394ce Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 12 Sep 2009 09:06:40 +0000
Subject: [PATCH] avoid numerical errors on min/max in getScaleValue

---
 CMakeLists.txt        | 4 ++--
 Post/PViewOptions.cpp | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96dced7179..9fda9a6f62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -398,8 +398,8 @@ if(ENABLE_METIS)
   add_subdirectory(contrib/Metis)
   set(HAVE_METIS TRUE)
   list(APPEND CONFIG_OPTIONS "Metis")
-  message("WARNING: By including Metis you have to comply with Metis' "
-          "special licensing requirements stated in contrib/Metis/README.")
+  message("WARNING: By including Metis you have to comply with Metis' special "
+          "licensing requirements stated in contrib/Metis/README.txt.")
 endif(ENABLE_METIS)
 
 if(ENABLE_NETGEN)
diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp
index 5641fef800..245b5f58a7 100644
--- a/Post/PViewOptions.cpp
+++ b/Post/PViewOptions.cpp
@@ -28,7 +28,12 @@ double PViewOptions::getScaleValue(int iso, int numIso, double min, double max)
   if(numIso == 1) return (min + max) / 2.;
   
   if(scaleType == Linear){
-    return min + iso * (max - min) / (numIso - 1.);
+    // treat min/max separately to avoid numerical errors (important
+    // not to miss first/last discrete iso on piece-wise constant
+    // datasets)
+    if(iso == 0) return min;
+    else if(iso == numIso - 1) return max;
+    else return min + iso * (max - min) / (numIso - 1.);
   }
   else if(scaleType == Logarithmic){
     // should translate scale instead, with smallest val an option!
-- 
GitLab