Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Spatial Searching: How to cope with duplicate points?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Spatial Searching: How to cope with duplicate points?


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Spatial Searching: How to cope with duplicate points?
  • Date: Wed, 20 Oct 2010 10:12:06 +0200

Hello,

I tried to run it with CGAL 3.7beta1 and CGAL-3.7 and your code
is working without assertion failure on my machine in both cases.

Can you provide details on your CGAL installation (version,compiler,OS,...)

S.


Sebastian Kapfer wrote:
Dear CGAL community,

I'm trying to use CGAL to locate closest points in a point cloud, and
am having problems with it.

I tried to modidy the example distance_browsing.cpp as below. When I
only insert one copy of the point set into the search tree, everything
is fine; however, once the second copy is inserted, I trigger a CGAL
assertion. (Of course in my real application the problem is that I
genuinely have duplicates.)

terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: new_rd >= copy_rd
File:
/opt/cgal/3.7_boost1.40/include/CGAL/Orthogonal_incremental_neighbor_search.h
Line: 267
Aborted

What do I need to change to make CGAL cope with duplicate points?

Best regards,
Sebastian Kapfer


Minimal example:
Input file:
http://www.theorie1.physik.uni-erlangen.de/people/skapfer/points_in_searchtree.txt
Code:
http://www.theorie1.physik.uni-erlangen.de/people/skapfer/distance_browsing.cpp

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Orthogonal_incremental_neighbor_search.h>
#include <CGAL/Search_traits_3.h>
#include <fstream>

typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_d;
typedef CGAL::Search_traits_3<K> TreeTraits;
typedef CGAL::Orthogonal_incremental_neighbor_search<TreeTraits>
NN_incremental_search;
typedef NN_incremental_search::iterator NN_iterator;
typedef NN_incremental_search::Tree Tree;

// A functor that returns true, iff the x-coordinate of a dD point is not
positive
struct X_not_positive {
bool operator()(const NN_iterator& it) { return ((*it).first)[0]<0; }
};

// An iterator that only enumerates dD points with positive x-coordinate
typedef CGAL::Filter_iterator<NN_iterator, X_not_positive>
NN_positive_x_iterator;

int main() {

Tree tree;
{
std::ifstream is ("points_in_searchtree.txt");
double x, y, z;
while (is >> x >> y >> z)
tree.insert (Point_d (x, y, z));
}
if (0) // change to 1 to insert second copy
{
std::ifstream is ("points_in_searchtree.txt");
double x, y, z;
while (is >> x >> y >> z)
tree.insert (Point_d (x, y, z));
}


for (int i = 0; i != 32; ++i)
for (int j = 0; j != 256; ++j)
for (int k = 0; k != 256; ++k) {
Point_d query (i*.5/32+.25, j*.5/32+.25, k*.5/32+.25);

NN_incremental_search NN(tree, query);
NN_positive_x_iterator it(NN.end(), X_not_positive(), NN.begin()),
end(NN.end(), X_not_positive());

for (int j=0; (j < 5)&&(it!=end); ++j,++it);
}

return 0;
}






Archive powered by MHonArc 2.6.16.

Top of Page