LookupTable: Shift computed idx by 1

The below range value is at index 0 and the actual table begins fron
index 1.
This commit is contained in:
Sujin Philip 2023-08-15 16:07:11 -04:00
parent c79bb5b07b
commit e734f14b88
3 changed files with 12 additions and 12 deletions

@ -466,14 +466,14 @@ void TestLookupTable()
const bool ran = vtkm::cont::ColorTableMap(field, samples, colors);
VTKM_TEST_ASSERT(ran, "color table failed to execute");
//values confirmed with ParaView 5.4
//values confirmed with ParaView 5.11
CheckColors(colors,
{ { 0, 0, 255 },
{ 59, 76, 192 },
{ 122, 157, 248 },
{ 191, 211, 246 },
{ 241, 204, 184 },
{ 238, 134, 105 },
{ 124, 159, 249 },
{ 192, 212, 245 },
{ 242, 203, 183 },
{ 238, 133, 104 },
{ 180, 4, 38 },
{ 255, 0, 0 } });
}

@ -42,10 +42,10 @@ void TestFieldToColors()
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> resultRGBAHandle;
Result.GetData().AsArrayHandle(resultRGBAHandle);
//values confirmed with ParaView 5.4
//values confirmed with ParaView 5.11
const vtkm::Vec4ui_8 correct_diverging_rgba_values[nvals] = {
{ 0, 0, 255, 255 }, { 59, 76, 192, 255 }, { 122, 157, 248, 255 }, { 191, 211, 246, 255 },
{ 241, 204, 184, 255 }, { 238, 134, 105, 255 }, { 180, 4, 38, 255 }, { 255, 0, 0, 255 }
{ 0, 0, 255, 255 }, { 59, 76, 192, 255 }, { 124, 159, 249, 255 }, { 192, 212, 245, 255 },
{ 242, 203, 183, 255 }, { 238, 133, 104, 255 }, { 180, 4, 38, 255 }, { 255, 0, 0, 255 }
};
auto portalRGBA = resultRGBAHandle.ReadPortal();
for (std::size_t i = 0; i < nvals; ++i)
@ -63,10 +63,10 @@ void TestFieldToColors()
vtkm::cont::ArrayHandle<vtkm::Vec3ui_8> resultRGBHandle;
Result.GetData().AsArrayHandle(resultRGBHandle);
//values confirmed with ParaView 5.4
//values confirmed with ParaView 5.11
const vtkm::Vec3ui_8 correct_diverging_rgb_values[nvals] = { { 0, 0, 255 }, { 59, 76, 192 },
{ 122, 157, 248 }, { 191, 211, 246 },
{ 241, 204, 184 }, { 238, 134, 105 },
{ 124, 159, 249 }, { 192, 212, 245 },
{ 242, 203, 183 }, { 238, 133, 104 },
{ 180, 4, 38 }, { 255, 0, 0 } };
auto portalRGB = resultRGBHandle.ReadPortal();
for (std::size_t i = 0; i < nvals; ++i)

@ -94,7 +94,7 @@ struct LookupTable : public vtkm::worklet::WorkletMapField
// When v is very close to p.Range[1], the floating point calculation giving
// idx may map above the highest value in the lookup table. That is why it
// is padded
idx = static_cast<vtkm::Int32>(v);
idx = 1 + static_cast<vtkm::Int32>(v);
}
output = lookupTable.Get(idx);
}