Я рассмотрел примеры, приведенные в руководстве, чтобы сделать это. с поиском соседей, но я не могу заставить его работать с запросом поиска по диапазону.
Мой рабочий код:
Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
typedef CGAL::Simple_cartesian K;
typedef K::Point_2 Point;
typedef CGAL::Random_points_in_square_2
Random_points_iterator;
typedef CGAL::Counting_iterator N_Random_points_iterator;
typedef CGAL::Search_traits_2 Traits;
typedef CGAL::Fuzzy_sphere Fuzzy_circle;
typedef CGAL::Kd_tree Tree;
typedef CGAL::Random Random;
int main() {
const int no_points = 2000; // arbitrary
const int size = 1000;
Random rand;
// Vector to store Points
std::vector point_vec;
for (int i = 0; i < no_points; ++i)
point_vec.push_back(Point(rand.get_double(0, size), rand.get_double(0, size)));
// Add this to a K-D tree
Tree tree(point_vec.begin(), point_vec.end());
// Find a random point to search
Point search_point = Point(rand.get_double(0, 12), rand.get_double(0, 12));
// Creating a fuzzy circle
Fuzzy_circle search_circle(search_point, 20, 0.1); // Center, sqrd radius, fuzziness
// Searching an the area that is specified in "search_area"
boost::optional search_area = tree.search_any_point(search_circle);
// declare list to store points found in search query
std::list search_result;
// Doing a range search on the tree KD tree space
tree.search(std::back_inserter(search_result), search_circle);
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78167799/cgal-k-d-trees-how-do-i-associate-information-to-a-point-when-range-searching[/url]
Мобильная версия