KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::VIEW_RTREE Class Reference

Implement a non-owning R-tree for fast spatial indexing of VIEW items. More...

#include <view_rtree.h>

Public Member Functions

void Insert (VIEW_ITEM *aItem, const BOX2I &bbox)
 Insert an item into the tree.
 
void Remove (VIEW_ITEM *aItem, const BOX2I *aBbox)
 Remove an item from the tree.
 
template<class Visitor>
void Query (const BOX2I &aBounds, Visitor &aVisitor) const
 Execute a function object aVisitor for each item whose bounding box intersects with aBounds.
 
void RemoveAll ()
 Remove all items from the tree.
 
void BulkLoad (std::vector< std::pair< VIEW_ITEM *, BOX2I > > &aItems)
 Build the R-tree from a batch of items using packed bulk loading.
 

Private Attributes

KIRTREE::DYNAMIC_RTREE< VIEW_ITEM *, int, 2 > m_tree
 

Detailed Description

Implement a non-owning R-tree for fast spatial indexing of VIEW items.

Uses DYNAMIC_RTREE with stored insertion bboxes, eliminating the O(N) fallback removal that the old RTree required when bbox was unavailable.

Definition at line 45 of file view_rtree.h.

Member Function Documentation

◆ BulkLoad()

void KIGFX::VIEW_RTREE::BulkLoad ( std::vector< std::pair< VIEW_ITEM *, BOX2I > > & aItems)
inline

Build the R-tree from a batch of items using packed bulk loading.

Dramatically faster than individual Insert calls when rebuilding from scratch.

Definition at line 128 of file view_rtree.h.

References m_tree.

◆ Insert()

void KIGFX::VIEW_RTREE::Insert ( VIEW_ITEM * aItem,
const BOX2I & bbox )
inline

Insert an item into the tree.

Item's bounding box is taken via its ViewBBox() method.

Definition at line 53 of file view_rtree.h.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), and m_tree.

◆ Query()

template<class Visitor>
void KIGFX::VIEW_RTREE::Query ( const BOX2I & aBounds,
Visitor & aVisitor ) const
inline

Execute a function object aVisitor for each item whose bounding box intersects with aBounds.

Definition at line 92 of file view_rtree.h.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), m_tree, and BOX2< Vec >::SetMaximum().

◆ Remove()

void KIGFX::VIEW_RTREE::Remove ( VIEW_ITEM * aItem,
const BOX2I * aBbox )
inline

Remove an item from the tree.

Removal is done by comparing pointers, attempting to remove a copy of the item will fail.

Definition at line 68 of file view_rtree.h.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), and m_tree.

◆ RemoveAll()

void KIGFX::VIEW_RTREE::RemoveAll ( )
inline

Remove all items from the tree.

Definition at line 118 of file view_rtree.h.

References m_tree.

Member Data Documentation

◆ m_tree

KIRTREE::DYNAMIC_RTREE<VIEW_ITEM*, int, 2> KIGFX::VIEW_RTREE::m_tree
private

Definition at line 149 of file view_rtree.h.

Referenced by BulkLoad(), Insert(), Query(), Remove(), and RemoveAll().


The documentation for this class was generated from the following file: