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

Classes

class  IJobStore
 Persistence for job records. Implementations must be thread-safe. More...
class  InMemoryJobStore
 The in-memory store: bounded per queue, nothing survives a restart. More...
struct  JobEvent
 One notification about a job. More...
class  JobQueue
 One project's jobs on a JobScheduler. Every member is thread-safe. More...
struct  JobRecord
 A job as reported by the runner. Snapshot; never a live view. More...
class  JobRunner
 FIFO, single-worker, in-process pipeline job runner. More...
struct  JobRunnerOptions
 Tuning knobs for the job store. More...
class  JobScheduler
 The worker pool. Safe to use from any thread. More...
struct  JobSchedulerOptions
struct  MeshStageOptions
struct  ParameterDescriptor
 One knob of one stage. More...
struct  StageArtifact
 One artifact a stage wrote, so a client can refresh exactly what changed instead of re-fetching everything. More...
struct  StageContext
 Everything a stage execution needs, independent of any HTTP/CLI front end. More...
struct  StageResult
 Outcome of one stage execution. More...
struct  TileIndexHeader
 Header of a serialized tile index blob (version 2). More...
struct  TileInfo
 Per-tile AABB and point count within the tile. More...

Typedefs

using JobListener = std::function<void(const JobEvent &)>
 Listener callback.
using WriterLease = std::unique_lock<std::timed_mutex>
 Exclusive right to write to a runner's project.
using ParameterDefault
 The default a parameter takes when the key is absent from the job's parameters object.
using StageExecutor = std::function<StageResult(const StageContext &)>
 Stage execution strategy.

Enumerations

enum class  JobStatus {
  queued , running , succeeded , failed ,
  cancelled
}
 Lifecycle of a submitted job. More...
enum class  ParameterType {
  number , integer , boolean , string ,
  integer_list , string_list
}
 Wire type of a stage parameter, i.e. what JSON a caller should send. More...
enum class  JobStage {
  clouds , planes , rooms , instances ,
  mesh , optimize , annotate
}
 A pipeline stage that can be executed as a job. More...

Functions

std::string_view to_string (JobStatus status)
 Canonical lower-case status name used on the wire.
std::optional< JobStatus > parse_job_status (std::string_view name)
 Parse a canonical status name. Returns nullopt for an unknown name.
bool is_terminal (JobStatus status)
 True for statuses a job can never leave.
std::string iso8601_utc_now ()
 UTC timestamp in ISO-8601 form (e.g. "2026-09-08T11:22:33Z").
std::string_view to_string (JobEvent::Type type)
 Canonical lower-case event-type name used on the wire.
MeshStageOptions mesh_options_from_parameters (std::string_view parameters)
 Read the mesh stage's JSON parameters ("" = defaults).
StageResult run_optimize_stage (ProjectDB &db, const StageContext &ctx)
 Run optimize on an open project: the library defaults (which the rux optimize flags mirror) plus the job's parameters through geometry::apply_optimize_parameters(), the reader rux optimize uses too.
StageExecutor stage_executor_with_optimize ()
 default_stage_executor() plus optimize (run_optimize_stage on a read-write open of the job's project).
std::string_view to_string (ParameterType type)
 Canonical lower-case token for type, as it appears on the wire.
const std::vector< ParameterDescriptor > & stage_parameters (JobStage stage)
 Every parameter stage recognises, in form-display order.
std::string_view to_string (JobStage stage)
 Canonical lower-case stage name (the token used on the wire and the CLI).
std::string_view pipeline_log_name (JobStage stage)
 The name this stage writes into pipeline_log.stage.
std::optional< JobStage > parse_job_stage (std::string_view name)
 Parse a canonical stage name. Returns nullopt for an unknown name.
std::vector< std::string > job_stage_names ()
 Every name accepted by parse_job_stage(), in pipeline order.
bool stage_supports_cancellation (JobStage stage)
 True when the stage threads the cancel token into its inner loop, i.e.
StageResult run_stage (ProjectDB &db, const StageContext &ctx)
 Run a stage against an already-open, writable ProjectDB.
StageResult run_stage (const StageContext &ctx)
 Open ctx.project read-write and run the stage against it.
StageExecutor default_stage_executor ()
 The executor that actually runs the pipeline (a thin wrap of run_stage).
uint32_t morton_tile_sort_key (float x, float y, float z, const float lo[3], const float range[3])
 30-bit bit-reversed Morton sort key of (x, y, z) quantised to 10 bits per axis over the box starting at lo with extent range (each > 0).
std::vector< uint8_t > compute_tile_index (const ProjectDB &db, std::string_view name, uint32_t tile_bits=6)
 Compute the spatial tile index for a morton_10bit_bitrev cloud.
std::pair< TileIndexHeader, std::vector< TileInfo > > parse_tile_index (const std::vector< uint8_t > &blob)
 Deserialize the header + tile array from a tile index blob.
std::size_t build_tile_index (ProjectDB &db, std::string_view name)
 Build and store the tile index of cloud name when it is Morton-ordered.

Variables

constexpr std::string_view kDefaultSemanticCloud = "labels"
 Name of the semantic-label cloud instances reads when the job does not say otherwise.
constexpr std::string_view kDefaultInstanceCloud = "instances"
 Name of the cloud instances writes when the job does not say otherwise.
constexpr uint32_t kTileIndexMagic = 0x52555854u
 Magic number identifying a tile index blob.
constexpr std::string_view kMortonStorageOrder = "morton_10bit_bitrev"
 The storage order a cloud must have for a tile index to make sense.

Typedef Documentation

◆ JobListener

using reusex::pipeline::JobListener = std::function<void(const JobEvent &)>

Listener callback.

Invoked on the worker (or submitting) thread with no runner lock held; implementations must be thread-safe and must not block.

Definition at line 111 of file job_types.hpp.

◆ ParameterDefault

Initial value:
std::variant<std::monostate, double, long long, bool, std::string>

The default a parameter takes when the key is absent from the job's parameters object.

monostate means "no scalar default" — the parameter is absent-by-default and has no neutral value to pre-fill a form with (planes.filter, instances.labels).

Definition at line 54 of file stage_parameters.hpp.

◆ StageExecutor

using reusex::pipeline::StageExecutor = std::function<StageResult(const StageContext &)>

Stage execution strategy.

Exists so JobRunner's state machine can be tested against a fake executor without touching real scan data.

Definition at line 148 of file stages.hpp.

◆ WriterLease

using reusex::pipeline::WriterLease = std::unique_lock<std::timed_mutex>

Exclusive right to write to a runner's project.

Empty (!lease.owns_lock()) when the lock could not be taken in time. Releases on destruction, so a handler simply keeps it alive for as long as its ProjectDB write handle is open.

Definition at line 118 of file job_types.hpp.

Enumeration Type Documentation

◆ JobStage

enum class reusex::pipeline::JobStage
strong

A pipeline stage that can be executed as a job.

Deliberately narrower than core::PipelineStage (which also covers stages with no runner yet) and than core::Stage (which is a progress-reporting phase, not a unit of work). Extending this enum is how a stage becomes GUI-runnable; see ruxd's docs/gui/openapi.yaml (in its own repo), which lists the same names.

Enumerator
clouds 

back-project sensor frames into "cloud" + "normals"

planes 

detect planar surfaces -> "planes"/"plane_*"

rooms 

partition planes into rooms -> "rooms"

instances 

split semantic labels into spatial instances

mesh 

MIP-solve the cell complex into a watertight mesh.

optimize 

refine per-frame sensor poses via plane-landmark pose graph

annotate 

ML semantic labelling of the stored sensor frames.

Definition at line 43 of file stages.hpp.

◆ JobStatus

enum class reusex::pipeline::JobStatus
strong

Lifecycle of a submitted job.

queued ──▶ running ──▶ succeeded │ ├──────▶ failed │ └──────▶ cancelled └──────────────────▶ cancelled (cancelled before it ever started)

Enumerator
queued 
running 
succeeded 
failed 
cancelled 

Definition at line 32 of file job_types.hpp.

◆ ParameterType

Wire type of a stage parameter, i.e. what JSON a caller should send.

Enumerator
number 

JSON number, fractional (float in the option struct).

integer 

JSON number, integral.

boolean 

JSON true/false.

string 

JSON string.

integer_list 

JSON array of non-negative integers.

string_list 

JSON array of strings.

Definition at line 38 of file stage_parameters.hpp.

Function Documentation

◆ build_tile_index()

std::size_t reusex::pipeline::build_tile_index ( ProjectDB & db,
std::string_view name )

Build and store the tile index of cloud name when it is Morton-ordered.

Returns
the stored blob's size in bytes; 0 when the cloud is absent, not Morton-ordered, or too small for an index (nothing is stored).

References build_tile_index().

Referenced by build_tile_index().

◆ compute_tile_index()

std::vector< uint8_t > reusex::pipeline::compute_tile_index ( const ProjectDB & db,
std::string_view name,
uint32_t tile_bits = 6 )

Compute the spatial tile index for a morton_10bit_bitrev cloud.

Two O(N) forward scans over the stored cloud (bbox, then assignment). Assigns each point to tile sort_key & (K-1) where K = 2^tile_bits.

Parameters
tile_bitslog2 of the tile count; 6 gives K=64 (a 4×4×4 grid).
Returns
serialized binary blob suitable for ProjectDB::save_tile_index(). Empty when the cloud has fewer than K points or is not found.

References compute_tile_index().

Referenced by compute_tile_index().

◆ default_stage_executor()

StageExecutor reusex::pipeline::default_stage_executor ( )

The executor that actually runs the pipeline (a thin wrap of run_stage).

References default_stage_executor().

Referenced by default_stage_executor(), reusex::pipeline::JobRunner::JobRunner(), reusex::pipeline::JobScheduler::make_queue(), and stage_executor_with_optimize().

◆ is_terminal()

bool reusex::pipeline::is_terminal ( JobStatus status)

True for statuses a job can never leave.

References is_terminal().

Referenced by is_terminal().

◆ iso8601_utc_now()

std::string reusex::pipeline::iso8601_utc_now ( )

UTC timestamp in ISO-8601 form (e.g. "2026-09-08T11:22:33Z").

References iso8601_utc_now().

Referenced by iso8601_utc_now().

◆ job_stage_names()

std::vector< std::string > reusex::pipeline::job_stage_names ( )

Every name accepted by parse_job_stage(), in pipeline order.

References job_stage_names().

Referenced by job_stage_names().

◆ mesh_options_from_parameters()

MeshStageOptions reusex::pipeline::mesh_options_from_parameters ( std::string_view parameters)

Read the mesh stage's JSON parameters ("" = defaults).

Unknown keys are ignored.

Exceptions
std::invalid_argumentfor a non-object JSON or an unknown solver.

References mesh_options_from_parameters().

Referenced by mesh_options_from_parameters().

◆ morton_tile_sort_key()

uint32_t reusex::pipeline::morton_tile_sort_key ( float x,
float y,
float z,
const float lo[3],
const float range[3] )

30-bit bit-reversed Morton sort key of (x, y, z) quantised to 10 bits per axis over the box starting at lo with extent range (each > 0).

Identical to the key reconstruct.cpp sorts a cloud by.

References morton_tile_sort_key().

Referenced by morton_tile_sort_key().

◆ parse_job_stage()

std::optional< JobStage > reusex::pipeline::parse_job_stage ( std::string_view name)

Parse a canonical stage name. Returns nullopt for an unknown name.

References parse_job_stage().

Referenced by parse_job_stage().

◆ parse_job_status()

std::optional< JobStatus > reusex::pipeline::parse_job_status ( std::string_view name)

Parse a canonical status name. Returns nullopt for an unknown name.

References parse_job_status().

Referenced by parse_job_status().

◆ parse_tile_index()

std::pair< TileIndexHeader, std::vector< TileInfo > > reusex::pipeline::parse_tile_index ( const std::vector< uint8_t > & blob)

Deserialize the header + tile array from a tile index blob.

Exceptions
std::runtime_erroron a corrupt or unknown-version blob.

References parse_tile_index().

Referenced by parse_tile_index().

◆ pipeline_log_name()

std::string_view reusex::pipeline::pipeline_log_name ( JobStage stage)

The name this stage writes into pipeline_log.stage.

Deliberately NOT the same as to_string(): the CLI has been writing segment_planes / cloud_reconstruction into that column since long before the GUI existed, and existing project databases are full of those values. The wire token stays short (planes); the log name stays compatible, so one table does not end up with two names for one operation.

References pipeline_log_name().

Referenced by pipeline_log_name().

◆ run_optimize_stage()

◆ run_stage() [1/2]

StageResult reusex::pipeline::run_stage ( const StageContext & ctx)

Open ctx.project read-write and run the stage against it.

References run_stage().

◆ run_stage() [2/2]

StageResult reusex::pipeline::run_stage ( ProjectDB & db,
const StageContext & ctx )

Run a stage against an already-open, writable ProjectDB.

Never throws: algorithm/IO failures are converted into a failed StageResult and, when a pipeline_log row was opened, closed out with the error message (STANDARDS §5 — no silent failure).

References run_stage().

Referenced by run_stage(), and run_stage().

◆ stage_executor_with_optimize()

StageExecutor reusex::pipeline::stage_executor_with_optimize ( )
inline

default_stage_executor() plus optimize (run_optimize_stage on a read-write open of the job's project).

Definition at line 77 of file optimize_stage.hpp.

References default_stage_executor(), reusex::pipeline::StageResult::failure(), optimize, run_optimize_stage(), and stage_executor_with_optimize().

Referenced by stage_executor_with_optimize().

◆ stage_parameters()

const std::vector< ParameterDescriptor > & reusex::pipeline::stage_parameters ( JobStage stage)

Every parameter stage recognises, in form-display order.

References stage_parameters().

Referenced by stage_parameters().

◆ stage_supports_cancellation()

bool reusex::pipeline::stage_supports_cancellation ( JobStage stage)

True when the stage threads the cancel token into its inner loop, i.e.

cancellation takes effect mid-run rather than only between jobs.

References stage_supports_cancellation().

Referenced by stage_supports_cancellation().

◆ to_string() [1/4]

std::string_view reusex::pipeline::to_string ( JobEvent::Type type)

Canonical lower-case event-type name used on the wire.

References to_string().

◆ to_string() [2/4]

std::string_view reusex::pipeline::to_string ( JobStage stage)

Canonical lower-case stage name (the token used on the wire and the CLI).

References to_string().

◆ to_string() [3/4]

std::string_view reusex::pipeline::to_string ( JobStatus status)

Canonical lower-case status name used on the wire.

References to_string().

Referenced by to_string(), to_string(), to_string(), and to_string().

◆ to_string() [4/4]

std::string_view reusex::pipeline::to_string ( ParameterType type)

Canonical lower-case token for type, as it appears on the wire.

References to_string().

Variable Documentation

◆ kDefaultInstanceCloud

std::string_view reusex::pipeline::kDefaultInstanceCloud = "instances"
inlineconstexpr

Name of the cloud instances writes when the job does not say otherwise.

Definition at line 93 of file stage_parameters.hpp.

◆ kDefaultSemanticCloud

std::string_view reusex::pipeline::kDefaultSemanticCloud = "labels"
inlineconstexpr

Name of the semantic-label cloud instances reads when the job does not say otherwise.

Shared with run_instances() so the descriptor's default and the runner's fallback cannot drift apart.

Definition at line 91 of file stage_parameters.hpp.

◆ kMortonStorageOrder

std::string_view reusex::pipeline::kMortonStorageOrder = "morton_10bit_bitrev"
inlineconstexpr

The storage order a cloud must have for a tile index to make sense.

Definition at line 28 of file tile_index.hpp.

◆ kTileIndexMagic

uint32_t reusex::pipeline::kTileIndexMagic = 0x52555854u
inlineconstexpr

Magic number identifying a tile index blob.

Definition at line 25 of file tile_index.hpp.