[vtkusers] Python interface of vtkCellLocator does not match C++ interface
Eric E. Monson
emonson at cs.duke.edu
Mon Apr 12 13:40:19 EDT 2010
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
On Apr 12, 2010, at 10:23 AM, Rodrigo Valiña Gutiérrez wrote:
> Hi, Eric.
>
> Using FindCell from vtk.vtkCellLocator in Python ( the only method I found useful in Python interface ) prints this:
>
> ..\archive\VTK\Filtering\vtkAbstractCellLocator.cxx, line 197
> vtkCellLocator (01EEEF90): vtkCellLocator Does not implement FindCell Reverting to slow DataSet implementation
>
> and few times returns a cell_id != -1.
>
> I want to highlight some points or cells, and put labels with their scalar or vector value. With pointdata I have done, but it remains celldata.
>
> With pointdata I use a vtk.vtkPropPicker() and vtk.vtkPointLocator()'s method .FindClosestPoint(pos).
>
> With celldata I am trying with vtk.vtkCellLocator()'s method .FindCell(pos)'s since .FindClosestPoint(pos) is not available in Python.
>
> At the moment labeling clicked points with their pointdata value works, but celldata does not.
>
> On Fri, Apr 9, 2010 at 3:37 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> Hello Rodrigo,
>
> Someone with more knowledge about the Python wrapping process will have to explain why some methods are wrapped and some aren't -- it's frustrating for me, too, sometimes.
>
> But, since you see FindCell, but it does not work, please explain in more detail what is going wrong when you try to use it so people can help with that.
>
> Talk to you later,
> -Eric
>
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
>
>
> On Apr 9, 2010, at 7:45 AM, Rodrigo Valiña Gutiérrez wrote:
>
> > Hi,
> >
> > I am using Python interface of VTK 5.4.2 and was using a
> > vtk.vtkPointLocator, which works well.
> >
> > But now I want to use vtk.vtkCellLocator, and there is a problem:
> > there are methods (specially FindClosestPoint) that I want to use and
> > they appear in documentation and in source of vtkCellLocator, but not
> > in Python interface. Also FindCell does not seem to work.
> >
> > vtkCellLocator:
> > http://www.vtk.org/doc/release/5.4/html/a00250.html
> >
> > The methods defined in Python are:
> >
> > a = vtk.vtkPointLocator()
> > dir(a)
> > ['AddObserver', 'AutomaticOff', 'AutomaticOn', 'BreakOnError',
> > 'BuildLocator', 'DebugOff', 'DebugOn', 'FastDelete',
> > 'FindClosestInsertedPoint', 'FindClosestNPoints', 'FindClosestPoint',
> > 'FindDistributedPoints', 'FindPointsWithinRadius',
> > 'FreeSearchStructure', 'GenerateRepresentation', 'GetAddressAsString',
> > 'GetAutomatic', 'GetBuildTime', 'GetClassName', 'GetDataSet',
> > 'GetDebug', 'GetDivisions', 'GetGlobalWarningDisplay', 'GetLevel',
> > 'GetMTime', 'GetMaxLevel', 'GetMaxLevelMaxValue',
> > 'GetMaxLevelMinValue', 'GetNumberOfPointsPerBucket',
> > 'GetNumberOfPointsPerBucketMaxValue',
> > 'GetNumberOfPointsPerBucketMinValue', 'GetPoints',
> > 'GetPointsInBucket', 'GetReferenceCount', 'GetTolerance',
> > 'GetToleranceMaxValue', 'GetToleranceMinValue',
> > 'GlobalWarningDisplayOff', 'GlobalWarningDisplayOn', 'HasObserver',
> > 'InitPointInsertion', 'Initialize', 'InsertNextPoint', 'InsertPoint',
> > 'InvokeEvent', 'IsA', 'IsInsertedPoint', 'IsTypeOf', 'Modified',
> > 'NewInstance', 'PrintRevisions', 'Register', 'RemoveAllObservers',
> > 'RemoveObserver', 'RemoveObservers', 'SafeDownCast', 'SetAutomatic',
> > 'SetDataSet', 'SetDebug', 'SetDivisions', 'SetGlobalWarningDisplay',
> > 'SetMaxLevel', 'SetNumberOfPointsPerBucket', 'SetReferenceCount',
> > 'SetTolerance', 'UnRegister', 'Update']
> >
> > b = vtk.vtkCellLocator()
> > dir(b)
> > ['AddObserver', 'AutomaticOff', 'AutomaticOn', 'BreakOnError',
> > 'BuildLocator', 'CacheCellBoundsOff', 'CacheCellBoundsOn', 'DebugOff',
> > 'DebugOn', 'FastDelete', 'FindCell', 'FindCellsAlongLine',
> > 'FreeSearchStructure', 'GenerateRepresentation', 'GetAddressAsString',
> > 'GetAutomatic', 'GetBuildTime', 'GetCacheCellBounds', 'GetCells',
> > 'GetClassName', 'GetDataSet', 'GetDebug', 'GetGlobalWarningDisplay',
> > 'GetLazyEvaluation', 'GetLevel', 'GetMTime', 'GetMaxLevel',
> > 'GetMaxLevelMaxValue', 'GetMaxLevelMinValue', 'GetNumberOfBuckets',
> > 'GetNumberOfCellsPerBucket', 'GetNumberOfCellsPerNode',
> > 'GetNumberOfCellsPerNodeMaxValue', 'GetNumberOfCellsPerNodeMinValue',
> > 'GetReferenceCount', 'GetRetainCellLists', 'GetTolerance',
> > 'GetToleranceMaxValue', 'GetToleranceMinValue',
> > 'GetUseExistingSearchStructure', 'GlobalWarningDisplayOff',
> > 'GlobalWarningDisplayOn', 'HasObserver', 'Initialize',
> > 'InsideCellBounds', 'IntersectWithLine', 'InvokeEvent', 'IsA',
> > 'IsTypeOf', 'LazyEvaluationOff', 'LazyEvaluationOn', 'Modified',
> > 'NewInstance', 'PrintRevisions', 'Register', 'RemoveAllObservers',
> > 'RemoveObserver', 'RemoveObservers', 'RetainCellListsOff',
> > 'RetainCellListsOn', 'SafeDownCast', 'SetAutomatic',
> > 'SetCacheCellBounds', 'SetDataSet', 'SetDebug',
> > 'SetGlobalWarningDisplay', 'SetLazyEvaluation', 'SetMaxLevel',
> > 'SetNumberOfCellsPerBucket', 'SetNumberOfCellsPerNode',
> > 'SetReferenceCount', 'SetRetainCellLists', 'SetTolerance',
> > 'SetUseExistingSearchStructure', 'UnRegister', 'Update',
> > 'UseExistingSearchStructureOff', 'UseExistingSearchStructureOn']
> >
> > is it a bug ?
> >
> > am I missing something ?
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100412/ee821478/attachment.htm>
More information about the vtkusers
mailing list