#include <CGAL/Simple_cartesian.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/algorithm.h>
#include <CGAL/Fuzzy_iso_box.h>
#include <CGAL/Search_traits_2.h>
template<class K>
struct Projection_xy_property_map
{
typedef typename K::Point_3 key_type;
typedef typename K::Point_2 value_type;
typedef value_type reference;
typedef boost::readable_property_map_tag category;
friend value_type get(Projection_xy_property_map<K>, const key_type& k)
{
return value_type(k.x(), k.y());
}
};
typedef K::Point_2 Point_2;
typedef K::Point_3 Point_3;
typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator;
int main()
{
const int N = 1000;
std::list<Point_3> points;
points.push_back(Point_3(0, 0, 0));
Tree tree;
Random_points_iterator rpg;
for(int i = 0; i < N; i++)
tree.insert(*rpg++);
std::list<Point_3> result;
Point_2 p(0.2, 0.2);
Point_2 q(0.7, 0.7);
Fuzzy_iso_box exact_range(p,q);
tree.search( std::back_inserter( result ), exact_range);
std::cout << "The points in the box [0.2, 0.7]^2 are: " << std::endl;
std::copy (result.begin(), result.end(), std::ostream_iterator<Point_3>(std::cout,"\n") );
std::cout << std::endl;
result.clear();
Fuzzy_iso_box approximate_range(p, q, 0.1);
tree.search(std::back_inserter( result ), approximate_range);
std::cout << "The points in the fuzzy box [[0.1, 0.3], [0.6, 0.8]]^2 are: " << std::endl;
std::copy (result.begin(), result.end(), std::ostream_iterator<Point_3>(std::cout,"\n") );
std::cout << std::endl;
return 0;
}
The class Fuzzy_iso_box implements fuzzy d-dimensional (closed) iso boxes.
Definition: Fuzzy_iso_box.h:22
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
The class Search_traits_adapter can be used as a template parameter of the kd tree and the search cla...
Definition: Search_traits_adapter.h:101