Hello,<br>
I get very strange behaviour while running the following script.
It should render a sphere colored according to a lookup table.<br>
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.<br>
Do you have an idea why??<br>
Thanks for help,<br>
Wojtek<br>
<br>
from vtk import *<br>
import pdb<br>
<br>
color_ind = 2<br>
<br>
source = vtkSphereSource()<br>
source.Update()<br>
<br>
arr = vtkFloatArray()<br>
arr.SetNumberOfComponents(1)<br>
arr.SetNumberOfTuples(source.GetOutput().GetNumberOfPoints())<br>
for i in range(arr.GetNumberOfTuples()):<br>
arr.SetTuple1(i,color_ind)<br>
<br>
source.GetOutput().GetPointData().SetScalars(arr)<br>
##########<br>
#source.SetRadius(0.05) #sphere becomes gray<br>
source.SetRadius(0.5) #ok<br>
##########<br>
lut = vtkLookupTable()<br>
lut.SetNumberOfColors(4)<br>
lut.SetTableValue(0,(1,0,0,1))<br>
lut.SetTableValue(1,(0,1,0,1))<br>
lut.SetTableValue(2,(0,0,1,1))<br>
lut.SetTableValue(3,(1,1,0,1))<br>
lut.SetRange(0,3)<br>
<br>
mapper = vtkPolyDataMapper()<br>
mapper.ImmediateModeRenderingOn()<br>
mapper.SetInput(source.GetOutput())<br>
mapper.ScalarVisibilityOn()<br>
mapper.SetScalarModeToUsePointData()<br>
mapper.SetLookupTable(lut)<br>
mapper.SetScalarRange(0,3)<br>
<br>
actor=vtkActor()<br>
actor.SetMapper(mapper)<br>
<br>
#renderer<br>
ren1 = vtkRenderer()<br>
ren1.AddActor( actor)<br>
ren1.SetBackground( 0.1, 0.2, 0.4 )<br>
<br>
#window<br>
renWin = vtkRenderWindow()<br>
renWin.AddRenderer( ren1 )<br>
renWin.SetSize( 500, 500 )<br>
<br>
#interactor<br>
iren = vtkRenderWindowInteractor()<br>
iren.SetRenderWindow(renWin)<br>
<br>
iren.Initialize()<br>
iren.Start()<br>
renWin.Render()<br>
#pdb.set_trace()<br>
<br>
<br>