11#include "reusex/core/component_record.hpp"
12#include "reusex/types/point_types.hpp"
38struct MaterialPassport;
39struct MaterialPassportMetadata;
40struct SensorIntrinsics;
68 explicit ProjectDB(std::filesystem::path dbPath,
bool readOnly =
false);
85 const std::filesystem::
path &
path() const noexcept;
94 const
cv::Mat &confidence,
95 const std::array<
double, 16> &worldPose,
96 const
core::SensorIntrinsics &intrinsics,
97 double timestamp = -1.0);
104 const std::array<
double, 16> &worldPose);
162 std::array<double, 16>
pose = {1, 0, 0, 0, 0, 1, 0, 0,
163 0, 0, 1, 0, 0, 0, 0, 1};
172 const std::vector<uint8_t> &jpeg_data,
173 double timestamp = -1.0,
int nodeId = -1);
185 int inliers,
double rms);
200 const std::vector<cv::Mat> &labels);
205 std::string_view stage =
"",
206 std::string_view paramsJson =
"");
209 std::string_view stage =
"",
210 std::string_view paramsJson =
"");
213 std::string_view stage =
"",
214 std::string_view paramsJson =
"");
217 const pcl::PointCloud<pcl::PointXYZ> &cloud,
218 std::string_view stage =
"",
219 std::string_view paramsJson =
"");
224 pcl::PointCloud<pcl::PointXYZ>::Ptr
266 uint64_t limit)
const;
271 const std::map<int, std::string> &labelMap);
273 std::map<int, std::string>
291 const std::vector<InstanceRecord> &records);
294 std::vector<InstanceRecord>
instances(
const std::string &cloud_name)
const;
299 uint32_t instance_id)
const;
310 std::string_view materialGuid);
314 int instanceId)
const;
317 std::map<int, std::string>
323 std::string_view stage =
"", std::string_view paramsJson =
"");
326 std::string_view stage =
"", std::string_view paramsJson =
"");
328 std::shared_ptr<pcl::PolygonMesh>
mesh(std::string_view name)
const;
329 std::shared_ptr<pcl::TextureMesh>
texture_mesh(std::string_view name)
const;
353 std::vector<MeshTextureMetadata>
394 const std::vector<uint8_t> &ply,
395 std::string_view stage =
"",
396 std::string_view parameters =
"");
440 std::vector<std::string>
447 std::string_view paramsJson =
"");
450 std::string_view errorMsg =
"");
540 std::string_view projectId);
554 std::string_view projectId, std::string_view
id);
580 std::map<std::string, std::string>
591 std::string_view fieldName)
const;
631 std::string_view column,
632 std::string_view value);
647 std::string_view fieldName,
648 std::string_view value);
657 std::string_view fieldName);
694 std::unique_ptr<Impl> impl_;
double sensor_frame_timestamp(int nodeId) const
Get the timestamp (epoch seconds) of a sensor frame.
int log_pipeline_start(std::string_view stage, std::string_view paramsJson="")
std::string point_cloud_type(std::string_view name) const
bool has_point_cloud(std::string_view name) const
bool delete_gaussian_splat(std::string_view name)
Deleting the metadata row cascades to its data chunks.
std::vector< uint8_t > mesh_data_blob(std::string_view name) const
void add_material_passport(const core::MaterialPassport &passport, std::string_view projectId)
bool has_sensor_frame_pose(int nodeId) const
True when this frame carries a usable stored world pose.
std::map< int, std::string > instance_materials(std::string_view cloudName) const
All instance_id → material_guid links for a cloud.
ProjectDB(const ProjectDB &)=delete
void save_point_cloud(std::string_view name, const pcl::PointCloud< pcl::PointXYZ > &cloud, std::string_view stage="", std::string_view paramsJson="")
std::shared_ptr< pcl::TextureMesh > texture_mesh(std::string_view name) const
bool has_segmentation_image(int nodeId) const
void log_pipeline_end(int logId, bool success, std::string_view errorMsg="")
std::vector< std::string > list_building_components() const
CloudLPtr point_cloud_label(std::string_view name) const
std::vector< std::string > list_building_components(std::string_view type) const
Names of the components whose stored type discriminator equals type.
ProjectDB & operator=(const ProjectDB &)=delete
int nearest_sensor_frame_by_timestamp(double timestamp) const
Find the sensor frame with the closest timestamp to the given value.
std::array< double, 16 > sensor_frame_pose(int nodeId) const
The stored world pose, verbatim — row-major 4x4, identity when the row is missing,...
std::vector< PipelineLogEntry > pipeline_log(int limit=0) const
std::vector< MeshTextureMetadata > mesh_texture_metadata(std::string_view name) const
void add_material_passport(const core::MaterialPassport &passport, std::string_view projectId, std::string_view id)
Add a material passport with a custom row ID.
void save_panoramic_image(const std::string &filename, const std::vector< uint8_t > &jpeg_data, double timestamp=-1.0, int nodeId=-1)
bool has_mesh(std::string_view name) const
std::vector< std::string > list_passport_guids() const
List document GUIDs ordered by created_at.
std::shared_ptr< pcl::PolygonMesh > mesh(std::string_view name) const
void set_passport_metadata_field(std::string_view documentGuid, std::string_view column, std::string_view value)
Set a metadata column on a material passport.
void delete_panoramic_image(std::string_view filename)
void save_point_cloud(std::string_view name, const Cloud &cloud, std::string_view stage="", std::string_view paramsJson="")
std::vector< int > sensor_frame_ids() const
void save_instances(const std::string &cloud_name, const std::vector< InstanceRecord > &records)
Replace the full set of instance rows for a cloud (transactional).
std::vector< std::string > list_gaussian_splats() const
Empty on a pre-v12 schema, for the same reason as has_gaussian_splat().
ProjectSummary project_summary() const
std::vector< core::MaterialPassport > all_material_passports() const
core::MaterialPassport material_passport(std::string_view documentGuid) const
void save_segmentation_image(int nodeId, const cv::Mat &labels)
int schema_version() const
void save_segmentation_images(const std::vector< int > &nodeIds, const std::vector< cv::Mat > &labels)
int building_component_count() const
ProjectDB(std::filesystem::path dbPath, bool readOnly=false)
Opens a ReUseX project database and validates its schema.
bool is_open() const noexcept
void delete_building_component(std::string_view name)
void save_mesh(std::string_view name, const pcl::TextureMesh &mesh, std::string_view stage="", std::string_view paramsJson="")
std::optional< int > passport_linked_node_id(std::string_view documentGuid) const
Return the sensor frame node_id this passport was linked to.
cv::Mat sensor_frame_confidence(int nodeId) const
void delete_point_cloud(std::string_view name)
GaussianSplatMetadata gaussian_splat_metadata(std::string_view name) const
cv::Mat sensor_frame_image(int nodeId) const
int panoramic_image_count() const
cv::Mat panoramic_image(std::string_view filename) const
std::map< int, std::string > label_definitions(std::string_view cloudName) const
std::vector< InstanceRecord > instances(const std::string &cloud_name) const
All instance rows for a cloud, ordered by instance_id.
bool has_panoramic_image(std::string_view filename) const
cv::Mat segmentation_image(int nodeId) const
std::vector< std::string > list_project_ids() const
List all project IDs in the database.
void save_panorama_segmentation(int panoId, const cv::Mat &labels)
void save_point_cloud(std::string_view name, const CloudL &cloud, std::string_view stage="", std::string_view paramsJson="")
std::string passport_property_value(std::string_view documentGuid, std::string_view fieldName) const
Get a single passport property value by field name.
std::vector< PanoramicImage > list_panoramic_images() const
core::ComponentRecord component_record(std::string_view name) const
Load the component row with the given name. Throws if absent.
void save_point_cloud(std::string_view name, const CloudN &cloud, std::string_view stage="", std::string_view paramsJson="")
CloudPtr point_cloud_xyzrgb(std::string_view name) const
MeshMetadata mesh_metadata(std::string_view name) const
CloudNPtr point_cloud_normal(std::string_view name) const
bool has_sensor_frame(int nodeId) const
void validate_schema() const
void update_project_metadata(const ProjectMetadata &metadata)
Update project metadata.
std::vector< MeshTextureInfo > mesh_texture_blobs(std::string_view name) const
std::map< std::string, std::string > passport_stored_properties(std::string_view documentGuid) const
Get stored property field_name→string pairs for a passport.
bool has_gaussian_splat(std::string_view name) const
False — not an error — on a project whose schema predates the splat tables, which is what a read-only...
bool has_building_component(std::string_view name) const
const std::filesystem::path & path() const noexcept
std::vector< std::string > list_point_clouds() const
void save_gaussian_splat(std::string_view name, const std::vector< uint8_t > &ply, std::string_view stage="", std::string_view parameters="")
Store an INRIA-format 3DGS .ply under name, replacing any splat already stored under it (chunks of th...
void delete_panoramic_image(int id)
void set_passport_property(std::string_view documentGuid, std::string_view fieldName, std::string_view value)
Set a single property value by field name (upsert).
std::string mesh_format(std::string_view name) const
void save_mesh(std::string_view name, const pcl::PolygonMesh &mesh, std::string_view stage="", std::string_view paramsJson="")
std::optional< std::string > instance_material_guid(std::string_view cloudName, int instanceId) const
Material passport guid linked to an instance, or nullopt if unlinked.
std::vector< uint8_t > gaussian_splat_blob(std::string_view name) const
The stored bytes, reassembled from their chunks — byte-for-byte what save_gaussian_splat() was given.
~ProjectDB()
Destructor closes database connection.
bool has_panorama_segmentation(int panoId) const
core::SensorIntrinsics sensor_frame_intrinsics(int nodeId) const
cv::Mat panoramic_image(int id) const
core::MaterialPassportMetadata passport_metadata(std::string_view documentGuid) const
Get passport metadata without loading all properties.
pcl::PointCloud< pcl::PointXYZ >::Ptr point_cloud_xyz(std::string_view name) const
void set_instance_material(std::string_view cloudName, int instanceId, std::string_view materialGuid)
Link an instance (a row in the instances table) to a material passport by its document guid.
void delete_passport_property(std::string_view documentGuid, std::string_view fieldName)
Delete a single property value by field name.
void update_sensor_frame_pose(int nodeId, const std::array< double, 16 > &worldPose)
Update only the stored world pose (transform) of an existing sensor frame.
cv::Mat panorama_segmentation(int panoId) const
void save_panorama_pose(int id, const std::array< double, 16 > &pose, int inliers, double rms)
Store a content-aligned pose (row-major 4x4 world) for a panorama.
std::vector< int > segmentation_image_ids() const
void save_component_record(const core::ComponentRecord &record)
Insert or replace the component row identified by record.name.
cv::Mat sensor_frame_depth(int nodeId) const
std::vector< std::string > list_meshes() const
void save_sensor_frame(int nodeId, const cv::Mat &colorImage)
CloudPage point_cloud_page(std::string_view name, uint64_t offset, uint64_t limit) const
Read one page of a point cloud without materializing the cloud.
void update_component_record_by_guid(const core::ComponentRecord &record)
Update an existing component's mutable fields (name, type, parent_id, confidence, metadata,...
ProjectDB(ProjectDB &&) noexcept
std::string instance_guid(const std::string &cloud_name, uint32_t instance_id) const
Stable GUID of a single instance.
ProjectMetadata get_project_metadata(std::string_view projectId) const
Get project metadata by project ID.
void delete_material_passport(std::string_view documentGuid)
Delete a material passport by GUID.
void save_label_definitions(std::string_view cloudName, const std::map< int, std::string > &labelMap)
typename CloudN::Ptr CloudNPtr
pcl::PointCloud< PointT > Cloud
typename CloudL::Ptr CloudLPtr
typename Cloud::Ptr CloudPtr
pcl::PointCloud< LabelT > CloudL
pcl::PointCloud< NormalT > CloudN
A contiguous window of one cloud's stored records, still in storage layout — no PCL type has been inf...
uint64_t total
Points in the whole cloud.
uint64_t count
Points actually read.
uint32_t point_step
Bytes per stored record.
std::string point_type
"PointXYZRGB" | "PointXYZ" | "Normal" | "Label".
std::vector< uint8_t > data
count * point_step bytes, exactly as stored.
uint64_t offset
First point index, clamped to total.
One row of the instances table: a spatially-distinct object within an instance-label cloud,...
int point_count
Number of points in the instance.
std::string guid
Stable identity (UUID-v4-like).
uint32_t instance_id
Label value in the instance cloud (>= 1).
int semantic_class
Semantic class this instance belongs to.
std::vector< uint8_t > image_data
std::array< double, 16 > pose
std::map< int, std::string > labels
std::map< std::string, int > count_by_type
std::string version_number
std::string building_address
std::string survey_organisation
std::vector< CloudInfo > clouds
std::vector< ProjectInfo > projects
std::filesystem::path path
std::vector< MaterialInfo > materials
SensorFrameInfo sensor_frames
std::vector< GaussianSplatMetadata > gaussian_splats
Metadata only — the summary never carries a splat's payload, which is routinely hundreds of MB.
std::vector< MeshInfo > meshes
PanoramicInfo panoramic_images
Core-owned persistence contract for a row of the building_components table (#227).
A complete material passport for a reused building material.