Re: [TVTK] Cannot add volume to renderer
Subject: Re: [TVTK] Cannot add volume to renderer
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-07-18 16:10:12 GMT
I believe I figured out what I was doing wrong. The line
vol = tvtk.Volume
returns a enthought.traits.has_traitis.MetaHasTraits. What I should have done is
vol = tvtk.Volume()
which returns a tvtk_classes.volume.Volume. The program still does not work as written because the the vtkVolumeRayCastMapper apparently cannot render float data. I will change datasources and see if I can get things to work.
- Jack
-----Original Message-----
From: Cook, Jack JE SIEP-EPT-RIX
Sent: Friday, July 18, 2008 8:55 AM
To: enthought-dev-oRDGkvazHdacsI7C1d+pp9BPR1lH4CV8@public.gmane.org
Subject: [TVTK] Cannot add volume to renderer
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
_______________________________________________ Enthought-dev mailing list Enthought-dev@... https://mail.enthought.com/mailman/listinfo/enthought-dev
RSS Feed