[prev in list] [next in list] [prev in thread] [next in thread]
List: vtkusers
Subject: [vtkusers] PointPicker to select only visible points
From: Dirk Fressmann <dirk.fressmann () dynamore ! de>
Date: 2008-11-26 17:45:29
Message-ID: 492D8B39.6010308 () dynamore ! de
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic