[vtkusers] one actor to display multiple lines with different colors

Kevin Wright krw at viz-solutions.com
Fri Aug 16 12:09:28 EDT 2002


>Hi,
>
>I would like to display multiple lines (of possibly different
>color) using just one actor. Furthermore I should be able to add
>additional lines dynamically. I played around with the vtkUnstructuredGrid
>data structure, but was never able to get multiple colors to work.

Try using vtkPolyData.  You can create any number of seperate lines all 
feeding into the same actor.  If you want to color parts of the same actor 
differently, you're going to have to use scalar values.  You can create a 
color map with each of the colors that you want to use, then assign 
appropriate scalar values to each point on the lines to get them colored 
properly.

For example, if you wanted all of your lines to be either red, green or 
blue.  You could create a color map with three entries, configure the 
mapper to have a min of 1 and a max of 3, then each point on a red line 
could be given a scalar value of one, green lines 2, and blue 3.  That 
would do it I think.

Kevin.




More information about the vtkusers mailing list