Commit 820fdea1 authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot

Merge topic 'log-lookup-nan'

f891d5d7 Check for NaN when using a log scale with vtkLookupTable
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1998
parents 7d8ec887 f891d5d7
Pipeline #27495 running with stage
in 0 seconds
......@@ -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