#include <fstream>
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Octree.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
typedef Point_set::Point_map Point_map;
typedef Octree::Node Node;
struct First_branch_traversal
{
Node first (Node root) const
{
return root;
}
Node next (Node n) const
{
if (n.is_leaf())
return Node();
return n[0];
}
};
int main(int argc, char **argv) {
Point_set points;
stream >> points;
if (0 == points.number_of_points()) {
std::cerr << "Error: cannot read file" << std::endl;
return EXIT_FAILURE;
}
std::cout << "loaded " << points.number_of_points() << " points\n" << std::endl;
Octree octree(points, points.point_map());
octree.refine();
for (auto &node : octree.traverse<First_branch_traversal>())
std::cout << node << std::endl;
return EXIT_SUCCESS;
}