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

#include <ProjectDB.hpp>

Classes

struct  PanoramicImage
struct  PipelineLogEntry
struct  ProjectSummary

Public Member Functions

 ProjectDB (std::filesystem::path dbPath, bool readOnly=false)
 Opens a ReUseX project database and validates its schema.
 ~ProjectDB ()
 Destructor closes database connection.
 ProjectDB (const ProjectDB &)=delete
ProjectDBoperator= (const ProjectDB &)=delete
 ProjectDB (ProjectDB &&) noexcept
ProjectDBoperator= (ProjectDB &&) noexcept
bool is_open () const noexcept
const std::filesystem::path & path () const noexcept
int schema_version () const
void validate_schema () const
void save_sensor_frame (int nodeId, const cv::Mat &colorImage)
void save_sensor_frame (int nodeId, const cv::Mat &color, const cv::Mat &depth, const cv::Mat &confidence, const std::array< double, 16 > &worldPose, const core::SensorIntrinsics &intrinsics, double timestamp=-1.0)
std::vector< int > sensor_frame_ids () const
cv::Mat sensor_frame_image (int nodeId) const
cv::Mat sensor_frame_depth (int nodeId) const
cv::Mat sensor_frame_confidence (int nodeId) const
std::array< double, 16 > sensor_frame_pose (int nodeId) const
core::SensorIntrinsics sensor_frame_intrinsics (int nodeId) const
bool has_sensor_frame (int nodeId) const
double sensor_frame_timestamp (int nodeId) const
 Get the timestamp (epoch seconds) of a sensor frame. Returns -1.0 if not set.
int nearest_sensor_frame_by_timestamp (double timestamp) const
 Find the sensor frame with the closest timestamp to the given value.
void save_panoramic_image (const std::string &filename, const std::vector< uint8_t > &jpeg_data, double timestamp=-1.0, int nodeId=-1)
cv::Mat panoramic_image (int id) const
cv::Mat panoramic_image (std::string_view filename) const
bool has_panoramic_image (std::string_view filename) const
void delete_panoramic_image (int id)
void delete_panoramic_image (std::string_view filename)
std::vector< PanoramicImagelist_panoramic_images () const
int panoramic_image_count () const
bool has_segmentation_image (int nodeId) const
cv::Mat segmentation_image (int nodeId) const
void save_segmentation_image (int nodeId, const cv::Mat &labels)
void save_segmentation_images (const std::vector< int > &nodeIds, const std::vector< cv::Mat > &labels)
void save_point_cloud (std::string_view name, const Cloud &cloud, std::string_view stage="", std::string_view paramsJson="")
void save_point_cloud (std::string_view name, const CloudN &cloud, std::string_view stage="", std::string_view paramsJson="")
void save_point_cloud (std::string_view name, const CloudL &cloud, std::string_view stage="", std::string_view paramsJson="")
void save_point_cloud (std::string_view name, const pcl::PointCloud< pcl::PointXYZ > &cloud, std::string_view stage="", std::string_view paramsJson="")
CloudPtr point_cloud_xyzrgb (std::string_view name) const
CloudNPtr point_cloud_normal (std::string_view name) const
CloudLPtr point_cloud_label (std::string_view name) const
pcl::PointCloud< pcl::PointXYZ >::Ptr point_cloud_xyz (std::string_view name) const
bool has_point_cloud (std::string_view name) const
void delete_point_cloud (std::string_view name)
std::vector< std::string > list_point_clouds () const
std::string point_cloud_type (std::string_view name) const
void save_label_definitions (std::string_view cloudName, const std::map< int, std::string > &labelMap)
std::map< int, std::string > label_definitions (std::string_view cloudName) const
void save_mesh (std::string_view name, const pcl::PolygonMesh &mesh, std::string_view stage="", std::string_view paramsJson="")
void save_mesh (std::string_view name, const pcl::TextureMesh &mesh, std::string_view stage="", std::string_view paramsJson="")
pcl::PolygonMesh::Ptr mesh (std::string_view name) const
pcl::TextureMesh::Ptr texture_mesh (std::string_view name) const
bool has_mesh (std::string_view name) const
std::vector< std::string > list_meshes () const
void save_building_component (const geometry::BuildingComponent &component)
geometry::BuildingComponent building_component (std::string_view name) const
bool has_building_component (std::string_view name) const
void delete_building_component (std::string_view name)
std::vector< std::string > list_building_components () const
std::vector< std::string > list_building_components (geometry::ComponentType type) const
int building_component_count () const
int log_pipeline_start (std::string_view stage, std::string_view paramsJson="")
void log_pipeline_end (int logId, bool success, std::string_view errorMsg="")
std::vector< PipelineLogEntrypipeline_log (int limit=0) const
ProjectSummary project_summary () const
core::MaterialPassport material_passport (std::string_view documentGuid) const
std::vector< core::MaterialPassportall_material_passports () const
void add_material_passport (const core::MaterialPassport &passport, std::string_view projectId)
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 delete_material_passport (std::string_view documentGuid)
 Delete a material passport by GUID.
std::vector< std::string > list_passport_guids () const
 List document GUIDs ordered by created_at.
std::map< std::string, std::string > passport_stored_properties (std::string_view documentGuid) const
 Get stored property field_name→string pairs for a passport.
std::string passport_property_value (std::string_view documentGuid, std::string_view fieldName) const
 Get a single passport property value by field name.
core::MaterialPassportMetadata passport_metadata (std::string_view documentGuid) const
 Get passport metadata without loading all properties.
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 set_passport_property (std::string_view documentGuid, std::string_view fieldName, std::string_view value)
 Set a single property value by field name (upsert).
void delete_passport_property (std::string_view documentGuid, std::string_view fieldName)
 Delete a single property value by field name.
ProjectMetadata get_project_metadata (std::string_view projectId) const
 Get project metadata by project ID.
void update_project_metadata (const ProjectMetadata &metadata)
 Update project metadata.
std::vector< std::string > list_project_ids () const
 List all project IDs in the database.

Detailed Description

Definition at line 30 of file ProjectDB.hpp.

Constructor & Destructor Documentation

◆ ProjectDB() [1/3]

reusex::ProjectDB::ProjectDB ( std::filesystem::path dbPath,
bool readOnly = false )
explicit

Opens a ReUseX project database and validates its schema.

Creates the following tables if they don't exist (write mode only):

  • projects: Project metadata (building info, survey details)
  • property_definitions: Leksikon-based property definitions
  • material_passports: Material passport documents
  • passport_property_values: Property values for each passport
  • passport_log: Audit log for tracking changes
  • schema_version: Schema version tracking
  • point_clouds / point_cloud_data: Point cloud storage
  • label_definitions: Semantic label lookup
  • meshes: Mesh storage
  • sensor_frames: Imported sensor frame color images
  • segmentation_images: Per-frame semantic label images
  • pipeline_log: Pipeline provenance log
Parameters
dbPathPath to the database file
readOnlyIf true, opens database in read-only mode
Exceptions
std::runtime_errorif database cannot be opened or schema is invalid

Referenced by operator=(), operator=(), ProjectDB(), and ProjectDB().

◆ ~ProjectDB()

reusex::ProjectDB::~ProjectDB ( )

Destructor closes database connection.

◆ ProjectDB() [2/3]

reusex::ProjectDB::ProjectDB ( const ProjectDB & )
delete

References ProjectDB().

◆ ProjectDB() [3/3]

reusex::ProjectDB::ProjectDB ( ProjectDB && )
noexcept

References ProjectDB().

Member Function Documentation

◆ add_material_passport() [1/2]

void reusex::ProjectDB::add_material_passport ( const core::MaterialPassport & passport,
std::string_view projectId )

◆ add_material_passport() [2/2]

void reusex::ProjectDB::add_material_passport ( const core::MaterialPassport & passport,
std::string_view projectId,
std::string_view id )

Add a material passport with a custom row ID.

The id parameter overrides the material_passports.id column value (normally set to document_guid). Use this to link a passport to a sensor frame by setting id to the frame's node_id.

Parameters
passportMaterial passport data
projectIdProject identifier (may be empty)
idCustom row ID for the material_passports.id column

◆ all_material_passports()

std::vector< core::MaterialPassport > reusex::ProjectDB::all_material_passports ( ) const

◆ building_component()

geometry::BuildingComponent reusex::ProjectDB::building_component ( std::string_view name) const

◆ building_component_count()

int reusex::ProjectDB::building_component_count ( ) const

◆ delete_building_component()

void reusex::ProjectDB::delete_building_component ( std::string_view name)

◆ delete_material_passport()

void reusex::ProjectDB::delete_material_passport ( std::string_view documentGuid)

Delete a material passport by GUID.

Parameters
documentGuidDocument GUID to delete
Exceptions
std::runtime_errorif passport does not exist

◆ delete_panoramic_image() [1/2]

void reusex::ProjectDB::delete_panoramic_image ( int id)

◆ delete_panoramic_image() [2/2]

void reusex::ProjectDB::delete_panoramic_image ( std::string_view filename)

◆ delete_passport_property()

void reusex::ProjectDB::delete_passport_property ( std::string_view documentGuid,
std::string_view fieldName )

Delete a single property value by field name.

Parameters
documentGuidDocument GUID
fieldNameProperty field name (name_en)
Exceptions
std::runtime_errorif passport or property not found

◆ delete_point_cloud()

void reusex::ProjectDB::delete_point_cloud ( std::string_view name)

◆ get_project_metadata()

ProjectMetadata reusex::ProjectDB::get_project_metadata ( std::string_view projectId) const

Get project metadata by project ID.

Parameters
projectIdProject identifier
Returns
Project metadata
Exceptions
std::runtime_errorif project does not exist

◆ has_building_component()

bool reusex::ProjectDB::has_building_component ( std::string_view name) const

◆ has_mesh()

bool reusex::ProjectDB::has_mesh ( std::string_view name) const

◆ has_panoramic_image()

bool reusex::ProjectDB::has_panoramic_image ( std::string_view filename) const

◆ has_point_cloud()

bool reusex::ProjectDB::has_point_cloud ( std::string_view name) const

◆ has_segmentation_image()

bool reusex::ProjectDB::has_segmentation_image ( int nodeId) const

◆ has_sensor_frame()

bool reusex::ProjectDB::has_sensor_frame ( int nodeId) const

References has_sensor_frame().

Referenced by has_sensor_frame().

◆ is_open()

bool reusex::ProjectDB::is_open ( ) const
noexcept

References is_open().

Referenced by is_open().

◆ label_definitions()

std::map< int, std::string > reusex::ProjectDB::label_definitions ( std::string_view cloudName) const

◆ list_building_components() [1/2]

std::vector< std::string > reusex::ProjectDB::list_building_components ( ) const

◆ list_building_components() [2/2]

std::vector< std::string > reusex::ProjectDB::list_building_components ( geometry::ComponentType type) const

◆ list_meshes()

std::vector< std::string > reusex::ProjectDB::list_meshes ( ) const

◆ list_panoramic_images()

std::vector< PanoramicImage > reusex::ProjectDB::list_panoramic_images ( ) const

◆ list_passport_guids()

std::vector< std::string > reusex::ProjectDB::list_passport_guids ( ) const

List document GUIDs ordered by created_at.

Returns
Vector of document GUID strings

◆ list_point_clouds()

std::vector< std::string > reusex::ProjectDB::list_point_clouds ( ) const

◆ list_project_ids()

std::vector< std::string > reusex::ProjectDB::list_project_ids ( ) const

List all project IDs in the database.

Returns
Vector of project IDs

◆ log_pipeline_end()

void reusex::ProjectDB::log_pipeline_end ( int logId,
bool success,
std::string_view errorMsg = "" )

◆ log_pipeline_start()

int reusex::ProjectDB::log_pipeline_start ( std::string_view stage,
std::string_view paramsJson = "" )

◆ material_passport()

core::MaterialPassport reusex::ProjectDB::material_passport ( std::string_view documentGuid) const

◆ mesh()

pcl::PolygonMesh::Ptr reusex::ProjectDB::mesh ( std::string_view name) const

Referenced by save_mesh(), and save_mesh().

◆ nearest_sensor_frame_by_timestamp()

int reusex::ProjectDB::nearest_sensor_frame_by_timestamp ( double timestamp) const

Find the sensor frame with the closest timestamp to the given value.

Returns -1 if no sensor frames have timestamps.

References nearest_sensor_frame_by_timestamp().

Referenced by nearest_sensor_frame_by_timestamp().

◆ operator=() [1/2]

ProjectDB & reusex::ProjectDB::operator= ( const ProjectDB & )
delete

References ProjectDB().

◆ operator=() [2/2]

ProjectDB & reusex::ProjectDB::operator= ( ProjectDB && )
noexcept

References ProjectDB().

◆ panoramic_image() [1/2]

cv::Mat reusex::ProjectDB::panoramic_image ( int id) const

◆ panoramic_image() [2/2]

cv::Mat reusex::ProjectDB::panoramic_image ( std::string_view filename) const

◆ panoramic_image_count()

int reusex::ProjectDB::panoramic_image_count ( ) const

◆ passport_metadata()

core::MaterialPassportMetadata reusex::ProjectDB::passport_metadata ( std::string_view documentGuid) const

Get passport metadata without loading all properties.

Parameters
documentGuidDocument GUID
Returns
MaterialPassportMetadata struct
Exceptions
std::runtime_errorif passport not found

◆ passport_property_value()

std::string reusex::ProjectDB::passport_property_value ( std::string_view documentGuid,
std::string_view fieldName ) const

Get a single passport property value by field name.

Parameters
documentGuidDocument GUID
fieldNameProperty field name (name_en in property_definitions)
Returns
String value of the property
Exceptions
std::runtime_errorif passport or property not found

◆ passport_stored_properties()

std::map< std::string, std::string > reusex::ProjectDB::passport_stored_properties ( std::string_view documentGuid) const

Get stored property field_name→string pairs for a passport.

Only includes properties that actually have rows in passport_property_values. Values are returned as human-readable strings (BLOB decoded via as_string()).

Parameters
documentGuidDocument GUID
Returns
Map of name_en → string value
Exceptions
std::runtime_errorif passport does not exist

◆ path()

const std::filesystem::path & reusex::ProjectDB::path ( ) const
noexcept

References path().

Referenced by path().

◆ pipeline_log()

std::vector< PipelineLogEntry > reusex::ProjectDB::pipeline_log ( int limit = 0) const

◆ point_cloud_label()

CloudLPtr reusex::ProjectDB::point_cloud_label ( std::string_view name) const

◆ point_cloud_normal()

CloudNPtr reusex::ProjectDB::point_cloud_normal ( std::string_view name) const

◆ point_cloud_type()

std::string reusex::ProjectDB::point_cloud_type ( std::string_view name) const

◆ point_cloud_xyz()

pcl::PointCloud< pcl::PointXYZ >::Ptr reusex::ProjectDB::point_cloud_xyz ( std::string_view name) const

◆ point_cloud_xyzrgb()

CloudPtr reusex::ProjectDB::point_cloud_xyzrgb ( std::string_view name) const

◆ project_summary()

ProjectSummary reusex::ProjectDB::project_summary ( ) const

◆ save_building_component()

void reusex::ProjectDB::save_building_component ( const geometry::BuildingComponent & component)

◆ save_label_definitions()

void reusex::ProjectDB::save_label_definitions ( std::string_view cloudName,
const std::map< int, std::string > & labelMap )

◆ save_mesh() [1/2]

void reusex::ProjectDB::save_mesh ( std::string_view name,
const pcl::PolygonMesh & mesh,
std::string_view stage = "",
std::string_view paramsJson = "" )

References mesh().

◆ save_mesh() [2/2]

void reusex::ProjectDB::save_mesh ( std::string_view name,
const pcl::TextureMesh & mesh,
std::string_view stage = "",
std::string_view paramsJson = "" )

References mesh().

◆ save_panoramic_image()

void reusex::ProjectDB::save_panoramic_image ( const std::string & filename,
const std::vector< uint8_t > & jpeg_data,
double timestamp = -1.0,
int nodeId = -1 )

◆ save_point_cloud() [1/4]

void reusex::ProjectDB::save_point_cloud ( std::string_view name,
const Cloud & cloud,
std::string_view stage = "",
std::string_view paramsJson = "" )

◆ save_point_cloud() [2/4]

void reusex::ProjectDB::save_point_cloud ( std::string_view name,
const CloudL & cloud,
std::string_view stage = "",
std::string_view paramsJson = "" )

◆ save_point_cloud() [3/4]

void reusex::ProjectDB::save_point_cloud ( std::string_view name,
const CloudN & cloud,
std::string_view stage = "",
std::string_view paramsJson = "" )

◆ save_point_cloud() [4/4]

void reusex::ProjectDB::save_point_cloud ( std::string_view name,
const pcl::PointCloud< pcl::PointXYZ > & cloud,
std::string_view stage = "",
std::string_view paramsJson = "" )

◆ save_segmentation_image()

void reusex::ProjectDB::save_segmentation_image ( int nodeId,
const cv::Mat & labels )

◆ save_segmentation_images()

void reusex::ProjectDB::save_segmentation_images ( const std::vector< int > & nodeIds,
const std::vector< cv::Mat > & labels )

◆ save_sensor_frame() [1/2]

void reusex::ProjectDB::save_sensor_frame ( int nodeId,
const cv::Mat & color,
const cv::Mat & depth,
const cv::Mat & confidence,
const std::array< double, 16 > & worldPose,
const core::SensorIntrinsics & intrinsics,
double timestamp = -1.0 )

References save_sensor_frame().

◆ save_sensor_frame() [2/2]

void reusex::ProjectDB::save_sensor_frame ( int nodeId,
const cv::Mat & colorImage )

◆ schema_version()

int reusex::ProjectDB::schema_version ( ) const

References schema_version().

Referenced by schema_version().

◆ segmentation_image()

cv::Mat reusex::ProjectDB::segmentation_image ( int nodeId) const

◆ sensor_frame_confidence()

cv::Mat reusex::ProjectDB::sensor_frame_confidence ( int nodeId) const

◆ sensor_frame_depth()

cv::Mat reusex::ProjectDB::sensor_frame_depth ( int nodeId) const

References sensor_frame_depth().

Referenced by sensor_frame_depth().

◆ sensor_frame_ids()

std::vector< int > reusex::ProjectDB::sensor_frame_ids ( ) const

References sensor_frame_ids().

Referenced by sensor_frame_ids().

◆ sensor_frame_image()

cv::Mat reusex::ProjectDB::sensor_frame_image ( int nodeId) const

References sensor_frame_image().

Referenced by sensor_frame_image().

◆ sensor_frame_intrinsics()

core::SensorIntrinsics reusex::ProjectDB::sensor_frame_intrinsics ( int nodeId) const

◆ sensor_frame_pose()

std::array< double, 16 > reusex::ProjectDB::sensor_frame_pose ( int nodeId) const

References sensor_frame_pose().

Referenced by sensor_frame_pose().

◆ sensor_frame_timestamp()

double reusex::ProjectDB::sensor_frame_timestamp ( int nodeId) const

Get the timestamp (epoch seconds) of a sensor frame. Returns -1.0 if not set.

References sensor_frame_timestamp().

Referenced by sensor_frame_timestamp().

◆ set_passport_metadata_field()

void reusex::ProjectDB::set_passport_metadata_field ( std::string_view documentGuid,
std::string_view column,
std::string_view value )

Set a metadata column on a material passport.

Supported columns: created_at, revised_at, version_number, version_date. document_guid cannot be changed (it is the primary key).

Parameters
documentGuidDocument GUID (must exist)
columnMetadata column name
valueNew value
Exceptions
std::runtime_errorif passport not found or column not allowed

◆ set_passport_property()

void reusex::ProjectDB::set_passport_property ( std::string_view documentGuid,
std::string_view fieldName,
std::string_view value )

Set a single property value by field name (upsert).

Looks up the property_definitions entry by name_en, then upserts into passport_property_values. Creates property_definitions entry if needed.

Parameters
documentGuidDocument GUID (must exist)
fieldNameProperty field name (name_en)
valueString value to store
Exceptions
std::runtime_errorif passport does not exist

◆ texture_mesh()

pcl::TextureMesh::Ptr reusex::ProjectDB::texture_mesh ( std::string_view name) const

◆ update_project_metadata()

void reusex::ProjectDB::update_project_metadata ( const ProjectMetadata & metadata)

Update project metadata.

Parameters
metadataProject metadata to update Creates project if it doesn't exist

◆ validate_schema()

void reusex::ProjectDB::validate_schema ( ) const

References validate_schema().

Referenced by validate_schema().


The documentation for this class was generated from the following file: