#include <CGAL/Simple_cartesian.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Search_traits_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/Fuzzy_sphere.h>
typedef K::Point_2 Point;
typedef CGAL::Random_points_in_square_2<Point> Random_points_iterator;
typedef CGAL::Random Random;
int main()
{
const int N=1000;
Random rnd(0);
Random_points_iterator rpit(1.0, rnd);
Tree tree(N_Random_points_iterator(rpit,0),
N_Random_points_iterator(N));
Point center(0.2, 0.2);
Fuzzy_circle default_range(center, 0.2);
std::optional<Point> any = tree.search_any_point(default_range);
if(any)
std::cout << *any << " is in the query circle\n";
else
std::cout << "Empty query circle\n";
std::list<Point> result;
tree.search(std::back_inserter(result), default_range);
std::cout << "\nPoints in circle with center " << center << " and radius 0.2" << std::endl;
std::list<Point>::iterator it;
for (it=result.begin(); (it != result.end()); ++it)
std::cout << *it << std::endl;
result.clear();
Fuzzy_circle approximate_range(center, 0.2, 0.1);
tree.search(std::back_inserter( result ), approximate_range);
std::cout << "\n\nPoints in circle with center " << center << " and fuzzy radius [0.1,0.3]" << std::endl;
for (it=result.begin(); (it != result.end()); ++it)
std::cout << *it << std::endl;
std::cout << "\ndone" << std::endl;
return 0;
}
The class Fuzzy_sphere implements fuzzy d-dimensional spheres.
Definition: Fuzzy_sphere.h:26
The class Kd_tree defines a k-d tree.
Definition: Kd_tree.h:39
The class Search_traits_2 can be used as a template parameter of the kd tree and the search classes.
Definition: Search_traits_2.h:19