[vtkusers] vtkSelectionNodes

Amine Aboufirass amine.aboufirass at gmail.com
Tue Nov 28 07:12:42 EST 2017


Dear all,

I developed a python script which extracts attributes from points in a
vtkUnstructuredGrid.

The script uses  SelectionNodes to extract the point using the LOCATIONS
attribute. I believe that this should select the point closest to the
desired world coordinates. The meat of my code is copied below. It is in
python.

reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(FileName)
SelectionList = vtk.vtkDoubleArray()
SelectionList.SetNumberOfComponents(3)
for Location in Locations:
SelectionList.InsertNextTuple(Location)
SelectionNode = vtk.vtkSelectionNode()
SelectionNode.SetFieldType(vtk.vtkSelectionNode.POINT)
SelectionNode.SetContentType(vtk.vtkSelectionNode.LOCATIONS)
SelectionNode.SetSelectionList(SelectionList)
Selection = vtk.vtkSelection()
Selection.AddNode(SelectionNode)
ExtractSelection = vtk.vtkExtractSelection()
ExtractSelection.SetInputConnection(0, reader.GetOutputPort())
ExtractSelection.SetInput(1,Selection)
ExtractSelection.Update()
Selected = vtk.vtkUnstructuredGrid()
Selected.ShallowCopy(ExtractSelection.GetOutput())
PointData = Selected.GetPointData()

While this does indeed select points based on the supplied coordinates, the
points are not necessarily the closest ones to the supplied coordinate. In
this case I wanted a set of points closest to the left extreme of my
unstructured grid, i.e (X = 0). As you can see from the attachment it is
selecting points quite far away from it.

Is there a better way to simply select the points I need?

Thanks and look forward to hearing from you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171128/b3bfc69f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Points.JPG
Type: image/jpeg
Size: 22109 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171128/b3bfc69f/attachment.jpe>


More information about the vtkusers mailing list