ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
BuildingComponent.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
7#include "reusex/geometry/CoplanarPolygon.hpp"
8
9#include <fmt/format.h>
10#include <string>
11#include <string_view>
12#include <variant>
13
14namespace reusex::geometry {
15
17enum class ComponentType { window, door, wall };
18
19std::string_view to_string(ComponentType type);
21
22struct WindowData {
23 std::string style; // "casement", "sliding", "fixed", etc.
24 int pane_count = 0;
25 bool operable = true;
26};
27
28struct DoorData {
29 std::string style; // "single", "double", "sliding"
30 std::string swing; // "left", "right", "none"
31};
32
33struct WallData {}; // stub for future use
34
37 std::string name;
40 int parent_id = -1; // optional link to parent component
41 double confidence = -1.0; // detection confidence, -1 if manual
42 std::string notes;
43 std::variant<WindowData, DoorData, WallData> data = WindowData{};
44};
45
48
50void component_data_from_json(BuildingComponent &c, const std::string &json);
51
52} // namespace reusex::geometry
53
54template <>
55struct fmt::formatter<reusex::geometry::BuildingComponent>
56 : fmt::formatter<std::string_view> {
58 format_context &ctx) const -> format_context::iterator {
59 return fmt::format_to(ctx.out(), "{} ({} vertices)", value.name,
60 value.boundary.vertices.size());
61 }
62};
std::string_view to_string(ComponentType type)
ComponentType
Discriminator for building component types.
ComponentType component_type_from_string(std::string_view str)
void component_data_from_json(BuildingComponent &c, const std::string &json)
Deserialize JSON TEXT into the variant data on a BuildingComponent.
std::string component_data_to_json(const BuildingComponent &c)
Serialize the type-specific variant data to JSON TEXT.
auto format(reusex::geometry::BuildingComponent value, format_context &ctx) const -> format_context::iterator
A detected or manual building component (window, door, wall, ...).
std::variant< WindowData, DoorData, WallData > data
A closed 3D polygon whose vertices are coplanar.