Commit 94498364 authored by Cory Quammen's avatar Cory Quammen

Enable coloring by indexed lookup for vtkStringArrays

This change makes it possible to map vtkStringArrays to colors using
indexed lookup mode. The vtkStringArrays may be associated with
points, cells, or neither (field data). A slew of changes were
required to give this capability:

- Changed signature of vtkScalarsToColors::MapScalars(...) and
  vtkDiscretizableColorTransferFunction::MapScalars(...)  to take a
  vtkAbstractArray instead of a vtkDataArray. This enables mapping
  non-vtkDataArray arrays, such as vtkStringArrays. These changes are
  backwards compatible because vtkAbstractArray is the parent class of
  vtkDataArray.

- Changed vtkLookupTable::MapScalarsThroughTable2(...) to handle
  vtkStringArrays.

- Changed vtkColorTransferFunction::MapScalarsThroughTable2(...) to handle
  vtkStringArrays.

- Added vtkAbstractMapper::GetAbstractScalars(...) that returns a data
  array as a vtkAbstractArray - needed to retrieve vtkStringArray
  scalars.

- Added some error reporting when unhandled array type is encountered
  in vtkScalarsToColors::MapScalarsThroughTable2.

- Enabled use of vtkStringArrays for coloring in the surface mappers.

- Added some tests for mapping vtkStringArrays with
  vtkColorTransferFunction and vtkDiscretizableColorTransferFunction.

- Added some tests for coloring objects by vtkStringArrays in cell data
  and point data.

- Added logic to vtkMapper and vtkPolyDataMapper2D that generates a
  reasonable default lookup table when a vtkStringArray or other
  non-numeric array is selected for coloring by scalars. This requires
  making the vtkRenderingCore module depend on vtkCommonColor. Added
  tests for this feature.

Change-Id: I91e2e451217139a7daabd7f4a63de0b8ff707ad4
parent a07731a2
......@@ -1130,8 +1130,14 @@ void vtkLookupTable::MapScalarsThroughTable2(void *input,
vtkLookupTableIndexedMapData(this,static_cast<VTK_TT*>(input),output,
numberOfValues,inputIncrement,outputFormat)
);
case VTK_STRING:
vtkLookupTableIndexedMapData(this,static_cast<vtkStdString*>(input),output,
numberOfValues,inputIncrement,outputFormat);
break;
default:
vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input ScalarType");
return;
}
}
......@@ -1167,7 +1173,7 @@ void vtkLookupTable::MapScalarsThroughTable2(void *input,
numberOfValues, inputIncrement, outputFormat, p)
);
default:
vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input ScalarType");
return;
}
}
......
......@@ -221,20 +221,22 @@ unsigned char *vtkScalarsToColors::MapValue(double v)
}
//----------------------------------------------------------------------------
vtkUnsignedCharArray *vtkScalarsToColors::MapScalars(vtkDataArray *scalars,
vtkUnsignedCharArray *vtkScalarsToColors::MapScalars(vtkAbstractArray *scalars,
int colorMode, int component)
{
int numberOfComponents = scalars->GetNumberOfComponents();
vtkUnsignedCharArray *newColors;
vtkDataArray *dataArray = vtkDataArray::SafeDownCast(scalars);
// map scalars through lookup table only if needed
if ((colorMode == VTK_COLOR_MODE_DEFAULT &&
vtkUnsignedCharArray::SafeDownCast(scalars) != NULL) ||
vtkUnsignedCharArray::SafeDownCast(dataArray) != NULL) ||
colorMode == VTK_COLOR_MODE_DIRECT_SCALARS)
{
newColors = this->
ConvertToRGBA(scalars, scalars->GetNumberOfComponents(),
scalars->GetNumberOfTuples());
ConvertToRGBA(dataArray, scalars->GetNumberOfComponents(),
dataArray->GetNumberOfTuples());
}
else
{
......@@ -1462,6 +1464,10 @@ void vtkScalarsToColors::MapScalarsThroughTable2(
vtkScalarsToColorsLuminanceToRGBA(
static_cast<VTK_TT*>(inPtr), outPtr,
numberOfTuples, numberOfComponents, shift, scale, alpha));
default:
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input data type");
break;
}
}
else if (outputFormat == VTK_RGB)
......@@ -1472,6 +1478,10 @@ void vtkScalarsToColors::MapScalarsThroughTable2(
vtkScalarsToColorsLuminanceToRGB(
static_cast<VTK_TT*>(inPtr), outPtr,
numberOfTuples, numberOfComponents, shift, scale));
default:
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input data type");
break;
}
}
else if (outputFormat == VTK_LUMINANCE_ALPHA)
......@@ -1482,6 +1492,10 @@ void vtkScalarsToColors::MapScalarsThroughTable2(
vtkScalarsToColorsLuminanceToLuminanceAlpha(
static_cast<VTK_TT*>(inPtr), outPtr,
numberOfTuples, numberOfComponents, shift, scale, alpha));
default:
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input data type");
break;
}
}
else if (outputFormat == VTK_LUMINANCE)
......@@ -1492,6 +1506,10 @@ void vtkScalarsToColors::MapScalarsThroughTable2(
vtkScalarsToColorsLuminanceToLuminance(
static_cast<VTK_TT*>(inPtr), outPtr,
numberOfTuples, numberOfComponents, shift, scale));
default:
vtkErrorMacro(<< "MapScalarsThroughTable2: Unknown input data type");
break;
}
}
}
......
......@@ -47,6 +47,7 @@
#include "vtkVariant.h" // Set/get annotation methods require variants.
#include "vtkObject.h"
class vtkAbstractArray;
class vtkDataArray;
class vtkUnsignedCharArray;
class vtkAbstractArray;
......@@ -131,7 +132,7 @@ public:
// to use to do the blending. When the component argument is -1,
// then the this object uses its own selected technique to change a
// vector into a scalar to map.
virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
virtual vtkUnsignedCharArray *MapScalars(vtkAbstractArray *scalars, int colorMode,
int component);
// Description:
......
......@@ -18,8 +18,14 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestBackfaceCulling.cxx
TestBareScalarsToColors.cxx
TestBlockOpacity.cxx
TestColorByCellDataStringArray.cxx
TestColorByPointDataStringArray.cxx
TestColorByStringArrayDefaultLookupTable.cxx
TestColorByStringArrayDefaultLookupTable2D.cxx
TestColorTransferFunctionStringArray.cxx,NO_VALID
TestDirectScalarsToColors.cxx
TestDiscretizableColorTransferFunction.cxx,NO_VALID
TestDiscretizableColorTransferFunctionStringArray.cxx,NO_VALID
TestEdgeFlags.cxx
TestFollowerPicking.cxx
TestGlyph3DMapper.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestColorByCellDataStringArray.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include <vtkActor.h>
#include <vtkCellData.h>
#include <vtkDiscretizableColorTransferFunction.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSphereSource.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
int TestColorByCellDataStringArray(int argc, char* argv[])
{
vtkNew<vtkSphereSource> sphere;
sphere->Update();
vtkNew<vtkPolyData> polydata;
polydata->ShallowCopy(sphere->GetOutput());
// Set up string array associated with cells
vtkNew<vtkStringArray> sArray;
sArray->SetName("color");
sArray->SetNumberOfComponents(1);
sArray->SetNumberOfTuples(polydata->GetNumberOfCells());
vtkVariant colors[5];
colors[0] = "red";
colors[1] = "blue";
colors[2] = "green";
colors[3] = "yellow";
colors[4] = "cyan";
// Round-robin assignment of color strings
for (int i = 0; i < polydata->GetNumberOfCells(); ++i)
{
sArray->SetValue(i, colors[i % 5].ToString());
}
vtkCellData* cd = polydata->GetCellData();
cd->AddArray(sArray.Get());
// Set up transfer function
vtkNew<vtkDiscretizableColorTransferFunction> tfer;
tfer->IndexedLookupOn();
tfer->SetNumberOfIndexedColors(5);
tfer->SetIndexedColor(0, 1.0, 0.0, 0.0);
tfer->SetIndexedColor(1, 0.0, 0.0, 1.0);
tfer->SetIndexedColor(2, 0.0, 1.0, 0.0);
tfer->SetIndexedColor(3, 1.0, 1.0, 0.0);
tfer->SetIndexedColor(4, 0.0, 1.0, 1.0);
vtkStdString red("red");
tfer->SetAnnotation(red, red);
vtkStdString blue("blue");
tfer->SetAnnotation(blue, blue);
vtkStdString green("green");
tfer->SetAnnotation(green, green);
vtkStdString yellow("yellow");
tfer->SetAnnotation(yellow, yellow);
vtkStdString cyan("cyan");
tfer->SetAnnotation(cyan, cyan);
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputDataObject(polydata.Get());
mapper->SetLookupTable(tfer.Get());
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUseCellFieldData();
mapper->SelectColorArray("color");
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.Get());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.Get());
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.Get());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestColorByPointDataStringArray.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include <vtkActor.h>
#include <vtkDiscretizableColorTransferFunction.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSphereSource.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
int TestColorByPointDataStringArray(int argc, char* argv[])
{
vtkNew<vtkSphereSource> sphere;
sphere->Update();
vtkNew<vtkPolyData> polydata;
polydata->ShallowCopy(sphere->GetOutput());
// Set up string array associated with cells
vtkNew<vtkStringArray> sArray;
sArray->SetName("color");
sArray->SetNumberOfComponents(1);
sArray->SetNumberOfTuples(polydata->GetNumberOfPoints());
vtkVariant colors[5];
colors[0] = "red";
colors[1] = "blue";
colors[2] = "green";
colors[3] = "yellow";
colors[4] = "cyan";
// Round-robin assignment of color strings
for (int i = 0; i < polydata->GetNumberOfPoints(); ++i)
{
sArray->SetValue(i, colors[i % 5].ToString());
}
vtkPointData* cd = polydata->GetPointData();
cd->AddArray(sArray.Get());
// Set up transfer function
vtkNew<vtkDiscretizableColorTransferFunction> tfer;
tfer->IndexedLookupOn();
tfer->SetNumberOfIndexedColors(5);
tfer->SetIndexedColor(0, 1.0, 0.0, 0.0);
tfer->SetIndexedColor(1, 0.0, 0.0, 1.0);
tfer->SetIndexedColor(2, 0.0, 1.0, 0.0);
tfer->SetIndexedColor(3, 1.0, 1.0, 0.0);
tfer->SetIndexedColor(4, 0.0, 1.0, 1.0);
vtkStdString red("red");
tfer->SetAnnotation(red, red);
vtkStdString blue("blue");
tfer->SetAnnotation(blue, blue);
vtkStdString green("green");
tfer->SetAnnotation(green, green);
vtkStdString yellow("yellow");
tfer->SetAnnotation(yellow, yellow);
vtkStdString cyan("cyan");
tfer->SetAnnotation(cyan, cyan);
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputDataObject(polydata.Get());
mapper->SetLookupTable(tfer.Get());
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUsePointFieldData();
mapper->SelectColorArray("color");
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.Get());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.Get());
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.Get());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestColorByStringArrayDefaultLookupTable.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include <vtkActor.h>
#include <vtkCellData.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSphereSource.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
int TestColorByStringArrayDefaultLookupTable(int argc, char* argv[])
{
vtkNew<vtkSphereSource> sphere;
sphere->Update();
vtkNew<vtkPolyData> polydata;
polydata->ShallowCopy(sphere->GetOutput());
// Set up string array associated with cells
vtkNew<vtkStringArray> sArray;
char arrayName[] = "string type";
sArray->SetName(arrayName);
sArray->SetNumberOfComponents(1);
sArray->SetNumberOfTuples(polydata->GetNumberOfCells());
vtkVariant strings[5];
strings[0] = "violin";
strings[1] = "viola";
strings[2] = "cello";
strings[3] = "bass";
strings[4] = "double bass";
// Round-robin assignment of color strings
for (int i = 0; i < polydata->GetNumberOfCells(); ++i)
{
sArray->SetValue(i, strings[i % 5].ToString());
}
vtkCellData* cd = polydata->GetCellData();
cd->AddArray(sArray.Get());
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputDataObject(polydata.Get());
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUseCellFieldData();
mapper->SelectColorArray(arrayName);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.Get());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.Get());
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.Get());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestColorByStringArrayDefaultLookupTable2D.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include <vtkActor2D.h>
#include <vtkCellData.h>
#include <vtkDiskSource.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper2D.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
int TestColorByStringArrayDefaultLookupTable2D(int argc, char* argv[])
{
vtkNew<vtkDiskSource> disk;
disk->SetInnerRadius(0.0);
disk->SetCircumferentialResolution(32);
disk->Update();
vtkNew<vtkPolyData> polydata;
polydata->ShallowCopy(disk->GetOutput());
// Set up string array associated with cells
vtkNew<vtkStringArray> sArray;
char arrayName[] = "string type";
sArray->SetName(arrayName);
sArray->SetNumberOfComponents(1);
sArray->SetNumberOfTuples(polydata->GetNumberOfCells());
vtkVariant strings[5];
strings[0] = "violin";
strings[1] = "viola";
strings[2] = "cello";
strings[3] = "bass";
strings[4] = "double bass";
// Round-robin assignment of string strings
for (int i = 0; i < polydata->GetNumberOfCells(); ++i)
{
sArray->SetValue(i, strings[i % 5].ToString());
}
vtkCellData* cd = polydata->GetCellData();
cd->AddArray(sArray.Get());
vtkNew<vtkCoordinate> pCoord;
pCoord->SetCoordinateSystemToWorld();
vtkNew<vtkCoordinate> coord;
coord->SetCoordinateSystemToNormalizedViewport();
coord->SetReferenceCoordinate(pCoord.GetPointer());
vtkNew<vtkPolyDataMapper2D> mapper;
mapper->SetInputDataObject(polydata.Get());
mapper->ScalarVisibilityOn();
mapper->SetColorModeToMapScalars();
mapper->SetScalarModeToUseCellFieldData();
mapper->ColorByArrayComponent(arrayName, -1);
mapper->SetTransformCoordinate(coord.GetPointer());
vtkNew<vtkActor2D> actor;
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.Get());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.Get());
renderWindow->Render();
renderer->ResetCamera();
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.Get());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestColorTransferFunctionStringArray.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkColorTransferFunction.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
#include <vtkUnsignedCharArray.h>
int TestColorTransferFunctionStringArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
vtkStringArray* sArray = vtkStringArray::New();
const int numStrings = 6;
sArray->SetNumberOfValues(numStrings);
sArray->SetName("TestArray");
vtkVariant category1("Category1");
vtkVariant category2("Category2");
vtkVariant category3("Category3");
sArray->SetValue(0, category1.ToString());
sArray->SetValue(1, category2.ToString());
sArray->SetValue(2, category3.ToString());
sArray->SetValue(3, category2.ToString());
sArray->SetValue(4, category3.ToString());
sArray->SetValue(5, category1.ToString());
for (int i = 0; i < sArray->GetNumberOfValues(); ++i)
{
std::cout << sArray->GetValue(i) << "\n";
}
vtkColorTransferFunction* tfer = vtkColorTransferFunction::New();
tfer->IndexedLookupOn();
// Need to set some nodes to avoid prematurely returning from
// vtkColorTransferFunction::MapScalarsThroughTable2()
tfer->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
tfer->AddRGBPoint(1.0, 1.0, 0.0, 0.0);
tfer->AddRGBPoint(2.0, 1.0, 0.0, 1.0);
tfer->SetAnnotation(category1, "Annotation1");
tfer->SetAnnotation(category2, "Annotation2");
tfer->SetAnnotation(category3, "Annotation3");
vtkUnsignedCharArray* colors = tfer->MapScalars(sArray, VTK_RGBA, -1);
tfer->Delete();
sArray->Delete();
unsigned char expectedColors[numStrings][4] = {
{0, 0, 0, 255},
{255, 0, 0, 255},
{255, 0, 255, 255},
{255, 0, 0, 255},
{255, 0, 255, 255},
{0, 0, 0, 255}};
for (int i = 0; i < sArray->GetNumberOfValues(); ++i)
{
unsigned char color[4];
colors->GetTupleValue(i, color);
if (expectedColors[i][0] != color[0] ||
expectedColors[i][1] != color[1] ||
expectedColors[i][2] != color[2] ||
expectedColors[i][3] != color[3])
{
std::cerr << "Color for string " << i << " ("
<< static_cast<int>(color[0]) << ", "
<< static_cast<int>(color[1]) << ", "
<< static_cast<int>(color[2]) << ", "
<< static_cast<int>(color[3])
<< ") does not match expected color ("
<< static_cast<int>(expectedColors[i][0]) << ", "
<< static_cast<int>(expectedColors[i][1]) << ", "
<< static_cast<int>(expectedColors[i][2]) << ", "
<< static_cast<int>(expectedColors[i][3]) << std::endl;
return EXIT_FAILURE;
}
}
colors->Delete();
return EXIT_SUCCESS;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestDiscretizableColorTransferFunctionStringArray.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkDiscretizableColorTransferFunction.h>
#include <vtkStdString.h>
#include <vtkStringArray.h>
#include <vtkUnsignedCharArray.h>
int TestDiscretizableColorTransferFunctionStringArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
vtkStringArray* sArray = vtkStringArray::New();
const int numStrings = 6;
sArray->SetNumberOfValues(numStrings);
sArray->SetName("TestArray");
vtkVariant category1("Category1");
vtkVariant category2("Category2");
vtkVariant category3("Category3");
sArray->SetValue(0, category1.ToString());
sArray->SetValue(1, category2.ToString());
sArray->SetValue(2, category3.ToString());
sArray->