#include namespace pdfengine { void MultiIndexSpatialIndex::buildFromTree(const PhysicalLayoutTree& tree) { clear(); for (const auto& block : tree.allBlocks) { if (!block) continue; m_indexedBlocks.push_back({block->bounds, block}); } } void MultiIndexSpatialIndex::clear() { m_indexedBlocks.clear(); m_indexedLines.clear(); } std::vector> MultiIndexSpatialIndex::queryBlocksAtPoint(float x, float y) const { std::vector> results; for (const auto& entry : m_indexedBlocks) { if (entry.bounds.contains(x, y)) { results.push_back(entry.block); } } return results; } std::vector> MultiIndexSpatialIndex::queryBlocksInRect(const geometry::Rect& rect) const { std::vector> results; for (const auto& entry : m_indexedBlocks) { if (entry.bounds.intersects(rect)) { results.push_back(entry.block); } } return results; } std::vector> MultiIndexSpatialIndex::queryBlocksByType(LayoutBlockType type) const { std::vector> results; for (const auto& entry : m_indexedBlocks) { if (entry.block && entry.block->type == type) { results.push_back(entry.block); } } return results; } } // namespace pdfengine