CGALのKdツリー実装とファジー球をクエリオブジェクトとして使用して、ポイント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フォルダーの下にあるinterior_neighbor_searching.cppファイルからコメント「Printpoints」の下の行を取得して適合させました(私のバージョンは3.9です)。
質問は次のとおりです。ポイントの座標を標準に出力する代わりに、ある種のコンテナで検索の結果として得られたポイントへのポインタ/イテレータ/ハンドルを格納する別のOutputIterator
(ではなく)を設定する方法はありますか?出力?ありがとうございました。std::ostream_iterator