[vtkusers] Color tubes

Phil Cook p.cook at cs.ucl.ac.uk
Thu Mar 6 11:49:26 EST 2003


> Message: 11
> Date: Thu, 6 Mar 2003 15:09:01 -0000
> From: "Alex Benn" <alex.benn at incenta.co.uk>
> To: <vtkusers at public.kitware.com>
> Subject: [vtkusers] Color tubes
>
> Hi,
>
> Im trying to create a tube, composed of two sections of that are =
> different colors.
>
> Initially I did something along the lines of :
>
> VtkLineSource > vtkTubeFilter > vtkPolyDataMapper > vtkActor
>
> And used the actor properties to change the color of each section ( =
> obviously each section having its own actor ).
>
> But I would like the entire tube to belong to one actor,
>
> Ie
> VtkLineSource > vtkTubeFilter > vtkPolyDataMapper > vtkAppendPolyData> 
> =
> vtkActor
>
> But cant seem to find a simple way now of controlling the color, 
> without =
> say mapping scalars and using a lookup table. I would just like to =
> specify an RGB colour for each section...
>
> Any help much appreciated,
>
> Alex.

If you use a vtkUnsignedCharArray for your scalars, then you can 
specify RGBA (where A == alpha == opacity).

vtkUnsignedCharArray scalars = new vtkUnsignedCharArray();
scalars.SetNumberOfComponents(4);

Then set as many tuples as you need, and assign each point R,G,B,A.

By default the vtkPolyDataMapper will not map these through a lookup 
table.


Phil




More information about the vtkusers mailing list