[vtkusers] Python interface of vtkCellLocator does not match C++ interface

David Doria daviddoria+vtk at gmail.com
Mon Apr 12 13:52:26 EDT 2010


On Mon, Apr 12, 2010 at 1:40 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> Hey Rodrigo,
> Until someone who knows more about vtkCellLocator than I do gets back to
> you, I can say I've seen various examples of using vtkCellPicker in python
> to pick cells. There is the Examples/Annotation/Python/annotatePick.py
> I've also seen slight variations on this that use the mouse to pick instead
> of the "p" key standard picking, where the picking stuff in annotatePick.py
> is replaced with this:
> [.....]
> textActor.SetMapper(textMapper)
> def set_mmZero(istyle, event):
>     global MouseMotion
>     MouseMotion = 0
>     style.OnLeftButtonDown()
> def set_mmOne(istyle, event):
>     global MouseMotion
>     MouseMotion = 1
>     style.OnMouseMove()
> def potential_pick(istyle, event):
>     if MouseMotion == 0:
>         pick_cell(style, event)
>     style.OnLeftButtonUp()
> def pick_cell(istyle, event):
>     x, y = istyle.GetInteractor().GetEventPosition()
>     picker.Pick(x, y, 0, ren)
>     cellId = picker.GetCellId()
>     if cellId == -1:
>         textActor.VisibilityOff()
>         istyle.GetInteractor().Render()
>     else:
>         selPt = picker.GetSelectionPoint()
>         pickPos = picker.GetPickPosition()
>         textMapper.SetInput("(%.6f, %.6f, %.6f)"%pickPos)
>         textActor.SetPosition(selPt[:2])
>         textActor.VisibilityOn()
>         iren.Render()
> picker = vtk.vtkCellPicker()
> style = vtk.vtkInteractorStyleTrackballCamera()
> style.AddObserver('LeftButtonPressEvent', set_mmZero)
> style.AddObserver('MouseMoveEvent', set_mmOne)
> style.AddObserver('LeftButtonReleaseEvent', potential_pick)
> ren = vtk.vtkRenderer()
> [......]
> (I can send you the whole code if it's not clear...)
> Hope this helps until you can find out how to use the other functionality.
> -Eric

Hi all,

I created a section on the wiki called "Broken/Missing Python Functionality"

http://www.vtk.org/Wiki/VTK/Examples#Broken.2FMissing_Python_Functionality

Please add this type of issue to this section when you come across it.

Thanks,

David



More information about the vtkusers mailing list