[vtkusers] How do I control the color of a surface?

David Doria daviddoria at gmail.com
Mon Mar 12 09:03:31 EDT 2012


On Mon, Mar 12, 2012 at 8:42 AM, Ilan <ilan.tal at gmail.com> wrote:
> I have an initial program going with a Java wrapper which gives me contours,
> of the skin or bones or both.
>
> What I think is the relevant code segment is:
>                vtkPolyDataMapper map1 = new vtkPolyDataMapper();
>                map1.SetInput(skinNormals.GetOutput());
>                map1.SetImmediateModeRendering(1);
>
>                actor1 = new vtkActor();
>                actor1.SetMapper(map1);
>                actor1.GetProperty().SetColor(0, 1.0, 0);
>
> Without the last line for setting the color what I receive is a red surface
> for values below 1000 and a blue surface for values above 1000. This is
> fine, but I thought I'd try making it a green surface, so I added the
> SetColor line. It ignores me completely and I don't know why. Can anyone
> give me a hint?
> Thanks,
> Ilan

I think you need:
 mapper->ScalarVisibilityOff();

As this seems to be a very common problem, I created a shell of an example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ScalarVisibility

Maybe you can set it up so it mirrors your case where the data has
associated scalars that are overriding the actor's coloring without
the call to ScalarVisibilityOff().

David



More information about the vtkusers mailing list