[vtkusers] Setting colors for Points does not work properly

Boehm, Lukas Lukas.Boehm at cellent.de
Thu Dec 8 09:35:46 EST 2011


Thank you very much!!! The problem is solved.

Many Greetings,
Lukas

-----Original Message-----
From: David Doria [mailto:daviddoria at gmail.com] 
Sent: Donnerstag, 8. Dezember 2011 13:23
To: Boehm, Lukas
Cc: vtkusers at public.kitware.com
Subject: Re: [vtkusers] Setting colors for Points does not work properly

2011/12/8 Boehm, Lukas <Lukas.Boehm at cellent.de>:
> Hi,
>
>
>
> i wrote a small POC to set some points in the render window. This 
> works fine and I've found many examples which describe how to set the 
> color for each point. But that's the problem. I've got the following code:
>
>
>
>             vtkRenderWindow renderWindow = 
> this.renderWindowControl1.RenderWindow;
>
>             // create points-object
>
>             vtkPoints pts = vtkPoints.New();
>
>             // create double-array for colors
>
>             vtkDoubleArray colors = vtkDoubleArray.New();
>
>             colors.SetName("colors");
>
>             colors.SetNumberOfComponents(3);
>
>             // insert point and color-tuple
>
>             pts.InsertNextPoint(0.0, 0.0, 0.0);
>
>             colors.InsertNextTuple3(0.3, 0.0, 0.0);
>
>
>
>             vtkPolyData polyData = vtkPolyData.New();
>
>             // add points to polydata object
>
>             polyData.SetPoints(pts);
>
>             // add colors to polydata object
>
>             polyData.GetPointData().AddArray(colors);
>
>
>
>             // points should be displayed as crosses
>
>             vtkGlyphSource2D cross = vtkGlyphSource2D.New();
>
>             cross.SetGlyphTypeToCross();
>
>             vtkGlyph3D glyph = vtkGlyph3D.New();
>
>             // connect polydata with glyph-object
>
>             glyph.SetInputConnection(0, polyData.GetProducerPort());
>
>             glyph.SetSourceConnection(0, cross.GetOutputPort());
>
>             // define the input array for colors
>
>             glyph.SetInputArrayToProcess(3, 0, 0, 0, "colors");
>
>             glyph.SetColorModeToColorByScalar();
>
>             vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
>
>             mapper.SetInput(glyph.GetOutput());
>
>             vtkActor actor = vtkActor.New();
>
>             actor.SetMapper(mapper);
>
>
>
> This code produces a yellow cross. But if I want to change the rgb 
> values of the point it does not work, as I expected. If I change the 
> line
>
>
>
>             colors.InsertNextTuple3(0.3, 0.0, 0.0);
>
>
>
> to
>
>             colors.InsertNextTuple3(0.3, 0.9, 0.9);
>
>
>
> then the cross is still yellow. I would have expected that the three 
> values are interpreted as rgb values. The only interpreted value is 
> the first double. If I change the first double value, the color of the cross changes.
> But I have to set rgb colors.
>
>
>
> Do you understand my problem? Do I make a mistake? I am using VTK 
> 5.6.1.599 with C#.NET.
>
>
>
> Thank you very much.
>
> Lukas

You have to use a vtkUnsignedCharArray instead of a vtkDoubleArray, and the range of each component must be [0, 255]. You can add double data to your points as you did, but it will be interpreted by a colormap type of operation instead of directly used as colors.

David
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cellent Aktiengesellschaft
Vorsitzender des Aufsichtsrates: Rudolf Zipf
Vertretungsberechtigter Vorstand: Andreas Schwegler
Gerichtsstand: Amtsgericht Stuttgart, HRB 22791
Umsatzsteuer-ID: DE 226611517
Firmensitz: Stuttgart

Diese EMail sowie etwaige Anlagen sind ausschliesslich fuer den Adressaten bestimmt und koennen vertrauliche oder gesetzlich
geschuetzte Informationen enthalten. Wenn Sie nicht der bestimmungsgemaesse Empfaenger sind, unterrichten Sie bitte den Absender 
und vernichten Sie diese Mail. Anderen als dem bestimmungsgemaessen Adressaten ist es untersagt, diese EMail zu speichern, 
weiterzuleiten oder ihren Inhalt, auf welche Weise auch immer, zu verwenden. Wir verwenden aktuelle Virenschutzprogramme. 
Fuer Schäden, die dem Empfaenger gleichwohl durch von uns zugesandte, mit Viren befallene EMails entstehen, schliessen wir jede Haftung aus.

The information contained in this e-mail or attachments is intended only for its addressee and may contain confidential and/or 
privileged information. If you have received this e-mail in error, please notify the sender and delete the e-mail. If you are not the 
intended recipient, you are hereby notified, that saving, distribution or use of the content of this e-mail in any way is prohibited. 
We use updated virus protection software. We do not accept any responsibility for damages caused anyhow by viruses transmitted via e-mail.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




More information about the vtkusers mailing list