[vtkusers] PolyDataMapper colors
David Gobbi
david.gobbi at gmail.com
Sun Dec 13 11:23:54 EST 2009
On Sun, Dec 13, 2009 at 7:38 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> From the documentation
> (http://www.vtk.org/doc/nightly/html/classvtkMapper.html#a80c7171bd1c972cc265c86715f3d8234)
> it looks like unsigned chars should be treated as colors. However, in
> this example:
> http://www.vtk.org/Wiki/VTK_Examples_Display_Colored_Lines
>
> The lines are not colored as expected, they are both just white.
> Anyone know why this might be?
The mapper is ignoring your array because it is not set as the
"scalars" of the data. You have added an array called "colors" but,
unless you tell the mapper otherwise, it will assume that this array
is your own private addition to the data and it will ignore it. The
name "colors" doesn't have any special value, you could call the array
"funkytown" just as easily and the results would be the same.
You need to set the color data as the scalars of either the points or
the cells, you can do this with
data->GetCellData()->SetScalars(array). To force it to use cell
scalars, you should call SetScalarModeToUseCellData(). The vtkMapper
documentation for SetScalarMode() documents this.
David
More information about the vtkusers
mailing list