<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey Rodrigo,<div><br></div><div>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</div><div><br></div><div>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:</div><div><br></div><div>[.....]</div><div><div>textActor.SetMapper(textMapper)</div><div><br></div><div>def set_mmZero(istyle, event):</div><div>&nbsp;&nbsp; &nbsp;global MouseMotion</div><div>&nbsp;&nbsp; &nbsp;MouseMotion = 0</div><div>&nbsp;&nbsp; &nbsp;style.OnLeftButtonDown()</div><div><br></div><div>def set_mmOne(istyle, event):</div><div>&nbsp;&nbsp; &nbsp;global MouseMotion</div><div>&nbsp;&nbsp; &nbsp;MouseMotion = 1</div><div>&nbsp;&nbsp; &nbsp;style.OnMouseMove()</div><div><br></div><div>def potential_pick(istyle, event):</div><div>&nbsp;&nbsp; &nbsp;if MouseMotion == 0:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pick_cell(style, event)</div><div>&nbsp;&nbsp; &nbsp;style.OnLeftButtonUp()</div><div><br></div><div>def pick_cell(istyle, event):</div><div>&nbsp;&nbsp; &nbsp;x, y = istyle.GetInteractor().GetEventPosition()</div><div><br></div><div>&nbsp;&nbsp; &nbsp;picker.Pick(x, y, 0, ren)</div><div>&nbsp;&nbsp; &nbsp;cellId = picker.GetCellId()</div><div>&nbsp;&nbsp; &nbsp;if cellId == -1:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;textActor.VisibilityOff()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;istyle.GetInteractor().Render() &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;selPt = picker.GetSelectionPoint()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pickPos = picker.GetPickPosition()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;textMapper.SetInput("(%.6f, %.6f, %.6f)"%pickPos)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;textActor.SetPosition(selPt[:2])</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;textActor.VisibilityOn()</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;iren.Render()</div><div><br></div><div>picker = vtk.vtkCellPicker()</div><div><br></div><div>style = vtk.vtkInteractorStyleTrackballCamera()</div><div>style.AddObserver('LeftButtonPressEvent', set_mmZero)</div><div>style.AddObserver('MouseMoveEvent', set_mmOne)</div><div>style.AddObserver('LeftButtonReleaseEvent', potential_pick)</div><div><br></div><div>ren = vtk.vtkRenderer()</div><div>[......]</div><div><br></div><div>(I can send you the whole code if it's not clear...)</div><div><br></div><div>Hope this helps until you can find out how to use the other functionality.</div><div>-Eric</div><div><br></div><div><br></div><div><div>On Apr 12, 2010, at 10:23 AM, Rodrigo Valiña Gutiérrez wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi, Eric.<br><br>Using FindCell from vtk.vtkCellLocator in Python ( the only method I 
found useful in Python interface ) prints this:<br>
<br>
..\archive\VTK\Filtering\vtkAbstractCellLocator.cxx, line 197<br>
vtkCellLocator (01EEEF90): vtkCellLocator Does not implement FindCell 
Reverting to slow DataSet implementation<br>
<br>
and few times returns a cell_id != -1.<br><br>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.<br><br>With pointdata I use a vtk.vtkPropPicker() and vtk.vtkPointLocator()'s method .FindClosestPoint(pos).<br>
<br>With celldata I am trying with vtk.vtkCellLocator()'s method .FindCell(pos)'s since .FindClosestPoint(pos) is not available in Python.<br><br>At the moment labeling clicked points with their pointdata value works, but celldata does not.<br>
<br><div class="gmail_quote">On Fri, Apr 9, 2010 at 3:37 PM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu">emonson@cs.duke.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello Rodrigo,<br>
<br>
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.<br>
<br>
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.<br>
<br>
Talk to you later,<br>
-Eric<br>
<br>
------------------------------------------------------<br>
Eric E Monson<br>
Duke Visualization Technology Group<br>
<div><div></div><div class="h5"><br>
<br>
On Apr 9, 2010, at 7:45 AM, Rodrigo Valiña Gutiérrez wrote:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; I am using Python interface of VTK 5.4.2 and was using a<br>
&gt; vtk.vtkPointLocator, which works well.<br>
&gt;<br>
&gt; But now I want to use vtk.vtkCellLocator, and there is a problem:<br>
&gt; there are methods (specially FindClosestPoint) that I want to use and<br>
&gt; they appear in documentation and in source of vtkCellLocator, but not<br>
&gt; in Python interface. Also FindCell does not seem to work.<br>
&gt;<br>
&gt; vtkCellLocator:<br>
&gt; <a href="http://www.vtk.org/doc/release/5.4/html/a00250.html" target="_blank">http://www.vtk.org/doc/release/5.4/html/a00250.html</a><br>
&gt;<br>
&gt; The methods defined in Python are:<br>
&gt;<br>
&gt; a = vtk.vtkPointLocator()<br>
&gt; dir(a)<br>
&gt; ['AddObserver', 'AutomaticOff', 'AutomaticOn', 'BreakOnError',<br>
&gt; 'BuildLocator', 'DebugOff', 'DebugOn', 'FastDelete',<br>
&gt; 'FindClosestInsertedPoint', 'FindClosestNPoints', 'FindClosestPoint',<br>
&gt; 'FindDistributedPoints', 'FindPointsWithinRadius',<br>
&gt; 'FreeSearchStructure', 'GenerateRepresentation', 'GetAddressAsString',<br>
&gt; 'GetAutomatic', 'GetBuildTime', 'GetClassName', 'GetDataSet',<br>
&gt; 'GetDebug', 'GetDivisions', 'GetGlobalWarningDisplay', 'GetLevel',<br>
&gt; 'GetMTime', 'GetMaxLevel', 'GetMaxLevelMaxValue',<br>
&gt; 'GetMaxLevelMinValue', 'GetNumberOfPointsPerBucket',<br>
&gt; 'GetNumberOfPointsPerBucketMaxValue',<br>
&gt; 'GetNumberOfPointsPerBucketMinValue', 'GetPoints',<br>
&gt; 'GetPointsInBucket', 'GetReferenceCount', 'GetTolerance',<br>
&gt; 'GetToleranceMaxValue', 'GetToleranceMinValue',<br>
&gt; 'GlobalWarningDisplayOff', 'GlobalWarningDisplayOn', 'HasObserver',<br>
&gt; 'InitPointInsertion', 'Initialize', 'InsertNextPoint', 'InsertPoint',<br>
&gt; 'InvokeEvent', 'IsA', 'IsInsertedPoint', 'IsTypeOf', 'Modified',<br>
&gt; 'NewInstance', 'PrintRevisions', 'Register', 'RemoveAllObservers',<br>
&gt; 'RemoveObserver', 'RemoveObservers', 'SafeDownCast', 'SetAutomatic',<br>
&gt; 'SetDataSet', 'SetDebug', 'SetDivisions', 'SetGlobalWarningDisplay',<br>
&gt; 'SetMaxLevel', 'SetNumberOfPointsPerBucket', 'SetReferenceCount',<br>
&gt; 'SetTolerance', 'UnRegister', 'Update']<br>
&gt;<br>
&gt; b = vtk.vtkCellLocator()<br>
&gt; dir(b)<br>
&gt; ['AddObserver', 'AutomaticOff', 'AutomaticOn', 'BreakOnError',<br>
&gt; 'BuildLocator', 'CacheCellBoundsOff', 'CacheCellBoundsOn', 'DebugOff',<br>
&gt; 'DebugOn', 'FastDelete', 'FindCell', 'FindCellsAlongLine',<br>
&gt; 'FreeSearchStructure', 'GenerateRepresentation', 'GetAddressAsString',<br>
&gt; 'GetAutomatic', 'GetBuildTime', 'GetCacheCellBounds', 'GetCells',<br>
&gt; 'GetClassName', 'GetDataSet', 'GetDebug', 'GetGlobalWarningDisplay',<br>
&gt; 'GetLazyEvaluation', 'GetLevel', 'GetMTime', 'GetMaxLevel',<br>
&gt; 'GetMaxLevelMaxValue', 'GetMaxLevelMinValue', 'GetNumberOfBuckets',<br>
&gt; 'GetNumberOfCellsPerBucket', 'GetNumberOfCellsPerNode',<br>
&gt; 'GetNumberOfCellsPerNodeMaxValue', 'GetNumberOfCellsPerNodeMinValue',<br>
&gt; 'GetReferenceCount', 'GetRetainCellLists', 'GetTolerance',<br>
&gt; 'GetToleranceMaxValue', 'GetToleranceMinValue',<br>
&gt; 'GetUseExistingSearchStructure', 'GlobalWarningDisplayOff',<br>
&gt; 'GlobalWarningDisplayOn', 'HasObserver', 'Initialize',<br>
&gt; 'InsideCellBounds', 'IntersectWithLine', 'InvokeEvent', 'IsA',<br>
&gt; 'IsTypeOf', 'LazyEvaluationOff', 'LazyEvaluationOn', 'Modified',<br>
&gt; 'NewInstance', 'PrintRevisions', 'Register', 'RemoveAllObservers',<br>
&gt; 'RemoveObserver', 'RemoveObservers', 'RetainCellListsOff',<br>
&gt; 'RetainCellListsOn', 'SafeDownCast', 'SetAutomatic',<br>
&gt; 'SetCacheCellBounds', 'SetDataSet', 'SetDebug',<br>
&gt; 'SetGlobalWarningDisplay', 'SetLazyEvaluation', 'SetMaxLevel',<br>
&gt; 'SetNumberOfCellsPerBucket', 'SetNumberOfCellsPerNode',<br>
&gt; 'SetReferenceCount', 'SetRetainCellLists', 'SetTolerance',<br>
&gt; 'SetUseExistingSearchStructure', 'UnRegister', 'Update',<br>
&gt; 'UseExistingSearchStructureOff', 'UseExistingSearchStructureOn']<br>
&gt;<br>
&gt; is it a bug ?<br>
&gt;<br>
&gt; am I missing something ?<br>
</div></div>&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote></div><br>
</blockquote></div><br></div></body></html>