KiCad PCB EDA Suite
|
Implement an R-tree for fast spatial and layer indexing of connectable items. More...
#include <drc_rtree.h>
Classes | |
struct | DRC_LAYER |
The DRC_LAYER struct provides a layer-specific auto-range iterator to the RTree. More... | |
struct | ITEM_WITH_SHAPE |
struct | PAIR_INFO |
Public Types | |
typedef std::pair< PCB_LAYER_ID, PCB_LAYER_ID > | LAYER_PAIR |
using | iterator = typename drc_rtree::Iterator |
Public Member Functions | |
DRC_RTREE () | |
~DRC_RTREE () | |
void | Insert (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0) |
Insert an item into the tree on a particular layer with an optional worst clearance. | |
void | Insert (BOARD_ITEM *aItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, int aWorstClearance) |
Insert an item into the tree on a particular layer with a worst clearance. | |
void | clear () |
Remove all items from the RTree. | |
bool | CheckColliding (SHAPE *aRefShape, PCB_LAYER_ID aTargetLayer, int aClearance=0, std::function< bool(BOARD_ITEM *)> aFilter=nullptr) const |
int | QueryColliding (BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const |
This is a fast test which essentially does bounding-box overlap given a worst-case clearance. | |
bool | QueryColliding (const BOX2I &aBox, SHAPE *aRefShape, PCB_LAYER_ID aLayer, int aClearance, int *aActual, VECTOR2I *aPos) const |
This one is for tessellated items. | |
bool | QueryColliding (const BOX2I &aBox, SHAPE *aRefShape, PCB_LAYER_ID aLayer) const |
Quicker version of above that just reports a raw yes/no. | |
std::unordered_set< BOARD_ITEM * > | GetObjectsAt (const VECTOR2I &aPt, PCB_LAYER_ID aLayer, int aClearance=0) |
Gets the BOARD_ITEMs that overlap the specified point/layer. | |
int | QueryCollidingPairs (DRC_RTREE *aRefTree, std::vector< LAYER_PAIR > aLayerPairs, std::function< bool(const LAYER_PAIR &, ITEM_WITH_SHAPE *, ITEM_WITH_SHAPE *, bool *aCollision)> aVisitor, int aMaxClearance, std::function< bool(int, int)> aProgressReporter) const |
size_t | size () const |
Return the number of items in the tree. | |
bool | empty () const |
DRC_LAYER | OnLayer (PCB_LAYER_ID aLayer) const |
DRC_LAYER | Overlapping (PCB_LAYER_ID aLayer, const VECTOR2I &aPoint, int aAccuracy=0) const |
DRC_LAYER | Overlapping (PCB_LAYER_ID aLayer, const BOX2I &aRect) const |
Private Types | |
using | drc_rtree = RTree< ITEM_WITH_SHAPE *, int, 2, double > |
Private Attributes | |
std::map< int, drc_rtree * > | m_tree |
size_t | m_count |
Implement an R-tree for fast spatial and layer indexing of connectable items.
Non-owning.
Definition at line 47 of file drc_rtree.h.
|
private |
Definition at line 78 of file drc_rtree.h.
using DRC_RTREE::iterator = typename drc_rtree::Iterator |
Definition at line 548 of file drc_rtree.h.
typedef std::pair<PCB_LAYER_ID, PCB_LAYER_ID> DRC_RTREE::LAYER_PAIR |
Definition at line 443 of file drc_rtree.h.
|
inline |
Definition at line 82 of file drc_rtree.h.
References LSET::AllLayersMask(), m_count, and m_tree.
|
inline |
Definition at line 90 of file drc_rtree.h.
|
inline |
Definition at line 178 of file drc_rtree.h.
References SHAPE::BBox(), SHAPE::Collide(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOX2< Vec >::Inflate(), and m_tree.
Referenced by extractDiffPairCoupledItems().
|
inline |
Remove all items from the RTree.
Definition at line 170 of file drc_rtree.h.
References _, m_count, and m_tree.
Referenced by DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), and DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run().
|
inline |
Definition at line 543 of file drc_rtree.h.
References m_count.
|
inline |
Gets the BOARD_ITEMs that overlap the specified point/layer.
aPt | Position on the tree |
aLayer | Layer to search |
Definition at line 424 of file drc_rtree.h.
References m_tree, VECTOR2< T >::x, and VECTOR2< T >::y.
|
inline |
Insert an item into the tree on a particular layer with an optional worst clearance.
Definition at line 104 of file drc_rtree.h.
References Insert().
Referenced by TEARDROP_MANAGER::buildTrackCaches(), TRACKS_CLEANER::cleanup(), Insert(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), and DRC_TEST_PROVIDER_SILK_CLEARANCE::Run().
|
inline |
Insert an item into the tree on a particular layer with a worst clearance.
Allows the source layer to be different from the tree layer.
Definition at line 113 of file drc_rtree.h.
References BOX2< Vec >::GetBottom(), BOARD_ITEM::GetEffectiveHoleShape(), BOARD_ITEM::GetEffectiveShape(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOARD_ITEM::HasHole(), BOX2< Vec >::Inflate(), EDA_TEXT::IsVisible(), m_count, m_tree, PCB_FIELD_T, PCB_PAD_T, PCB_TEXT_T, EDA_ITEM::Type(), and UNDEFINED_LAYER.
|
inline |
|
inline |
Definition at line 599 of file drc_rtree.h.
References m_tree.
|
inline |
Definition at line 591 of file drc_rtree.h.
References BOX2< Vec >::Inflate(), and m_tree.
|
inline |
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
It's used when looking up the specific item-to-item clearance might be expensive and should be deferred till we know we have a possible hit.
Definition at line 217 of file drc_rtree.h.
References BOX2< Vec >::GetBottom(), EDA_ITEM::GetBoundingBox(), BOARD_ITEM::GetEffectiveShape(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOX2< Vec >::Inflate(), and m_tree.
Referenced by TRACKS_CLEANER::cleanup(), collidesWithArea(), TEARDROP_MANAGER::findTouchingTrack(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testKnockoutTextAgainstZone(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), and CONNECTIVITY_DATA::TestTrackEndpointDangling().
|
inline |
Quicker version of above that just reports a raw yes/no.
Definition at line 349 of file drc_rtree.h.
References SHAPE::Collide(), SHAPE_LINE_CHAIN::Collide(), SHAPE_LINE_CHAIN::CPoint(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), SHAPE_POLY_SET::HoleCount(), m_tree, SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SH_POLY_SET_TRIANGLE, and SHAPE_BASE::Type().
|
inline |
This one is for tessellated items.
(All shapes in the tree will be from a single BOARD_ITEM.) It checks all items in the bbox overlap to find the minimal actual distance and position.
Definition at line 292 of file drc_rtree.h.
References SHAPE::Collide(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOX2< Vec >::Inflate(), and m_tree.
|
inline |
Definition at line 458 of file drc_rtree.h.
References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), BOX2< Vec >::Inflate(), m_tree, and OnLayer().
Referenced by DRC_TEST_PROVIDER_SILK_CLEARANCE::Run().
|
inline |
Return the number of items in the tree.
Definition at line 538 of file drc_rtree.h.
References m_count.
Referenced by DRC_TEST_PROVIDER_SILK_CLEARANCE::Run().
|
private |
Definition at line 608 of file drc_rtree.h.
Referenced by clear(), DRC_RTREE(), empty(), Insert(), and size().
|
private |
Definition at line 607 of file drc_rtree.h.
Referenced by CheckColliding(), clear(), DRC_RTREE(), GetObjectsAt(), Insert(), OnLayer(), Overlapping(), QueryColliding(), QueryCollidingPairs(), and ~DRC_RTREE().