fix classification example using region growing

This commit is contained in:
Sébastien Loriot 2022-08-04 09:07:36 +02:00
parent ce0ae181c4
commit 66b14125e8
1 changed files with 7 additions and 9 deletions

View File

@ -30,8 +30,8 @@ typedef Point_set::Property_map<int> Imap;
typedef Point_set::Property_map<unsigned char> UCmap;
typedef CGAL::Shape_detection::Point_set::Sphere_neighbor_query<Kernel, Point_set, Pmap> Neighbor_query;
typedef CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region<Kernel, Point_set, Pmap, Vmap> Region_type;
typedef CGAL::Shape_detection::Point_set::Sphere_neighbor_query_for_point_set<Point_set> Neighbor_query;
typedef CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region_for_point_set<Point_set> Region_type;
typedef CGAL::Shape_detection::Region_growing<Neighbor_query, Region_type> Region_growing;
namespace Classification = CGAL::Classification;
@ -111,26 +111,24 @@ int main (int argc, char** argv)
const double max_accepted_angle = 25.0;
const std::size_t min_region_size = 10;
Neighbor_query neighbor_query (
Neighbor_query neighbor_query = CGAL::Shape_detection::Point_set::make_sphere_neighbor_query (
pts, CGAL::parameters::sphere_radius(search_sphere_radius)
.point_map(pts.point_map()));
Region_type region_type(
Region_type region_type = CGAL::Shape_detection::Point_set::make_least_squares_plane_fit_region(
pts, CGAL::parameters::maximum_distance(max_distance_to_plane)
.maximum_angle(max_accepted_angle)
.minimum_region_size(min_region_size)
.point_map(pts.point_map())
.normal_map(pts.normal_map()));
.minimum_region_size(min_region_size));
Region_growing region_growing (
pts, neighbor_query, region_type);
std::vector<Cluster> clusters;
region_growing.detect
(boost::make_function_output_iterator
([&](const std::vector<std::size_t>& region) -> void {
([&](const std::pair<Kernel::Plane_3, std::vector<Point_set::Index>>& region) -> void {
// Create a new cluster.
Classification::Cluster<Point_set, Pmap> cluster (pts, pts.point_map());
for (const std::size_t idx : region)
for (Point_set::Index idx : region.second)
cluster.insert(idx);
clusters.push_back(cluster);
}));