[vtkusers] Colour

Immo Trinks trinks at esc.cam.ac.uk
Wed Jun 30 13:11:09 EDT 2004


Hi Donald,

The following tcl script does the job for the data file given below.
The colours are defined  as RGB values

Immo

##########################################
# load the necessary VTK libraries.
package require vtk
package require vtkinteraction
package require vtktesting

vtkPolyDataReader reader
reader SetFileName "test.vtk"

vtkPolyDataMapper mapper
mapper SetInput [reader GetOutput]
mapper SelectColorArray "colour"

vtkActor Points
Points SetMapper mapper
Points SetScale 1 1 1
[Points GetProperty] SetPointSize  10
Points SetPosition 0 0 0
Points SetScale 1 1 1
[Points GetProperty] SetOpacity 1
[Points GetProperty] SetColor 1 1 1
mapper SetScalarMode 3
[Points GetProperty] SetRepresentationToPoints

vtkRenderer ren1
ren1 AddActor2D Points
ren1 SetBackground 1 1 1

vtkRenderWindow renWin 
renWin AddRenderer ren1
renWin SetSize 700 700

vtkRenderWindowInteractor iren 
iren SetRenderWindow renWin 

vtkCamera cam1
cam1 Elevation 90
cam1 SetFocalPoint -15.48  16.44  -0.50
cam1 SetViewUp 0 0 1
cam1 SetPosition -20 20 0
ren1 SetActiveCamera cam1
ren1 ResetCamera

iren Initialize 
########################################

Test-file "test.vtk" with 4 points:

# vtk DataFile Version 3.0
####
ASCII
DATASET POLYDATA

POINTS 4 float
 0.0  0.0  0.0
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  1.0  1.0

POLYGONS 1 5
4 0 1 2 3

POINT_DATA 4
VECTORS colour unsigned_char
 255  0  0
 0  255  0
 0   0 255
 255   0 255



On Wednesday 30 Jun 2004 16:20, Hamp Donald wrote:
> Hi
>      I have  a set of points and the points are stored
> in vtkPolyData. Depending uon the condition, can I
> change the coloor of some of the vertices with a
> different color.
>
> Hope you will respond.
>
> Best Regards
> Subhas
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq> Follow this link to
> subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list