1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Dimension.h>
#include <CGAL/Orthtree.h>
#include <CGAL/Orthtree_traits_base.h>
using Kernel = CGAL::Simple_cartesian<double>;
namespace CGAL {
struct empty_type {
};
template <typename K, int dimension>
struct Orthtree_traits_empty : public Orthtree_traits_base<K, dimension> {
using Self = Orthtree_traits_empty<K, dimension>;
using Tree = Orthtree<Self>;
using Node_data = std::array<empty_type, 0>;
Orthtree_traits_empty(typename Self::Bbox_d bbox) : m_bbox(bbox) {};
auto construct_root_node_bbox_object() const {
return [&]() -> typename Self::Bbox_d { return m_bbox; };
}
auto construct_root_node_contents_object() const { return [&]() -> Node_data { return {}; }; }
auto distribute_node_contents_object() {
return [&](typename Tree::Node_index /* n */, Tree& /* tree */, const typename Self::Point_d& /* center */) -> void {};
}
private:
typename Self::Bbox_d m_bbox;
};
}
using EmptyQuadtree = CGAL::Orthtree<CGAL::Orthtree_traits_empty<Kernel, 2 >>;
int main() {
// Build an empty quadtree which covers the domain (-1, -1) to (1, 1)
EmptyQuadtree quadtree{{{-1, -1, 1, 1}}};
// Split several nodes of the tree
quadtree.split(quadtree.root());
quadtree.split(quadtree.node(0));
quadtree.split(quadtree.node(3));
quadtree.split(quadtree.node(3, 0));
std::cout << quadtree.bbox(quadtree.root()) << std::endl;
std::cout << quadtree << std::endl;
return EXIT_SUCCESS;
}
|