[vtkusers] PointPicker to select only visible points

David E DeMarle dave.demarle at kitware.com
Mon Dec 1 10:57:05 EST 2008


Hi Dirk,

Take a look at VTK/Rendering/Testing/Cxx/TestAreaSelections.cxx. That
test I adds a callback to the endpick event and in the handler
executes the selection visible selection mechanism.

cheers,
Dave DeMarle


On Wed, Nov 26, 2008 at 12:45 PM, Dirk Fressmann
<dirk.fressmann at dynamore.de> wrote:
>
> I have a vtkUnstructuredGrid with corresponding nodes, cells and actors.
> I want to be able to pick single nodes, where the pick should only apply to
> the visible nodes.
>
> My code looks like this (python)
>
> -------------------------
> import vtk
> nodes = vtk.vtkPoints()
> nodes.InsertPoint(0,[0.0, 0.0, 0.0])
> nodes.InsertPoint(1,[1.0, 0.0, 0.0])
> nodes.InsertPoint(2,[1.0, 1.0, 0.0])
> nodes.InsertPoint(3,[0.0, 1.0, 0.0])
> nodes.InsertPoint(4,[0.0, 0.0, 1.0])
> nodes.InsertPoint(5,[1.0, 0.0, 1.0])
> nodes.InsertPoint(6,[1.0, 1.0, 1.0])
> nodes.InsertPoint(7,[0.0, 1.0, 1.0])
>
> grid = vtk.vtkUnstructuredGrid()
> grid.SetPoints(nodes)
>
> pts = vtk.vtkIdList()
> pts.InsertId(0,0)
> pts.InsertId(1,1)
> pts.InsertId(2,2)
> pts.InsertId(3,3)
> pts.InsertId(4,4)
> pts.InsertId(5,5)
> pts.InsertId(6,6)
> pts.InsertId(7,7)
> grid.InsertNextCell(12,pts)
>
> mapper = vtk.vtkDataSetMapper()
> mapper.SetInput(grid)
> actor = vtk.vtkActor()
> actor.SetMapper(mapper)
>
> renderer = vtk.vtkRenderer()
> renderer.AddActor(actor)
>
> renwin = vtk.vtkRenderWindow()
> renwin.AddRenderer(renderer)
>
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renwin)
>
>
> def lPickCallback(object,event):
>    nid = object.GetPointId()
>    print "picked point", nid
>
> lpicker = vtk.vtkPointPicker()
> iren.SetPicker(lpicker)
> lpicker.AddObserver("StartPickEvent", lPickCallback)
> lpicker.AddObserver("PickEvent", lPickCallback)
> lpicker.AddObserver("EndPickEvent", lPickCallback)
>
> iren.Initialize()
> renwin.Render()
> iren.Start()
> --------------------------------
>
> I figured out that I have to use the vtkSelectVisiblePoints() class, i.e.
>
> visPts = vtk.vtkSelectVisiblePoints()
> visPts.SetInput(grid)
> visPts.SetRenderer(renderer)
>
> Can anyone give me a hint how to connect this class to the pick-observer
> events? And how would the above example be used using the newer
> AddInputConnection() pipeline connections?
>
> I would greatly appreciate any help on this
>
> Cheers Dirk
>
>
>
>
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



More information about the vtkusers mailing list