我使用 CGAL 的 Kd-tree 实现以及模糊球体作为查询对象,以获取包围在r_max
以一个点为中心的半径球体中的点。这是这个最小的工作示例:
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Search_traits_2.h>
#include <CGAL/Fuzzy_sphere.h>
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_2 Point;
typedef CGAL::Search_traits_2<K> TreeTraits;
typedef CGAL::Kd_tree<TreeTraits> Kd_tree;
typedef Kd_tree::Tree Tree;
typedef CGAL::Fuzzy_sphere<TreeTraits> Sphere;
int main(int argc, char* argv[])
{
double r_max;
Tree tree;
/* ... fill the tree with points, set the value of r_max ...*/
// Report indices for the neighbors within a sphere
unsigned int idc_query = tree.size()/2; // test index
Tree::iterator kti = idc_query + tree.begin();
Sphere s_query(*kti, r_max);
// Print points
tree.search(std::ostream_iterator<Point>(std::cout, "\n"), s_query);
return 0;
}
我从 CGAL 示例的 Spatial_searching 文件夹(我的版本是 3.9)下的最近的_neighbor_searching.cpp 文件中获取并修改了注释“打印点”下面的行。
问题是:有没有办法让我设置一个不同的OutputIterator
(而不是std::ostream_iterator
)存储指针/迭代器/句柄到在排序容器中搜索产生的点,而不是将点的坐标打印到标准输出?谢谢你。