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

Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs/gui/openapi.yaml, in the ruxd repo). More...

Namespaces

namespace  json_export
namespace  json_import
namespace  serialization
namespace  traits

Classes

class  AndNode
 AND combinator: expr1 && expr2. More...
struct  Artifact
 One named cloud / table / mesh the pipeline traffics in. More...
struct  BlockingType
struct  Certifications
 Certifications, approvals and declarations for the item. More...
class  CloudMisalignedError
 Mean position of one instance's points. More...
class  CloudReferenceNode
 Cloud reference: a label cloud loaded from ProjectDB by name. More...
struct  ColumnPatch
 Sparse update of a user column definition. More...
class  CompareNode
 Comparison operators: <cloud> >= value, etc. More...
struct  ComponentRecord
 Core-owned persistence contract for a row of the building_components table (#227). More...
struct  Condition
 Condition assessment of the construction item. More...
struct  ConstructionItemDescription
 Description of the reused construction item. More...
struct  CsvOptions
 A template's CSV export options (templates.csv). More...
struct  DangerousSubstance
 Dangerous substance analysis record. More...
struct  Dimensions
 Physical dimensions and geometry of the construction item. More...
struct  Emission
 Emission measurement record. More...
struct  EnvironmentalPotential
 Environmental and resource potential for sustainable utilization. More...
class  EqualNode
 Equality: <cloud> == value. More...
struct  FilterExpression
 Parsed filter expression with resolved label cloud references. More...
class  FilterNode
 Base AST node for filter expressions. More...
struct  FireProperties
 Fire-related properties of the construction item. More...
struct  Fraction
struct  FractionReport
struct  FrameVisibility
 One frame in which a queried world point is visible, with the geometry of its projection. More...
struct  GaussianSplatHeader
 What the PLY header of an INRIA 3D Gaussian Splatting file says. More...
struct  History
 Historical usage information for the construction item. More...
class  InNode
 In-set: <cloud> in [v1, v2, v3]. More...
struct  InstanceCentroid
struct  InstanceEvidence
 Everything the photo evidence knows about one instance: where it is and the frames that see it, best first (visible_frames_occluded). More...
struct  InstanceProbe
 An instance's centroid plus evenly spread samples of its points. More...
class  IObserver
class  IProgressObserver
class  IVisualObserver
class  KeyValueError
 A write the catalogue refuses: unknown key, read-only key, or a value the key's type does not accept. More...
struct  LeksikonField
 One top-level leksikon property, in leksikon (MaterialEPAS section) order. More...
struct  MaskProjectionOptions
 Tunables for project_frame_mask() (STANDARDS §4). More...
class  MaskSelectionError
 A frame cannot be projected (no usable pose, no depth image, no base cloud, degenerate intrinsics) or a selection is unusable (no points). More...
struct  MaskSelectionOptions
 Tunables for apply_mask_selection(). More...
struct  MaskSelectionResult
 What apply_mask_selection() created. More...
struct  MaterialPassport
 A complete material passport for a reused building material. More...
 Document-level metadata for the material passport. More...
class  NameConflictError
 A name that must be unique (template, user column, stored field) is already taken. More...
class  NotEqualNode
 Not equal: <cloud> != value. More...
struct  OcclusionQuery
 Tunables for visible_frames_occluded(). More...
class  OperationCancelled
 Thrown by visible_frames_occluded() when its cancel flag is raised. More...
class  OrNode
 OR combinator: expr1 || expr2. More...
struct  Owner
 Owner contact information for the material passport. More...
struct  PanoramaQuery
 Tunables for panoramas_for_point(). More...
struct  PanoramaSighting
 One panorama near a world point. More...
struct  PartPhotos
 The photo evidence of one survey part. More...
struct  PhotoQuery
 Tunables for the photo evidence of an instance. More...
struct  Pollution
 Pollution, content and emission information. More...
struct  ProductInformation
 Original product information. More...
class  ProgressObserver
 One stage's progress report, RAII: started on construction, finished on destruction, update() in between. More...
struct  ReportSurveyRow
 One survey type as the PDF report's Kortlægning section lists it. More...
struct  ResolvedTemplate
struct  Resource
struct  ResourceKey
struct  ResourcePatchResult
struct  ResourceReportSection
struct  ResourceTable
struct  ResourceValue
struct  ResourceWrite
class  SamplePendingError
struct  SampleState
class  ScopedProgressObserver
 Route progress started on this thread to observer for the lifetime of the scope, without touching the process-global observer. More...
struct  SeedTemplate
struct  SensorIntrinsics
 Lightweight camera intrinsics replacing rtabmap::CameraModel in downstream code. More...
struct  StageContract
 The full input/output contract of one pipeline stage. More...
struct  StageInput
 One prerequisite of a stage. More...
class  stopwatch
struct  SurveySyncOptions
 Options for sync_survey — the cloud names it reads from. More...
struct  SurveySyncReport
 Counts of what sync_survey changed. More...
struct  SurveyTypeDeletion
 Delete a survey type and every part in it, with delete_resource's rules for each part (tombstones, passports), in one transaction. More...
struct  TemplateInput
 A create or sparse edit; absent fields are left alone. More...
struct  TemplateMember
struct  TemplateView
 One template as the API shows it: its row, parsed members and CSV options, and its resolution against the live key catalogue. More...
struct  TransactionLogEntry
 A single entry in the material passport transaction log. More...
struct  TypeTotals
struct  ValidationIssue
 One problem discovered by a validation check. More...
struct  ValidationReport
 Aggregate result of running all validation checks over a project. More...
struct  VisibilityProbe
 What visible_frames_occluded() tests for one object: an anchor that decides the frustum test and the ranking (usually the centroid), plus surface samples. More...
struct  VisibilityQuery
 Tunables for visible_frames(). More...

Typedefs

using LogHandler
using ArtifactOverrides = std::map<std::string, std::string, std::less<>>
 Runtime substitutions for artifact names, for the flags that let a stage be pointed at a differently-named cloud (rux create instances --semantic-cloud foo).

Enumerations

enum class  PanoramaHeading { resected , levelled }
 Where a panorama's orientation comes from (mirrors the frontend's PanoramaHeading in viewport/panorama.ts). More...
enum class  LogLevel {
  trace = 0 , debug = 1 , info = 2 , warn = 3 ,
  error = 4 , critical = 5 , off = 6
}
enum class  Material {
  natural_stone , lime_mortar , concrete , terrazzo ,
  cement_mortar , aerated_concrete , lightweight_clinker_concrete , plaster ,
  brick , glazed_tile , metal_general , iron ,
  steel , stainless_steel , aluminum , copper ,
  zinc , lead , construction_wood , wood_unclassified ,
  precious_wood , laminated_wood , veneer , wood_fibers ,
  wood_fiber_boards , wood_shavings , chipboards , paper ,
  corrugated_cardboard , impregnated_cardboard , wood_concrete_cement_fibers , mineral_wool ,
  asphalt , fibers , lining_paper , linoleum ,
  rubber , plastic , foam_plastic , glass ,
  natural_filling_aggregate , painting_supplies , other
}
 Material types from the Danish material passport standard (v1.0). More...
enum class  TriState { yes , no , unknown }
 Tri-state value for Yes/No/Unknown fields. More...
enum class  EmissionQuantityType { exact , minimum , maximum , interval }
 Emission quantity type. More...
enum class  SubstanceContentMethod { assumed , measured_surface , measured_material }
 Method used to determine substance content. More...
enum class  TransactionType { document , property }
 Transaction log entry type. More...
enum class  EventType { process , progress , visualization }
enum class  KeySource { builtin , leksikon , column }
 Where a key's value lives. More...
enum class  KeyScope { type , part }
 What a write changes: the survey type (all its parts) or the one part. More...
enum class  MemberKind { category , key }
enum class  PipelineStage {
  import , optimize , clouds , annotate ,
  project , planes , rooms , instances ,
  mesh , texture , windows , materials ,
  survey , attributes , gsplat
}
 Pipeline stages that have an input contract. More...
enum class  ArtifactKind { point_cloud , mesh , gaussian_splat , table }
 What kind of thing a named artifact is inside a .rux project. More...
enum class  Alignment { none , per_point , per_plane }
 Which index-alignment class an artifact belongs to. More...
enum class  Stage {
  idle , mesh_generation , importing_data , assembling_cloud ,
  creating_material , retrieving_textures , computing_face_coverage , computing_room_probabilities ,
  processing_batch , annotating_batches , projecting_labels , ray_tracing ,
  region_growing , instance_clustering , creating_windows , room_segmentation ,
  dense_reconstruction
}
enum class  Treatment {
  bevaring , genbrug , genanvendelse , nyttiggoerelse ,
  bortskaffelse
}
enum class  ReviewStatus { queue , approved , rejected }
enum class  SampleStage { planlagt , udtaget , sendt , svar }
enum class  SampleResult { none , ren , forurenet }
enum class  EnvironmentStatus { ren_screening , afventer , forurenet , ren_proevesvar }
enum class  BlockingReason { review , sample , mass }
 Why a type blocks the waste report; a type gets one reason, by precedence sample > review > mass. More...
enum class  ValidationSeverity { warning , error }
 Severity of a single validation finding. More...

Functions

int32_t cloud_label_at (const std::vector< CloudReferenceNode > &clouds, size_t cloud_idx, size_t point_idx)
 Helper for leaf nodes: read the label for point_idx from cloud cloud_idx, returning -1 if the index is out of range.
auto parse_filter_expression (const std::string &expression, ProjectDB &db) -> std::unique_ptr< FilterExpression >
 Parse filter expression and resolve label cloud references from ProjectDB.
auto evaluate_filter (const FilterExpression &expr, size_t cloud_size) -> IndicesPtr
 Evaluate filter expression against all points, generate Indices.
auto evaluate_filter_expression (const std::string &filter_expr, ProjectDB &db, size_t expected_size) -> IndicesPtr
 Parse and evaluate a filter expression against a project in one step.
std::vector< FrameVisibility > visible_frames (const ProjectDB &db, const Eigen::Vector3d &world_point, const VisibilityQuery &query={})
 Rank the posed sensor frames by how centrally a world point projects.
std::vector< std::vector< FrameVisibility > > visible_frames_batch (const ProjectDB &db, const std::vector< Eigen::Vector3d > &world_points, const VisibilityQuery &query={})
 visible_frames() for many points at once.
std::vector< std::vector< FrameVisibility > > visible_frames_occluded (const ProjectDB &db, const std::vector< VisibilityProbe > &probes, const OcclusionQuery &query={}, const std::atomic< bool > *cancel=nullptr)
 Occlusion-aware visible_frames_batch(): frames that actually see each probe, not merely frames whose frustum contains it.
GaussianSplatHeader parse_gaussian_splat_ply_header (std::string_view head)
 Parse the PLY header in head and verify it is an INRIA splat file.
std::string generate_guid ()
 Generate a fresh UUID-v4-like identifier (36-char, hyphenated hex).
std::map< std::uint32_t, InstanceCentroid > instance_centroids (const ProjectDB &db, std::string_view label_cloud, std::string_view positions_cloud="cloud")
 Centroid of every instance id in an instance-label cloud.
std::map< std::uint32_t, InstanceProbe > instance_probes (const ProjectDB &db, std::string_view label_cloud, std::string_view positions_cloud="cloud", std::size_t samples=PhotoQuery{}.samples_per_instance)
 instance_centroids() plus up to samples points per instance, taken at evenly spaced positions in the instance's (finite) point list — spatially spread, since the clouds are stored in Morton order (#394).
std::map< std::uint32_t, InstanceEvidence > instance_evidence (const ProjectDB &db, std::string_view label_cloud, const PhotoQuery &query={}, std::string_view positions_cloud="cloud", const std::atomic< bool > *cancel=nullptr)
 The ranked, occlusion-aware frames of every instance of label_cloud that has points: visible_frames_occluded over all its probes in one pass over the frames (each depth image decoded at most once).
std::map< std::uint32_t, PartPhotos > instance_photos (const ProjectDB &db, std::string_view label_cloud, const PhotoQuery &query={}, std::string_view positions_cloud="cloud")
 instance_evidence() reduced to count + best frame per instance.
Eigen::Vector2d equirect_uv (const Eigen::Vector3d &bearing)
 Normalised equirect coordinates of a bearing in the panorama frame.
std::vector< PanoramaSighting > panoramas_for_point (const ProjectDB &db, const Eigen::Vector3d &world_point, const PanoramaQuery &query={})
 Panoramas that can be placed in the world, nearest first, with where world_point appears in each.
constexpr bool is_valid_label (uint32_t label) noexcept
constexpr bool is_out_of_contract_label (uint32_t label) noexcept
size_t label_to_index (uint32_t label)
 Convert a point label to a zero-based vector index, replacing the error-prone bare label - 1 idiom used to index parallel arrays such as plane_normals.
uint32_t api_to_point_label (int api_label)
 API (CV_32S, -1 = background) → point label (uint32_t, 0 = unlabeled).
int point_label_to_api (uint32_t point_label)
 Point label (uint32_t, 0 = unlabeled) → API (CV_32S, -1 = background).
uint16_t api_to_storage (int api_label)
 API label (CV_32S, -1 = background) → storage value (CV_16U, 0 = bg, label + 1).
int storage_to_api (uint16_t storage_value)
 Storage value (CV_16U, 0 = bg, label + 1) → API label (CV_32S, -1 = background).
cv::Mat storage_mat_to_api (const cv::Mat &storage)
 Convert a storage label image (CV_16U, 0 = bg) to an API label image (CV_32S, -1 = background) by subtracting the +1 offset.
cv::Mat api_mat_to_storage (const cv::Mat &api)
 Convert an API label image (CV_32S, -1 = background) to a storage label image (CV_16U, 0 = bg) by adding the +1 offset.
void set_log_handler (LogHandler handler)
void reset_log_handler ()
void set_log_level (LogLevel level)
auto get_log_level () -> LogLevel
auto should_log (LogLevel level) -> bool
void log_message (LogLevel level, std::string_view message)
template<typename... Args>
void log (LogLevel level, fmt::format_string< Args... > format, Args &&...args)
void log (LogLevel level, std::string_view message)
template<typename... Args>
void trace (fmt::format_string< Args... > format, Args &&...args)
void trace (std::string_view message)
template<typename... Args>
void debug (fmt::format_string< Args... > format, Args &&...args)
void debug (std::string_view message)
template<typename... Args>
void info (fmt::format_string< Args... > format, Args &&...args)
void info (std::string_view message)
template<typename... Args>
void warn (fmt::format_string< Args... > format, Args &&...args)
void warn (std::string_view message)
template<typename... Args>
void error (fmt::format_string< Args... > format, Args &&...args)
void error (std::string_view message)
template<typename... Args>
void critical (fmt::format_string< Args... > format, Args &&...args)
void critical (std::string_view message)
std::vector< std::size_t > project_frame_mask (const ProjectDB &db, int frame_id, const cv::Mat &mask, const MaskProjectionOptions &opts={})
 Indices of the base-cloud points that the mask covers in one frame.
MaskSelectionResult apply_mask_selection (ProjectDB &db, const std::vector< std::size_t > &indices, const std::string &class_name, const MaskSelectionOptions &opts={})
 Label the selected points as class_name, make them one new instance, and file a survey part for it — in one transaction.
auto to_string (Material value) -> std::string_view
 Convert Material enum to its string identifier.
auto material_from_string (std::string_view str) -> std::optional< Material >
 Parse a Material from its string identifier.
auto material_names () -> std::vector< std::string_view >
 Every Material string identifier, in enum order.
auto to_string (TriState value) -> std::string_view
 Convert TriState enum to its string identifier.
auto tri_state_from_string (std::string_view str) -> std::optional< TriState >
 Parse a TriState from its string identifier.
auto to_string (EmissionQuantityType value) -> std::string_view
 Convert EmissionQuantityType enum to its string identifier.
auto emission_quantity_type_from_string (std::string_view str) -> std::optional< EmissionQuantityType >
 Parse an EmissionQuantityType from its string identifier.
auto to_string (SubstanceContentMethod value) -> std::string_view
 Convert SubstanceContentMethod enum to its string identifier.
auto substance_content_method_from_string (std::string_view str) -> std::optional< SubstanceContentMethod >
 Parse a SubstanceContentMethod from its string identifier.
auto to_string (TransactionType value) -> std::string_view
 Convert TransactionType enum to its string identifier.
auto transaction_type_from_string (std::string_view str) -> std::optional< TransactionType >
 Parse a TransactionType from its string identifier.
void set_visual_observer (IVisualObserver *observer)
void set_progress_observer (IProgressObserver *observer)
void reset_visual_observer ()
void reset_progress_observer ()
auto get_visual_observer () -> IVisualObserver *
auto get_progress_observer () -> IProgressObserver *
auto current_progress_observer () -> IProgressObserver *
 The observer progress reported from THIS thread goes to: the innermost ScopedProgressObserver installed on it, else the global one (which may be null).
nlohmann::json report_version_json (const ProjectDB::ReportPdfRecord &r)
 {id, created_at, label, size_bytes, version, blocking_types}; blocking_types is null for a version generated before schema v23.
std::string display_value (const ResourceKey &key, const std::optional< std::string > &value)
 A value as a reader sees it: treatment and miljøstatus as their Danish labels, booleans as Ja/Nej, unset as "".
std::string csv_cell (std::string_view value, std::string_view delimiter)
 One CSV cell: a cell starting with = + - @ TAB or CR gets a leading ' (formula injection), then RFC 4180 quoting when it holds the delimiter, a quote, CR or LF.
std::vector< std::string > csv_labels (const std::vector< ResourceKey > &columns)
 The CSV header labels of columns: each key's label, with " (<category>)" appended to every label that occurs more than once (counting the "Kode" column), so no two headers read the same.
std::string build_resource_csv (const std::vector< ResourceKey > &columns, const std::vector< Resource > &rows, const CsvOptions &options)
 Header + one CRLF-terminated row per resource, led by the resource code.
std::string export_resources_csv (const ProjectDB &db, int64_t template_id)
 The CSV for one template: its resolved keys, every resource by code, its CSV options.
std::vector< ResourceTable > resource_tables (const std::vector< ResourceKey > &columns, const std::vector< Resource > &rows, std::size_t max_columns=kResourceTableMaxColumns)
 Wrap columns into tables of at most max_columns, each led by a "Betegnelse" column whose cell is "<sys:name> · <code>" (sys:name is not repeated among the others).
ResourceReportSection resource_report_section (const ProjectDB &db, int64_t template_id)
 The PDF's Ressourcetabel for one template: every resource whose type is not rejected, by code.
std::string_view to_string (KeyScope)
std::vector< LeksikonField > leksikon_fields ()
 Nested object-array fields (dangerous substances, emissions) are skipped: they are rows, not one value.
std::vector< std::string > leksikon_categories ()
 Distinct categories of leksikon_fields(), in order.
std::vector< ResourceKey > builtin_keys ()
 the 11 sys: keys, spec order
std::vector< ResourceKey > leksikon_keys ()
ResourceKey column_key (const ProjectDB::PropertyDefinition &def)
std::vector< ResourceKey > key_catalogue (const std::vector< ProjectDB::PropertyDefinition > &columns)
 Built-in, then leksikon, then user columns (in the given order) — the "catalogue order" template categories expand in.
std::vector< ResourceKey > key_catalogue (const ProjectDB &db)
const ResourceKey * find_key (const std::vector< ResourceKey > &catalogue, std::string_view id)
 nullptr when id is not in catalogue.
std::optional< double > parse_number (std::string_view text)
 Finite number with '.
std::string format_number (double v)
 Shortest round-trip text: 290.0 -> "290", 0.1 -> "0.1".
std::optional< std::string > normalise_value (const ResourceKey &key, const std::optional< std::string > &value)
 Validate value for key and return it normalised for storage (numbers with '.
std::vector< TemplateMember > parse_members (const nlohmann::json &members)
 Parse [{"category": name} | {"key": id}, …].
std::vector< TemplateMember > read_members (std::string_view stored, std::string_view template_name)
 Stored members, tolerantly: unreadable JSON logs warn and reads as none.
nlohmann::json members_json (const std::vector< TemplateMember > &members)
ResolvedTemplate resolve_template (const std::vector< TemplateMember > &members, const std::vector< ResourceKey > &catalogue)
 Spec §5.2: a category member expands to every catalogue key in that category (catalogue order), a key member adds that key, duplicates keep their first position, and members that resolve to nothing go to missing.
std::vector< SeedTemplate > seed_templates ()
 "Materialepas (fuld)" (one category member per leksikon category) and "Hurtig genbrugsscreening" (the 11 sys: keys), in that order.
CsvOptions parse_csv_options (const nlohmann::json &csv)
CsvOptions read_csv_options (std::string_view stored, std::string_view template_name)
 Stored options, tolerantly: a bad field logs warn and uses its default.
nlohmann::json csv_options_json (const CsvOptions &options)
TemplateMember legacy_column_member (std::string_view column, const std::vector< ResourceKey > &catalogue)
std::string unique_name (std::string_view base, std::string_view tag, const std::vector< std::string > &taken)
 First of "<base> (<tag>)", "<base> (<tag> 2)", "<base> (<tag> 3)", … that is not in taken.
std::vector< TemplateView > template_views (const ProjectDB &db)
 Every template by id. Logs warn once per template with missing members.
TemplateView template_view (const ProjectDB &db, int64_t id)
TemplateView create_template (ProjectDB &db, const TemplateInput &input)
TemplateView update_template (ProjectDB &db, int64_t id, const TemplateInput &input)
void delete_template (ProjectDB &db, int64_t id)
TemplateView duplicate_template (ProjectDB &db, int64_t id)
 Copy as "<name> (kopi)", "<name> (kopi 2)", … (never a seed).
std::vector< TemplateView > restore_seed_templates (ProjectDB &db)
 Insert every seed whose tag no template carries ("Gendan standardskabeloner"); a seed whose name is taken gets " (standard)".
std::optional< std::string > value_of (const Resource &r, std::string_view key)
 The value stored under key in r, or nullopt (absent or unset).
std::vector< Resource > list_resources (const ProjectDB &db, const std::optional< std::vector< std::string > > &keys=std::nullopt)
 One per survey part, by code.
Resource resource (const ProjectDB &db, std::string_view code, const std::optional< std::vector< std::string > > &keys=std::nullopt)
ResourcePatchResult patch_resource (ProjectDB &db, std::string_view code, const std::vector< ResourceWrite > &writes, const std::optional< std::vector< std::string > > &keys=std::nullopt)
 Validate every write (normalise_value), then apply them in one transaction: type-scoped keys to the survey type, part-scoped built-ins to the part, leksikon/column keys to the part's passport (created on the first non-null write).
Resource create_resource (ProjectDB &db, int64_t type_id, const std::optional< std::string > &name=std::nullopt)
 A manual part with the next RX code; name becomes its designation.
void delete_resource (ProjectDB &db, std::string_view code)
 Delete a part — manual or instance-backed — in one transaction.
SurveyTypeDeletion delete_survey_type (ProjectDB &db, int64_t type_id)
ProjectDB::PropertyDefinition create_column (ProjectDB &db, ProjectDB::PropertyDefinition def)
 Add a user column (def.id is ignored and returned filled in).
void delete_column (ProjectDB &db, const std::string &id)
 Delete a user column and, in the same transaction, every value stored under its name (logged at warn with the count), so the name can be used again.
ProjectDB::PropertyDefinition update_column (ProjectDB &db, const std::string &id, const ColumnPatch &patch)
 A rename moves the stored values in the same transaction.
const std::vector< StageContract > & stage_contracts ()
 Every stage contract, in pipeline order.
const StageContract & stage_contract (PipelineStage stage)
 The contract of one stage.
const std::vector< Artifact > & pipeline_artifacts ()
 Every artifact the contracts refer to.
const Artifact * find_artifact (std::string_view name)
 Look up an artifact by name, or nullptr when it is not a pipeline artifact.
std::optional< PipelineStage > producing_stage (std::string_view artifact)
 The earliest stage that writes artifact, or nullopt when nothing does (an externally sourced artifact).
std::optional< PipelineStage > parse_pipeline_stage (std::string_view name)
 Parse a stage name (e.g.
std::string_view to_string (PipelineStage stage)
 Canonical lower-case name of a stage (the primary CLI token).
std::vector< std::string > pipeline_stage_names ()
 All stage names accepted by parse_pipeline_stage(), for help text.
std::string_view to_string (Stage stage)
std::string_view to_string (Treatment)
std::string_view to_string (ReviewStatus)
std::string_view to_string (SampleStage)
std::string_view to_string (SampleResult)
std::string_view to_string (EnvironmentStatus)
std::string_view treatment_label_da (Treatment)
 Danish user-facing labels (the PDF report).
std::string_view environment_label_da (EnvironmentStatus)
std::optional< Treatment > treatment_from_string (std::string_view)
std::optional< ReviewStatus > review_status_from_string (std::string_view)
std::optional< SampleStage > sample_stage_from_string (std::string_view)
std::optional< SampleResult > sample_result_from_string (std::string_view)
void validate_sample_state (const SampleState &)
EnvironmentStatus environment_status (const std::vector< SampleState > &linked)
std::array< double, kTreatmentCount > circularity_breakdown (const std::vector< TypeTotals > &)
std::string_view to_string (BlockingReason)
bool reportable (ReviewStatus status, EnvironmentStatus environment)
 True when a type's tonnes may be reported: it is approved and not awaiting a sample (an afventer answer can still make it contaminated).
FractionReport fractions_by_eak (const std::vector< TypeTotals > &)
 Approved tonnes per (EAK code, treatment, contaminated), for the bygningsaffald.dk report (GUI Phase 5, R3).
std::string_view eak_fraction_name (std::string_view code)
std::map< std::uint32_t, std::uint32_t > majority_room (const std::vector< std::uint32_t > &instance_labels, const std::vector< std::uint32_t > &room_labels)
std::vector< double > redistribute_quantity (const std::vector< double > &current, double total)
std::string part_code (int number)
std::string sample_code (int number)
std::map< int64_t, EnvironmentStatus > environment_statuses (const ProjectDB &db)
EnvironmentStatus environment_status_of (const ProjectDB &db, int64_t type_id)
ProjectDB::SurveyTypeRecord set_review_status (ProjectDB &db, int64_t type_id, ReviewStatus status)
 Approving a type whose miljøstatus is afventer throws SamplePendingError.
std::vector< ProjectDB::SurveyPartRecord > set_type_quantity (ProjectDB &db, int64_t type_id, double total)
 Scales the type's parts to sum to total (redistribute_quantity).
std::vector< TypeTotals > type_totals (const ProjectDB &db)
ProjectDB::SampleRecord update_sample_checked (ProjectDB &db, int64_t id, const ProjectDB::SamplePatch &patch)
 Sample edit with the stage/result rule enforced (validate_sample_state on the merged state).
std::vector< ReportSurveyRow > report_survey_rows (const ProjectDB &db)
 One row per reportable survey type, in id order, for the PDF report's survey section ("kun godkendte mængder indgår").
SurveySyncReport sync_survey (ProjectDB &db, const SurveySyncOptions &opts={})
 Fill survey_types / survey_parts from the instances table: one type per semantic class, one bygningsdel (survey part) per instance, placed in the room most of its points fall in.
void check_orphaned_passports (const ProjectDB &db, std::vector< ValidationIssue > &out)
 Material passports not referenced by any instance_materials link.
void check_dangling_instance_materials (const ProjectDB &db, std::vector< ValidationIssue > &out)
 instance_materials rows whose instance row or passport is missing.
void check_instances_without_label_defs (const ProjectDB &db, std::vector< ValidationIssue > &out)
 instances rows with no corresponding label_definitions entry.
void check_sibling_cloud_sizes (const ProjectDB &db, std::vector< ValidationIssue > &out)
 Parallel/sibling clouds (cloud, labels, normals, planes, rooms, instances) whose point counts disagree — they are supposed to be index-aligned.
ValidationReport validate_project (const ProjectDB &db)
 Run every check and aggregate the findings.
void check_stage_inputs (const ProjectDB &db, PipelineStage stage, std::vector< ValidationIssue > &out, const ArtifactOverrides &overrides={})
 Assert that stage's input clouds/tables exist in db and are index-aligned, per the contract in core/stage_contract.hpp.
ValidationReport validate_stage (const ProjectDB &db, PipelineStage stage, const ArtifactOverrides &overrides={})
 Run check_stage_inputs for a single stage and aggregate the findings.

Variables

constexpr std::size_t kGaussianSplatHeaderProbeBytes = 64 * 1024
 How many bytes from the head of a file are enough to find end_header.
constexpr uint32_t kUnlabeled = 0
 Point-cloud convention: 0 means "unlabeled" in every CloudL (labels, planes, rooms, instances).
constexpr int kBackgroundApi = -1
 ProjectDB segmentation API convention: -1 marks background/unlabeled in the CV_32S label images returned by ProjectDB.
constexpr uint16_t kMaxStorableLabel = 65534
 Largest label that can be stored in the CV_16U PNG layer.
constexpr std::string_view kCsvCodeLabel = "Kode"
 The leading resource-code column of the CSV: its header in label mode and in key mode.
constexpr std::string_view kCsvCodeKey = "code"
constexpr std::size_t kResourceTableMaxColumns = 8
constexpr std::string_view kBuiltinCategory = "Kortlægning"
constexpr std::string_view kColumnCategory = "Egne felter"
constexpr std::string_view kSeedMaterialepas = "materialepas"
constexpr std::string_view kSeedScreening = "screening"
constexpr std::string_view kLegacyKeyPrefix = "legacy:"
 Export-template columns (schema v21 config.columns) as members.
constexpr std::string_view kDesignationField = "designation"
 The leksikon field a hand-added resource's name is stored under.
constexpr std::size_t kTreatmentCount = 5
constexpr int kManualSemanticClass = -2
 semantic_class of a survey type created by hand, never matched by sync_survey.
constexpr std::string_view kDefaultInstanceCloud = "instances"
 Default name of the instance-label cloud sync_survey reads from, and the default SurveySyncOptions::instances_cloud.

Detailed Description

Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs/gui/openapi.yaml, in the ruxd repo).

Survey operations that need a project.

Survey (Ressourcekortlægning) rules that need no database: the wire vocabulary shared by ProjectDB, the REST API and the frontend, and the derivations the GUI shows — miljøstatus from linked samples, tonnes per affaldshierarki step, approved tonnes per EAK code.

Resources (docs/superpowers/specs/2026-10-02-resources-templates-ia-design.md §4): a resource is one survey part; its values are addressed by key id (core/resource_keys.hpp) and routed by scope — the type, the part, or the part's own passport, created on the first passport write.

Templates (docs/superpowers/specs/2026-10-02-resources-templates-ia-design.md §5): an ordered list of category and key members that resolves, against the live key catalogue, to an ordered list of key ids.

The resource key catalogue (docs/superpowers/specs/ 2026-10-02-resources-templates-ia-design.md §4.3): every key a resource (survey part) can carry, and the ONE mapping from a key id to where its value is stored.

Resources out through a template (docs/superpowers/specs/ 2026-10-02-resources-templates-ia-design.md §6.3): the backend CSV (GET /resources/export.csv) and the PDF report's Ressourcetabel.

The servers that answer it (ruxd) serialise through this one function so their responses cannot drift.

The API and the frontend only see key ids; the storage field names (leksikon name_en, column display name) stay in here.

The pure half is here first; the ProjectDB-backed service follows below.

Everything here is pure so it is testable without a project, and so rux, ruxd and a future Qt client all compute the same numbers.

Thin over ProjectDB storage and the pure rules in survey.hpp — the gate and redistribution live here, not in ProjectDB, which stays storage-only.

Typedef Documentation

◆ ArtifactOverrides

using reusex::core::ArtifactOverrides = std::map<std::string, std::string, std::less<>>

Runtime substitutions for artifact names, for the flags that let a stage be pointed at a differently-named cloud (rux create instances --semantic-cloud foo).

Maps the contract's declared name to the name to actually look for; when any member of an any_of input is overridden, the input collapses to the override so the check is exact rather than lenient.

Definition at line 98 of file validate.hpp.

◆ LogHandler

Initial value:
std::function<void(LogLevel level, std::string_view message)>

Definition at line 27 of file logging.hpp.

Enumeration Type Documentation

◆ Alignment

enum class reusex::core::Alignment
strong

Which index-alignment class an artifact belongs to.

This is a property of the ARTIFACT, not of the stage that consumes it, so no stage can accidentally declare the per-plane plane_centroids to be index-aligned with the per-point cloud (STANDARDS §3.2).

Enumerator
none 

not index-aligned with anything (tables, meshes)

per_point 

one entry per point of cloud

per_plane 

one entry per detected plane

Definition at line 73 of file stage_contract.hpp.

◆ ArtifactKind

enum class reusex::core::ArtifactKind
strong

What kind of thing a named artifact is inside a .rux project.

Enumerator
point_cloud 

a named ProjectDB point cloud

mesh 

a row in the meshes table

gaussian_splat 

a row in the gaussian_splats table

table 

a relational table (sensor_frames, …)

Definition at line 61 of file stage_contract.hpp.

◆ BlockingReason

enum class reusex::core::BlockingReason
strong

Why a type blocks the waste report; a type gets one reason, by precedence sample > review > mass.

Enumerator
review 
sample 
mass 

Definition at line 105 of file survey.hpp.

◆ EmissionQuantityType

Emission quantity type.

Note
Danish: 'Emissionsmængdetype'
Enumerator
exact 

Exact measured value.

Note
Danish: 'Eksakt'
minimum 

Minimum value.

Note
Danish: 'Minimum'
maximum 

Maximum value.

Note
Danish: 'Maksimum'
interval 

Interval (use lower/upper interval fields).

Note
Danish: 'Interval'

Definition at line 171 of file materialepas_enums.hpp.

◆ EnvironmentStatus

Enumerator
ren_screening 
afventer 
forurenet 
ren_proevesvar 

Definition at line 43 of file survey.hpp.

◆ EventType

enum class reusex::core::EventType
strong
Enumerator
process 
progress 
visualization 

Definition at line 24 of file processing_observer.hpp.

◆ KeyScope

enum class reusex::core::KeyScope
strong

What a write changes: the survey type (all its parts) or the one part.

Enumerator
type 
part 

Definition at line 28 of file resource_keys.hpp.

◆ KeySource

enum class reusex::core::KeySource
strong

Where a key's value lives.

Enumerator
builtin 
leksikon 
column 

Definition at line 26 of file resource_keys.hpp.

◆ LogLevel

enum class reusex::core::LogLevel
strong
Enumerator
trace 
debug 
info 
warn 
error 
critical 
off 

Definition at line 17 of file logging.hpp.

◆ Material

enum class reusex::core::Material
strong

Material types from the Danish material passport standard (v1.0).

Closed value list with 43 entries. Each value corresponds to a building material category defined in the "Materialepas for genbrugte byggevarer" specification.

Enumerator
natural_stone 

Natural stone.

Note
Danish: 'Natursten'
lime_mortar 

Lime mortar.

Note
Danish: 'Kalkmørtel'
concrete 

Concrete.

Note
Danish: 'Beton'
terrazzo 

Terrazzo.

Note
Danish: 'Terrazzo'
cement_mortar 

Cement mortar.

Note
Danish: 'Cementmørtel'
aerated_concrete 

Aerated concrete.

Note
Danish: 'Porebeton'
lightweight_clinker_concrete 

Lightweight clinker concrete.

Note
Danish: 'Letklinkerbeton'
plaster 

Plaster.

Note
Danish: 'Puds'
brick 

Brick.

Note
Danish: 'Mursten/tegl'
glazed_tile 

Glazed tile.

Note
Danish: 'Glaseret tegl'
metal_general 

Metal (general).

Note
Danish: 'Metal (generelt)'
iron 

Iron.

Note
Danish: 'Jern'
steel 

Steel.

Note
Danish: 'Stål'
stainless_steel 

Stainless steel.

Note
Danish: 'Rustfrit stål'
aluminum 

Aluminum.

Note
Danish: 'Aluminium'
copper 

Copper.

Note
Danish: 'Kobber'
zinc 

Zinc.

Note
Danish: 'Zink'
lead 

Lead.

Note
Danish: 'Bly'
construction_wood 

Construction wood.

Note
Danish: 'Konstruktionstræ'
wood_unclassified 

Wood (unclassified).

Note
Danish: 'Træ (uklassificeret)'
precious_wood 

Precious wood.

Note
Danish: 'Ædeltræ'
laminated_wood 

Laminated wood.

Note
Danish: 'Lamineret træ'
veneer 

Veneer.

Note
Danish: 'Finer'
wood_fibers 

Wood fibers.

Note
Danish: 'Træfibre'
wood_fiber_boards 

Wood fiber boards.

Note
Danish: 'Træfiberplader'
wood_shavings 

Wood shavings.

Note
Danish: 'Træspåner'
chipboards 

Chipboards.

Note
Danish: 'Spånplader'
paper 

Paper.

Note
Danish: 'Papir'
corrugated_cardboard 

Corrugated cardboard.

Note
Danish: 'Bølgepap'
impregnated_cardboard 

Impregnated cardboard.

Note
Danish: 'Imprægneret pap'
wood_concrete_cement_fibers 

Wood concrete / cement fibers.

Note
Danish: 'Træbeton/cementfibre'
mineral_wool 

Mineral wool.

Note
Danish: 'Mineraluld'
asphalt 

Asphalt.

Note
Danish: 'Asfalt'
fibers 

Fibers.

Note
Danish: 'Fibre'
lining_paper 

Lining paper.

Note
Danish: 'Vægbeklædningspapir'
linoleum 

Linoleum.

Note
Danish: 'Linoleum'
rubber 

Rubber.

Note
Danish: 'Gummi'
plastic 

Plastic.

Note
Danish: 'Plast'
foam_plastic 

Foam plastic.

Note
Danish: 'Skumplast'
glass 

Glass.

Note
Danish: 'Glas'
natural_filling_aggregate 

Natural filling / aggregate.

Note
Danish: 'Naturligt fyld/tilslag'
painting_supplies 

Painting supplies.

Note
Danish: 'Malerartikler'
other 

Other.

Note
Danish: 'Andet'

Definition at line 19 of file materialepas_enums.hpp.

◆ MemberKind

enum class reusex::core::MemberKind
strong
Enumerator
category 
key 

Definition at line 25 of file resource_templates.hpp.

◆ PanoramaHeading

enum class reusex::core::PanoramaHeading
strong

Where a panorama's orientation comes from (mirrors the frontend's PanoramaHeading in viewport/panorama.ts).

Enumerator
resected 

rux align 360 pose: position and heading measured.

levelled 

Matched frame's position, heading unknown (LEVELLED basis).

Definition at line 149 of file instance_evidence.hpp.

◆ PipelineStage

enum class reusex::core::PipelineStage
strong

Pipeline stages that have an input contract.

Declared in pipeline order: a stage's inputs may only be produced by a strictly earlier stage, which is asserted by tests/unit/core/test_stage_contract.cpp.

Enumerator
import 

extract raw sensor frames from a scan

optimize 

refine per-frame sensor poses (a.k.a. register)

clouds 

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

annotate 

ML semantic labelling of the stored frames.

project 

project 2D semantic labels onto the 3D cloud

planes 

detect planar surfaces

rooms 

partition into rooms

instances 

separate semantic labels into spatial instances

mesh 

generate the reconstructed mesh

texture 

texture-map the reconstructed mesh

windows 

derive window building components

materials 

create one material passport per instance + link it

survey 

fill the Ressourcekortlægning from the instances table

attributes 

VLM-derived per-material annotations (description + kv).

gsplat 

train a 3D Gaussian splat and store it in the project

Definition at line 37 of file stage_contract.hpp.

◆ ReviewStatus

enum class reusex::core::ReviewStatus
strong
Enumerator
queue 
approved 
rejected 

Definition at line 40 of file survey.hpp.

◆ SampleResult

enum class reusex::core::SampleResult
strong
Enumerator
none 
ren 
forurenet 

Definition at line 42 of file survey.hpp.

◆ SampleStage

enum class reusex::core::SampleStage
strong
Enumerator
planlagt 
udtaget 
sendt 
svar 

Definition at line 41 of file survey.hpp.

◆ Stage

enum class reusex::core::Stage
strong
Enumerator
idle 
mesh_generation 
importing_data 
assembling_cloud 
creating_material 
retrieving_textures 
computing_face_coverage 
computing_room_probabilities 
processing_batch 
annotating_batches 
projecting_labels 
ray_tracing 
region_growing 
instance_clustering 
creating_windows 
room_segmentation 
dense_reconstruction 

Definition at line 11 of file stages.hpp.

◆ SubstanceContentMethod

Method used to determine substance content.

Note
Danish: 'Indhold af farlige stoffer (metode)'
Enumerator
assumed 

Assumed based on knowledge or documentation.

Note
Danish: 'Antaget'
measured_surface 

Measured on the surface of the material.

Note
Danish: 'Målt (overflade)'
measured_material 

Measured in the material itself.

Note
Danish: 'Målt (materiale)'

Definition at line 189 of file materialepas_enums.hpp.

◆ TransactionType

enum class reusex::core::TransactionType
strong

Transaction log entry type.

Note
Danish: 'Type'
Enumerator
document 

Change to the document itself (metadata).

Note
Danish: 'Dokument'
property 

Change to a property value.

Note
Danish: 'Egenskab'

Definition at line 204 of file materialepas_enums.hpp.

◆ Treatment

enum class reusex::core::Treatment
strong
Enumerator
bevaring 
genbrug 
genanvendelse 
nyttiggoerelse 
bortskaffelse 

Definition at line 26 of file survey.hpp.

◆ TriState

enum class reusex::core::TriState
strong

Tri-state value for Yes/No/Unknown fields.

Used where the standard defines three possible states, as distinct from std::optional<bool> which represents present-or-absent.

Enumerator
yes 

Yes / true.

Note
Danish: 'Ja'
no 

No / false.

Note
Danish: 'Nej'
unknown 

Unknown / not determined.

Note
Danish: 'Ukendt'

Definition at line 156 of file materialepas_enums.hpp.

◆ ValidationSeverity

Severity of a single validation finding.

Enumerator
warning 
error 

Definition at line 21 of file validate.hpp.

Function Documentation

◆ api_mat_to_storage()

cv::Mat reusex::core::api_mat_to_storage ( const cv::Mat & api)
inline

Convert an API label image (CV_32S, -1 = background) to a storage label image (CV_16U, 0 = bg) by adding the +1 offset.

Exceptions
std::invalid_argumentif api is not CV_32S.
std::out_of_rangeif any label is < -1 or > kMaxStorableLabel (would wrap the CV_16U storage layer).

Definition at line 148 of file label_semantics.hpp.

References api_mat_to_storage(), kBackgroundApi, and kMaxStorableLabel.

Referenced by api_mat_to_storage().

◆ api_to_point_label()

uint32_t reusex::core::api_to_point_label ( int api_label)
inline

API (CV_32S, -1 = background) → point label (uint32_t, 0 = unlabeled).

Background (kBackgroundApi) maps to kUnlabeled. Valid class ids pass through unchanged (the semantic-class layer keeps its own numbering; only the background sentinel is translated).

Exceptions
std::out_of_rangeif api_label is negative but not the background sentinel.

Definition at line 81 of file label_semantics.hpp.

References api_to_point_label(), kBackgroundApi, and kUnlabeled.

Referenced by api_to_point_label().

◆ api_to_storage()

uint16_t reusex::core::api_to_storage ( int api_label)
inline

API label (CV_32S, -1 = background) → storage value (CV_16U, 0 = bg, label + 1).

Exceptions
std::out_of_rangeif api_label < -1, or if api_label exceeds kMaxStorableLabel (would wrap the 16-bit storage layer).

Definition at line 104 of file label_semantics.hpp.

References api_to_storage(), kBackgroundApi, and kMaxStorableLabel.

Referenced by api_to_storage().

◆ apply_mask_selection()

MaskSelectionResult reusex::core::apply_mask_selection ( ProjectDB & db,
const std::vector< std::size_t > & indices,
const std::string & class_name,
const MaskSelectionOptions & opts = {} )

Label the selected points as class_name, make them one new instance, and file a survey part for it — in one transaction.

  • Semantic class: the id whose label_definitions(semantic_cloud) name is exactly class_name, else a new id (one past the largest used). The semantic cloud is created all-zero (cloud-sized) when absent.
  • Instance: a new id one past the largest used, assigned to the selected points (taking them from whatever instance held them), an instances row with a fresh GUID, and an SM<cls>-<id> (<n>p) label definition. The instances that lost points get their row and definition counts updated; one left with no points keeps its row (its material link and survey part stay intact) and is reported with a warn.
  • Survey part: linked to the new instance (so sync_survey will not add a second one), in the type chosen per MaskSelectionOptions::type_id.
  • A pipeline_log entry (segment_resource) records the parameters.

Existing instance rows are never deleted and re-inserted, so material links (instance_materials cascades on that delete) survive. Rewritten clouds keep the stage/parameters they were produced with; a cloud created here is saved with stage segment_resource. All reads happen inside the write transaction (BEGIN IMMEDIATE), so a concurrent writer cannot be overwritten from stale copies.

Exceptions
std::invalid_argumentfor an empty/blank class_name or an index out of range.
MaskSelectionErrorfor an empty selection, a missing base cloud, or a label cloud whose size differs from the base cloud's.
MaskSelectionErrorwhen opts.type_id names a rejected type.
std::out_of_rangewhen opts.type_id names no survey type.

References apply_mask_selection().

Referenced by apply_mask_selection().

◆ build_resource_csv()

std::string reusex::core::build_resource_csv ( const std::vector< ResourceKey > & columns,
const std::vector< Resource > & rows,
const CsvOptions & options )

Header + one CRLF-terminated row per resource, led by the resource code.

header "label" writes csv_labels() and display values; "key" writes key ids and raw values. A "utf-8-bom" encoding prefixes the UTF-8 byte-order mark.

References build_resource_csv().

Referenced by build_resource_csv().

◆ builtin_keys()

std::vector< ResourceKey > reusex::core::builtin_keys ( )

the 11 sys: keys, spec order

References builtin_keys().

Referenced by builtin_keys().

◆ check_dangling_instance_materials()

void reusex::core::check_dangling_instance_materials ( const ProjectDB & db,
std::vector< ValidationIssue > & out )

instance_materials rows whose instance row or passport is missing.

References check_dangling_instance_materials().

Referenced by check_dangling_instance_materials().

◆ check_instances_without_label_defs()

void reusex::core::check_instances_without_label_defs ( const ProjectDB & db,
std::vector< ValidationIssue > & out )

instances rows with no corresponding label_definitions entry.

References check_instances_without_label_defs().

Referenced by check_instances_without_label_defs().

◆ check_orphaned_passports()

void reusex::core::check_orphaned_passports ( const ProjectDB & db,
std::vector< ValidationIssue > & out )

Material passports not referenced by any instance_materials link.

Reported as warnings (an unused passport is not necessarily a bug).

References check_orphaned_passports().

Referenced by check_orphaned_passports().

◆ check_sibling_cloud_sizes()

void reusex::core::check_sibling_cloud_sizes ( const ProjectDB & db,
std::vector< ValidationIssue > & out )

Parallel/sibling clouds (cloud, labels, normals, planes, rooms, instances) whose point counts disagree — they are supposed to be index-aligned.

References check_sibling_cloud_sizes().

Referenced by check_sibling_cloud_sizes().

◆ check_stage_inputs()

void reusex::core::check_stage_inputs ( const ProjectDB & db,
PipelineStage stage,
std::vector< ValidationIssue > & out,
const ArtifactOverrides & overrides = {} )

Assert that stage's input clouds/tables exist in db and are index-aligned, per the contract in core/stage_contract.hpp.

Appends an issue per missing input or size mismatch, each carrying a derived resolution hint.

References check_stage_inputs().

Referenced by check_stage_inputs().

◆ circularity_breakdown()

std::array< double, kTreatmentCount > reusex::core::circularity_breakdown ( const std::vector< TypeTotals > & )

◆ cloud_label_at()

int32_t reusex::core::cloud_label_at ( const std::vector< CloudReferenceNode > & clouds,
size_t cloud_idx,
size_t point_idx )
inline

Helper for leaf nodes: read the label for point_idx from cloud cloud_idx, returning -1 if the index is out of range.

Definition at line 53 of file filter_expression.hpp.

References cloud_label_at(), and clouds.

Referenced by cloud_label_at(), reusex::core::CompareNode::evaluate(), reusex::core::EqualNode::evaluate(), reusex::core::InNode::evaluate(), and reusex::core::NotEqualNode::evaluate().

◆ column_key()

ResourceKey reusex::core::column_key ( const ProjectDB::PropertyDefinition & def)

References column_key().

Referenced by column_key().

◆ create_column()

ProjectDB::PropertyDefinition reusex::core::create_column ( ProjectDB & db,
ProjectDB::PropertyDefinition def )

Add a user column (def.id is ignored and returned filled in).

Exceptions
NameConflictErrorwhen a user column or a leksikon field already has that name, or any passport already stores values under it (left by a deleted column — never inherited silently), std::invalid_argument for an empty name.

References create_column().

Referenced by create_column().

◆ create_resource()

Resource reusex::core::create_resource ( ProjectDB & db,
int64_t type_id,
const std::optional< std::string > & name = std::nullopt )

A manual part with the next RX code; name becomes its designation.

Exceptions
std::out_of_range(no type), std::invalid_argument (empty name).

References create_resource().

Referenced by create_resource().

◆ create_template()

TemplateView reusex::core::create_template ( ProjectDB & db,
const TemplateInput & input )
Exceptions
std::invalid_argument(no/empty name, bad members or csv), NameConflictError (name taken).

References create_template().

Referenced by create_template().

◆ critical() [1/2]

template<typename... Args>
void reusex::core::critical ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 107 of file logging.hpp.

References critical(), critical, and log().

Referenced by critical(), and critical().

◆ critical() [2/2]

void reusex::core::critical ( std::string_view message)
inline

Definition at line 111 of file logging.hpp.

References critical(), critical, and log().

◆ csv_cell()

std::string reusex::core::csv_cell ( std::string_view value,
std::string_view delimiter )

One CSV cell: a cell starting with = + - @ TAB or CR gets a leading ' (formula injection), then RFC 4180 quoting when it holds the delimiter, a quote, CR or LF.

References csv_cell().

Referenced by csv_cell().

◆ csv_labels()

std::vector< std::string > reusex::core::csv_labels ( const std::vector< ResourceKey > & columns)

The CSV header labels of columns: each key's label, with " (<category>)" appended to every label that occurs more than once (counting the "Kode" column), so no two headers read the same.

References csv_labels().

Referenced by csv_labels().

◆ csv_options_json()

nlohmann::json reusex::core::csv_options_json ( const CsvOptions & options)

References csv_options_json().

Referenced by csv_options_json().

◆ current_progress_observer()

auto reusex::core::current_progress_observer ( ) -> IProgressObserver *

The observer progress reported from THIS thread goes to: the innermost ScopedProgressObserver installed on it, else the global one (which may be null).

References current_progress_observer().

Referenced by current_progress_observer().

◆ debug() [1/2]

template<typename... Args>
void reusex::core::debug ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 79 of file logging.hpp.

References debug(), debug, and log().

Referenced by debug(), and debug().

◆ debug() [2/2]

void reusex::core::debug ( std::string_view message)
inline

Definition at line 83 of file logging.hpp.

References debug(), debug, and log().

◆ delete_column()

void reusex::core::delete_column ( ProjectDB & db,
const std::string & id )

Delete a user column and, in the same transaction, every value stored under its name (logged at warn with the count), so the name can be used again.

Exceptions
std::out_of_range(no column).

References delete_column().

Referenced by delete_column().

◆ delete_resource()

void reusex::core::delete_resource ( ProjectDB & db,
std::string_view code )

Delete a part — manual or instance-backed — in one transaction.

An instance-backed part's instance guid is tombstoned (ProjectDB::dismiss_instance) so sync_survey does not re-create it, and its instance's passport link is dropped when it points at the part's passport. The passport is then deleted unless something else (another part or instance) still links it; a kept passport is logged at warn.

Exceptions
std::out_of_rangefor an unknown code.

References delete_resource().

Referenced by delete_resource().

◆ delete_survey_type()

SurveyTypeDeletion reusex::core::delete_survey_type ( ProjectDB & db,
int64_t type_id )

References delete_survey_type().

Referenced by delete_survey_type().

◆ delete_template()

void reusex::core::delete_template ( ProjectDB & db,
int64_t id )
Exceptions
std::out_of_rangewhen id is unknown.

References delete_template().

Referenced by delete_template().

◆ display_value()

std::string reusex::core::display_value ( const ResourceKey & key,
const std::optional< std::string > & value )

A value as a reader sees it: treatment and miljøstatus as their Danish labels, booleans as Ja/Nej, unset as "".

References display_value().

Referenced by display_value().

◆ duplicate_template()

TemplateView reusex::core::duplicate_template ( ProjectDB & db,
int64_t id )

Copy as "<name> (kopi)", "<name> (kopi 2)", … (never a seed).

Exceptions
std::out_of_rangewhen id is unknown.

References duplicate_template().

Referenced by duplicate_template().

◆ eak_fraction_name()

std::string_view reusex::core::eak_fraction_name ( std::string_view code)

References eak_fraction_name().

Referenced by eak_fraction_name().

◆ emission_quantity_type_from_string()

auto reusex::core::emission_quantity_type_from_string ( std::string_view str) -> std::optional< EmissionQuantityType >
nodiscard

Parse an EmissionQuantityType from its string identifier.

References emission_quantity_type_from_string().

Referenced by emission_quantity_type_from_string().

◆ environment_label_da()

std::string_view reusex::core::environment_label_da ( EnvironmentStatus )

References environment_label_da().

Referenced by environment_label_da().

◆ environment_status()

EnvironmentStatus reusex::core::environment_status ( const std::vector< SampleState > & linked)

References environment_status().

Referenced by environment_status().

◆ environment_status_of()

EnvironmentStatus reusex::core::environment_status_of ( const ProjectDB & db,
int64_t type_id )

◆ environment_statuses()

std::map< int64_t, EnvironmentStatus > reusex::core::environment_statuses ( const ProjectDB & db)

References environment_statuses().

Referenced by environment_statuses().

◆ equirect_uv()

Eigen::Vector2d reusex::core::equirect_uv ( const Eigen::Vector3d & bearing)

Normalised equirect coordinates of a bearing in the panorama frame.

The panorama frame is the pipeline's optical convention (+x right, +y down, +z forward); theta = atan2(x, z), phi = asin(-y), u = (theta + pi) / 2pi, v = (pi/2 - phi) / pi. Identical to geometry::bearing_to_pixel divided by the image size and to the frontend's bearingToUv. The bearing need not be normalised; a zero bearing maps to the image centre.

References equirect_uv().

Referenced by equirect_uv().

◆ error() [1/2]

template<typename... Args>
void reusex::core::error ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 100 of file logging.hpp.

References error(), error, and log().

Referenced by error(), and error().

◆ error() [2/2]

void reusex::core::error ( std::string_view message)
inline

Definition at line 104 of file logging.hpp.

References error(), error, and log().

◆ evaluate_filter()

auto reusex::core::evaluate_filter ( const FilterExpression & expr,
size_t cloud_size ) -> IndicesPtr

Evaluate filter expression against all points, generate Indices.

Parameters
exprParsed filter expression
cloud_sizeNumber of points to evaluate
Returns
Indices of points matching filter

References evaluate_filter().

Referenced by evaluate_filter().

◆ evaluate_filter_expression()

auto reusex::core::evaluate_filter_expression ( const std::string & filter_expr,
ProjectDB & db,
size_t expected_size ) -> IndicesPtr

Parse and evaluate a filter expression against a project in one step.

The whole "resolve the named label clouds, check they line up with the cloud being filtered, evaluate, and say how much survived" sequence, which every caller needs and which used to be duplicated in the app layer. It lives here so rux and the pipeline stage runners filter identically (#284).

Parameters
filter_exprExpression string; an empty string yields nullptr, i.e. "no filter", so callers can pass an unset option straight through.
dbProject to resolve the referenced label clouds from.
expected_sizePoint count of the cloud the indices will index into.
Returns
Indices of matching points, or nullptr for an empty expression.
Exceptions
std::runtime_erroron a parse error, a missing cloud, or a referenced cloud whose size disagrees with expected_size.

References evaluate_filter_expression().

Referenced by evaluate_filter_expression().

◆ export_resources_csv()

std::string reusex::core::export_resources_csv ( const ProjectDB & db,
int64_t template_id )

The CSV for one template: its resolved keys, every resource by code, its CSV options.

Exceptions
std::out_of_rangewhen the template is unknown.

References export_resources_csv().

Referenced by export_resources_csv().

◆ find_artifact()

const Artifact * reusex::core::find_artifact ( std::string_view name)

Look up an artifact by name, or nullptr when it is not a pipeline artifact.

References find_artifact().

Referenced by find_artifact().

◆ find_key()

const ResourceKey * reusex::core::find_key ( const std::vector< ResourceKey > & catalogue,
std::string_view id )

nullptr when id is not in catalogue.

References find_key().

Referenced by find_key().

◆ format_number()

std::string reusex::core::format_number ( double v)

Shortest round-trip text: 290.0 -> "290", 0.1 -> "0.1".

References format_number().

Referenced by format_number().

◆ fractions_by_eak()

FractionReport reusex::core::fractions_by_eak ( const std::vector< TypeTotals > & )

Approved tonnes per (EAK code, treatment, contaminated), for the bygningsaffald.dk report (GUI Phase 5, R3).

Rejected types are ignored. bevaring never counts: it stays in the building, so it is not waste — but an unapproved bevaring type still blocks. A type awaiting a sample blocks (reason sample) and is withheld even when approved, because its answer can make it contaminated. Any other unapproved type blocks (review). An approved, reportable non-bevaring type without tonnes blocks (mass) and is never counted as zero, so the report cannot be ready while incomplete. Contaminated tonnes are never merged into a clean fraction. Rows are in code, then waste-hierarchy, then clean-before-contaminated order; the blocking list is in input order.

References fractions_by_eak().

Referenced by fractions_by_eak().

◆ generate_guid()

std::string reusex::core::generate_guid ( )

Generate a fresh UUID-v4-like identifier (36-char, hyphenated hex).

Used for stable entity identity (material passports, building components, instances). Non-deterministic by design: each call yields a new value from a random_device-seeded generator. Do not use where reproducibility across runs is required.

References generate_guid().

Referenced by generate_guid().

◆ get_log_level()

auto reusex::core::get_log_level ( ) -> LogLevel

References get_log_level().

Referenced by get_log_level().

◆ get_progress_observer()

auto reusex::core::get_progress_observer ( ) -> IProgressObserver *

◆ get_visual_observer()

auto reusex::core::get_visual_observer ( ) -> IVisualObserver *

References get_visual_observer().

Referenced by get_visual_observer().

◆ info() [1/2]

template<typename... Args>
void reusex::core::info ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 86 of file logging.hpp.

References info(), info, and log().

Referenced by info(), and info().

◆ info() [2/2]

void reusex::core::info ( std::string_view message)
inline

Definition at line 90 of file logging.hpp.

References info(), info, and log().

◆ instance_centroids()

std::map< std::uint32_t, InstanceCentroid > reusex::core::instance_centroids ( const ProjectDB & db,
std::string_view label_cloud,
std::string_view positions_cloud = "cloud" )

Centroid of every instance id in an instance-label cloud.

The label cloud stores labels only; positions come from positions_cloud, index-aligned point for point (the instances stage's contract). Label 0 (unlabeled, STANDARDS §3) is skipped, as are non-finite points. One pass over the clouds, whatever the number of instances.

Exceptions
std::invalid_argumentwhen either cloud is not in the project.
CloudMisalignedErrorwhen the clouds are not index-aligned.
std::runtime_errorwhen a cloud cannot be loaded.

References instance_centroids().

Referenced by instance_centroids().

◆ instance_evidence()

std::map< std::uint32_t, InstanceEvidence > reusex::core::instance_evidence ( const ProjectDB & db,
std::string_view label_cloud,
const PhotoQuery & query = {},
std::string_view positions_cloud = "cloud",
const std::atomic< bool > * cancel = nullptr )

The ranked, occlusion-aware frames of every instance of label_cloud that has points: visible_frames_occluded over all its probes in one pass over the frames (each depth image decoded at most once).

Instances without finite points are absent.

Parameters
cancelpassed to visible_frames_occluded (throws OperationCancelled when raised).
Exceptions
asinstance_probes().

References instance_evidence().

Referenced by instance_evidence().

◆ instance_photos()

std::map< std::uint32_t, PartPhotos > reusex::core::instance_photos ( const ProjectDB & db,
std::string_view label_cloud,
const PhotoQuery & query = {},
std::string_view positions_cloud = "cloud" )

instance_evidence() reduced to count + best frame per instance.

References instance_photos().

Referenced by instance_photos().

◆ instance_probes()

std::map< std::uint32_t, InstanceProbe > reusex::core::instance_probes ( const ProjectDB & db,
std::string_view label_cloud,
std::string_view positions_cloud = "cloud",
std::size_t samples = PhotoQuery{}.samples_per_instance )

instance_centroids() plus up to samples points per instance, taken at evenly spaced positions in the instance's (finite) point list — spatially spread, since the clouds are stored in Morton order (#394).

An instance with fewer points keeps all of them. Same throws as instance_centroids().

References instance_probes().

Referenced by instance_probes().

◆ is_out_of_contract_label()

bool reusex::core::is_out_of_contract_label ( uint32_t label)
inlineconstexprnoexcept
Returns
true if label is outside the point-label contract: above INT32_MAX, i.e. a negative API label (typically -1, the background or an uninitialised room) that reached a uint32 point cloud and wrapped to 0xFFFFFFFF (STANDARDS §3.1). Such a value is neither unlabeled nor a class.

Definition at line 54 of file label_semantics.hpp.

References is_out_of_contract_label().

Referenced by is_out_of_contract_label().

◆ is_valid_label()

bool reusex::core::is_valid_label ( uint32_t label)
inlineconstexprnoexcept
Returns
true if label denotes a valid (non-unlabeled) point label.

Definition at line 46 of file label_semantics.hpp.

References is_valid_label(), and kUnlabeled.

Referenced by reusex::geometry::CellComplex::compute_room_probabilities(), is_valid_label(), and label_to_index().

◆ key_catalogue() [1/2]

std::vector< ResourceKey > reusex::core::key_catalogue ( const ProjectDB & db)

References key_catalogue().

◆ key_catalogue() [2/2]

std::vector< ResourceKey > reusex::core::key_catalogue ( const std::vector< ProjectDB::PropertyDefinition > & columns)

Built-in, then leksikon, then user columns (in the given order) — the "catalogue order" template categories expand in.

References key_catalogue().

Referenced by key_catalogue(), and key_catalogue().

◆ label_to_index()

size_t reusex::core::label_to_index ( uint32_t label)
inline

Convert a point label to a zero-based vector index, replacing the error-prone bare label - 1 idiom used to index parallel arrays such as plane_normals.

Exceptions
std::out_of_rangeif label is kUnlabeled (0), which has no associated index.

Definition at line 64 of file label_semantics.hpp.

References is_valid_label(), and label_to_index().

Referenced by label_to_index().

◆ legacy_column_member()

TemplateMember reusex::core::legacy_column_member ( std::string_view column,
const std::vector< ResourceKey > & catalogue )

References legacy_column_member().

Referenced by legacy_column_member().

◆ leksikon_categories()

std::vector< std::string > reusex::core::leksikon_categories ( )

Distinct categories of leksikon_fields(), in order.

References leksikon_categories().

Referenced by leksikon_categories().

◆ leksikon_fields()

std::vector< LeksikonField > reusex::core::leksikon_fields ( )

Nested object-array fields (dangerous substances, emissions) are skipped: they are rows, not one value.

References leksikon_fields().

Referenced by leksikon_fields().

◆ leksikon_keys()

std::vector< ResourceKey > reusex::core::leksikon_keys ( )

References leksikon_keys().

Referenced by leksikon_keys().

◆ list_resources()

std::vector< Resource > reusex::core::list_resources ( const ProjectDB & db,
const std::optional< std::vector< std::string > > & keys = std::nullopt )

One per survey part, by code.

With keys, values holds exactly those keys in that order (null when unset or unknown); without, every built-in key plus each catalogue key the part's passport stores, in catalogue order. Passport fields with no catalogue key are skipped, and stored blanks ("", "[]", a leksikon TriState's "unknown") read as unset.

References list_resources().

Referenced by list_resources().

◆ log() [1/2]

template<typename... Args>
void reusex::core::log ( LogLevel level,
fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 55 of file logging.hpp.

References log(), log_message(), and should_log().

Referenced by critical(), critical(), debug(), debug(), error(), error(), info(), info(), log(), log(), trace(), trace(), warn(), and warn().

◆ log() [2/2]

void reusex::core::log ( LogLevel level,
std::string_view message )
inline

Definition at line 64 of file logging.hpp.

References log(), log_message(), and should_log().

◆ log_message()

void reusex::core::log_message ( LogLevel level,
std::string_view message )

References log_message().

Referenced by log(), log(), and log_message().

◆ majority_room()

std::map< std::uint32_t, std::uint32_t > reusex::core::majority_room ( const std::vector< std::uint32_t > & instance_labels,
const std::vector< std::uint32_t > & room_labels )

References majority_room().

Referenced by majority_room().

◆ material_from_string()

auto reusex::core::material_from_string ( std::string_view str) -> std::optional< Material >
nodiscard

Parse a Material from its string identifier.

Returns
The matching Material, or std::nullopt if not found.

References material_from_string().

Referenced by material_from_string().

◆ material_names()

auto reusex::core::material_names ( ) -> std::vector< std::string_view >
nodiscard

Every Material string identifier, in enum order.

References material_names().

Referenced by material_names().

◆ members_json()

nlohmann::json reusex::core::members_json ( const std::vector< TemplateMember > & members)

References members_json().

Referenced by members_json().

◆ normalise_value()

std::optional< std::string > reusex::core::normalise_value ( const ResourceKey & key,
const std::optional< std::string > & value )

Validate value for key and return it normalised for storage (numbers with '.

', booleans "true"/"false", multiselect arrays compact JSON); nullopt means clear. "" clears any key except a built-in text key (stored as ""); an empty multiselect array "[]" clears too.

Exceptions
KeyValueErrorwhen the key is read-only, the value does not fit its data_type/options (a multiselect wants a JSON array of distinct options; a leksikon whole number must fit an int), sys:quantity is negative, sys:name or sys:unit is empty, or a clear hits sys:name/quantity/unit/treatment/starred.

References normalise_value().

Referenced by normalise_value().

◆ panoramas_for_point()

std::vector< PanoramaSighting > reusex::core::panoramas_for_point ( const ProjectDB & db,
const Eigen::Vector3d & world_point,
const PanoramaQuery & query = {} )

Panoramas that can be placed in the world, nearest first, with where world_point appears in each.

Placement follows the frontend's resolvePlacement: a resected pose (has_pose) wins; otherwise the matched sensor frame's position with the levelled, heading-free basis (+z forward on world +X, +y down on world -Z). Panoramas with neither are skipped. For a levelled panorama u is relative to that arbitrary heading, so it is only as good as the heading (the heading field says which). Sorted by distance, then id (STANDARDS §6).

When the project has panoramas but none can be placed, a warn with the counts is logged (STANDARDS §5).

References panoramas_for_point().

Referenced by panoramas_for_point().

◆ parse_csv_options()

CsvOptions reusex::core::parse_csv_options ( const nlohmann::json & csv)
Exceptions
std::invalid_argumentwhen csv is not an object or a known field has a value outside its set.

References parse_csv_options().

Referenced by parse_csv_options().

◆ parse_filter_expression()

auto reusex::core::parse_filter_expression ( const std::string & expression,
ProjectDB & db ) -> std::unique_ptr< FilterExpression >

Parse filter expression and resolve label cloud references from ProjectDB.

Parameters
expressionFilter expression string (e.g., "planes in [1, 2]")
dbProjectDB to load label clouds from
Returns
Parsed expression with resolved cloud references
Exceptions
std::runtime_errorif syntax invalid or cloud not found

References parse_filter_expression().

Referenced by parse_filter_expression().

◆ parse_gaussian_splat_ply_header()

GaussianSplatHeader reusex::core::parse_gaussian_splat_ply_header ( std::string_view head)

Parse the PLY header in head and verify it is an INRIA splat file.

Parameters
headThe first bytes of the file, at least up to end_header (see kGaussianSplatHeaderProbeBytes).
Exceptions
std::runtime_errorwhen head is not a PLY, is truncated before end_header, is binary_big_endian, or is a PLY without the Gaussian properties — the last being the interesting case, since rux export ply writes a perfectly valid PLY that no splat renderer can draw. The message is user-facing: it names what is missing and which command produces the right file.

References parse_gaussian_splat_ply_header().

Referenced by parse_gaussian_splat_ply_header().

◆ parse_members()

std::vector< TemplateMember > reusex::core::parse_members ( const nlohmann::json & members)

Parse [{"category": name} | {"key": id}, …].

Shape only: a category or key that does not exist is accepted and later reported as missing.

Exceptions
std::invalid_argumentnaming the bad element.

References parse_members().

Referenced by parse_members().

◆ parse_number()

std::optional< double > reusex::core::parse_number ( std::string_view text)

Finite number with '.

' or one ',' as decimal separator; surrounding blanks and a leading '+' are allowed. nullopt otherwise.

References parse_number().

Referenced by parse_number().

◆ parse_pipeline_stage()

std::optional< PipelineStage > reusex::core::parse_pipeline_stage ( std::string_view name)

Parse a stage name (e.g.

"mesh", "register") to a PipelineStage. Returns std::nullopt for an unknown name.

References parse_pipeline_stage().

Referenced by parse_pipeline_stage().

◆ part_code()

std::string reusex::core::part_code ( int number)

References part_code().

Referenced by part_code().

◆ patch_resource()

ResourcePatchResult reusex::core::patch_resource ( ProjectDB & db,
std::string_view code,
const std::vector< ResourceWrite > & writes,
const std::optional< std::vector< std::string > > & keys = std::nullopt )

Validate every write (normalise_value), then apply them in one transaction: type-scoped keys to the survey type, part-scoped built-ins to the part, leksikon/column keys to the part's passport (created on the first non-null write).

Clearing an absent value succeeds.

Exceptions
KeyValueError(nothing written) — also when one key appears twice in writes —, std::out_of_range (no part).

References patch_resource().

Referenced by patch_resource().

◆ pipeline_artifacts()

const std::vector< Artifact > & reusex::core::pipeline_artifacts ( )

Every artifact the contracts refer to.

References pipeline_artifacts().

Referenced by pipeline_artifacts().

◆ pipeline_stage_names()

std::vector< std::string > reusex::core::pipeline_stage_names ( )

All stage names accepted by parse_pipeline_stage(), for help text.

References pipeline_stage_names().

Referenced by pipeline_stage_names().

◆ point_label_to_api()

int reusex::core::point_label_to_api ( uint32_t point_label)
inline

Point label (uint32_t, 0 = unlabeled) → API (CV_32S, -1 = background).

Inverse of api_to_point_label(): kUnlabeled maps to kBackgroundApi.

Definition at line 93 of file label_semantics.hpp.

References kBackgroundApi, kUnlabeled, and point_label_to_api().

Referenced by point_label_to_api().

◆ producing_stage()

std::optional< PipelineStage > reusex::core::producing_stage ( std::string_view artifact)

The earliest stage that writes artifact, or nullopt when nothing does (an externally sourced artifact).

optimize rewrites sensor_frames in place, so the earliest producer — import — is the one reported.

References producing_stage().

Referenced by producing_stage().

◆ project_frame_mask()

std::vector< std::size_t > reusex::core::project_frame_mask ( const ProjectDB & db,
int frame_id,
const cv::Mat & mask,
const MaskProjectionOptions & opts = {} )

Indices of the base-cloud points that the mask covers in one frame.

Every point of opts.cloud is placed in the camera optical frame with world -> camera = (pose * local_transform)^-1 (the visible_frames() / vision::project() convention) and projected with the frame's pinhole intrinsics. Pixel coordinates are computed in the intrinsics' own width x height and rescaled to the mask's and the depth image's sizes, so the mask may be the colour image's size (a saved segmentation image) or any other. A point is selected when it is in front of the camera, within max_depth, lands inside the image on a non-zero mask pixel, and passes the occlusion test against the frame's depth image (CV_16U millimetres or CV_32F metres; a pixel with no depth reading rejects the point — it cannot be confirmed visible).

Zero hits is not an error (the mask may cover only background beyond the cloud); it logs a warn with the counts that explain it (STANDARDS §5).

Parameters
maskSingle-channel mask, non-zero = selected (CV_8U or CV_32S).
Returns
Selected point indices, ascending.
Exceptions
MaskSelectionErrorwhen the frame has no usable stored pose, no depth image, degenerate intrinsics, or the base cloud is missing.
std::invalid_argumentwhen the mask is empty or multi-channel.

References project_frame_mask().

Referenced by project_frame_mask().

◆ read_csv_options()

CsvOptions reusex::core::read_csv_options ( std::string_view stored,
std::string_view template_name )

Stored options, tolerantly: a bad field logs warn and uses its default.

References read_csv_options().

Referenced by read_csv_options().

◆ read_members()

std::vector< TemplateMember > reusex::core::read_members ( std::string_view stored,
std::string_view template_name )

Stored members, tolerantly: unreadable JSON logs warn and reads as none.

References read_members().

Referenced by read_members().

◆ redistribute_quantity()

std::vector< double > reusex::core::redistribute_quantity ( const std::vector< double > & current,
double total )

◆ report_survey_rows()

std::vector< ReportSurveyRow > reusex::core::report_survey_rows ( const ProjectDB & db)

One row per reportable survey type, in id order, for the PDF report's survey section ("kun godkendte mængder indgår").

A type is listed when it is approved and not awaiting a sample (core::reportable) and it does not block the waste report — so the rows agree with fractions_by_eak: an approved, non-bevaring type without tonnes blocks there (reason mass) and is left out here too. A bevaring type without tonnes never blocks (it is not waste), so it is listed with mass_t nullopt. quantity is the sum of the type's parts.

References report_survey_rows().

Referenced by report_survey_rows().

◆ report_version_json()

nlohmann::json reusex::core::report_version_json ( const ProjectDB::ReportPdfRecord & r)

{id, created_at, label, size_bytes, version, blocking_types}; blocking_types is null for a version generated before schema v23.

References report_version_json().

Referenced by report_version_json().

◆ reportable()

bool reusex::core::reportable ( ReviewStatus status,
EnvironmentStatus environment )

True when a type's tonnes may be reported: it is approved and not awaiting a sample (an afventer answer can still make it contaminated).

The single rule shared by fractions_by_eak and the report's tonnes (Phase 5, F2).

References reportable().

Referenced by reportable().

◆ reset_log_handler()

void reusex::core::reset_log_handler ( )

References reset_log_handler().

Referenced by reset_log_handler().

◆ reset_progress_observer()

void reusex::core::reset_progress_observer ( )

◆ reset_visual_observer()

void reusex::core::reset_visual_observer ( )

◆ resolve_template()

ResolvedTemplate reusex::core::resolve_template ( const std::vector< TemplateMember > & members,
const std::vector< ResourceKey > & catalogue )

Spec §5.2: a category member expands to every catalogue key in that category (catalogue order), a key member adds that key, duplicates keep their first position, and members that resolve to nothing go to missing.

References resolve_template().

Referenced by resolve_template().

◆ resource()

Resource reusex::core::resource ( const ProjectDB & db,
std::string_view code,
const std::optional< std::vector< std::string > > & keys = std::nullopt )
Exceptions
std::out_of_rangewhen code is unknown.

References resource().

Referenced by resource().

◆ resource_report_section()

ResourceReportSection reusex::core::resource_report_section ( const ProjectDB & db,
int64_t template_id )

The PDF's Ressourcetabel for one template: every resource whose type is not rejected, by code.

Exceptions
std::out_of_rangefor an unknown template.

References resource_report_section().

Referenced by resource_report_section().

◆ resource_tables()

std::vector< ResourceTable > reusex::core::resource_tables ( const std::vector< ResourceKey > & columns,
const std::vector< Resource > & rows,
std::size_t max_columns = kResourceTableMaxColumns )

Wrap columns into tables of at most max_columns, each led by a "Betegnelse" column whose cell is "<sys:name> · <code>" (sys:name is not repeated among the others).

No rows: no tables.

References kResourceTableMaxColumns, and resource_tables().

Referenced by resource_tables().

◆ restore_seed_templates()

std::vector< TemplateView > reusex::core::restore_seed_templates ( ProjectDB & db)

Insert every seed whose tag no template carries ("Gendan standardskabeloner"); a seed whose name is taken gets " (standard)".

Returns the inserted ones.

References restore_seed_templates().

Referenced by restore_seed_templates().

◆ review_status_from_string()

std::optional< ReviewStatus > reusex::core::review_status_from_string ( std::string_view )

◆ sample_code()

std::string reusex::core::sample_code ( int number)

References sample_code().

Referenced by sample_code().

◆ sample_result_from_string()

std::optional< SampleResult > reusex::core::sample_result_from_string ( std::string_view )

◆ sample_stage_from_string()

std::optional< SampleStage > reusex::core::sample_stage_from_string ( std::string_view )

◆ seed_templates()

std::vector< SeedTemplate > reusex::core::seed_templates ( )

"Materialepas (fuld)" (one category member per leksikon category) and "Hurtig genbrugsscreening" (the 11 sys: keys), in that order.

References seed_templates().

Referenced by seed_templates().

◆ set_log_handler()

void reusex::core::set_log_handler ( LogHandler handler)

References set_log_handler().

Referenced by set_log_handler().

◆ set_log_level()

void reusex::core::set_log_level ( LogLevel level)

References set_log_level().

Referenced by set_log_level().

◆ set_progress_observer()

void reusex::core::set_progress_observer ( IProgressObserver * observer)

◆ set_review_status()

ProjectDB::SurveyTypeRecord reusex::core::set_review_status ( ProjectDB & db,
int64_t type_id,
ReviewStatus status )

Approving a type whose miljøstatus is afventer throws SamplePendingError.

References set_review_status().

Referenced by set_review_status().

◆ set_type_quantity()

std::vector< ProjectDB::SurveyPartRecord > reusex::core::set_type_quantity ( ProjectDB & db,
int64_t type_id,
double total )

Scales the type's parts to sum to total (redistribute_quantity).

Throws std::invalid_argument when the type has no parts or total < 0.

References set_type_quantity().

Referenced by set_type_quantity().

◆ set_visual_observer()

void reusex::core::set_visual_observer ( IVisualObserver * observer)

References set_visual_observer().

Referenced by set_visual_observer().

◆ should_log()

auto reusex::core::should_log ( LogLevel level) -> bool

References should_log().

Referenced by log(), log(), and should_log().

◆ stage_contract()

const StageContract & reusex::core::stage_contract ( PipelineStage stage)

The contract of one stage.

Throws std::logic_error for an enumerator with no table row — a programming error, never a runtime condition.

References stage_contract().

Referenced by stage_contract().

◆ stage_contracts()

const std::vector< StageContract > & reusex::core::stage_contracts ( )

Every stage contract, in pipeline order.

References stage_contracts().

Referenced by stage_contracts().

◆ storage_mat_to_api()

cv::Mat reusex::core::storage_mat_to_api ( const cv::Mat & storage)
inline

Convert a storage label image (CV_16U, 0 = bg) to an API label image (CV_32S, -1 = background) by subtracting the +1 offset.

Exceptions
std::invalid_argumentif storage is not CV_16U (empty is passed through as empty).

Definition at line 130 of file label_semantics.hpp.

References storage_mat_to_api().

Referenced by storage_mat_to_api().

◆ storage_to_api()

int reusex::core::storage_to_api ( uint16_t storage_value)
inline

Storage value (CV_16U, 0 = bg, label + 1) → API label (CV_32S, -1 = background).

Definition at line 119 of file label_semantics.hpp.

References storage_to_api().

Referenced by storage_to_api().

◆ substance_content_method_from_string()

auto reusex::core::substance_content_method_from_string ( std::string_view str) -> std::optional< SubstanceContentMethod >
nodiscard

Parse a SubstanceContentMethod from its string identifier.

References substance_content_method_from_string().

Referenced by substance_content_method_from_string().

◆ sync_survey()

SurveySyncReport reusex::core::sync_survey ( ProjectDB & db,
const SurveySyncOptions & opts = {} )

Fill survey_types / survey_parts from the instances table: one type per semantic class, one bygningsdel (survey part) per instance, placed in the room most of its points fall in.

Idempotent — only adds instances that have no part yet (has_survey_part_for, keyed on instance guid) and were not dismissed (a deleted part stays deleted, see parts_dismissed), and never touches existing types/parts, so edits made in the GUI survive a rerun. If the instance cloud has labels but no instances rows (a pre-v10 cloud), the rows are backfilled first from the cloud's labels and its "SM{class}-{id}" definitions (see instances_backfilled). Lost instance links of parts that own a passport are restored (see links_restored). Throws std::runtime_error naming rux create instances if the instances cloud does not exist.

References sync_survey().

Referenced by sync_survey().

◆ template_view()

TemplateView reusex::core::template_view ( const ProjectDB & db,
int64_t id )
Exceptions
std::out_of_rangewhen id is unknown.

References template_view().

Referenced by template_view().

◆ template_views()

std::vector< TemplateView > reusex::core::template_views ( const ProjectDB & db)

Every template by id. Logs warn once per template with missing members.

References template_views().

Referenced by template_views().

◆ to_string() [1/14]

std::string_view reusex::core::to_string ( BlockingReason )

References to_string().

◆ to_string() [2/14]

auto reusex::core::to_string ( EmissionQuantityType value) -> std::string_view
nodiscard

Convert EmissionQuantityType enum to its string identifier.

References to_string().

◆ to_string() [3/14]

std::string_view reusex::core::to_string ( EnvironmentStatus )

References to_string().

◆ to_string() [4/14]

std::string_view reusex::core::to_string ( KeyScope )

References to_string().

◆ to_string() [5/14]

◆ to_string() [6/14]

std::string_view reusex::core::to_string ( PipelineStage stage)

Canonical lower-case name of a stage (the primary CLI token).

References to_string().

◆ to_string() [7/14]

std::string_view reusex::core::to_string ( ReviewStatus )

References to_string().

◆ to_string() [8/14]

std::string_view reusex::core::to_string ( SampleResult )

References to_string().

◆ to_string() [9/14]

std::string_view reusex::core::to_string ( SampleStage )

References to_string().

◆ to_string() [10/14]

std::string_view reusex::core::to_string ( Stage stage)

References to_string().

◆ to_string() [11/14]

auto reusex::core::to_string ( SubstanceContentMethod value) -> std::string_view
nodiscard

Convert SubstanceContentMethod enum to its string identifier.

References to_string().

◆ to_string() [12/14]

auto reusex::core::to_string ( TransactionType value) -> std::string_view
nodiscard

Convert TransactionType enum to its string identifier.

References to_string().

◆ to_string() [13/14]

std::string_view reusex::core::to_string ( Treatment )

References to_string().

◆ to_string() [14/14]

auto reusex::core::to_string ( TriState value) -> std::string_view
nodiscard

Convert TriState enum to its string identifier.

References to_string().

◆ trace() [1/2]

template<typename... Args>
void reusex::core::trace ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 72 of file logging.hpp.

References log(), trace, and trace().

Referenced by trace(), and trace().

◆ trace() [2/2]

void reusex::core::trace ( std::string_view message)
inline

Definition at line 76 of file logging.hpp.

References log(), trace, and trace().

◆ transaction_type_from_string()

auto reusex::core::transaction_type_from_string ( std::string_view str) -> std::optional< TransactionType >
nodiscard

Parse a TransactionType from its string identifier.

References transaction_type_from_string().

Referenced by transaction_type_from_string().

◆ treatment_from_string()

std::optional< Treatment > reusex::core::treatment_from_string ( std::string_view )

◆ treatment_label_da()

std::string_view reusex::core::treatment_label_da ( Treatment )

Danish user-facing labels (the PDF report).

Mirror the rux-frontend repo's src/kortlaegning/vocab.ts TREATMENT_LABEL / ENV_LABEL.

References treatment_label_da().

Referenced by treatment_label_da().

◆ tri_state_from_string()

auto reusex::core::tri_state_from_string ( std::string_view str) -> std::optional< TriState >
nodiscard

Parse a TriState from its string identifier.

References tri_state_from_string().

Referenced by tri_state_from_string().

◆ type_totals()

std::vector< TypeTotals > reusex::core::type_totals ( const ProjectDB & db)

References type_totals().

Referenced by type_totals().

◆ unique_name()

std::string reusex::core::unique_name ( std::string_view base,
std::string_view tag,
const std::vector< std::string > & taken )

First of "<base> (<tag>)", "<base> (<tag> 2)", "<base> (<tag> 3)", … that is not in taken.

References unique_name().

Referenced by unique_name().

◆ update_column()

ProjectDB::PropertyDefinition reusex::core::update_column ( ProjectDB & db,
const std::string & id,
const ColumnPatch & patch )

A rename moves the stored values in the same transaction.

Exceptions
std::out_of_range(no column), NameConflictError (name taken, or any passport already stores values under it — even when this column holds none), std::invalid_argument (empty).

References update_column().

Referenced by update_column().

◆ update_sample_checked()

ProjectDB::SampleRecord reusex::core::update_sample_checked ( ProjectDB & db,
int64_t id,
const ProjectDB::SamplePatch & patch )

Sample edit with the stage/result rule enforced (validate_sample_state on the merged state).

References update_sample_checked().

Referenced by update_sample_checked().

◆ update_template()

TemplateView reusex::core::update_template ( ProjectDB & db,
int64_t id,
const TemplateInput & input )
Exceptions
ascreate_template, plus std::out_of_range for an unknown id.

References update_template().

Referenced by update_template().

◆ validate_project()

ValidationReport reusex::core::validate_project ( const ProjectDB & db)

Run every check and aggregate the findings.

References validate_project().

Referenced by validate_project().

◆ validate_sample_state()

void reusex::core::validate_sample_state ( const SampleState & )

◆ validate_stage()

ValidationReport reusex::core::validate_stage ( const ProjectDB & db,
PipelineStage stage,
const ArtifactOverrides & overrides = {} )

Run check_stage_inputs for a single stage and aggregate the findings.

References validate_stage().

Referenced by validate_stage().

◆ value_of()

std::optional< std::string > reusex::core::value_of ( const Resource & r,
std::string_view key )

The value stored under key in r, or nullopt (absent or unset).

References value_of().

Referenced by value_of().

◆ visible_frames()

std::vector< FrameVisibility > reusex::core::visible_frames ( const ProjectDB & db,
const Eigen::Vector3d & world_point,
const VisibilityQuery & query = {} )

Rank the posed sensor frames by how centrally a world point projects.

For every sensor frame that carries a usable stored pose (gated on ProjectDB::has_sensor_frame_pose, per #336) and valid pinhole intrinsics, the point is transformed into the camera optical frame using world -> camera = (pose * local_transform)^-1 — the same convention reusex::vision::project() uses. A frame keeps the point when it is in front of the camera (z > 0) and its pinhole projection lands within the image bounds (a frustum test). The centrality score is the projection's normalised distance from the principal point.

The result is sorted best-first: ascending centrality, ties broken by nearer depth, then by frame_id — so the order is fully deterministic (STANDARDS §6). Work is bounded by the number of sensor frames.

Frames without a usable pose or with degenerate intrinsics are skipped, not fatal: a project may be partway through import. When no frame carries a pose the returned vector is empty and a warn is logged with the counts (STANDARDS §5), rather than failing outright.

Lives in core (not vision) deliberately: it depends only on ProjectDB and SensorIntrinsics plus Eigen, and the GUI read endpoint that drives it (ruxd_api_lib) links reusex_core but NOT reusex_vision, which stays out of the light test binary (#268). There is no PCL, CGAL, RTABMap or ML here, so core's header-hygiene rule (STANDARDS §1) is respected.

Parameters
dbProject to read sensor frames from.
world_pointThe 3D point in world coordinates.
queryOptional visibility tunables.
Returns
Visible frames, most central first. Empty when the point is seen by no posed frame.

References visible_frames().

Referenced by visible_frames().

◆ visible_frames_batch()

std::vector< std::vector< FrameVisibility > > reusex::core::visible_frames_batch ( const ProjectDB & db,
const std::vector< Eigen::Vector3d > & world_points,
const VisibilityQuery & query = {} )

visible_frames() for many points at once.

Reads every frame's pose and intrinsics once and projects all points through them, so the cost is one pass over the sensor frames rather than one per point. result[i] is exactly visible_frames(db, world_points[i], query), sorted the same way.

References visible_frames_batch().

Referenced by visible_frames_batch().

◆ visible_frames_occluded()

std::vector< std::vector< FrameVisibility > > reusex::core::visible_frames_occluded ( const ProjectDB & db,
const std::vector< VisibilityProbe > & probes,
const OcclusionQuery & query = {},
const std::atomic< bool > * cancel = nullptr )

Occlusion-aware visible_frames_batch(): frames that actually see each probe, not merely frames whose frustum contains it.

Per posed frame (one pass, each depth image decoded at most once and only when some anchor projects inside the frame): an anchor that passes the frustum test of query.visibility keeps the frame when the anchor or one of its samples, projected into the frame, is in front of the camera, inside the image, and within query.depth_tolerance of the stored depth (CV_16U millimetres; pixel scaled from the intrinsics' size to the depth image's). Ranking and the reported u/v/depth/centrality are the anchor's, sorted as in visible_frames().

Logs (debug) how many frames were depth-tested, had no depth, and how many frustum hits the depth test removed; warns when no frame is usable.

Parameters
cancelwhen non-null, checked once per frame; raising it makes the call throw OperationCancelled within one frame's work (a server shutting down mid-computation does not wait for the whole pass).

References visible_frames_occluded().

Referenced by visible_frames_occluded().

◆ warn() [1/2]

template<typename... Args>
void reusex::core::warn ( fmt::format_string< Args... > format,
Args &&... args )
inline

Definition at line 93 of file logging.hpp.

References log(), warn, and warn().

Referenced by warn(), and warn().

◆ warn() [2/2]

void reusex::core::warn ( std::string_view message)
inline

Definition at line 97 of file logging.hpp.

References log(), warn, and warn().

Variable Documentation

◆ kBackgroundApi

int reusex::core::kBackgroundApi = -1
inlineconstexpr

ProjectDB segmentation API convention: -1 marks background/unlabeled in the CV_32S label images returned by ProjectDB.

Definition at line 38 of file label_semantics.hpp.

Referenced by api_mat_to_storage(), api_to_point_label(), api_to_storage(), and point_label_to_api().

◆ kBuiltinCategory

std::string_view reusex::core::kBuiltinCategory = "Kortlægning"
inlineconstexpr

Definition at line 31 of file resource_keys.hpp.

◆ kColumnCategory

std::string_view reusex::core::kColumnCategory = "Egne felter"
inlineconstexpr

Definition at line 32 of file resource_keys.hpp.

◆ kCsvCodeKey

std::string_view reusex::core::kCsvCodeKey = "code"
inlineconstexpr

Definition at line 36 of file resource_export.hpp.

◆ kCsvCodeLabel

std::string_view reusex::core::kCsvCodeLabel = "Kode"
inlineconstexpr

The leading resource-code column of the CSV: its header in label mode and in key mode.

Definition at line 35 of file resource_export.hpp.

◆ kDefaultInstanceCloud

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

Default name of the instance-label cloud sync_survey reads from, and the default SurveySyncOptions::instances_cloud.

Definition at line 39 of file survey.hpp.

◆ kDesignationField

std::string_view reusex::core::kDesignationField = "designation"
inlineconstexpr

The leksikon field a hand-added resource's name is stored under.

Definition at line 74 of file resources.hpp.

◆ kGaussianSplatHeaderProbeBytes

std::size_t reusex::core::kGaussianSplatHeaderProbeBytes = 64 * 1024
inlineconstexpr

How many bytes from the head of a file are enough to find end_header.

An INRIA header is ~1.5 KiB (62 properties at degree 3). 64 KiB is room for an implementation with comments and then some, while bounding the read of a file that turns out not to be a PLY at all.

Definition at line 42 of file gaussian_splat.hpp.

◆ kLegacyKeyPrefix

std::string_view reusex::core::kLegacyKeyPrefix = "legacy:"
inlineconstexpr

Export-template columns (schema v21 config.columns) as members.

Matches a user column label, then any key label, then a leksikon field name; otherwise a legacy:<name> key member that never resolves (so it shows up in missing).

Definition at line 80 of file resource_templates.hpp.

◆ kManualSemanticClass

int reusex::core::kManualSemanticClass = -2
inlineconstexpr

semantic_class of a survey type created by hand, never matched by sync_survey.

Definition at line 36 of file survey.hpp.

◆ kMaxStorableLabel

uint16_t reusex::core::kMaxStorableLabel = 65534
inlineconstexpr

Largest label that can be stored in the CV_16U PNG layer.

Storage encodes label + 1, so the maximum encodable value before wrapping 16 bits is 65535 - 1 = 65534.

Definition at line 43 of file label_semantics.hpp.

Referenced by api_mat_to_storage(), and api_to_storage().

◆ kResourceTableMaxColumns

std::size_t reusex::core::kResourceTableMaxColumns = 8
inlineconstexpr

Definition at line 56 of file resource_export.hpp.

Referenced by resource_tables().

◆ kSeedMaterialepas

std::string_view reusex::core::kSeedMaterialepas = "materialepas"
inlineconstexpr

Definition at line 51 of file resource_templates.hpp.

◆ kSeedScreening

std::string_view reusex::core::kSeedScreening = "screening"
inlineconstexpr

Definition at line 52 of file resource_templates.hpp.

◆ kTreatmentCount

std::size_t reusex::core::kTreatmentCount = 5
inlineconstexpr

Definition at line 33 of file survey.hpp.

◆ kUnlabeled

uint32_t reusex::core::kUnlabeled = 0
inlineconstexpr

Point-cloud convention: 0 means "unlabeled" in every CloudL (labels, planes, rooms, instances).

Valid point labels start at 1.

Definition at line 34 of file label_semantics.hpp.

Referenced by api_to_point_label(), is_valid_label(), and point_label_to_api().