[vtkusers] problem with opacity when volume rendering with vtkUnstructuredGridVolumeRayCastMapper

Vladislav Petyuk petyuk at gmail.com
Thu Apr 5 17:20:57 EDT 2007


Hi vtkUsers,
I'm trying to volume render with vtkUnstructuredGrid mappers, but can not
make it completely opaque.
I can make it more trasparent though by changing the settings of
the opacityTransferFunction.
But setting point values at 1.0 does not make it completely opaque.
None of other listed below vtkUnstructuredGrid mappers help.
vtkUnstructuredGridVolumeRayCastMapper
vtkProjectedTetrahedraMapper
vtkUnstructuredGridVolumeZSweepMapper

The python code is below.
What I'm missing?
Thanks for help,
Vlad




import vtk

ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

pts = vtk.vtkStructuredPoints()
pts.SetDimensions(2,2,2)
scalars = vtk.vtkUnsignedCharArray()
scalars.SetNumberOfComponents(1)
for x in range(8):
 scalars.InsertValue(x, 100)
pts.GetPointData().SetScalars(scalars)

trifilter = vtk.vtkDataSetTriangleFilter()
trifilter.SetInput(pts)

# Create transfer mapping scalar value to opacity
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(0,   1.0)
opacityTransferFunction.AddPoint(255,   1.0)

# Create transfer mapping scalar value to color
colorTransferFunction = vtk.vtkColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.0,   0.0, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(127.0, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(255.0, 1.0, 0.0, 0.0)

volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(colorTransferFunction)
volumeProperty.SetScalarOpacity(opacityTransferFunction)

# Neither one of the 3 mappers below help to make the cube opaque
volumeMapper = vtk.vtkUnstructuredGridVolumeRayCastMapper()
##volumeMapper = vtk.vtkProjectedTetrahedraMapper()
##volumeMapper = vtk.vtkUnstructuredGridVolumeZSweepMapper()
volumeMapper.SetInputConnection(trifilter.GetOutputPort())

# The volume holds the mapper and the property and
# can be used to position/orient the volume
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)

ren1.AddVolume(volume)
ren1.SetBackground(0.5,0.5,0.5)
renWin.SetSize(800,800)

iren.Initialize()
renWin.Render()
iren.Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070405/5e524570/attachment.htm>


More information about the vtkusers mailing list