Skip to content
Snippets Groups Projects
Commit d75aa7f8 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

avoid numerical errors on min/max in getScaleValue

parent c21803e7
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment