[vtk-developers] bug with vtkpython and plane widget

Michael Halle mhalle at bwh.harvard.edu
Sat Jan 25 19:44:28 EST 2003


Here's a strange one.  The following code is basically a faithful
translation of the ProbingWithPlaneWidget.tcl example
into python.  I find that under a fairly recent CVS checkout of
vtk (maybe within a week), if I drag one of the corners of
the widget's plane outside of the window and move slowly,
or release and then try to move around in the window again, the
process will hang briefly and then the plane will disappear
(GetPoint1 and GetPoint2 return NaN,NaN,NaN, but the origin looks
okay).

Sometimes it takes a couple of tries, but it's not hard to do.
The funny thing is, I can't get the Tcl example to behave in
the same way.

I'm running on Solaris8.

Michael Halle
mhalle at bwh.harvard.edu


# -------------------------------------------------------------
import vtk
from vtk import *
import sys, os
from vtk.util.misc import *

def BeginInteraction(widget, eventString):
    pw.GetPolyData(plane)
    contourActor.VisibilityOn()

def ProbeData(widget, eventString):
    pw.GetPolyData(plane)

pl3d = vtkPLOT3DReader()
pl3d.SetXYZFileName(os.environ["VTK_DATA_ROOT"] + "/Data/combxyz.bin")
pl3d.SetQFileName(os.environ["VTK_DATA_ROOT"] + "/Data/combq.bin")
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()

pw = vtkPlaneWidget()
pw.SetInput(pl3d.GetOutput())
pw.NormalToXAxisOn()
pw.SetResolution(5)
pw.SetRepresentationToOutline()
pw.PlaceWidget()

plane = vtkPolyData()
pw.GetPolyData(plane)

probe = vtkProbeFilter()
probe.SetInput(plane)
probe.SetSource(pl3d.GetOutput())

contourMapper = vtkPolyDataMapper()
contourMapper.SetInput(probe.GetOutput())
contourMapper.SetScalarRange(pl3d.GetOutput().GetScalarRange())

contourActor = vtkActor()
contourActor.SetMapper(contourMapper)
contourActor.VisibilityOff()

outline = vtkStructuredGridOutlineFilter()
outline.SetInput(pl3d.GetOutput())
outlineMapper = vtkPolyDataMapper()
outlineMapper.SetInput(outline.GetOutput())
outlineActor = vtkActor()
outlineActor.SetMapper(outlineMapper)

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

pw.SetInteractor(iren)
pw.AddObserver("EnableEvent", BeginInteraction)
pw.AddObserver("StartInteractionEvent", BeginInteraction)
pw.AddObserver("InteractionEvent", ProbeData)

pw.On()

renWin.SetSize(300, 300)

ren1.AddActor(outlineActor)
ren1.AddActor(contourActor)
ren1.SetBackground(0.1, 0.2, 0.4)

cam = ren1.GetActiveCamera()
cam.SetClippingRange(3.95297,50)
cam.SetFocalPoint(9.71821,0.458166,29.3999)
cam.SetPosition(2.7439,-37.3196,38.7167)
cam.SetViewUp(-0.16123,0.264271,0.950876)
renWin.Render()

iren.Initialize()
iren.Start()
# -------------------------------------------------------------





More information about the vtk-developers mailing list