[vtkusers] Bug in vtkTexture / volume
jon n
elwo73 at hotmail.com
Wed Mar 20 16:08:01 EST 2002
Sorry about posting this again, but i've tested with new versions of Mesa
and VTK and i guess this is a bug.
I'm using Mesa 4.0.1, Mandrake 8.1, GCC 2.96, Python 2.1 and VTK from the
CVS this morning. My video card is an ATI Rage 128. The following program is
supposed to create a volume from the VTK data directory's iron protein file
and also make a plane nearby it which is colored red and black from a slice
of the iron protein.
If you run the script and comment out the line "f.AddVolume(volume)", the
plane displays correctly in black and red and you can rotate it.
But if the volume is in the render, then the plane displays correctly when
the scene first loads up, but as soon as you interact with the render by
rotating or whatever, the black and red texture disappears from the plane
and is replaced by a copy of what you can see on the volume. The texture on
the plane dynamically changes as you rotate the view. Also, the plane starts
out at the right size but when you interact it suddenly shrinks. The same
problem occurs when you use a vtkCubeSource() instead of a vtkPlaneSource().
As well, if you comment out the line "RayActor.SetTexture(rayTexture)", so
the texture is not applied to the plane, then everything works correctly.
Here's the script:
from vtkpython import *
from Tkinter import *
from vtkTkRenderWidget import vtkTkRenderWidget
theReader = vtkStructuredPointsReader()
theReader.SetFileName('/home/datatmp/VTKData/Data/ironProt.vtk')
myVOI = vtkExtractVOI()
myVOI.SetVOI(50, 50, 30, 50, 30, 50)
myVOI.SetInput(theReader.GetOutput())
theLUT = vtkLookupTable()
theLUT.SetTableRange(0, 255)
theLUT.SetHueRange(1, 1)
theLUT.SetSaturationRange(1, 1)
theLUT.SetValueRange(0.1, 0.9)
theLUT.Build()
rayTexture = vtkTexture()
rayTexture.SetInput( myVOI.GetOutput() )
rayTexture.InterpolateOn()
rayTexture.SetLookupTable( theLUT )
rayTexture.MapColorScalarsThroughLookupTableOn()
RayPlane = vtkPlaneSource()
RayPlane.SetXResolution(1)
RayPlane.SetYResolution(1)
RayPlane.SetOrigin(0,0, -0.1)
RayPlane.SetPoint1(50, 0, -0.1)
RayPlane.SetPoint2(0, -50, -0.1)
rayMapper = vtkPolyDataMapper()
rayMapper.SetInput(RayPlane.GetOutput())
rayMapper.ImmediateModeRenderingOn()
RayActor = vtkActor()
RayActor.SetMapper(rayMapper)
RayActor.SetTexture(rayTexture)
inStuff = vtkStructuredPointsReader()
inStuff.SetFileName('/home/datatmp/VTKData/Data/ironProt.vtk')
opacity = vtkPiecewiseFunction()
opacity.AddSegment(0, 0, 255, 1.0)
grey = vtkPiecewiseFunction()
grey.AddSegment(0, 0.7, 255, 1.0)
volProperty = vtkVolumeProperty()
volProperty.SetColor(grey)
volProperty.SetScalarOpacity(opacity)
volProperty.SetInterpolationTypeToLinear()
compositeFunction = vtkVolumeRayCastCompositeFunction()
volMapper = vtkVolumeRayCastMapper()
volMapper.SetInput(inStuff.GetOutput())
volMapper.SetVolumeRayCastFunction(compositeFunction)
volume = vtkVolume()
volume.SetMapper(volMapper)
volume.SetProperty(volProperty)
f = vtkRenderer()
f.SetBackground(0.0, 0.4, 0.4)
f.AddActor(RayActor)
f.AddVolume(volume)
win=vtkRenderWindow()
win.AddRenderer(f)
iren=vtkRenderWindowInteractor()
iren.SetRenderWindow(win)
iren.Initialize()
iren.Start()
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
More information about the vtkusers
mailing list