Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Nearest neighbourhood incremental search

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Nearest neighbourhood incremental search


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Nearest neighbourhood incremental search
  • Date: Thu, 04 Sep 2014 08:34:55 +0200
  • Organization: GeometryFactory

On 08/29/2014 01:14 AM, David Scriven wrote:
Given a set, D, of (x, y, z) triplets in Euclidean 3 space, I want
identify groups K1..n that have the following simple characteristic:

For every tj that is a member of Ki there exists a tm (m != j) s.t.
Euclidean dist(tj, tm) < value.

Looking through CGAL it seemed that the NN incremental search would help
me identify these groups and I modified the example given:
........
int valsq = value*value;
// A functor that returns true, iff the distance of a 3D point is
greater than value^2
struct X_gt_valsq {
bool operator()(const NN_iterator& it) { return ((*it).second > valsq); }
};

typedef CGAL::Filter_iterator<NN_iterator, X_gt_valsq> NN_gtvalsq_iterator;

std::list<Point_3> coords;
......// add points.....
Tree tree(coords.begin(), coords.end());
Point_3 query(x,y,z); // some member of coords
NN_incremental_search NN(tree, query);
NN_gtvalsq_iterator it(NN.end(), X_gt_valsq(), NN.begin()),
end(NN.end(), X_gt_valsq());
......
while(it!=end)
{
std::cout << (*it).first << " at squared distance = " <<
(*it).second << std::endl;
it++;
}

which works, but I can't see how to use the information from the
iterator it (which is an input_iterator) to identify which members of
coords are with a NN distance of < valsq so that I can delete them from
the coords dataset to start the next search. Any advice?


First, points are duplicated inside the search structure so you'll need to create a new search structure.

If you want to relate to the original points, you can use for example an integer as point type in the search structure. like in this example:

http://doc.cgal.org/latest/Spatial_searching/index.html#title11

Sebastien.


  • Re: [cgal-discuss] Nearest neighbourhood incremental search, Sebastien Loriot (GeometryFactory), 09/04/2014

Archive powered by MHonArc 2.6.18.

Top of Page