[Paraview] Find points within radius

Bertrand Gazanion b.gazanion at gantha.com
Thu Jun 23 10:10:57 EDT 2016


On behalf of a colleague of mine working with ParaView 4.3.1

 

Hello,


I am using an algorithm doing calculation on points and their neighbours and
I find the results of those points locators to be strange. To test it I made
a simple algorithm counting how many neighbours each point has.
When I create a plane and set its x and y resolution to 100 each, all points
should have the same number of neighbours except on the sides. However
vtkPointLocator, vtkKdTreePointLocator and vtkOctreePointLocator do not find
the same number of neighbours for each point.

Here is the algorithm that I use to get the number of neighbors each points
has :
import vtk

pdi = self.GetInputDataObject(0,0)
nb_pts = pdi.GetNumberOfPoints()

# Point locator
loc = vtk.vtkPointLocator()
#loc = vtk.vtkOctreePointLocator()
#loc = vtk. vtkKdTreePointLocator()

loc.SetDataSet(pdi)
loc.BuildLocator()

pts = pdi.GetPoints()

neighbours = vtk.vtkTypeInt64Array()
neighbours.SetNumberOfComponents(1)
neighbours.SetNumberOfTuples(nb_pts)
neighbours.SetName('neighbours')

for k in range(nb_pts):

    xp = pdi.GetPoint(k)

    id_list = vtk.vtkIdList()

    loc.FindPointsWithinRadius(0.01,xp,id_list)
    loc.Update()

    N = id_list.GetNumberOfIds()
    neighbours.InsertTuple1(k,N)


self.GetOutput().GetPointData().AddArray(neighbours)

 

You will find attached sample picture describing the result I get with each
point locator.

thank you very much

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20160623/f0bbee7e/attachment.html>


More information about the ParaView mailing list