CGAL 6.1.2 - Quadtrees, Octrees, and Orthtrees: Orthtree/octree_build_from_point_set.cpp

CGAL 6.1.2 - Quadtrees, Octrees, and Orthtrees

Loading...
Searching...
No Matches
Orthtree/octree_build_from_point_set.cpp
#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>
// Type Declarations
using Kernel = CGAL::Simple_cartesian<double>;
using Point = Kernel::Point_3;
using Point_set = CGAL::Point_set_3<Point>;
using Point_map = Point_set::Point_map;
using Octree = CGAL::Octree<Kernel, Point_set, Point_map>;
int main(int argc, char **argv) {
// Point set will be used to hold our points
Point_set points;
// Load points from a file.
std::ifstream stream((argc > 1) ? argv[1] : CGAL::data_file_path("points_3/cube.pwn"));
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;
// Create an octree from the points
Octree octree(points, points.point_map());
// Build the octree with a small bucket size, using a more verbose method
octree.refine(CGAL::Orthtrees::Maximum_contained_elements(10));
// Print out the tree
std::cout << octree << std::endl;
return EXIT_SUCCESS;
}
CGAL::Orthtree
A data structure using an axis-aligned hyperrectangle decomposition of dD space for efficient access ...
Definition: Orthtree.h:117
CGAL::Orthtrees::Maximum_contained_elements
A class used to choose when a node should be split depending on the number of contained elements.
Definition: Split_predicates.h:36
CGAL::Point_set_3
Kernel::Point_3
Kernel
CGAL::Simple_cartesian