[vtkusers] strange color behaviour
Wojtek B
vojtekb at gmail.com
Fri Sep 30 12:07:11 EDT 2005
Hello,
I get very strange behaviour while running the following script. It should
render a sphere colored according to a lookup table.
It works until I try to specify the sphere radius: if it's too small (0.05)
the sphere is no longer colored. It becomes gray.
Do you have an idea why??
Thanks for help,
Wojtek
from vtk import *
import pdb
color_ind = 2
source = vtkSphereSource()
source.Update()
arr = vtkFloatArray()
arr.SetNumberOfComponents(1)
arr.SetNumberOfTuples(source.GetOutput().GetNumberOfPoints())
for i in range(arr.GetNumberOfTuples()):
arr.SetTuple1(i,color_ind)
source.GetOutput().GetPointData().SetScalars(arr)
##########
#source.SetRadius(0.05) #sphere becomes gray
source.SetRadius(0.5) #ok
##########
lut = vtkLookupTable()
lut.SetNumberOfColors(4)
lut.SetTableValue(0,(1,0,0,1))
lut.SetTableValue(1,(0,1,0,1))
lut.SetTableValue(2,(0,0,1,1))
lut.SetTableValue(3,(1,1,0,1))
lut.SetRange(0,3)
mapper = vtkPolyDataMapper()
mapper.ImmediateModeRenderingOn()
mapper.SetInput(source.GetOutput())
mapper.ScalarVisibilityOn()
mapper.SetScalarModeToUsePointData()
mapper.SetLookupTable(lut)
mapper.SetScalarRange(0,3)
actor=vtkActor()
actor.SetMapper(mapper)
#renderer
ren1 = vtkRenderer()
ren1.AddActor( actor)
ren1.SetBackground( 0.1, 0.2, 0.4 )
#window
renWin = vtkRenderWindow()
renWin.AddRenderer( ren1 )
renWin.SetSize( 500, 500 )
#interactor
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
iren.Start()
renWin.Render()
#pdb.set_trace()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050930/fe0a0a17/attachment.htm>
More information about the vtkusers
mailing list