Commit 13aa55ca authored by Cory Quammen's avatar Cory Quammen

BUG: Direct scalar coloring with string arrays caused crash

Fixed logic to handle when coloring mode is direct scalar mode and a
vtkStringArray is being mapped. In this case, you can't use the
scalars directly, so the string values are mapped instead.
parent f97acaa8
......@@ -239,7 +239,7 @@ vtkUnsignedCharArray *vtkScalarsToColors::MapScalars(vtkAbstractArray *scalars,
// map scalars through lookup table only if needed
if ((colorMode == VTK_COLOR_MODE_DEFAULT &&
vtkUnsignedCharArray::SafeDownCast(dataArray) != NULL) ||
colorMode == VTK_COLOR_MODE_DIRECT_SCALARS)
(colorMode == VTK_COLOR_MODE_DIRECT_SCALARS && dataArray))
{
newColors = this->
ConvertToRGBA(dataArray, scalars->GetNumberOfComponents(),
......
......@@ -66,6 +66,11 @@ int TestColorByStringArrayDefaultLookupTable(int argc, char* argv[])
mapper->SetScalarModeToUseCellFieldData();
mapper->SelectColorArray(arrayName);
// Direct coloring shouldn't be possible with string arrays, so we
// enable direct scalars to test that the string arrays get mapped
// despite the color mode setting being direct scalars.
mapper->SetColorModeToDirectScalars();
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
......
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