ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::geometry Namespace Reference

Namespaces

namespace  cgal

Classes

struct  WindowData
struct  DoorData
struct  WallData
struct  BuildingComponent
 A detected or manual building component (window, door, wall, ...). More...
struct  CellVertexData
struct  FaceData
struct  CellData
struct  VertexProperties
struct  CellEdgeData
class  CellComplex
struct  CoplanarPolygon
 A closed 3D polygon whose vertices are coplanar. More...
struct  WallCandidate
 A connected component of approximately-vertical, coplanar mesh faces. More...
struct  CreateWindowsOptions
 Configuration for the create_windows pipeline. More...
struct  CreateWindowsResult
 Output of create_windows(). More...
struct  MeshOptions
 Options for mesh generation. More...
struct  ReconstructionParams
 Parameters for point cloud reconstruction from stored sensor frames. More...
class  Registry
struct  PointCluster
struct  ScenePlane
struct  SceneObject
struct  SceneVertexData
struct  SceneEdgeData
class  SceneGraph
struct  SegmentInstancesRequest
 Request structure for instance segmentation via Euclidean clustering. More...
struct  SegmentInstancesResult
 Result structure for instance segmentation. More...
struct  SegmentPlanesOptions
struct  SegmentRoomsOptions
class  Solidifier
 Solidifier solves room segmentation using Mixed Integer Programming. More...
struct  CameraData
 Camera data for texture mapping. More...

Typedefs

template<typename Scalar>
using Plane = Eigen::Matrix<Scalar, 4, 1>
template<typename Scalar>
using PlaneVector

Enumerations

enum class  ComponentType { window , door , wall }
 Discriminator for building component types. More...
enum class  CellNodeType { cell , face , vertex }
enum class  WindowBoundaryMode { rectangle , polyline }
 How to compute the window boundary polygon. More...
enum class  SceneNodeType { point_cluster , plane , object }

Functions

std::string_view to_string (ComponentType type)
ComponentType component_type_from_string (std::string_view str)
std::string component_data_to_json (const BuildingComponent &c)
 Serialize the type-specific variant data to JSON TEXT.
void component_data_from_json (BuildingComponent &c, const std::string &json)
 Deserialize JSON TEXT into the variant data on a BuildingComponent.
std::vector< WallCandidateextract_wall_candidates (const pcl::PolygonMesh &mesh, float normal_z_threshold=0.3f, float coplanarity_angle_deg=10.0f)
 Extract planar vertical wall candidates from a triangle mesh.
CreateWindowsResult create_windows (CloudConstPtr cloud, CloudLConstPtr instance_labels, const std::map< uint32_t, uint32_t > &instance_to_semantic, const pcl::PolygonMesh &mesh, const std::vector< uint32_t > &window_semantic_labels, const CreateWindowsOptions &options={})
 Create window BuildingComponents from instance-labeled points and wall geometry.
void apply_depth_discontinuity_filter (cv::Mat &depth, cv::Mat &confidence, float gradient_threshold=0.5f)
 Remove "flying pixels" at depth discontinuity edges.
void apply_ray_consistency_filter (cv::Mat &depth, cv::Mat &confidence, float consistency_threshold=0.2f)
 Remove isolated noisy depth measurements.
pcl::PolygonMeshPtr mesh (CloudConstPtr cloud, CloudNConstPtr normals, EigenVectorContainer< double, 4 > &planes, EigenVectorContainer< double, 3 > &centroids, std::vector< IndicesPtr > &inliers, CloudLConstPtr rooms, MeshOptions const opt=MeshOptions{})
 Generate a mesh from point cloud and geometric primitives.
void reconstruct_point_clouds (ProjectDB &db, const ReconstructionParams &params)
 Generate merged point clouds from sensor frames stored in a ProjectDB.
template<typename Scalar, typename PointT>
auto regularizePlanes (PlaneVector< Scalar > &planes, typename pcl::PointCloud< PointT >::ConstPtr points, std::vector< pcl::IndicesPtr > &inliers, double angle_threshold=25.0, double distance_threshold=0.01)
auto segment_instances (const SegmentInstancesRequest &request) -> SegmentInstancesResult
 Segment point cloud into instances using Euclidean clustering.
auto segment_instances_impl (const SegmentInstancesRequest &request) -> SegmentInstancesResult
 Implementation function for segment_instances.
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 >
auto segment_rooms_impl (CloudConstPtr cloud, CloudNConstPtr normals, CloudLConstPtr planes, const SegmentRoomsOptions &options) -> CloudLPtr
auto segment_rooms (CloudConstPtr cloud, CloudNConstPtr normals, CloudLConstPtr planes, const SegmentRoomsOptions &options=SegmentRoomsOptions{}) -> CloudLPtr
pcl::TextureMesh::Ptr texture_mesh_with_cloud (pcl::PolygonMesh::Ptr mesh, CloudConstPtr cloud)
pcl::TextureMesh::Ptr texture_mesh (pcl::PolygonMesh::Ptr mesh, std::map< int, rtabmap::Transform > const &poses, std::map< int, rtabmap::Signature > const &nodes)
 Texture mesh using RTABMap signatures (legacy API).
pcl::TextureMesh::Ptr texture_mesh (pcl::PolygonMesh::Ptr mesh, std::map< int, CameraData > const &cameras)
 Texture mesh using simple camera data (ProjectDB API).
pcl::PolygonMeshPtr unweld_mesh (const pcl::PolygonMesh &mesh, float threshold_radians)
 Unweld (split) mesh vertices along sharp edges.
auto dist_plane_point (const Eigen::Vector4d &plane, const Eigen::Vector3d &point) -> double
 Calculate distance from a point to a plane.
auto make_pairs (EigenVectorContainer< double, 4 > &planes, std::vector< IndicesPtr > &inliers, EigenVectorContainer< double, 3 > &centroids, const double threshold=0.6, const double new_plane_offset=0.5) -> std::vector< std::pair< size_t, size_t > >
 Create pairs of opposite parallel planes.
auto force_orthogonal_planes (EigenVectorContainer< double, 4 > &planes, const double threshold=0.1, const Eigen::Matrix< double, 3, 1 > &up=Eigen::Matrix< double, 3, 1 >(0, 0, 1)) -> EigenVectorContainer< double, 4 >
 Force planes to be orthogonal to a reference direction.
auto compute_number_of_inliers (CloudConstPtr cloud, Eigen::Vector4d const &plane, IndicesConstPtr indices, const float threshold=0.2) -> size_t
 Count number of inliers for a plane.
auto merge_planes (EigenVectorContainer< double, 4 > const &planes_, std::vector< IndicesPtr > const &inliers_, EigenVectorContainer< double, 3 > const &centroids_, CloudConstPtr cloud, const double angle_threshold=0.1, const double distance_threshold=0.5, const double min_overlap=0.8) -> std::tuple< EigenVectorContainer< double, 4 >, std::vector< IndicesPtr >, EigenVectorContainer< double, 3 > >
 Merge similar planes based on angle, distance, and overlap.
auto separate_planes (const EigenVectorContainer< double, 4 > &planes, const Eigen::Vector3d &up=Eigen::Vector3d(0, 0, 1), const double epsilon=0.1) -> std::tuple< std::vector< size_t >, std::vector< size_t > >
 Separate planes into horizontal and vertical based on up vector.
template<typename CloudPtr>
auto compute_polygon_normal (const pcl::Vertices &poly, const CloudPtr &cloud) -> Eigen::Vector3f
 Compute the normal vector of a polygon.

Typedef Documentation

◆ Plane

template<typename Scalar>
using reusex::geometry::Plane = Eigen::Matrix<Scalar, 4, 1>

Definition at line 70 of file regularization.hpp.

◆ PlaneVector

template<typename Scalar>
using reusex::geometry::PlaneVector
Initial value:
std::vector<Plane<Scalar>, Eigen::aligned_allocator<Plane<Scalar>>>

Definition at line 73 of file regularization.hpp.

Enumeration Type Documentation

◆ CellNodeType

enum class reusex::geometry::CellNodeType
strong
Enumerator
cell 
face 
vertex 

Definition at line 28 of file CellComplex.hpp.

◆ ComponentType

Discriminator for building component types.

Enumerator
window 
door 
wall 

Definition at line 17 of file BuildingComponent.hpp.

◆ SceneNodeType

Enumerator
point_cluster 
plane 
object 

Definition at line 31 of file SceneGraph.hpp.

◆ WindowBoundaryMode

How to compute the window boundary polygon.

Enumerator
rectangle 
polyline 

Definition at line 34 of file create_windows.hpp.

Function Documentation

◆ apply_depth_discontinuity_filter()

void reusex::geometry::apply_depth_discontinuity_filter ( cv::Mat & depth,
cv::Mat & confidence,
float gradient_threshold = 0.5f )

Remove "flying pixels" at depth discontinuity edges.

Computes depth gradients via Sobel operators and zeros out pixels with gradient magnitudes exceeding gradient_threshold.

Parameters
depthInput/output depth map (single-channel), modified in-place.
confidenceInput/output confidence map, modified in-place (may be empty).
gradient_thresholdMaximum allowed gradient in meters per pixel.

◆ apply_ray_consistency_filter()

void reusex::geometry::apply_ray_consistency_filter ( cv::Mat & depth,
cv::Mat & confidence,
float consistency_threshold = 0.2f )

Remove isolated noisy depth measurements.

Compares each pixel to the median of its 5x5 neighbourhood and zeros out pixels deviating by more than consistency_threshold.

Parameters
depthInput/output depth map (single-channel), modified in-place.
confidenceInput/output confidence map, modified in-place (may be empty).
consistency_thresholdMaximum allowed deviation from neighbourhood median in meters.

◆ component_data_from_json()

void reusex::geometry::component_data_from_json ( BuildingComponent & c,
const std::string & json )

Deserialize JSON TEXT into the variant data on a BuildingComponent.

◆ component_data_to_json()

std::string reusex::geometry::component_data_to_json ( const BuildingComponent & c)

Serialize the type-specific variant data to JSON TEXT.

◆ component_type_from_string()

ComponentType reusex::geometry::component_type_from_string ( std::string_view str)

◆ compute_number_of_inliers()

auto reusex::geometry::compute_number_of_inliers ( CloudConstPtr cloud,
Eigen::Vector4d const & plane,
IndicesConstPtr indices,
const float threshold = 0.2 ) -> size_t

Count number of inliers for a plane.

Parameters
cloudInput point cloud.
planePlane coefficients.
indicesPoint indices to check.
thresholdDistance threshold for inliers. Default 0.2.
Returns
Number of inliers.

◆ compute_polygon_normal()

template<typename CloudPtr>
auto reusex::geometry::compute_polygon_normal ( const pcl::Vertices & poly,
const CloudPtr & cloud ) -> Eigen::Vector3f

Compute the normal vector of a polygon.

Calculates the normal vector of a polygon using the cross product sum method (also known as Newell's method). The normal is automatically normalized.

Template Parameters
CloudPtrPoint cloud pointer type (const or non-const, e.g., CloudLocConstPtr).
Parameters
polyPolygon with vertex indices.
cloudPoint cloud containing the vertices (read-only).
Returns
Normalized normal vector of the polygon.
Exceptions
std::invalid_argumentif polygon has fewer than 3 vertices.
std::runtime_errorif polygon is degenerate (zero normal magnitude).

Definition at line 129 of file utils.hpp.

◆ create_windows()

CreateWindowsResult reusex::geometry::create_windows ( CloudConstPtr cloud,
CloudLConstPtr instance_labels,
const std::map< uint32_t, uint32_t > & instance_to_semantic,
const pcl::PolygonMesh & mesh,
const std::vector< uint32_t > & window_semantic_labels,
const CreateWindowsOptions & options = {} )

Create window BuildingComponents from instance-labeled points and wall geometry.

For each window instance, projects its points onto the nearest wall plane, computes a boundary polygon (AABB or concave hull), and offsets it along the outward wall normal. Performs validation to filter out windows that intersect the mesh, are out of bounds, or are internal (optional).

References mesh().

◆ dist_plane_point()

auto reusex::geometry::dist_plane_point ( const Eigen::Vector4d & plane,
const Eigen::Vector3d & point ) -> double

Calculate distance from a point to a plane.

Parameters
planePlane coefficients (nx, ny, nz, d) where n is the normal.
point3D point coordinates.
Returns
Signed distance from point to plane.

◆ extract_wall_candidates()

std::vector< WallCandidate > reusex::geometry::extract_wall_candidates ( const pcl::PolygonMesh & mesh,
float normal_z_threshold = 0.3f,
float coplanarity_angle_deg = 10.0f )

Extract planar vertical wall candidates from a triangle mesh.

Decomposes the mesh into connected components of approximately-vertical, coplanar faces. Each component becomes a WallCandidate with a fitted plane, centroid, outward normal, and boundary vertices.

References mesh().

◆ force_orthogonal_planes()

auto reusex::geometry::force_orthogonal_planes ( EigenVectorContainer< double, 4 > & planes,
const double threshold = 0.1,
const Eigen::Matrix< double, 3, 1 > & up = Eigen::Matrix< double, 3, 1 >(0, 0, 1) ) -> EigenVectorContainer< double, 4 >

Force planes to be orthogonal to a reference direction.

Adjusts plane normals to be either parallel or perpendicular to the up vector.

Parameters
planesPlane coefficients to adjust.
thresholdAngular threshold for orthogonality. Default 0.1.
upReference up vector. Default (0, 0, 1).
Returns
Adjusted plane coefficients.

◆ make_pairs()

auto reusex::geometry::make_pairs ( EigenVectorContainer< double, 4 > & planes,
std::vector< IndicesPtr > & inliers,
EigenVectorContainer< double, 3 > & centroids,
const double threshold = 0.6,
const double new_plane_offset = 0.5 ) -> std::vector< std::pair< size_t, size_t > >

Create pairs of opposite parallel planes.

Finds pairs of planes with opposite normals within a distance threshold. Creates new planes for unpaired planes.

Parameters
planesPlane coefficients.
inliersIndices of points belonging to each plane.
centroidsPlane centroids.
thresholdMaximum distance threshold for pairing. Default 0.6.
new_plane_offsetOffset for creating new planes. Default 0.5.
Returns
Vector of plane index pairs.

◆ merge_planes()

auto reusex::geometry::merge_planes ( EigenVectorContainer< double, 4 > const & planes_,
std::vector< IndicesPtr > const & inliers_,
EigenVectorContainer< double, 3 > const & centroids_,
CloudConstPtr cloud,
const double angle_threshold = 0.1,
const double distance_threshold = 0.5,
const double min_overlap = 0.8 ) -> std::tuple< EigenVectorContainer< double, 4 >, std::vector< IndicesPtr >, EigenVectorContainer< double, 3 > >

Merge similar planes based on angle, distance, and overlap.

Parameters
planes_Input plane coefficients.
inliers_Inliers for each plane.
centroids_Plane centroids.
cloudPoint cloud.
angle_thresholdAngular similarity threshold. Default 0.1.
distance_thresholdDistance threshold for merging. Default 0.5.
min_overlapMinimum overlap ratio for merging. Default 0.8.
Returns
Tuple of (merged planes, merged inliers, merged centroids).

◆ mesh()

pcl::PolygonMeshPtr reusex::geometry::mesh ( CloudConstPtr cloud,
CloudNConstPtr normals,
EigenVectorContainer< double, 4 > & planes,
EigenVectorContainer< double, 3 > & centroids,
std::vector< IndicesPtr > & inliers,
CloudLConstPtr rooms,
MeshOptions const opt = MeshOptions{} )

Generate a mesh from point cloud and geometric primitives.

Parameters
cloudInput point cloud.
normalsPoint cloud normals.
planesDetected plane coefficients.
centroidsPlane centroids.
inliersIndices of points belonging to each plane.
roomsRoom labels for points.
optMesh generation options (includes optional filter).
Returns
Generated polygon mesh.

Referenced by create_windows(), reusex::geometry::cgal::decompose_mesh(), extract_wall_candidates(), texture_mesh(), texture_mesh(), texture_mesh_with_cloud(), and unweld_mesh().

◆ reconstruct_point_clouds()

void reusex::geometry::reconstruct_point_clouds ( ProjectDB & db,
const ReconstructionParams & params )

Generate merged point clouds from sensor frames stored in a ProjectDB.

For each sensor frame the function reads depth, confidence, color, pose, and intrinsics; applies depth filters; performs custom pinhole back-projection; estimates normals; and accumulates into a single cloud. Post-processing includes voxelisation, NaN removal, label majority voting, statistical outlier removal, and radius outlier removal.

Results are saved into the ProjectDB as "cloud", "normals", and "labels".

Parameters
dbProject database (read/write).
paramsReconstruction parameters.

◆ regularizePlanes()

template<typename Scalar, typename PointT>
auto reusex::geometry::regularizePlanes ( PlaneVector< Scalar > & planes,
typename pcl::PointCloud< PointT >::ConstPtr points,
std::vector< pcl::IndicesPtr > & inliers,
double angle_threshold = 25.0,
double distance_threshold = 0.01 )

Definition at line 77 of file regularization.hpp.

References reusex::trace().

◆ segment_instances()

auto reusex::geometry::segment_instances ( const SegmentInstancesRequest & request) -> SegmentInstancesResult

Segment point cloud into instances using Euclidean clustering.

Applies PCL's Euclidean clustering algorithm within each semantic class to separate spatially-disconnected regions into distinct instances.

Algorithm:

  1. Extract unique semantic labels (skip label 0)
  2. For each semantic class (parallelized with OpenMP):
    • Build KdTree with points from that class
    • Apply pcl::extractEuclideanClusters
    • Assign sequential instance IDs
  3. Store metadata (instance → semantic mapping, sizes)
Parameters
requestConfiguration and input data
Returns
Result containing instance labels and metadata
Exceptions
std::invalid_argumentif inputs are invalid
std::runtime_errorif cancellation requested

◆ segment_instances_impl()

auto reusex::geometry::segment_instances_impl ( const SegmentInstancesRequest & request) -> SegmentInstancesResult

Implementation function for segment_instances.

Separated for future enhancements (e.g., different clustering algorithms)

◆ segment_planes()

auto reusex::geometry::segment_planes ( CloudConstPtr cloud,
CloudNConstPtr normals,
const SegmentPlanesOptions & options = SegmentPlanesOptions{} ) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >

◆ segment_planes_impl()

auto reusex::geometry::segment_planes_impl ( CloudConstPtr cloud,
CloudNConstPtr normals,
const SegmentPlanesOptions & options ) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >

◆ segment_rooms()

auto reusex::geometry::segment_rooms ( CloudConstPtr cloud,
CloudNConstPtr normals,
CloudLConstPtr planes,
const SegmentRoomsOptions & options = SegmentRoomsOptions{} ) -> CloudLPtr

◆ segment_rooms_impl()

auto reusex::geometry::segment_rooms_impl ( CloudConstPtr cloud,
CloudNConstPtr normals,
CloudLConstPtr planes,
const SegmentRoomsOptions & options ) -> CloudLPtr

◆ separate_planes()

auto reusex::geometry::separate_planes ( const EigenVectorContainer< double, 4 > & planes,
const Eigen::Vector3d & up = Eigen::Vector3d(0, 0, 1),
const double epsilon = 0.1 ) -> std::tuple< std::vector< size_t >, std::vector< size_t > >

Separate planes into horizontal and vertical based on up vector.

Parameters
planesPlane coefficients.
upReference up vector. Default (0, 0, 1).
epsilonAngular epsilon for classification. Default 0.1.
Returns
Tuple of (horizontal indices, vertical indices).

◆ texture_mesh() [1/2]

pcl::TextureMesh::Ptr reusex::geometry::texture_mesh ( pcl::PolygonMesh::Ptr mesh,
std::map< int, CameraData > const & cameras )

Texture mesh using simple camera data (ProjectDB API).

References mesh().

◆ texture_mesh() [2/2]

pcl::TextureMesh::Ptr reusex::geometry::texture_mesh ( pcl::PolygonMesh::Ptr mesh,
std::map< int, rtabmap::Transform > const & poses,
std::map< int, rtabmap::Signature > const & nodes )

Texture mesh using RTABMap signatures (legacy API).

References mesh().

◆ texture_mesh_with_cloud()

pcl::TextureMesh::Ptr reusex::geometry::texture_mesh_with_cloud ( pcl::PolygonMesh::Ptr mesh,
CloudConstPtr cloud )

References mesh().

◆ to_string()

std::string_view reusex::geometry::to_string ( ComponentType type)

◆ unweld_mesh()

pcl::PolygonMeshPtr reusex::geometry::unweld_mesh ( const pcl::PolygonMesh & mesh,
float threshold_radians )

Unweld (split) mesh vertices along sharp edges.

Vertices shared by faces whose normals differ by more than threshold_radians are duplicated so each smooth face group gets its own copy. This produces correct per-face normals for export to formats like OBJ, Speckle, or Rhino.

Parameters
meshInput polygon mesh (const ref, not modified).
threshold_radiansMaximum dihedral angle (in radians) between face normals for vertices to remain shared. 0 = fully unweld, pi = preserve all sharing.
Returns
New polygon mesh with split vertices.

References mesh().