[vtkusers] Setting specific colors to vtkPolyData

David Doria daviddoria at gmail.com
Thu Jan 12 08:18:56 EST 2012


On Thu, Jan 12, 2012 at 2:47 AM, Miri Trope <miritrope at gmail.com> wrote:
> Hi David,
>
> I'd like to get a colored surface with three colors like a traffic light:
> green  -  (which represents  low values)
> orange -  (which represents  middle values)
> red     -   (which represents high values)
>
> each of those values should get its brightness due to the value its range.
> for example:
> lets say that my vtkFloatArray consists of six elements s.t.:
>   [5,2,1,6,4,1]
> -divide the elements to three groups and normalized each value s.t:
> lighter    (LI)     color x {green,orange,red}
> stronger (ST)    color x { " }
>   [LI red, ST green, LI green, ST red, ST orange, LI green]
>
> Hope that now my question is clearer.
> Thanks in advance :-)

I'd suggest you insert the colors in the color map as HSV values. I
don't think there is direct support for doing this, but you can
convert them manually.

You'll want to end up with something like:

ColorMap = { {H_g, S_g, V_light}, {H_g, S_g, V_dark}, {H_o, S_o,
V_light}, {H_o, S_o, V_dark}, {H_r, S_r, V_light}, {H_r, S_r, V_dark}
}

That is, choose a green hue (H_g), a green saturation (S_g), hues for
orange and red, and then the values of "light" and "dark" you want.

But you'll have to insert them as RGB values. You can convert the HSV
values to choose to RGB using functions from vtkMath
(http://www.vtk.org/doc/nightly/html/classvtkMath.html#a432c7d56d981a3030cb0d6f4a8789b79)
such as vtkMath::HSVToRGB.

For reference:
http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV

Good luck,

David



More information about the vtkusers mailing list