# r-lidar/arbor architecture

> Architecture diagram of the GitHub repository r-lidar/arbor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r-lidar/arbor
- Repository: https://github.com/r-lidar/arbor

## Overview

Arbor is an R-accessible C++ pipeline that turns forest mobile-laser-scanning point clouds into ground, semantic and individual-tree classifications, then reconstructs quantitative structure models (QSMs). The README’s example establishes the user-facing stage order; source excerpts and the index support the point-cloud, graph, fitting and QSM internals shown here. Some documented stages are represented by their existing source directories because their implementation files were not sampled. Edges reflect documented workflow or visible source references; unsampled internals are not inferred.

Main entry points: [`src/api/arbor.h`](https://github.com/r-lidar/arbor/blob/main/src/api/arbor.h) (Arbor API), [`src/segment/segment_semantic_api.cpp`](https://github.com/r-lidar/arbor/blob/main/src/segment/segment_semantic_api.cpp) (Semantic segmentation), [`src/segment/GraphBuilder.cpp`](https://github.com/r-lidar/arbor/blob/main/src/segment/GraphBuilder.cpp) (Neighborhood graph), [`src/R`](https://github.com/r-lidar/arbor/tree/main/src/R) (R interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["API and point clouds"]
  node_r_api["R interface"]
  node_api["Arbor API<br/>[arbor.h]"]
  node_pointcloud["Point cloud<br/>[PointCloud.h]"]
end

subgraph group_classify["Point-cloud classification"]
  node_ground["Ground segmentation"]
  node_wood["Wood likelihood"]
  node_semantic["Semantic segmentation"]
  node_graph["Neighborhood graph<br/>[GraphBuilder.cpp]"]
  node_seeds["Tree seeds<br/>[SeedDetector.cpp]"]
  node_instances["Instance segmentation"]
end

subgraph group_reconstruct["QSM reconstruction"]
  node_qsm["QSM model<br/>[QSM.h]"]
  node_builder["QSM builder<br/>[QSMbuilder.h]"]
  node_radius["Radius fitting"]
  node_qsf["QSM collection<br/>[QSF.h]"]
end

subgraph group_support["Shared algorithms"]
  node_fitting["Geometric fitting"]
  node_allometry["Allometry<br/>[allometry.h]"]
  node_grid["3D grid<br/>[Grid3D.h]"]
  node_services["Runtime services<br/>[services.cpp]"]
  node_knn["KD-tree search<br/>[nanoflann.h]"]
end

node_user(("R user"))

node_user -->|"calls"| node_r_api
node_r_api -->|"runs"| node_ground
node_ground -->|"then computes"| node_wood
node_wood -->|"then segments"| node_semantic
node_semantic -->|"then finds"| node_seeds
node_seeds -->|"then segments"| node_instances
node_instances -->|"then reconstructs"| node_builder
node_r_api -->|"uses API"| node_api
node_api -->|"uses"| node_pointcloud
node_api -->|"uses"| node_qsm
node_api -->|"uses"| node_qsf
node_graph -->|"queries"| node_pointcloud
node_graph -.->|"searches via"| node_knn
node_semantic -->|"uses"| node_graph
node_semantic -->|"uses"| node_grid
node_builder -->|"builds"| node_qsm
node_radius -->|"fits with"| node_fitting
node_radius -->|"estimates with"| node_allometry
node_graph -->|"logs via"| node_services
node_builder -.->|"accepts"| node_pointcloud

click node_r_api "https://github.com/r-lidar/arbor/tree/main/src/R"
click node_api "https://github.com/r-lidar/arbor/blob/main/src/api/arbor.h"
click node_pointcloud "https://github.com/r-lidar/arbor/blob/main/src/pointcloud/PointCloud.h"
click node_ground "https://github.com/r-lidar/arbor/tree/main/src/segment"
click node_wood "https://github.com/r-lidar/arbor/tree/main/src/segment"
click node_semantic "https://github.com/r-lidar/arbor/blob/main/src/segment/segment_semantic_api.cpp"
click node_graph "https://github.com/r-lidar/arbor/blob/main/src/segment/GraphBuilder.cpp"
click node_seeds "https://github.com/r-lidar/arbor/blob/main/src/seed/SeedDetector.cpp"
click node_instances "https://github.com/r-lidar/arbor/tree/main/src/segment"
click node_qsm "https://github.com/r-lidar/arbor/blob/main/src/qsm/QSM.h"
click node_builder "https://github.com/r-lidar/arbor/blob/main/src/qsm/QSMbuilder.h"
click node_radius "https://github.com/r-lidar/arbor/blob/main/src/qsm/QSMbuilder_radius.cpp"
click node_qsf "https://github.com/r-lidar/arbor/blob/main/src/qsf/QSF.h"
click node_fitting "https://github.com/r-lidar/arbor/tree/main/src/fitting"
click node_allometry "https://github.com/r-lidar/arbor/blob/main/src/utils/allometry.h"
click node_grid "https://github.com/r-lidar/arbor/blob/main/src/utils/Grid3D.h"
click node_services "https://github.com/r-lidar/arbor/blob/main/src/utils/services.cpp"
click node_knn "https://github.com/r-lidar/arbor/blob/main/src/nanoflann/nanoflann.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_r_api,node_api,node_pointcloud,node_user toneBlue
class node_ground,node_wood,node_semantic,node_graph,node_seeds,node_instances toneAmber
class node_qsm,node_builder,node_radius,node_qsf toneMint
class node_fitting,node_allometry,node_grid,node_services,node_knn toneRose
```

## Components

### API and point clouds

- [R interface](https://github.com/r-lidar/arbor/tree/main/src/R): `src/R`
- [Arbor API](https://github.com/r-lidar/arbor/blob/main/src/api/arbor.h): `src/api/arbor.h`
- [Point cloud](https://github.com/r-lidar/arbor/blob/main/src/pointcloud/PointCloud.h): `src/pointcloud/PointCloud.h`

### Point-cloud classification

- [Ground segmentation](https://github.com/r-lidar/arbor/tree/main/src/segment): `src/segment`
- [Wood likelihood](https://github.com/r-lidar/arbor/tree/main/src/segment): `src/segment`
- [Semantic segmentation](https://github.com/r-lidar/arbor/blob/main/src/segment/segment_semantic_api.cpp): `src/segment/segment_semantic_api.cpp`
- [Neighborhood graph](https://github.com/r-lidar/arbor/blob/main/src/segment/GraphBuilder.cpp): `src/segment/GraphBuilder.cpp`
- [Tree seeds](https://github.com/r-lidar/arbor/blob/main/src/seed/SeedDetector.cpp): `src/seed/SeedDetector.cpp`
- [Instance segmentation](https://github.com/r-lidar/arbor/tree/main/src/segment): `src/segment`

### QSM reconstruction

- [QSM model](https://github.com/r-lidar/arbor/blob/main/src/qsm/QSM.h): `src/qsm/QSM.h`
- [QSM builder](https://github.com/r-lidar/arbor/blob/main/src/qsm/QSMbuilder.h): `src/qsm/QSMbuilder.h`
- [Radius fitting](https://github.com/r-lidar/arbor/blob/main/src/qsm/QSMbuilder_radius.cpp): `src/qsm/QSMbuilder_radius.cpp`
- [QSM collection](https://github.com/r-lidar/arbor/blob/main/src/qsf/QSF.h): `src/qsf/QSF.h`

### Shared algorithms

- [Geometric fitting](https://github.com/r-lidar/arbor/tree/main/src/fitting): `src/fitting`
- [Allometry](https://github.com/r-lidar/arbor/blob/main/src/utils/allometry.h): `src/utils/allometry.h`
- [3D grid](https://github.com/r-lidar/arbor/blob/main/src/utils/Grid3D.h): `src/utils/Grid3D.h`
- [Runtime services](https://github.com/r-lidar/arbor/blob/main/src/utils/services.cpp): `src/utils/services.cpp`
- [KD-tree search](https://github.com/r-lidar/arbor/blob/main/src/nanoflann/nanoflann.h): `src/nanoflann/nanoflann.h`

### Other components

- **R user**

## Connections

- R user → R interface: calls
- R interface → Ground segmentation: runs (evidence: `src/R/RcppApi_tools.cpp`)
- Ground segmentation → Wood likelihood: then computes
- Wood likelihood → Semantic segmentation: then segments (evidence: `src/segment/segment_semantic_api.cpp`)
- Semantic segmentation → Tree seeds: then finds
- Tree seeds → Instance segmentation: then segments
- Instance segmentation → QSM builder: then reconstructs
- R interface → Arbor API: uses API (evidence: `src/R/RcppApi_params.h`)
- Arbor API → Point cloud: uses (evidence: `src/api/arbor.h`)
- Arbor API → QSM model: uses (evidence: `src/api/arbor.h`)
- Arbor API → QSM collection: uses (evidence: `src/api/arbor.h`)
- Neighborhood graph → Point cloud: queries (evidence: `src/segment/GraphBuilder.cpp`)
- Neighborhood graph → KD-tree search: searches via
- Semantic segmentation → Neighborhood graph: uses (evidence: `src/segment/segment_semantic_api.cpp`)
- Semantic segmentation → 3D grid: uses (evidence: `src/segment/segment_semantic_api.cpp`)
- QSM builder → QSM model: builds (evidence: `src/qsm/QSMbuilder.h`)
- Radius fitting → Geometric fitting: fits with (evidence: `src/qsm/QSMbuilder_radius.cpp`)
- Radius fitting → Allometry: estimates with (evidence: `src/qsm/QSMbuilder_radius.cpp`)
- Neighborhood graph → Runtime services: logs via (evidence: `src/segment/GraphBuilder.cpp`)
- QSM builder → Point cloud: accepts
