ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
segment_planes.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6#include "reusex/core/logging.hpp"
7#include "reusex/core/processing_observer.hpp"
8#include "reusex/types/point_types.hpp"
9#include "reusex/utils/fmt_formatter.hpp"
10
11#include <fmt/format.h>
12#include <pcl/common/colors.h>
13#include <pcl/filters/filter.h>
14#include <pcl/io/auto_io.h>
15#include <pcl/io/pcd_io.h>
16#include <pcl/planar_region_growing.hpp>
17
18#include <atomic>
19#include <optional>
20
21namespace reusex::geometry {
22
24 IndicesConstPtr filter = nullptr; // Optional filter to limit processing
25
26 float angle_threshold = 25.0F;
27
28 // Distance and inlier thresholds are derived per-cloud from the measured
29 // noise/density when `adaptive` is true (issue #214), UNLESS the caller
30 // supplies an explicit override below. An explicit override always wins over
31 // adaptivity for that one parameter (e.g. a `-d` CLI flag pins the distance
32 // threshold while `min_inliers` still adapts). When `adaptive` is false the
33 // legacy fixed defaults are used.
34 float plane_dist_threshold = 0.07F;
35 int min_inliers = 1000;
36
37 float radius = 0.5F;
38 float interval_0 = 16.0F;
39 float interval_factor = 1.5F;
40
42 bool adaptive = true;
44 std::optional<float> plane_dist_threshold_override;
46 std::optional<int> min_inliers_override;
48 unsigned noise_seed = 42;
49
50 // --- Adaptive scaling constants (issue #214) ------------------------------
53 float dist_sigma_factor = 3.0F;
54 float dist_min = 0.01F;
55 float dist_max = 0.15F;
58 float min_surface_area = 0.5F;
61
62 // --- Post-segmentation sanity thresholds (issue #214) ---------------------
66 float warn_labeled_fraction = 0.30F;
67
68 // Optional cancellation flag. Caller retains ownership and must keep this
69 // alive for the full duration of the segment_planes(...) call.
70 const std::atomic_bool *cancel_token = nullptr;
71};
72
74 const SegmentPlanesOptions &options)
75 -> std::tuple<CloudLPtr, CloudLocPtr, CloudNPtr>;
76
78 CloudConstPtr cloud, CloudNConstPtr normals,
80 -> std::tuple<CloudLPtr, CloudLocPtr, CloudNPtr>;
81
82} // namespace reusex::geometry
auto segment_planes_impl(CloudConstPtr cloud, CloudNConstPtr normals, const SegmentPlanesOptions &options) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >
auto segment_planes(CloudConstPtr cloud, CloudNConstPtr normals, const SegmentPlanesOptions &options=SegmentPlanesOptions{}) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >
pcl::IndicesConstPtr IndicesConstPtr
typename Cloud::ConstPtr CloudConstPtr
typename CloudN::ConstPtr CloudNConstPtr
unsigned noise_seed
Deterministic seed for the noise estimator (STANDARDS ยง6).
float warn_labeled_fraction
Warn when the labeled point fraction falls below this (under-coverage).
std::optional< int > min_inliers_override
Explicit min-inliers override; bypasses adaptivity when set.
int warn_plane_count
Warn when the detected plane count exceeds this (over-fragmentation).
float dist_max
upper clamp for adaptive distance threshold [m]
float min_surface_area
Target minimum planar surface area [m^2] used to scale min_inliers by the measured point density (poi...
bool adaptive
Enable noise-adaptive threshold derivation (default ON, issue #214).
std::optional< float > plane_dist_threshold_override
Explicit distance-threshold override [m]; bypasses adaptivity when set.
float dist_sigma_factor
plane_dist_threshold = clamp(dist_sigma_factor * sigma, dist_min,dist_max)
int min_inliers_ceiling
upper clamp for adaptive min_inliers
int min_inliers_floor
lower clamp for adaptive min_inliers
float dist_min
lower clamp for adaptive distance threshold [m]