API Reference C++

The roofer C++ API allows you to use the roofer as a C++ library. Most notably it provides a reconstruct() function that takes a pointcloud and a roofprint polygon for a single building object and returns a reconstructed building model mesh.

Note

Because roofer internally uses floats to represent coordinates, it is advised to translate your data to the origin prior to calling reconstruct() to prevent loss of precision.

See this file for a short example of how to use the C++ bindings.

namespace roofer

Functions

inline ReconstructOptions to_reconstruct_options(const ReconstructionConfig &legacy)
template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, const PointCollection &points_ground, Footprint &footprint, std::span<const Underpass> underpasses, ReconstructOptions cfg)

Reconstructs a single instance of a building from a point cloud.

Template Parameters:

Footprint – Type of the footprint, either a LinearRing or a CGAL::Polygon_with_holes_2<Epick>

Parameters:
  • points_roof – Point cloud representing the roof points

  • points_ground – Point cloud representing the ground points

  • footprint – Footprint of the building

  • cfg – Configuration parameters

Returns:

std::vector<Mesh> Building geometry meshes. The number of meshes is equal to the number of building parts.

template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, const PointCollection &points_ground, Footprint &footprint, ReconstructOptions cfg)

Reconstruct without optional underpass input.

template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, Footprint &footprint, std::span<const Underpass> underpasses, ReconstructOptions cfg)

Reconstruct with underpasses when no ground point cloud is supplied.

template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, const PointCollection &points_ground, Footprint &footprint, ReconstructionConfig cfg = ReconstructionConfig())

Compatibility overload for the flattened 1.x configuration.

template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, Footprint &footprint, ReconstructionConfig cfg = ReconstructionConfig())

Reconstructs a single instance of a building from a point cloud Overload for when the ground points are not available.

Template Parameters:

Footprint – Type of the footprint, either a LinearRing or a CGAL::Polygon_with_holes_2<Epick>

Parameters:
  • points_roof – Point cloud representing the roof points

  • footprint – Footprint of the building

  • cfg – Configuration parameters

Returns:

std::vector<Mesh> Building geometry meshes. The number of meshes is equal to the number of building parts. This number is equal to one if no ground points are available.

template<typename Footprint>
std::vector<Mesh> reconstruct(const PointCollection &points_roof, Footprint &footprint, ReconstructOptions cfg)
TriangleCollection triangulate_mesh(const Mesh &mesh)

Triangulates a mesh using roofer::reconstruction::MeshTriangulatorLegacy.

Parameters:

mesh – Mesh to triangulate

Returns:

TriangleCollection Triangulated mesh

struct ReconstructionConfig
#include <roofer.h>

Configuration parameters for the roofer building reconstruction algorithm.

Coordinate units are assumed to be in meters.

Public Members

float complexity_factor = reconstruction::ArrangementOptimiserConfig{}.complexity_factor

Complexity factor for building model geometry.

A number between 0.0 and 1.0. Higher values lead to more detailed building models, lower values to simpler models.

bool clip_ground = true

Set to true to activate the procedure that clips parts from the input footprint wherever patches of ground points are detected.

May cause irregular outlines in reconstruction result.

int lod = 22

Requested Level of Detail.

  • 12: LoD 1.2

  • 13: LoD 1.3

  • 22: LoD 2.2

float lod13_step_height = reconstruction::ReconstructionConfig{}.lod13_step_height

Step height used for LoD13 generalisation, i.e.

roofparts with a height discontinuity that is smaller than this value are merged. Only affects LoD 1.3 reconstructions. Unit: meters.

float unit_scale = reconstruction::ReconstructionConfig{}.unit_scale

Metres per input coordinate unit.

Distance parameters specified in metres are converted to input coordinate units for reconstruction.

float floor_elevation = 0.

Floor elevation in case it is not provided by the footprint (API only).

bool override_with_floor_elevation = false

Force flat floor instead of using the elevation of the footprint (API only).

int plane_detect_k = reconstruction::PlaneDetectorConfig{}.plane_neighbour_count

Number of points used in nearest neighbour queries during plane detection.

int plane_detect_min_points = reconstruction::PlaneDetectorConfig{}.min_plane_points

Minimum number of points required for detecting a plane.

float plane_detect_epsilon = reconstruction::PlaneDetectorConfig{}.plane_epsilon

# Maximum distance from candidate points to plane during plane fitting procedure.

Higher values offer more robustness against oversegmentation in plane detection, lower values give more planes that are closer to the point cloud. Unit: meters.

float plane_detect_normal_angle = 0.75F

Minimum dot-product similarity between unit normals within a detected plane.

This legacy value ranges from 0 (90 degrees) to 1 (0 degrees).

float line_detect_epsilon = reconstruction::LineDetectorConfig{}.distance_threshold

Maximum distance from candidate points to line during line fitting procedure.

Higher values offer more robustness against irregular lines, lower values give more accurate lines (ie. more closely wrapping around point cloud). Unit: meters.

float thres_alpha = reconstruction::AlphaShaperConfig{}.alpha

Squared-radius parameter used in computing the alpha-shape of detected plane segments prior to line detection.

Higher values offer more robustness against irregular lines, lower values give more accurate lines (ie. more closely wrapping around point cloud). Unit: square metres.

float thres_reg_line_dist = reconstruction::LineRegulariserConfig{}.distance_threshold

Maximum distance to merge lines during line regularisation (after line detection).

Approximately parallel lines that are closer to each other than this threshold are merged. Higher values yield more regularisation, lower values preserve more finer details. Unit: meters.

float thres_reg_line_ext = reconstruction::LineRegulariserConfig{}.extension

Extension of regularised lines prior to optimisation.

Used to compensate for undetected parts in the roofpart boundaries. Use higher values when the input pointcloud is less dense. However, setting this too high can lead to unrealistic reconstruction results. Unit: meters.

struct ReconstructOptions
#include <roofer.h>

Options for the nested reconstruction API.