Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Kd_tree::search does not return incremented output iterator

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Kd_tree::search does not return incremented output iterator


Chronological Thread 
  • From: Andreas Fabri <>
  • To:
  • Subject: Re: [cgal-discuss] Kd_tree::search does not return incremented output iterator
  • Date: Mon, 12 Jan 2015 17:53:09 +0100
  • Organization: GeometryFactory

Hello,

You are right with your analysis and the fix.
We will incorporate it in the next release.

Thanks,

Andreas

On 12/01/2015 16:02, xeno1991 wrote:
I am using CGAL-4.5.1.

Kd_tree::search takes OutputIterator and FuzzyQueryItem as arguments and
returns OutputIterator. The returned OutputIterator should be incremented
value of the argument otherwise we have no way to know the end of search
result, because other functions (e.g. std::copy) do so.


/** Example **/
Tree tree(points.begin(), points.end());
Fuzzy_sphere fs(p, 100);

// It is ok.
// tree.search(std::ostream_iterator<Point_d>(std::cout, "\n"), fs);

// This code seems to be equivalent to the above, but Kd_tree::search
returns
// same iterator as the argument. Therefore, for-loop does not work.
std::vector<Point_d> result(N);
auto end = tree.search(result.begin(), fs);
for (auto it = result.begin(); it != end; ++it) {
std::cout << *it << std::endl; // Nothing will be shown!!
}
/****/


I read the source code. I guess Kd_tree.h:292 should be fixed as below:

- tree_root->search(it,q,b);
+ return tree_root->search(it,q,b);

and I confirmed that by fixing in this way it works as I expected.
Could anyone fix this? or have any ideas for this issue?

Thanks.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Kd-tree-search-does-not-return-incremented-output-iterator-tp4660300.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


--
Andreas Fabri, PhD
Chief Officer, GeometryFactory
Editor, The CGAL Project

phone: +33.492.954.912 skype: andreas.fabri



Archive powered by MHonArc 2.6.18.

Top of Page