#pragma once #include #include #include #include #include namespace pdfengine { class MultiIndexSpatialIndex { public: MultiIndexSpatialIndex() = default; void buildFromTree(const PhysicalLayoutTree& tree); void clear(); [[nodiscard]] std::vector> queryBlocksAtPoint(float x, float y) const; [[nodiscard]] std::vector> queryBlocksInRect(const geometry::Rect& rect) const; [[nodiscard]] std::vector> queryBlocksByType(LayoutBlockType type) const; [[nodiscard]] size_t totalIndexedBlocks() const noexcept { return m_indexedBlocks.size(); } private: struct SpatialEntry { geometry::Rect bounds; std::shared_ptr block; }; std::vector m_indexedBlocks; std::vector m_indexedLines; }; } // namespace pdfengine