[vtkusers] Setting colors for Points does not work properly
Boehm, Lukas
Lukas.Boehm at cellent.de
Thu Dec 8 04:54:34 EST 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111208/5dbbc851/attachment.htm>
-------------- next part --------------
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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