ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
mesh_router.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 "resource_router.hpp"
8
9namespace rux::database {
10
26class MeshRouter : public ResourceRouter {
27 public:
29
30 DataPayload get(const std::vector<PathComponent> &components) override;
31 void set(const std::vector<PathComponent> &components,
32 const DataPayload &data) override;
33 void del(const std::vector<PathComponent> &components) override;
34 std::vector<std::string> list() const override;
35
36 private:
37 nlohmann::json get_metadata(std::string_view name) const;
38 std::vector<uint8_t> get_data(std::string_view name) const;
39 std::vector<uint8_t> get_material(std::string_view name) const;
40 std::vector<uint8_t> get_texture(std::string_view name) const;
41
42 void set_mesh_from_binary(std::string_view name,
43 const std::vector<uint8_t> &data);
44
45 static bool is_ply_data(const std::vector<uint8_t> &data);
46
47 static std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
48 split_obj_mtl_blob(const std::vector<uint8_t> &combined);
49
50 static std::vector<uint8_t>
51 rewrite_obj_mtllib(const std::vector<uint8_t> &obj,
52 std::string_view mesh_name);
53
54 static std::vector<uint8_t>
55 rewrite_mtl_map_kd(const std::vector<uint8_t> &mtl,
56 std::string_view mesh_name);
57};
58
59} // namespace rux::database
Router for mesh resources.
void del(const std::vector< PathComponent > &components) override
Delete resource at the given path.
ResourceRouter(std::shared_ptr< reusex::ProjectDB > db)
void set(const std::vector< PathComponent > &components, const DataPayload &data) override
Set resource data at the given path.
std::vector< std::string > list() const override
List all items in this collection.
DataPayload get(const std::vector< PathComponent > &components) override
Get resource data at the given path.
ResourceRouter(std::shared_ptr< reusex::ProjectDB > db)
std::variant< std::string, std::vector< uint8_t >, nlohmann::json > DataPayload
Data payload that can be returned by routers.