#include <CGAL/Simple_cartesian.h>
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
#include "include/utils.h"
#include <boost/range/irange.hpp>
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(
std::make_pair(Point_2(a, b), Vector_2(d, e)));
}
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;
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;
}