|
KiCad PCB EDA Suite
|
#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 | SetDeferred (bool aDeferred) |
| When deferred, Add() registers items in metadata but skips spatial index insertion. | |
| void | BuildSpatialIndex () |
| Bulk load the spatial sub-indices from all registered items. | |
| std::unique_ptr< INDEX > | Clone () const |
| Create a copy-on-write clone of this 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_LIST * | GetItemsForNet (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< std::unique_ptr< ITEM_SHAPE_INDEX > > | m_subIndices |
| std::map< NET_HANDLE, NET_ITEMS_LIST > | m_netMap |
| ITEM_SET | m_allItems |
| bool | m_deferred |
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 46 of file pns_index.h.
| typedef std::unordered_set<ITEM*> PNS::INDEX::ITEM_SET |
Definition at line 51 of file pns_index.h.
| typedef SHAPE_INDEX<ITEM*> PNS::INDEX::ITEM_SHAPE_INDEX |
Definition at line 50 of file pns_index.h.
| typedef std::list<ITEM*> PNS::INDEX::NET_ITEMS_LIST |
Definition at line 49 of file pns_index.h.
|
inline |
Definition at line 53 of file pns_index.h.
References m_deferred.
| void PNS::INDEX::Add | ( | ITEM * | aItem | ) |
Adds item to the spatial index.
Definition at line 28 of file pns_index.cpp.
References PNS::ITEM::Layers(), m_allItems, m_deferred, m_netMap, m_subIndices, and PNS::ITEM::Net().
Referenced by Replace().
|
inline |
Definition at line 146 of file pns_index.h.
References m_allItems.
| void PNS::INDEX::BuildSpatialIndex | ( | ) |
Bulk load the spatial sub-indices from all registered items.
Call after SetDeferred(false) to populate the R-trees.
Definition at line 61 of file pns_index.cpp.
References boundingBox(), m_allItems, and m_subIndices.
|
inline |
Create a copy-on-write clone of this index.
The spatial tree structure is shared (O(1)) while metadata (net map, item set) is copied.
Definition at line 71 of file pns_index.h.
References m_allItems, m_netMap, and m_subIndices.
|
inline |
Function Contains()
Returns true if item aItem exists in the index.
Definition at line 136 of file pns_index.h.
References m_allItems.
|
inline |
Definition at line 147 of file pns_index.h.
References m_allItems.
| INDEX::NET_ITEMS_LIST * PNS::INDEX::GetItemsForNet | ( | NET_HANDLE | aNet | ) |
Returns list of all items in a given net.
Definition at line 112 of file pns_index.cpp.
References m_netMap.
| 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.
| aItem | item to search against |
| aMinDistance | proximity distance (wrs to the item's shape) |
| aVisitor | function object called on each found item. Return false from the visitor to stop searching. |
Definition at line 172 of file pns_index.h.
References PNS_LAYER_RANGE::End(), PNS::ITEM::INVALID_T, PNS::ITEM::Kind(), PNS::ITEM::Layers(), querySingle(), PNS::ITEM::Shape(), and PNS_LAYER_RANGE::Start().
| 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.
| aShape | shape to search against |
| aMinDistance | proximity distance (wrs to the item's shape) |
| aVisitor | function object called on each found item. Return false from the visitor to stop searching. |
Definition at line 187 of file pns_index.h.
References m_subIndices, and querySingle().
|
private |
Definition at line 162 of file pns_index.h.
References m_subIndices.
| void PNS::INDEX::Remove | ( | ITEM * | aItem | ) |
Removes an item from the spatial index.
Definition at line 86 of file pns_index.cpp.
References PNS::ITEM::Layers(), m_allItems, m_netMap, m_subIndices, and PNS::ITEM::Net().
Referenced by Replace().
Replaces one item with another.
Definition at line 105 of file pns_index.cpp.
| void PNS::INDEX::SetDeferred | ( | bool | aDeferred | ) |
When deferred, Add() registers items in metadata but skips spatial index insertion.
Call BuildSpatialIndex() to bulk load all items at once.
Definition at line 55 of file pns_index.cpp.
References m_deferred.
|
inline |
Returns number of items stored in the index.
Definition at line 144 of file pns_index.h.
References m_allItems.
Referenced by PNS::NODE::Branch().
|
private |
Definition at line 156 of file pns_index.h.
Referenced by Add(), begin(), BuildSpatialIndex(), Clone(), Contains(), end(), Remove(), and Size().
|
private |
Definition at line 157 of file pns_index.h.
Referenced by Add(), INDEX(), and SetDeferred().
|
private |
Definition at line 155 of file pns_index.h.
Referenced by Add(), Clone(), GetItemsForNet(), and Remove().
|
private |
Definition at line 154 of file pns_index.h.
Referenced by Add(), BuildSpatialIndex(), Clone(), Query(), querySingle(), and Remove().