Subject: CGAL users discussion list
List archive
- From: xeno1991 <>
- To:
- Subject: [cgal-discuss] Kd_tree::search does not return incremented output iterator
- Date: Mon, 12 Jan 2015 07:02:10 -0800 (PST)
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.
- [cgal-discuss] Kd_tree::search does not return incremented output iterator, xeno1991, 01/12/2015
- Re: [cgal-discuss] Kd_tree::search does not return incremented output iterator, Andreas Fabri, 01/12/2015
Archive powered by MHonArc 2.6.18.