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

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

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, 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.

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 <ReconstructionConfig.hpp>

Configuration parameters for the roofer building reconstruction algorithm.

Coordinate units are assumed to be in meters.

Public Members

float complexity_factor = 0.888

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 = 3.

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 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 = 15

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

int plane_detect_min_points = 15

Minimum number of points required for detecting a plane.

float plane_detect_epsilon = 0.300000

# 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.750000

Maximum allowed angle between points inside the same detected plane.

This value is compared to the dot product between two unit normals. Eg. 0 means 90 degrees (orthogonal normals), and 1.0 means 0 degrees (parallel normals)

float line_detect_epsilon = 1.000000

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 = 0.250000

Distance used in computing 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: meters.

float thres_reg_line_dist = 0.800000

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 = 3.000000

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.