[vtkusers] Glyphs colored by one scalar, scaled by another?
Theodore D. Sternberg
tdsternberg at lbl.gov
Fri Apr 25 01:05:09 EDT 2003
Is it possible to color glyphs by one scalar, but scale them by another?
As the little script below shows, I can scale and color by the *same*
scalar. That's nice, but nicer yet would be to use scale and color to
display two different sets of scalars. How would that be done?
Ted Sternberg
Lawrence Berkeley National Laboratory
----------- script begins here --------------
#
# Example of glyphs scaled and colored by scalars.
#
from vtkpython import *
points = vtkPoints()
points.SetNumberOfPoints( 3 )
points.SetPoint( 0, 0.0, 0.0, 0.0 )
points.SetPoint( 1, 1.0, 1.0, 1.0 )
points.SetPoint( 2, 2.0, 2.0, 2.0 )
scalars = vtkScalars()
scalars.InsertScalar(0, 1.0 )
scalars.InsertScalar(1, 1.5 )
scalars.InsertScalar(2, 2.0 )
polydata = vtkPolyData()
polydata.SetPoints( points )
polydata.GetPointData().SetScalars( scalars )
sphere = vtkSphereSource()
glyph = vtkGlyph3D()
glyph.SetSource( sphere.GetOutput() )
glyph.SetInput( polydata )
glyph.Update()
mapper = vtkDataSetMapper()
mapper.SetInput( glyph.GetOutput() )
mapper.SetScalarRange( glyph.GetOutput().GetScalarRange() )
actor = vtkActor()
actor.SetMapper( mapper )
renWin = vtkRenderWindow()
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow( renWin )
ren = vtkRenderer()
renWin.AddRenderer( ren )
ren.AddActor( actor )
iren.Initialize()
iren.Start()
-------------------- end of script ----------------
More information about the vtkusers
mailing list