KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PNS::INDEX Class Reference

INDEX. More...

#include <pns_index.h>

Public Types

typedef std::list< ITEM * > NET_ITEMS_LIST
 
typedef SHAPE_INDEX< ITEM * > ITEM_SHAPE_INDEX
 
typedef std::unordered_set< ITEM * > ITEM_SET
 

Public Member Functions

 INDEX ()
 
void Add (ITEM *aItem)
 Adds item to the spatial index.
 
void Remove (ITEM *aItem)
 Removes an item from the spatial index.
 
void Replace (ITEM *aOldItem, ITEM *aNewItem)
 Replaces one item with another.
 
template<class Visitor >
int Query (const ITEM *aItem, int aMinDistance, Visitor &aVisitor) const
 Searches items in the index that are in proximity of aItem.
 
template<class Visitor >
int Query (const SHAPE *aShape, int aMinDistance, Visitor &aVisitor) const
 Searches items in the index that are in proximity of aShape.
 
NET_ITEMS_LISTGetItemsForNet (NET_HANDLE aNet)
 Returns list of all items in a given net.
 
bool Contains (ITEM *aItem) const
 Function Contains()
 
int Size () const
 Returns number of items stored in the index.
 
ITEM_SET::iterator begin ()
 
ITEM_SET::iterator end ()
 

Private Member Functions

template<class Visitor >
int querySingle (std::size_t aIndex, const SHAPE *aShape, int aMinDistance, Visitor &aVisitor) const
 

Private Attributes

std::deque< ITEM_SHAPE_INDEXm_subIndices
 
std::map< NET_HANDLE, NET_ITEMS_LISTm_netMap
 
ITEM_SET m_allItems
 

Detailed Description

INDEX.

Custom spatial index, holding our board items and allowing for very fast searches. Items are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing overlap and improving search time.

Definition at line 45 of file pns_index.h.

Member Typedef Documentation

◆ ITEM_SET

typedef std::unordered_set<ITEM*> PNS::INDEX::ITEM_SET

Definition at line 50 of file pns_index.h.

◆ ITEM_SHAPE_INDEX

Definition at line 49 of file pns_index.h.

◆ NET_ITEMS_LIST

typedef std::list<ITEM*> PNS::INDEX::NET_ITEMS_LIST

Definition at line 48 of file pns_index.h.

Constructor & Destructor Documentation

◆ INDEX()

PNS::INDEX::INDEX ( )
inline

Definition at line 52 of file pns_index.h.

Member Function Documentation

◆ Add()

◆ begin()

ITEM_SET::iterator PNS::INDEX::begin ( )
inline

Definition at line 117 of file pns_index.h.

References m_allItems.

◆ Contains()

bool PNS::INDEX::Contains ( ITEM aItem) const
inline

Function Contains()

Returns true if item aItem exists in the index.

Definition at line 107 of file pns_index.h.

References m_allItems.

◆ end()

ITEM_SET::iterator PNS::INDEX::end ( )
inline

Definition at line 118 of file pns_index.h.

References m_allItems.

◆ GetItemsForNet()

INDEX::NET_ITEMS_LIST * PNS::INDEX::GetItemsForNet ( NET_HANDLE  aNet)

Returns list of all items in a given net.

Definition at line 73 of file pns_index.cpp.

References m_netMap.

Referenced by PNS::NODE::AllItemsInNet(), and PNS::NODE::FindItemByParent().

◆ Query() [1/2]

template<class Visitor >
int PNS::INDEX::Query ( const ITEM aItem,
int  aMinDistance,
Visitor &  aVisitor 
) const

Searches items in the index that are in proximity of aItem.

For each item, function object aVisitor is called. Only items on overlapping layers are considered.

Parameters
aItemitem to search against
aMinDistanceproximity distance (wrs to the item's shape)
aVisitorfunction object called on each found item. Return false from the visitor to stop searching.
Returns
number of items found.

Definition at line 141 of file pns_index.h.

References LAYER_RANGE::End(), PNS::ITEM::Layers(), querySingle(), PNS::ITEM::Shape(), and LAYER_RANGE::Start().

Referenced by PNS::NODE::HitTest(), and PNS::NODE::QueryColliding().

◆ Query() [2/2]

template<class Visitor >
int PNS::INDEX::Query ( const SHAPE aShape,
int  aMinDistance,
Visitor &  aVisitor 
) const

Searches items in the index that are in proximity of aShape.

For each item, function object aVisitor is called. Treats all layers as colliding.

Parameters
aShapeshape to search against
aMinDistanceproximity distance (wrs to the item's shape)
aVisitorfunction object called on each found item. Return false from the visitor to stop searching.
Returns
number of items found.

Definition at line 154 of file pns_index.h.

References m_subIndices, and querySingle().

◆ querySingle()

template<class Visitor >
int PNS::INDEX::querySingle ( std::size_t  aIndex,
const SHAPE aShape,
int  aMinDistance,
Visitor &  aVisitor 
) const
private

Definition at line 132 of file pns_index.h.

References m_subIndices.

Referenced by Query().

◆ Remove()

void PNS::INDEX::Remove ( ITEM aItem)

Removes an item from the spatial index.

Definition at line 47 of file pns_index.cpp.

References LAYER_RANGE::End(), PNS::ITEM::Layers(), m_allItems, m_netMap, m_subIndices, PNS::ITEM::Net(), and LAYER_RANGE::Start().

Referenced by PNS::NODE::doRemove(), and Replace().

◆ Replace()

void PNS::INDEX::Replace ( ITEM aOldItem,
ITEM aNewItem 
)

Replaces one item with another.

Definition at line 66 of file pns_index.cpp.

References Add(), and Remove().

◆ Size()

int PNS::INDEX::Size ( ) const
inline

Returns number of items stored in the index.

Definition at line 115 of file pns_index.h.

References m_allItems.

Referenced by PNS::NODE::Branch(), PNS::NODE::GetUpdatedItems(), and PNS::NODE::~NODE().

Member Data Documentation

◆ m_allItems

ITEM_SET PNS::INDEX::m_allItems
private

Definition at line 127 of file pns_index.h.

Referenced by Add(), begin(), Contains(), end(), Remove(), and Size().

◆ m_netMap

std::map<NET_HANDLE, NET_ITEMS_LIST> PNS::INDEX::m_netMap
private

Definition at line 126 of file pns_index.h.

Referenced by Add(), GetItemsForNet(), and Remove().

◆ m_subIndices

std::deque<ITEM_SHAPE_INDEX> PNS::INDEX::m_subIndices
private

Definition at line 125 of file pns_index.h.

Referenced by Add(), Query(), querySingle(), and Remove().


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