KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_rtree.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 * Copyright (C) 2020 CERN
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef DRC_RTREE_H_
22#define DRC_RTREE_H_
23
24#include <board_item.h>
25#include <pcb_field.h>
26#include <memory>
27#include <unordered_set>
28#include <set>
29#include <vector>
30
32#include <geometry/shape.h>
34#include <math/vector2d.h>
35#include "geometry/shape_null.h"
36#include "board.h"
37
38#define ATOMIC_TABLES true
39
45{
46public:
48 {
49 ITEM_WITH_SHAPE( BOARD_ITEM *aParent, const SHAPE* aShape,
50 std::shared_ptr<SHAPE> aParentShape = nullptr ) :
51 parent( aParent ),
52 shape( aShape ),
53 shapeStorage( nullptr ),
54 parentShape( std::move( aParentShape ) )
55 {};
56
57 ITEM_WITH_SHAPE( BOARD_ITEM *aParent, const std::shared_ptr<SHAPE>& aShape,
58 std::shared_ptr<SHAPE> aParentShape = nullptr ) :
59 parent( aParent ),
60 shape( aShape.get() ),
61 shapeStorage( aShape ),
62 parentShape( std::move( aParentShape ) )
63 {};
64
66 const SHAPE* shape;
67 std::shared_ptr<SHAPE> shapeStorage;
68 std::shared_ptr<SHAPE> parentShape;
69 };
70
71private:
73 using drc_rtree_builder = typename drc_rtree::Builder;
74
75public:
77 {
78 m_count = 0;
79 }
80
82 {
83 for( ITEM_WITH_SHAPE* p : m_owned )
84 delete p;
85 }
86
91 void Insert( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int aWorstClearance = 0, bool aAtomicTables = false )
92 {
93 Insert( aItem, aLayer, aLayer, aWorstClearance, aAtomicTables );
94 }
95
100 void Insert( BOARD_ITEM* aItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer,
101 int aWorstClearance, bool aAtomicTables = false )
102 {
103 wxCHECK( aTargetLayer != UNDEFINED_LAYER, /* void */ );
104 wxCHECK_MSG( !m_tree.count( aTargetLayer ), /* void */,
105 wxT( "Insert after Build() is silently wrong" ) );
106
107 if( aItem->Type() == PCB_FIELD_T && !static_cast<PCB_FIELD*>( aItem )->IsVisible() )
108 return;
109
110 BOARD_ITEM* parent = aItem;
111
112 if( aAtomicTables && aItem->Type() == PCB_TABLECELL_T )
113 parent = aItem->GetParent();
114
115 std::vector<const SHAPE*> subshapes;
116 std::shared_ptr<SHAPE> shape = aItem->GetEffectiveShape( aRefLayer );
117
118 wxCHECK2_MSG( shape, return, wxT( "Item does not have a valid shape for this layer" ) );
119
120 if( shape->HasIndexableSubshapes() )
121 shape->GetIndexableSubshapes( subshapes );
122 else
123 subshapes.push_back( shape.get() );
124
125 for( const SHAPE* subshape : subshapes )
126 {
127 if( dynamic_cast<const SHAPE_NULL*>( subshape ) )
128 continue;
129
130 BOX2I bbox = subshape->BBox();
131
132 bbox.Inflate( aWorstClearance );
133
134 const int mmin[2] = { bbox.GetX(), bbox.GetY() };
135 const int mmax[2] = { bbox.GetRight(), bbox.GetBottom() };
136 ITEM_WITH_SHAPE* itemShape = new ITEM_WITH_SHAPE( parent, subshape, shape );
137
138 m_owned.push_back( itemShape );
139 m_builders[aTargetLayer].Add( mmin, mmax, itemShape );
140 m_count++;
141 }
142
143 if( aItem->Type() == PCB_PAD_T && aItem->HasHole() )
144 {
145 std::shared_ptr<SHAPE_SEGMENT> hole = aItem->GetEffectiveHoleShape();
146 BOX2I bbox = hole->BBox();
147
148 bbox.Inflate( aWorstClearance );
149
150 const int mmin[2] = { bbox.GetX(), bbox.GetY() };
151 const int mmax[2] = { bbox.GetRight(), bbox.GetBottom() };
152 ITEM_WITH_SHAPE* itemShape = new ITEM_WITH_SHAPE( parent, hole, shape );
153
154 m_owned.push_back( itemShape );
155 m_builders[aTargetLayer].Add( mmin, mmax, itemShape );
156 m_count++;
157 }
158 }
159
164 void Build()
165 {
166 for( auto& [layer, builder] : m_builders )
167 m_tree[layer] = builder.Build();
168
169 m_builders.clear();
170 }
171
175 void clear()
176 {
177 for( ITEM_WITH_SHAPE* p : m_owned )
178 delete p;
179
180 m_owned.clear();
181 m_tree.clear();
182 m_builders.clear();
183 m_count = 0;
184 }
185
186 bool CheckColliding( SHAPE* aRefShape, PCB_LAYER_ID aTargetLayer, int aClearance = 0,
187 std::function<bool( BOARD_ITEM*)> aFilter = nullptr ) const
188 {
189 BOX2I box = aRefShape->BBox();
190 box.Inflate( aClearance );
191
192 int min[2] = { box.GetX(), box.GetY() };
193 int max[2] = { box.GetRight(), box.GetBottom() };
194
195 int count = 0;
196
197 auto visit =
198 [&] ( ITEM_WITH_SHAPE* aItem ) -> bool
199 {
200 if( !aFilter || aFilter( aItem->parent ) )
201 {
202 int actual;
203
204 if( aRefShape->Collide( aItem->shape, aClearance, &actual ) )
205 {
206 count++;
207 return false;
208 }
209 }
210
211 return true;
212 };
213
214 if( auto it = m_tree.find( aTargetLayer ); it != m_tree.end() )
215 it->second.Search( min, max, visit );
216
217 return count > 0;
218 }
219
225 int QueryColliding( BOARD_ITEM* aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer,
226 std::function<bool( BOARD_ITEM* )> aFilter = nullptr,
227 std::function<bool( BOARD_ITEM* )> aVisitor = nullptr,
228 int aClearance = 0 ) const
229 {
230 // keep track of BOARD_ITEMs that have already been found to collide (some items might
231 // be built of COMPOUND/triangulated shapes and a single subshape collision means we have
232 // a hit)
233 std::unordered_set<BOARD_ITEM*> collidingCompounds;
234
235 // keep track of results of client filter so we don't ask more than once for compound
236 // shapes
237 std::unordered_map<BOARD_ITEM*, bool> filterResults;
238
239 BOX2I box = aRefItem->GetBoundingBox();
240 box.Inflate( aClearance );
241
242 int min[2] = { box.GetX(), box.GetY() };
243 int max[2] = { box.GetRight(), box.GetBottom() };
244
245 std::shared_ptr<SHAPE> refShape = aRefItem->GetEffectiveShape( aRefLayer );
246
247 int count = 0;
248
249 auto visit =
250 [&]( ITEM_WITH_SHAPE* aItem ) -> bool
251 {
252 if( aItem->parent == aRefItem )
253 return true;
254
255 if( collidingCompounds.find( aItem->parent ) != collidingCompounds.end() )
256 return true;
257
258 bool filtered;
259 auto it = filterResults.find( aItem->parent );
260
261 if( it == filterResults.end() )
262 {
263 filtered = aFilter && !aFilter( aItem->parent );
264 filterResults[ aItem->parent ] = filtered;
265 }
266 else
267 {
268 filtered = it->second;
269 }
270
271 if( filtered )
272 return true;
273
274 wxCHECK( aItem->shape, false );
275
276 if( refShape->Collide( aItem->shape, aClearance ) )
277 {
278 collidingCompounds.insert( aItem->parent );
279 count++;
280
281 if( aVisitor )
282 return aVisitor( aItem->parent );
283 }
284
285 return true;
286 };
287
288 if( auto it = m_tree.find( aTargetLayer ); it != m_tree.end() )
289 it->second.Search( min, max, visit );
290
291 return count;
292 }
293
300 bool QueryColliding( const BOX2I& aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer, int aClearance,
301 int* aActual, VECTOR2I* aPos ) const
302 {
303 BOX2I bbox = aBox;
304 bbox.Inflate( aClearance );
305
306 int min[2] = { bbox.GetX(), bbox.GetY() };
307 int max[2] = { bbox.GetRight(), bbox.GetBottom() };
308
309 bool collision = false;
310 int actual = INT_MAX;
311 VECTOR2I pos;
312
313 auto visit =
314 [&]( ITEM_WITH_SHAPE* aItem ) -> bool
315 {
316 int curActual;
317 VECTOR2I curPos;
318
319 if( aRefShape->Collide( aItem->shape, aClearance, &curActual, &curPos ) )
320 {
321 collision = true;
322
323 if( curActual < actual )
324 {
325 actual = curActual;
326 pos = curPos;
327 }
328
329 // Stop looking after we have a true collision
330 if( actual <= 0 )
331 return false;
332 }
333
334 return true;
335 };
336
337 if( auto it = m_tree.find( aLayer ); it != m_tree.end() )
338 it->second.Search( min, max, visit );
339
340 if( collision )
341 {
342 if( aActual )
343 *aActual = std::max( 0, actual );
344
345 if( aPos )
346 *aPos = pos;
347
348 return true;
349 }
350
351 return false;
352 }
353
357 bool QueryColliding( const BOX2I& aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer ) const
358 {
359 SHAPE_POLY_SET* poly = dynamic_cast<SHAPE_POLY_SET*>( aRefShape );
360
361 int min[2] = { aBox.GetX(), aBox.GetY() };
362 int max[2] = { aBox.GetRight(), aBox.GetBottom() };
363 bool collision = false;
364
365 // Special case the polygon case. Otherwise we'll call its Collide() method which will
366 // triangulate it as well and then do triangle/triangle collisions. This ends up being
367 // *much* slower than 3 segment Collide()s and a PointInside().
368 auto polyVisitor =
369 [&]( ITEM_WITH_SHAPE* aItem ) -> bool
370 {
371 const SHAPE* shape = aItem->shape;
372
373 // There are certain degenerate cases that result in empty zone fills, which
374 // will be represented in the rtree with only a root (and no triangles).
375 // https://gitlab.com/kicad/code/kicad/-/issues/18600
376 if( shape->Type() != SH_POLY_SET_TRIANGLE )
377 return true;
378
379 auto tri = static_cast<const SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI*>( shape );
380
381 const SHAPE_LINE_CHAIN& outline = poly->Outline( 0 );
382
383 for( int ii = 0; ii < (int) tri->GetSegmentCount(); ++ii )
384 {
385 if( outline.Collide( tri->GetSegment( ii ) ) )
386 {
387 collision = true;
388 return false;
389 }
390 }
391
392 // Also must check for poly being completely inside the triangle
393 if( tri->PointInside( outline.CPoint( 0 ) ) )
394 {
395 collision = true;
396 return false;
397 }
398
399 return true;
400 };
401
402 auto visitor =
403 [&]( ITEM_WITH_SHAPE* aItem ) -> bool
404 {
405 if( aRefShape->Collide( aItem->shape, 0 ) )
406 {
407 collision = true;
408 return false;
409 }
410
411 return true;
412 };
413
414 auto it = m_tree.find( aLayer );
415
416 if( it == m_tree.end() )
417 return false;
418
419 if( poly && poly->OutlineCount() == 1 && poly->HoleCount( 0 ) == 0 )
420 it->second.Search( min, max, polyVisitor );
421 else
422 it->second.Search( min, max, visitor );
423
424 return collision;
425 }
426
433 std::unordered_set<BOARD_ITEM*> GetObjectsAt( const VECTOR2I& aPt, PCB_LAYER_ID aLayer,
434 int aClearance = 0 )
435 {
436 std::unordered_set<BOARD_ITEM*> retval;
437 int min[2] = { aPt.x - aClearance, aPt.y - aClearance };
438 int max[2] = { aPt.x + aClearance, aPt.y + aClearance };
439
440 auto visitor =
441 [&]( ITEM_WITH_SHAPE* aItem ) -> bool
442 {
443 retval.insert( aItem->parent );
444 return true;
445 };
446
447 auto it = m_tree.find( aLayer );
448
449 if( it != m_tree.end() )
450 it->second.Search( min, max, visitor );
451
452 return retval;
453 }
454
455 typedef std::pair<PCB_LAYER_ID, PCB_LAYER_ID> LAYER_PAIR;
456
458 {
460 layerPair( aPair ),
461 refItem( aRef ),
462 testItem( aTest )
463 { };
464
468 };
469
470 int QueryCollidingPairs( DRC_RTREE* aRefTree, std::vector<LAYER_PAIR> aLayerPairs,
471 std::function<bool( const LAYER_PAIR&, ITEM_WITH_SHAPE*,
472 ITEM_WITH_SHAPE*, bool* aCollision )> aVisitor,
473 int aMaxClearance,
474 std::function<bool(int, int )> aProgressReporter ) const
475 {
476 std::vector<PAIR_INFO> pairsToVisit;
477
478 for( LAYER_PAIR& layerPair : aLayerPairs )
479 {
480 const PCB_LAYER_ID refLayer = layerPair.first;
481 const PCB_LAYER_ID targetLayer = layerPair.second;
482
483 for( ITEM_WITH_SHAPE* refItem : aRefTree->OnLayer( refLayer ) )
484 {
485 BOX2I box = refItem->shape->BBox();
486 box.Inflate( aMaxClearance );
487
488 int min[2] = { box.GetX(), box.GetY() };
489 int max[2] = { box.GetRight(), box.GetBottom() };
490
491 auto visit =
492 [&]( ITEM_WITH_SHAPE* aItemToTest ) -> bool
493 {
494 // don't collide items against themselves
495 if( aItemToTest->parent == refItem->parent )
496 return true;
497
498 pairsToVisit.emplace_back( layerPair, refItem, aItemToTest );
499 return true;
500 };
501
502 auto it = m_tree.find( targetLayer );
503
504 if( it != m_tree.end() )
505 it->second.Search( min, max, visit );
506 };
507 }
508
509 // keep track of BOARD_ITEMs pairs that have been already found to collide (some items
510 // might be build of COMPOUND/triangulated shapes and a single subshape collision
511 // means we have a hit)
512 std::unordered_map<PTR_PTR_CACHE_KEY, int> collidingCompounds;
513
514 int progress = 0;
515 int count = pairsToVisit.size();
516
517 for( const PAIR_INFO& pair : pairsToVisit )
518 {
519 if( !aProgressReporter( progress++, count ) )
520 break;
521
522 BOARD_ITEM* a = pair.refItem->parent;
523 BOARD_ITEM* b = pair.testItem->parent;
524
525 // store canonical order so we don't collide in both directions (a:b and b:a)
526 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
527 std::swap( a, b );
528
529 // don't report multiple collisions for compound or triangulated shapes
530 if( collidingCompounds.count( { a, b } ) )
531 continue;
532
533 bool collisionDetected = false;
534
535 if( !aVisitor( pair.layerPair, pair.refItem, pair.testItem, &collisionDetected ) )
536 break;
537
538 if( collisionDetected )
539 collidingCompounds[ { a, b } ] = 1;
540 }
541
542 return 0;
543 }
544
550 size_t size() const
551 {
552 return m_count;
553 }
554
555 bool empty() const
556 {
557 return m_count == 0;
558 }
559
569 {
570 DRC_LAYER() = default;
571
572 DRC_LAYER( const drc_rtree& aTree )
573 {
574 for( ITEM_WITH_SHAPE* item : aTree )
575 m_items.push_back( item );
576 }
577
578 DRC_LAYER( const drc_rtree& aTree, const BOX2I& aRect )
579 {
580 int min[2] = { aRect.GetX(), aRect.GetY() };
581 int max[2] = { aRect.GetRight(), aRect.GetBottom() };
582
583 auto collector = [this]( ITEM_WITH_SHAPE* aItem ) -> bool
584 {
585 m_items.push_back( aItem );
586 return true;
587 };
588
589 aTree.Search( min, max, collector );
590 }
591
592 std::vector<ITEM_WITH_SHAPE*> m_items;
593
594 std::vector<ITEM_WITH_SHAPE*>::iterator begin() { return m_items.begin(); }
595 std::vector<ITEM_WITH_SHAPE*>::iterator end() { return m_items.end(); }
596 };
597
599 {
600 auto it = m_tree.find( aLayer );
601 return it == m_tree.end() ? DRC_LAYER() : DRC_LAYER( it->second );
602 }
603
604 DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const VECTOR2I& aPoint, int aAccuracy = 0 ) const
605 {
606 BOX2I rect( aPoint, VECTOR2I( 0, 0 ) );
607 rect.Inflate( aAccuracy );
608 auto it = m_tree.find( aLayer );
609 return it == m_tree.end() ? DRC_LAYER() : DRC_LAYER( it->second, rect );
610 }
611
612 DRC_LAYER Overlapping( PCB_LAYER_ID aLayer, const BOX2I& aRect ) const
613 {
614 auto it = m_tree.find( aLayer );
615 return it == m_tree.end() ? DRC_LAYER() : DRC_LAYER( it->second, aRect );
616 }
617
618
619private:
620 std::map<int, drc_rtree> m_tree;
621 std::map<int, drc_rtree_builder> m_builders;
622 std::vector<ITEM_WITH_SHAPE*> m_owned;
623 size_t m_count = 0;
624};
625
626
627#endif /* DRC_RTREE_H_ */
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:231
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
virtual bool HasHole() const
Definition board_item.h:177
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:554
constexpr coord_type GetY() const
Definition box2.h:204
constexpr coord_type GetX() const
Definition box2.h:203
constexpr coord_type GetRight() const
Definition box2.h:213
constexpr coord_type GetBottom() const
Definition box2.h:218
DRC_LAYER OnLayer(PCB_LAYER_ID aLayer) const
Definition drc_rtree.h:598
size_t size() const
Return the number of items in the tree.
Definition drc_rtree.h:550
bool empty() const
Definition drc_rtree.h:555
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.
Definition drc_rtree.h:225
typename drc_rtree::Builder drc_rtree_builder
Definition drc_rtree.h:73
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, int aWorstClearance, bool aAtomicTables=false)
Insert an item into the tree on a particular layer with a worst clearance.
Definition drc_rtree.h:100
bool CheckColliding(SHAPE *aRefShape, PCB_LAYER_ID aTargetLayer, int aClearance=0, std::function< bool(BOARD_ITEM *)> aFilter=nullptr) const
Definition drc_rtree.h:186
DRC_LAYER Overlapping(PCB_LAYER_ID aLayer, const BOX2I &aRect) const
Definition drc_rtree.h:612
KIRTREE::PACKED_RTREE< ITEM_WITH_SHAPE *, int, 2 > drc_rtree
Definition drc_rtree.h:72
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.
Definition drc_rtree.h:433
bool QueryColliding(const BOX2I &aBox, SHAPE *aRefShape, PCB_LAYER_ID aLayer) const
Quicker version of above that just reports a raw yes/no.
Definition drc_rtree.h:357
void clear()
Remove all items from the RTree.
Definition drc_rtree.h:175
std::pair< PCB_LAYER_ID, PCB_LAYER_ID > LAYER_PAIR
Definition drc_rtree.h:455
size_t m_count
Definition drc_rtree.h:623
std::map< int, drc_rtree_builder > m_builders
Definition drc_rtree.h:621
DRC_LAYER Overlapping(PCB_LAYER_ID aLayer, const VECTOR2I &aPoint, int aAccuracy=0) const
Definition drc_rtree.h:604
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
Definition drc_rtree.h:470
std::vector< ITEM_WITH_SHAPE * > m_owned
Definition drc_rtree.h:622
void Build()
Finalize all pending inserts by bulk-building packed R-trees from the staged items.
Definition drc_rtree.h:164
bool QueryColliding(const BOX2I &aBox, SHAPE *aRefShape, PCB_LAYER_ID aLayer, int aClearance, int *aActual, VECTOR2I *aPos) const
This one is for tessellated items.
Definition drc_rtree.h:300
std::map< int, drc_rtree > m_tree
Definition drc_rtree.h:620
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0, bool aAtomicTables=false)
Insert an item into the tree on a particular layer with an optional worst clearance.
Definition drc_rtree.h:91
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:135
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual bool IsVisible() const
Definition eda_text.h:208
Static (immutable) packed R-tree built via Hilbert-curve bulk loading.
int Search(const ELEMTYPE aMin[NUMDIMS], const ELEMTYPE aMax[NUMDIMS], VISITOR &aVisitor) const
Search for all items whose bounding boxes overlap the query rectangle.
SHAPE_TYPE Type() const
Return the type of the shape.
Definition shape.h:96
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
An abstract shape on 2D plane.
Definition shape.h:124
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition shape.h:179
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
STL namespace.
@ SH_POLY_SET_TRIANGLE
a single triangle belonging to a POLY_SET triangulation
Definition shape.h:52
The DRC_LAYER struct provides a layer-specific auto-range iterator to the RTree.
Definition drc_rtree.h:569
DRC_LAYER(const drc_rtree &aTree, const BOX2I &aRect)
Definition drc_rtree.h:578
DRC_LAYER(const drc_rtree &aTree)
Definition drc_rtree.h:572
std::vector< ITEM_WITH_SHAPE * >::iterator begin()
Definition drc_rtree.h:594
std::vector< ITEM_WITH_SHAPE * > m_items
Definition drc_rtree.h:592
std::vector< ITEM_WITH_SHAPE * >::iterator end()
Definition drc_rtree.h:595
ITEM_WITH_SHAPE(BOARD_ITEM *aParent, const SHAPE *aShape, std::shared_ptr< SHAPE > aParentShape=nullptr)
Definition drc_rtree.h:49
std::shared_ptr< SHAPE > parentShape
Definition drc_rtree.h:68
ITEM_WITH_SHAPE(BOARD_ITEM *aParent, const std::shared_ptr< SHAPE > &aShape, std::shared_ptr< SHAPE > aParentShape=nullptr)
Definition drc_rtree.h:57
std::shared_ptr< SHAPE > shapeStorage
Definition drc_rtree.h:67
ITEM_WITH_SHAPE * refItem
Definition drc_rtree.h:466
PAIR_INFO(LAYER_PAIR aPair, ITEM_WITH_SHAPE *aRef, ITEM_WITH_SHAPE *aTest)
Definition drc_rtree.h:459
ITEM_WITH_SHAPE * testItem
Definition drc_rtree.h:467
LAYER_PAIR layerPair
Definition drc_rtree.h:465
int actual
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:83
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:88
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683