ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
segment_rooms.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 <pcl/community_clustering.hpp>
12
13
#include <fmt/format.h>
14
15
#include <pcl/common/pca.h>
16
#include <pcl/correspondence.h>
17
#include <pcl/filters/filter.h>
18
#include <pcl/filters/uniform_sampling.h>
19
#include <pcl/io/auto_io.h>
20
#include <pcl/io/pcd_io.h>
21
#include <pcl/point_types.h>
22
#include <pcl/search/kdtree.h>
23
24
#include <atomic>
25
26
namespace
reusex::geometry
{
27
struct
SegmentRoomsOptions
{
28
IndicesConstPtr
filter
=
nullptr
;
// Optional filter to limit processing
29
30
float
grid_size
= 0.5F;
31
float
resolution
= 1.0F;
32
float
beta
= 0.01F;
33
// Finite Leiden iteration bound. STANDARDS ยง5 forbids unbounded loops in
34
// long-running stages; the previous -1 ("until convergence") could spin
35
// indefinitely on pathological graphs. 100 iterations is well past the
36
// point where Leiden modularity plateaus for room-scale graphs.
37
int
max_iter
= 100;
38
39
// --- Label propagation to non-sampled points (distance-bounded k-NN) ---
40
// Room clustering runs on a uniformly sampled subset; the remaining points
41
// inherit a room label from their sampled neighbours. A distance-bounded
42
// k-NN majority vote replaces the old unchecked 1-NN so that a single
43
// misclassified seed cannot smear across a whole region, and points with no
44
// labelled neighbour inside the radius stay kUnlabeled (0) instead of
45
// silently copying a far-away label.
46
int
propagate_k
= 5;
47
float
propagate_max_radius
= 0.5F;
49
50
// Optional cancellation flag. Caller retains ownership and must keep this
51
// alive for the full duration of the segment_rooms(...) call.
52
const
std::atomic_bool *
cancel_token
=
nullptr
;
53
};
54
73
auto
propagate_room_labels
(
CloudConstPtr
cloud,
CloudLPtr
labels,
74
IndicesConstPtr
sampled_indices,
75
IndicesConstPtr
missing_indices,
int
k,
76
float
max_radius) -> size_t;
77
78
auto
segment_rooms_impl
(
CloudConstPtr
cloud,
CloudNConstPtr
normals,
79
CloudLConstPtr
planes,
80
const
SegmentRoomsOptions
&options) ->
CloudLPtr
;
81
auto
segment_rooms
(
CloudConstPtr
cloud,
CloudNConstPtr
normals,
82
CloudLConstPtr
planes,
83
const
SegmentRoomsOptions
&options =
SegmentRoomsOptions
{})
84
->
CloudLPtr
;
85
86
}
// namespace reusex::geometry
reusex::geometry
Definition
visual_observer.hpp:33
reusex::geometry::propagate_room_labels
auto propagate_room_labels(CloudConstPtr cloud, CloudLPtr labels, IndicesConstPtr sampled_indices, IndicesConstPtr missing_indices, int k, float max_radius) -> size_t
Propagate room labels from a labelled subset to a set of missing points using a distance-bounded k-NN...
reusex::geometry::segment_rooms_impl
auto segment_rooms_impl(CloudConstPtr cloud, CloudNConstPtr normals, CloudLConstPtr planes, const SegmentRoomsOptions &options) -> CloudLPtr
reusex::geometry::segment_rooms
auto segment_rooms(CloudConstPtr cloud, CloudNConstPtr normals, CloudLConstPtr planes, const SegmentRoomsOptions &options=SegmentRoomsOptions{}) -> CloudLPtr
reusex::IndicesConstPtr
pcl::IndicesConstPtr IndicesConstPtr
Definition
point_types.hpp:25
reusex::CloudLPtr
typename CloudL::Ptr CloudLPtr
Definition
point_types.hpp:36
reusex::CloudLConstPtr
typename CloudL::ConstPtr CloudLConstPtr
Definition
point_types.hpp:37
reusex::CloudConstPtr
typename Cloud::ConstPtr CloudConstPtr
Definition
point_types.hpp:29
reusex::CloudNConstPtr
typename CloudN::ConstPtr CloudNConstPtr
Definition
point_types.hpp:33
reusex::geometry::SegmentRoomsOptions
Definition
segment_rooms.hpp:27
reusex::geometry::SegmentRoomsOptions::grid_size
float grid_size
Definition
segment_rooms.hpp:30
reusex::geometry::SegmentRoomsOptions::resolution
float resolution
Definition
segment_rooms.hpp:31
reusex::geometry::SegmentRoomsOptions::propagate_max_radius
float propagate_max_radius
Max search radius (meters); no label beyond this stays unlabeled.
Definition
segment_rooms.hpp:47
reusex::geometry::SegmentRoomsOptions::cancel_token
const std::atomic_bool * cancel_token
Definition
segment_rooms.hpp:52
reusex::geometry::SegmentRoomsOptions::propagate_k
int propagate_k
Neighbours polled per missing point.
Definition
segment_rooms.hpp:46
reusex::geometry::SegmentRoomsOptions::filter
IndicesConstPtr filter
Definition
segment_rooms.hpp:28
reusex::geometry::SegmentRoomsOptions::beta
float beta
Definition
segment_rooms.hpp:32
reusex::geometry::SegmentRoomsOptions::max_iter
int max_iter
Definition
segment_rooms.hpp:37
libs
reusex
include
segmentation
segment_rooms.hpp
Generated by
1.17.0