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