I am just learning how to do volume rendering using tvtk. I was attempting to mimic the volume rendering example in the VTK User's Guide doing the conversion from tcl to tvtk/python (see script below). When I try to add the volume to the renderer I get:
ValueError: method requires a VTK object
I googled the error message and was directed to an FAQ at the Kitware site. The FAQ suggested that I possibly might have two installations of VTK installed on my system. I have checked this and I do not believe this to be the case. Furthermore, most of the tvtk and mayavi2 examples work fine. Does someone know what I am doing wrong?
#### Begin session log
import sys
from enthought.tvtk.tools import ivtk
from enthought.tvtk.api import tvtk
from enthought.mayavi.sources.vtk_file_reader import VTKFileReader
from enthought.mayavi.sources.vtk_file_reader import VTKFileReader
reader = tvtk.StructuredPointsReader()
reader.file_name = './Data/heart.vtk'
pwd = tvtk.PiecewiseFunction()
pwd.add_point(20, 0.0)
pwd.add_point(255, 0.2)
ctf = tvtk.ColorTransferFunction()
ctf.add_rgb_point(0.0, 0.0, 0.0, 0.0)
ctf.add_rgb_point(64.0, 1.0, 0.0, 0.0)
ctf.add_rgb_point(128.0, 0.0, 0.0, 1.0)
ctf.add_rgb_point(192.0, 0.0, 1.0, 0.0)
ctf.add_rgb_point(255.0, 0.0, 0.2, 0.0)
vprop = tvtk.VolumeProperty()
vprop.set_color(ctf)
vprop.set_scalar_opacity(pwd)
cf = tvtk.VolumeRayCastCompositeFunction()
vm = tvtk.VolumeRayCastMapper()
vm.volume_ray_cast_function = cf
vm.input_connection = reader.output_port
vol = tvtk.Volume
vol.mapper = vm
vol.property = vprop
v = ivtk.viewer()
v.scene.renderer.add_view_prop(vol)
#### End session log
Thanks,
Jack
Kind Regards,
Jack Cook
Jack Cook
Savior Research Development
Shell International Exploration & Production, Inc.
3737 Bellaire Boulevard Houston, Texas 77025
Tel: +1 713 245 8771