51 const int mmin[2] = { std::min( bbox.
GetX(), bbox.
GetRight() ),
53 const int mmax[2] = { std::max( bbox.
GetX(), bbox.
GetRight() ),
56 m_tree.Insert( mmin, mmax, aItem );
68 const int mmin[2] = { std::min( aBbox->
GetX(), aBbox->
GetRight() ),
70 const int mmax[2] = { std::max( aBbox->
GetX(), aBbox->
GetRight() ),
72 m_tree.Remove( mmin, mmax, aItem );
78 const int mmin[2] = { INT_MIN, INT_MIN };
79 const int mmax[2] = { INT_MAX, INT_MAX };
80 m_tree.Remove( mmin, mmax, aItem );
87 template <
class Visitor>
88 void Query(
const BOX2I& aBounds, Visitor& aVisitor )
const
90 int mmin[2] = { std::min( aBounds.
GetX(), aBounds.
GetRight() ),
92 int mmax[2] = { std::max( aBounds.
GetX(), aBounds.
GetRight() ),
102 if( aBounds == max_box )
104 mmin[0] = mmin[1] = INT_MIN;
105 mmax[0] = mmax[1] = INT_MAX;
108 m_tree.Search( mmin, mmax, aVisitor );
124 void BulkLoad( std::vector<std::pair<VIEW_ITEM*, BOX2I>>& aItems )
127 std::vector<BULK_ENTRY> entries;
128 entries.reserve( aItems.size() );
130 for(
const auto& [item, bbox] : aItems )
133 e.min[0] = std::min( bbox.GetX(), bbox.GetRight() );
134 e.min[1] = std::min( bbox.GetY(), bbox.GetBottom() );
135 e.max[0] = std::max( bbox.GetX(), bbox.GetRight() );
136 e.max[1] = std::max( bbox.GetY(), bbox.GetBottom() );
138 entries.push_back( e );
141 m_tree.BulkLoad( entries );
constexpr void SetMaximum()
constexpr coord_type GetY() const
constexpr coord_type GetX() const
constexpr coord_type GetRight() const
constexpr coord_type GetBottom() const
An abstract base class for deriving all objects that can be added to a VIEW.
Implement a non-owning R-tree for fast spatial indexing of VIEW items.
KIRTREE::DYNAMIC_RTREE< VIEW_ITEM *, int, 2 > m_tree
void BulkLoad(std::vector< std::pair< VIEW_ITEM *, BOX2I > > &aItems)
Build the R-tree from a batch of items using packed bulk loading.
void Insert(VIEW_ITEM *aItem, const BOX2I &bbox)
Insert an item into the tree.
void RemoveAll()
Remove all items from the tree.
void Query(const BOX2I &aBounds, Visitor &aVisitor) const
Execute a function object aVisitor for each item whose bounding box intersects with aBounds.
void Remove(VIEW_ITEM *aItem, const BOX2I *aBbox)
Remove an item from the tree.
Dynamic R*-tree with SoA node layout and stored insertion bounding boxes.
The Cairo implementation of the graphics abstraction layer.
Entry type for bulk loading.