[vtkusers] vtkCellPicker tolerance problems
Clinton Stimpson
clinton at elemtech.com
Fri Jun 15 01:29:08 EDT 2012
I'm seeing a tolerance problem with vtkCellPicker and I'm wondering if anyone has suggestions for a way to fix this or a workaround (vtkPicker has the same problem).
The vtkPicker tolerance is in terms of the display size, but not adjusted accordingly when passed down to the routines that check for intersections in world space.
I have a script below to demonstrate the problem. You can run the script with two different camera positions to see the difference in behavior even though the object appears the same size on the screen.
This becomes a more serious problem when there are several objects on the screen with plenty of screen space to differentiate between them, but the user cannot pick the desired object.
=====
#!/usr/bin/env python
import vtk
# toggle this to see the difference in picking tolerance even though the
# object appears the same size both either way.
# Hold the 'p' key and move the mouse around the window to see how close
# the mouse needs to be to pick the object.
test1 = 1
#test1 = 0
# create a sphere source, mapper, and actor
sphere = vtk.vtkSphereSource()
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(sphere.GetOutputPort())
sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)
# Create a cell picker.
picker = vtk.vtkCellPicker()
picker.SetTolerance(0.001)
# Create the Renderer, RenderWindow, etc. and set the Picker.
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetPicker(picker)
# Add the actors to the renderer, set the background and size
ren.AddActor(sphereActor)
ren.SetBackground(1, 1, 1)
renWin.SetSize(300, 300)
# Get the camera and zoom in closer to the image.
cam1 = ren.GetActiveCamera()
if test1 == 1:
cam1.SetFocalPoint(0, 0, -2000)
cam1.SetPosition(0, 0, 10)
else:
cam1.SetFocalPoint(0, 0, 0)
cam1.SetPosition(0, 0, 10)
ren.ResetCameraClippingRange()
iren.Initialize()
iren.SetKeyEventInformation(0,0,'t')
iren.CharEvent()
renWin.Render()
iren.Start()
=====
Thanks,
Clint
More information about the vtkusers
mailing list