ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
survey.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
13
14#include <array>
15#include <cstddef>
16#include <cstdint>
17#include <map>
18#include <optional>
19#include <stdexcept>
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace reusex::core {
25
33inline constexpr std::size_t kTreatmentCount = 5;
36inline constexpr int kManualSemanticClass = -2;
39inline constexpr std::string_view kDefaultInstanceCloud = "instances";
42enum class SampleResult { none, ren, forurenet };
49
50std::string_view to_string(Treatment);
51std::string_view to_string(ReviewStatus);
52std::string_view to_string(SampleStage);
53std::string_view to_string(SampleResult); // none -> ""
54std::string_view to_string(EnvironmentStatus);
57std::string_view treatment_label_da(Treatment);
59std::optional<Treatment> treatment_from_string(std::string_view);
60std::optional<ReviewStatus> review_status_from_string(std::string_view);
61std::optional<SampleStage> sample_stage_from_string(std::string_view);
62std::optional<SampleResult>
63 sample_result_from_string(std::string_view); // "" -> none
64
69void validate_sample_state(const SampleState &); // throws std::invalid_argument
70EnvironmentStatus environment_status(const std::vector<SampleState> &linked);
71
72class SamplePendingError : public std::runtime_error {
73 public:
74 using std::runtime_error::runtime_error;
75};
76
79class NameConflictError : public std::runtime_error {
80 public:
81 using std::runtime_error::runtime_error;
82};
83
94std::array<double, kTreatmentCount>
95circularity_breakdown(const std::vector<TypeTotals> &);
96struct Fraction {
97 std::string eak_code;
98 std::string name;
100 double mass_t = 0.0;
101 bool contaminated = false;
102};
103
106std::string_view to_string(BlockingReason); // "review" | "sample" | "mass"
116 std::vector<Fraction> fractions;
117 double total_t = 0.0;
118 std::size_t blocking_types = 0; // == blocking.size()
119 std::vector<BlockingType> blocking;
120};
121
124bool reportable(ReviewStatus status, EnvironmentStatus environment);
136FractionReport fractions_by_eak(const std::vector<TypeTotals> &);
137std::string_view eak_fraction_name(std::string_view code); // "" when unknown
138std::map<std::uint32_t, std::uint32_t>
139majority_room(const std::vector<std::uint32_t> &instance_labels,
140 const std::vector<std::uint32_t> &room_labels);
141std::vector<double> redistribute_quantity(const std::vector<double> &current,
142 double total);
143std::string part_code(int number); // 1 -> "RX-001"
144std::string sample_code(int number); // 1 -> "P-01"
145
146} // namespace reusex::core
A name that must be unique (template, user column, stored field) is already taken.
Definition survey.hpp:79
Wire form of one stored report PDF version — the ReportPdfVersion schema in ruxd's API contract (docs...
void validate_sample_state(const SampleState &)
@ none
not index-aligned with anything (tables, meshes)
std::string part_code(int number)
std::optional< SampleStage > sample_stage_from_string(std::string_view)
std::array< double, kTreatmentCount > circularity_breakdown(const std::vector< TypeTotals > &)
constexpr int kManualSemanticClass
semantic_class of a survey type created by hand, never matched by sync_survey.
Definition survey.hpp:36
constexpr std::size_t kTreatmentCount
Definition survey.hpp:33
std::string_view eak_fraction_name(std::string_view code)
std::string_view environment_label_da(EnvironmentStatus)
std::string_view treatment_label_da(Treatment)
Danish user-facing labels (the PDF report).
auto to_string(Material value) -> std::string_view
Convert Material enum to its string identifier.
EnvironmentStatus environment_status(const std::vector< SampleState > &linked)
std::optional< ReviewStatus > review_status_from_string(std::string_view)
FractionReport fractions_by_eak(const std::vector< TypeTotals > &)
Approved tonnes per (EAK code, treatment, contaminated), for the bygningsaffald.dk report (GUI Phase ...
BlockingReason
Why a type blocks the waste report; a type gets one reason, by precedence sample > review > mass.
Definition survey.hpp:105
std::optional< SampleResult > sample_result_from_string(std::string_view)
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)
constexpr std::string_view kDefaultInstanceCloud
Default name of the instance-label cloud sync_survey reads from, and the default SurveySyncOptions::i...
Definition survey.hpp:39
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 answ...
std::string sample_code(int number)
std::vector< double > redistribute_quantity(const std::vector< double > &current, double total)
std::optional< Treatment > treatment_from_string(std::string_view)
std::optional< double > mass_t
Definition survey.hpp:112
BlockingReason reason
Definition survey.hpp:113
std::vector< BlockingType > blocking
Definition survey.hpp:119
std::vector< Fraction > fractions
Definition survey.hpp:116
std::string eak_code
Definition survey.hpp:97
ReviewStatus status
Definition survey.hpp:86
std::optional< double > mass_t
Definition survey.hpp:87
std::int64_t type_id
Identify the type in a blocking list; not used by the arithmetic.
Definition survey.hpp:91
EnvironmentStatus environment
Definition survey.hpp:89