From d7a95fd37c75b9cfccd2ccf11102c8c80e6f1c95 Mon Sep 17 00:00:00 2001 From: Ralph Wessel Date: Tue, 5 Nov 2024 11:25:33 +0000 Subject: [PATCH] Added BIMElementDatabase::findObjects --- .../Speckle/Database/BIMElementDatabase.cpp | 15 +++++++++++++++ SpeckleLib/Speckle/Database/BIMElementDatabase.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/SpeckleLib/Speckle/Database/BIMElementDatabase.cpp b/SpeckleLib/Speckle/Database/BIMElementDatabase.cpp index dd461f1..0d44627 100644 --- a/SpeckleLib/Speckle/Database/BIMElementDatabase.cpp +++ b/SpeckleLib/Speckle/Database/BIMElementDatabase.cpp @@ -101,6 +101,21 @@ void BIMElementDatabase::clearSelection() const { } //BIMElementDatabase::clearSelection +/*-------------------------------------------------------------------- + Find a filtered list of objects + + filter: The object filter (nullptr = find all objects) + tableID: Optional table ID (defaults to the first table) + documentID: Optional document ID (filter for this document only - nullopt = all objects) + + return: A list containing IDs of found elements (empty if none found) + --------------------------------------------------------------------*/ +std::vector BIMElementDatabase::findElements(const Filter& filter, std::optional tableID, + std::optional documentID) const { + return m_engine->findObjects(filter, tableID, documentID); +} //BIMElementDatabase::findElements + + /*-------------------------------------------------------------------- Get a specified element diff --git a/SpeckleLib/Speckle/Database/BIMElementDatabase.h b/SpeckleLib/Speckle/Database/BIMElementDatabase.h index 16e31d7..c9a9ad2 100644 --- a/SpeckleLib/Speckle/Database/BIMElementDatabase.h +++ b/SpeckleLib/Speckle/Database/BIMElementDatabase.h @@ -21,6 +21,11 @@ namespace speckle::database { */ class BIMElementDatabase { public: + + // MARK: - Types + + ///Element filter (NB: expand in future to support optimised filtering) + using Filter = std::function; // MARK: - Constructors @@ -49,6 +54,15 @@ namespace speckle::database { Clear the element selection */ void clearSelection() const; + /*! + Find a filtered list of objects + @param filter The object filter (nullptr = find all objects) + @param tableID Optional table ID (defaults to the first table) + @param documentID Optional document ID (filter for this document only - nullopt = all objects) + @return A list containing IDs of found elements (empty if none found) + */ + std::vector findElements(const Filter& filter = nullptr, std::optional tableID = std::nullopt, + std::optional documentID = std::nullopt) const; /*! Get a specified element @param elementID The ID of the target element