# Refer to the VTK built-in routines examples/GUI/Python/volumerenderwithboxwidget. py # From http://www.vtk.org/doc/nightly /Html // or see vtkdicomimagereader and vtkimageshi in the manual To use ftscale and other classes, modify the routine file as follows:
# Conversion is required because volumemapper can accept the unsigned number unsigned short or unsigned char. Vtkimageshift is used here. Scale #! /Usr/bin/ENV Python
# Demonstrate how to use the vtkboxwidget to Control Volume Rendering
# Within the interior of the widget.
# Load a volume, use the widget to control what's volume
# Rendered. Basically the idea is that the vtkboxwidget provides a box
# Which clips the volume rendering.
# Create the renderwindow, Renderer and both actors
Ren = VTK. vtkrenderer ()
Renwin = VTK. vtkrenderwindow ()
Renwin. addrenderer (ren)
Iren = VTK. vtkrenderwindowindowinteractor ()
Iren. setrenderwindow (renwin)
# The setinteractor method is how 3D widgets are associated with
# Render window interactor. Internally, setinteractor sets up a bunch
# Of callbacks using the command/Observer Mechanic (addobserver ()).
Boxwidget = VTK. vtkboxwidget ()
Boxwidget. setinteractor (iren)
Boxwidget. setplacefactor (1.0)
# Add the actors to the Renderer, set the background and size
Ren. addactor (outlineactor)
Ren. addvolume (newvol)
# When interaction starts, the requested frame rate is increased.
Def startinteraction (OBJ, event ):
Global renwin
Renwin. setdesi1_pdaterate (10)
# When interaction ends, the requested frame rate is decreased
# Normal levels. This causes a full resolution render to occur.
Def endinteraction (OBJ, event ):
Global renwin
Renwin. setdesi1_pdaterate (0.001)
# The implicit function vtkplanes is used in conjunction with
# Volume Ray cast Mapper to limit which portion of the volume is
# Volume rendered.
Planes = VTK. vtkplanes ()
Def clw.olumerender (OBJ, event ):
Global planes, volumemapper
OBJ. getplanes (PLANeS)
Volumemapper. setclippingplanes (PLANeS)
# Place the interactor initially. The output of the reader is used
# Place the box widget.
Boxwidget. setinput (shifter. getoutput ())
Boxwidget. placewidget ()
Boxwidget. insideouton ()
Boxwidget. addobserver ("startinteractionevent", startinteraction)
Boxwidget. addobserver ("interactionevent", clw.olumerender)
Boxwidget. addobserver ("endinteractionevent", endinteraction)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.