[vtkusers] 3D point cloud nearest neighbor search

David Doria daviddoria at gmail.com
Tue Oct 12 07:40:56 EDT 2010


On Tue, Oct 12, 2010 at 4:23 AM, G. Allegri <giohappy at gmail.com> wrote:
> Hello. I'm new to VTK and this list, so forgive my trivial questions.
>
> I'm considering to use VTK to solve a conceptually simple problem, but
> that require efficient 3D algorithms and data structures. I have a csv
> file which represents a 3D grid of points (SET1). In this specific
> case their regularly spaced on the three axes, but the general case
> can be an irregular point cloud. The dataset is made of a couple of
> millions of points. I also have another set of 3D points (SET2). I
> need to set attributes in SET2 "sampling" the NN from SET1.
>
> I've chosen VTK having seen the various kd-tree and locator classes,
> but I wonder what is the most efficient way to achieve my goal, and
> what data structured is best for this. I'm considering vtkPolyData or
> vtkUnstructuredGrid. What would you suggest for my datas and problem?
> Are there efficient classes to read csv input streams to fill my data
> structures?
>
> Thanks a lot,
> Giovanni

You can modify this to read your csv file into a vtkPolyData:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/InfoVis/ReadDelimitedFile

Then build a vtkKdTreePointLocator to do the NN queries:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/KdTreePointLocator/ClosestPoint

Let us know if you have any trouble once you give it a shot.

David



More information about the vtkusers mailing list