[vtkusers] Adding chars to 3D char array in python or how to add colors to array?

lynx.abraxas at freenet.de lynx.abraxas at freenet.de
Mon Dec 21 14:32:47 EST 2009


On 21/12/09 01:42:22, David Gobbi wrote:
> Hi Lynx,
> 
> Use SetTuple3(), the doubles are converted to the array type before
> they are stored.

Thanks David G. for this hint. It works nicely with this.

> Also a note about this example: it's best to use SetScalars() to add
> colors to the data, so that you don't have to do anything special in
> order to display them.  That example is misleading, the array name
> "Colors" doesn't have any special meaning in VTK.
> 
> smoothed_polys.GetPointData().SetScalars(colors)

Hm, I'm not getting this. Isn't my colors actually a vector? If I use 
smoothed_polys.GetPointData().SetScalars(colors) instead of
smoothed_polys.GetPointData().AddArray(colors)

I get an error in vtkDataArray.cxx line 470:
vtkUnsignedCharArray ...: The number of components do not match the number requested: 3 != 1

Am I doing something wrong?

Thanks again.
Lynx



More information about the vtkusers mailing list