55 const int mmin[2] = { std::min( bbox.
GetX(), bbox.
GetRight() ),
57 const int mmax[2] = { std::max( bbox.
GetX(), bbox.
GetRight() ),
60 m_tree.Insert( mmin, mmax, aItem );
72 const int mmin[2] = { std::min( aBbox->
GetX(), aBbox->
GetRight() ),
74 const int mmax[2] = { std::max( aBbox->
GetX(), aBbox->
GetRight() ),
76 m_tree.Remove( mmin, mmax, aItem );
82 const int mmin[2] = { INT_MIN, INT_MIN };
83 const int mmax[2] = { INT_MAX, INT_MAX };
84 m_tree.Remove( mmin, mmax, aItem );
91 template <
class Visitor>
92 void Query(
const BOX2I& aBounds, Visitor& aVisitor )
const
94 int mmin[2] = { std::min( aBounds.
GetX(), aBounds.
GetRight() ),
96 int mmax[2] = { std::max( aBounds.
GetX(), aBounds.
GetRight() ),
106 if( aBounds == max_box )
108 mmin[0] = mmin[1] = INT_MIN;
109 mmax[0] = mmax[1] = INT_MAX;
112 m_tree.Search( mmin, mmax, aVisitor );
128 void BulkLoad( std::vector<std::pair<VIEW_ITEM*, BOX2I>>& aItems )
131 std::vector<BULK_ENTRY> entries;
132 entries.reserve( aItems.size() );
134 for(
const auto& [item, bbox] : aItems )
137 e.min[0] = std::min( bbox.GetX(), bbox.GetRight() );
138 e.min[1] = std::min( bbox.GetY(), bbox.GetBottom() );
139 e.max[0] = std::max( bbox.GetX(), bbox.GetRight() );
140 e.max[1] = std::max( bbox.GetY(), bbox.GetBottom() );
142 entries.push_back( e );
145 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.