Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

[cgal-discuss] Nearest neighbourhood incremental search


Chronological Thread 
  • From: David Scriven <>
  • To: "" <>
  • Subject: [cgal-discuss] Nearest neighbourhood incremental search
  • Date: Thu, 28 Aug 2014 16:14:19 -0700

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?




  • [cgal-discuss] Nearest neighbourhood incremental search, David Scriven, 08/29/2014

Archive powered by MHonArc 2.6.18.

Top of Page