Commit f891d5d7 authored by David Gobbi's avatar David Gobbi

Check for NaN when using a log scale with vtkLookupTable

The NaN check was only done for the linear scale, the log scale missed
the check, and NaN would be displayed in the BelowRangeColor instead of
the NanColor.  For performance reasons, the NaN check is only performed
on floating-point values, not on integer values.
parent bace0bcf
Pipeline #27475 passed with stage
......@@ -166,6 +166,7 @@ int TestLookupTable(int,char *[])
TestAssert(table->GetIndex(hi) == 255);
TestAssert(table->GetIndex(lo+tol) == 0);
TestAssert(table->GetIndex(hi-tol) == 255);
TestAssert(table->GetIndex(vtkMath::Nan()) == -1);
// Note - both below- and above-range colors are enabled at this point
TestAssert(table->GetIndex(lo/step) == 0);
......
......@@ -415,8 +415,8 @@ inline void vtkLookupTableLogRange(const double range[2], double logRange[2])
//----------------------------------------------------------------------------
// Apply log to value, with appropriate constraints.
inline double vtkApplyLogScale(double v, const double range[2],
const double logRange[2])
static double vtkApplyLogScaleMain(double v, const double range[2],
const double logRange[2])
{
// is the range set for negative numbers?
if (range[0] < 0)
......@@ -452,6 +452,40 @@ inline double vtkApplyLogScale(double v, const double range[2],
return v;
}
//----------------------------------------------------------------------------
template<class T>
double vtkApplyLogScale(T v, const double range[2],
const double logRange[2])
{
return vtkApplyLogScaleMain(v, range, logRange);
}
//----------------------------------------------------------------------------
// Apply log to a float value (NaN values pass through)
inline double vtkApplyLogScale(float v, const double range[2],
const double logRange[2])
{
if (vtkMath::IsNan(v))
{
return v;
}
return vtkApplyLogScaleMain(v, range, logRange);
}
//----------------------------------------------------------------------------
// Apply log to a double value (NaN values pass through)
inline double vtkApplyLogScale(double v, const double range[2],
const double logRange[2])
{
if (vtkMath::IsNan(v))
{
return v;
}
return vtkApplyLogScaleMain(v, range, logRange);
}
//----------------------------------------------------------------------------
// Data structure for passing data around various internal functions
struct TableParameters {
......
4fabbc42a15ea77fd8bfa7a0c4546b05
99e7c509f50c6593cdbb3727621a38d9
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment