[vtkusers] Volume rendering not visible (vtkVolumeTextureMapper3D)

Bryn Lloyd lloyd at itis.ethz.ch
Mon Nov 7 05:07:42 EST 2011


Hi

 

I am trying to figure out why for a specific dataset the volume rendering is
not visible UNLESS I am interacting with the window.

In other words, the still render is not visible. For other example datasets
(head from VTK_DATA), the still render is visible.

 

I am using the vtkVolumeTextureMapper3D (from vtk 5.8.0). The same thing
happens on OSX and Win7 installations with different hardware.

 

 

Additional information:

-          vtkGPUVolumeRayCastMapper works fine for the dataset

-          For whatever reason, if use the vtkSmartVolumeMapper, the still
render is visible even if I set the render mode to texture. 

-          The image data is 64x64x64, unsigned char, scaled to fit in
0-255.

 

Thanks for any ideas what might be going wrong. Below is the script I am
using to visualize the data.

 

Thanks,

Bryn

 

 

 

reader = vtk.vtkDataSetReader()

reader.SetFileName("C:/Temp/debug_imagedata.vtk")

reader.Update()

 

input = reader.GetStructuredPointsOutput()

 

bounds = [0,0,0,0,0,0]

input.GetBounds(bounds)

 

resample = vtk.vtkImageResample()

resample.SetInputConnection(reader.GetOutputPort())

resample.SetAxisOutputSpacing(0, (bounds[1]-bounds[0])/63.0)

resample.SetAxisOutputSpacing(1, (bounds[3]-bounds[2])/63.0)

resample.SetAxisOutputSpacing(2, (bounds[5]-bounds[4])/63.0)

resample.Update()

 

dims = [0,0,0]

resample.GetOutput().GetDimensions(dims)

print "Dimensions: ",dims

 

srange = [0,0]

resample.GetOutput().GetPointData().GetScalars().GetRange(srange)

print "Scalar range: ", srange

 

 

scale = vtk.vtkImageShiftScale()

scale.SetInputConnection(resample.GetOutputPort())

scale.SetShift(-srange[0])

scale.SetScale(255.0/(srange[1]-srange[0]))

scale.ClampOverflowOn()

scale.SetOutputScalarTypeToUnsignedChar()

scale.Update()

 

volumeMapper = vtk.vtkVolumeTextureMapper3D()

volumeMapper.SetInputConnection(scale.GetOutputPort())

 

volumeColor = vtk.vtkColorTransferFunction()

volumeColor.RemoveAllPoints()

volumeColor.AddRGBPoint(0.00, 0.0,0.0,1.0)

volumeColor.AddRGBPoint(100, 1.0,1.0,0.0)

volumeColor.AddRGBPoint(255, 1.0,0.0,0.0)

                                

volumeScalarOpacity = vtk.vtkPiecewiseFunction()

volumeScalarOpacity.RemoveAllPoints()

volumeScalarOpacity.AddPoint(  0, 1.0)

volumeScalarOpacity.AddPoint( 50, 1.0)

volumeScalarOpacity.AddPoint(150, 1.0)

volumeScalarOpacity.AddPoint(200, 1.0)

volumeScalarOpacity.AddPoint(255, 1.0)

 

volumeProperty = vtk.vtkVolumeProperty()

volumeProperty.SetColor(volumeColor)

volumeProperty.SetScalarOpacity(volumeScalarOpacity)

volumeProperty.SetInterpolationTypeToLinear()

volumeProperty.ShadeOn()

volumeProperty.SetAmbient(0.6)

volumeProperty.SetDiffuse(0.6)

volumeProperty.SetSpecular(0.5)

 

volume = vtk.vtkVolume()

volume.SetMapper(volumeMapper)

volume.SetProperty(volumeProperty)

 

 

#-----------------------------------------------------

# Create the standard renderer, render window and interactor

ren = vtk.vtkRenderer()

renWin = vtk.vtkRenderWindow()

renWin.AddRenderer(ren)

iren = vtk.vtkRenderWindowInteractor()

iren.SetRenderWindow(renWin)

 

ren.SetBackground(0.5,0.5,0.5)

ren.AddVolume(volume)

 

 

renWin.Render()

 

def CheckAbort(obj, event):

                if obj.GetEventPending() != 0:

                                obj.SetAbortRender(1)

  

renWin.AddObserver("AbortCheckEvent", CheckAbort)

iren.Initialize()

renWin.Render()

iren.Start()

 

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111107/429f8c98/attachment.htm>


More information about the vtkusers mailing list