[vtkusers] ExtractByLocation

Sankhesh Jhaveri sankhesh.jhaveri at kitware.com
Mon Dec 11 11:00:17 EST 2017


Hello Amine,

Take a look at point locators in VTK.

Here is an example of the KdTreePointLocator:
https://lorensen.github.io/VTKExamples/site/Cxx/DataStructures/KdTreePointLocator/ClosestNPoints/

For your particular use case, you might want to look at
vtkKdTreePointLocator::FindPointsWithinRadius
<https://www.vtk.org/doc/nightly/html/classvtkKdTreePointLocator.html#a9ccf7b19974592b6821716bf48265f08>

Hope this helps.

Best,
Sankhesh
​

On Sat, Dec 9, 2017 at 5:49 AM kenichiro yoshimi <rccm.kyoshimi at gmail.com>
wrote:

> Hello Amine,
>
> The searching range for location selection of points is limited by
> EPSILON key. You can set a bigger value to expand the searching range
> as below.
> SelectionNode.GetProperties().Set(SelectionNode.EPSILON(), 1000)
>
> Thanks
>
> 2017-12-02 0:45 GMT+09:00 Amine Aboufirass <amine.aboufirass at gmail.com>:
> > Hello,
> >
> > I am trying to figure out how to select the closest neighboring points
> to a
> > list of coordinates using the vtk library. I have a simple point data
> set in
> > the Unstructured Grid Format. The dataset contains one attribute named
> the
> > 'point_id' which is just enumerating the points starting from 1 instead
> of
> > 0. The raw text from the ASCII file is attached in testScalar.vtk below.
> >
> > I have also written a script in python which I thought would function as
> > follows:
> >
> > INPUT:
> >
> > List of tuples containing world coordinates [(X1,Y1,Z1),(X2,Y2,Z2)]
> > name of attribute to extract as a string. in this case "point_id"
> >
> > OUTPUT:
> >
> > List of floating point values of the attribute for the selected points
> >
> > This does work to a certain degree, for instance when I do :
> >
> > ExtractByLocation('testScalar.vtk', [(5.999,0,0)], 'point_id')
> >
> > I do indeed get back the following:
> >
> > array([ 2.], dtype=float32)
> >
> > So point_id 2 is the closest point to the coordinates I have specified.
> > However, as soon as I get a bit too far from one of the points, the
> function
> > starts returning an empty list. For instance:
> >
> > ExtractByLocation('testScalar.vtk', [(5.888,0,0)], 'point_id')
> >
> > Returns
> > array([], dtype=float32)
> >
> > I found out that the cut off point is 5.89-5.90. If I plugin 5.9 I get
> the
> > point, if I plugin 5.89 I get back an empty list.
> >
> > According to the object reference
> > (
> https://www.vtk.org/doc/nightly/html/classvtkSelectionNode.html#aa7b54148c40adf4f5019b8ad3e160535a97d8505c922b2a25c5d2755607d3cbb6
> )
> >  LOCATIONS is supposed to select the points near the supplied world
> > coordinates. Is there an option or something that selects the nearest
> point
> > PERIOD? i.e using a simple distance formula? I would like to never get
> back
> > an empty list but always get back a list of the closest point to the
> > supplied coordinates.
> >
> > Kind Regards,
> >
> > Amine
> >
> >
> > _______________________________________________
> > 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
> >
> > Search the list archives at: http://markmail.org/search/?q=vtkusers
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> >
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-- 
Sankhesh Jhaveri *Sr. Research & Development Engineer* | Kitware
<http://www.kitware.com/> | (518) 881-4417
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171211/ae037e89/attachment.html>


More information about the vtkusers mailing list