#include <CGAL/Simple_cartesian.h>
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
#include "include/utils.h"
#include <boost/range/irange.hpp>
using FT = typename Kernel::FT;
using Point_with_normal = std::pair<Point_2, Vector_2>;
using Point_set_2 = std::vector<Point_with_normal>;
int main(int argc, char *argv[]) {
const bool is_default_input = argc > 1 ? false : true;
std::ifstream in(is_default_input ?
CGAL::data_file_path(
"points_3/buildings_outline.xyz") : argv[1]);
if (!in) {
std::cerr << "ERROR: cannot read the input file!" << std::endl;
return EXIT_FAILURE;
}
FT a, b, c, d, e, f;
Point_set_2 point_set_2;
while (in >> a >> b >> c >> d >> e >> f) {
point_set_2.push_back(
}
in.close();
std::cout << "* number of input points: " << point_set_2.size() << std::endl;
assert(!is_default_input || point_set_2.size() == 3634);
const FT sphere_radius = FT(5);
const FT max_distance = FT(45) / FT(10);
const FT max_angle = FT(45);
const std::size_t min_region_size = 5;
Point_map point_map(CGAL::make_random_access_property_map(point_set_2));
Normal_map normal_map(CGAL::make_random_access_property_map(point_set_2));
Neighbor_query neighbor_query(
boost::irange<std::size_t>(0,point_set_2.size()),
CGAL::parameters::sphere_radius(sphere_radius)
.point_map(point_map));
Region_type region_type(
maximum_distance(max_distance).
maximum_angle(max_angle).
minimum_region_size(min_region_size).
normal_map(normal_map).
point_map(point_map));
Region_growing region_growing(
boost::irange<std::size_t>(0,point_set_2.size()), neighbor_query, region_type);
std::vector<typename Region_growing::Primitive_and_region> regions;
region_growing.detect(std::back_inserter(regions));
std::cout << "* number of found lines: " << regions.size() << std::endl;
assert(!is_default_input || regions.size() == 72);
const std::string fullpath = (argc > 2 ? argv[2] : "lines_point_set_2.ply");
utils::save_point_regions_2<Kernel, std::vector<typename Region_growing::Primitive_and_region>, Point_map>(
regions, fullpath, point_map);
return EXIT_SUCCESS;
}
A convenience header that includes all classes related to the region growing algorithm on a point set...
Region type based on the quality of the least squares line fit applied to 2D points.
Definition: Least_squares_line_fit_region.h:60
Fuzzy sphere neighbors search in a set of 2D or 3D points.
Definition: Sphere_neighbor_query.h:57
Main class/entry point for running the region growing algorithm.
Definition: Region_growing.h:72
Mode set_ascii_mode(std::ios &s)
std::string data_file_path(const std::string &filename)