KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_test_provider_edge_clearance.cpp
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.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <atomic>
25#include <common.h>
26#include <pcb_shape.h>
27#include <pcb_board_outline.h>
29#include <footprint.h>
30#include <pad.h>
31#include <pcb_track.h>
32#include <geometry/seg.h>
34#include <drc/drc_engine.h>
35#include <drc/drc_item.h>
36#include <drc/drc_rule.h>
38#include <drc/drc_rtree.h>
39#include <thread_pool.h>
40#include <mutex>
41
42/*
43 Board edge clearance test. Checks all items for their mechanical clearances against the board
44 edge.
45 Errors generated:
46 - DRCE_EDGE_CLEARANCE
47 - DRCE_SILK_EDGE_CLEARANCE
48*/
49
57
58
60{
61public:
67
69
70 virtual bool Run() override;
71
72 virtual const wxString GetName() const override { return wxT( "edge_clearance" ); }
73
74private:
75 void resolveSilkDisposition( BOARD_ITEM* aItem, const SHAPE* aItemShape, const SHAPE_POLY_SET& aBoardOutline );
76
77 bool testAgainstEdge( BOARD_ITEM* item, SHAPE* itemShape, PCB_LAYER_ID shapeLayer, BOARD_ITEM* other,
78 DRC_CONSTRAINT_T aConstraintType, PCB_DRC_CODE aErrorCode );
79
80private:
81 std::vector<PAD*> m_castellatedPads;
85
86 std::map<BOARD_ITEM*, SILK_DISPOSITION> m_silkDisposition;
87 std::mutex m_silkMutex;
88};
89
90
92 const SHAPE_POLY_SET& aBoardOutline )
93{
94 SILK_DISPOSITION disposition = UNKNOWN;
95
96 if( aItemShape->Type() == SH_COMPOUND )
97 {
98 const SHAPE_COMPOUND* compound = static_cast<const SHAPE_COMPOUND*>( aItemShape );
99
100 for( const SHAPE* elem : compound->Shapes() )
101 {
102 SILK_DISPOSITION elem_disposition = aBoardOutline.Contains( elem->Centre() ) ? ON_BOARD : OFF_BOARD;
103
104 if( disposition == UNKNOWN )
105 {
106 disposition = elem_disposition;
107 }
108 else if( disposition != elem_disposition )
109 {
110 disposition = CROSSES_EDGE;
111 break;
112 }
113 }
114 }
115 else
116 {
117 disposition = aBoardOutline.Contains( aItemShape->Centre() ) ? ON_BOARD : OFF_BOARD;
118 }
119
120 {
121 std::lock_guard<std::mutex> lock( m_silkMutex );
122 m_silkDisposition[aItem] = disposition;
123 }
124
125 if( disposition == CROSSES_EDGE )
126 {
127 BOARD_ITEM* nearestEdge = nullptr;
128 VECTOR2I itemPos = aItem->GetCenter();
129 VECTOR2I nearestEdgePt = aBoardOutline.Outline( 0 ).NearestPoint( itemPos, false );
130
131 for( int outlineIdx = 1; outlineIdx < aBoardOutline.OutlineCount(); ++outlineIdx )
132 {
133 VECTOR2I otherEdgePt = aBoardOutline.Outline( outlineIdx ).NearestPoint( itemPos, false );
134
135 if( otherEdgePt.SquaredDistance( itemPos ) < nearestEdgePt.SquaredDistance( itemPos ) )
136 nearestEdgePt = otherEdgePt;
137 }
138
139 for( BOARD_ITEM* edge : m_edgesTree.GetObjectsAt( nearestEdgePt, Edge_Cuts, m_epsilon ) )
140 {
141 if( edge->HitTest( nearestEdgePt, m_epsilon ) )
142 {
143 nearestEdge = edge;
144 break;
145 }
146 }
147
148 if( !nearestEdge )
149 return;
150
151 auto constraint = m_drcEngine->EvalRules( SILK_CLEARANCE_CONSTRAINT, nearestEdge, aItem, UNDEFINED_LAYER );
152 int minClearance = constraint.GetValue().Min();
153
154 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && minClearance >= 0 )
155 {
156 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SILK_EDGE_CLEARANCE );
157
158 // Report clearance info if there is any, even though crossing is just a straight-up collision
159 if( minClearance > 0 )
160 {
161 drcItem->SetErrorDetail( formatMsg( _( "(%s clearance %s; actual %s)" ),
162 constraint.GetName(),
163 minClearance,
164 0 ) );
165 }
166
167 drcItem->SetItems( nearestEdge->m_Uuid, aItem->m_Uuid );
168 drcItem->SetViolatingRule( constraint.GetParentRule() );
169 reportTwoPointGeometry( drcItem, nearestEdgePt, nearestEdgePt, nearestEdgePt, aItem->GetLayer() );
170 }
171 }
172#if 0
173 // If you want "Silk outside board edge" errors:
174 else if( disposition == OFF_BOARD )
175 {
176 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SILK_EDGE_CLEARANCE );
177 drcItem->SetErrorMessage( _( "Silkscreen outside board edge" ) );
178
179 drcItem->SetItems( aItem->m_Uuid );
180 reportTwoPointGeometry( drcItem, aItem->GetCenter(), aItem->GetCenter(), aItem->GetCenter(),
181 aItem->GetLayer() );
182 }
183#endif
184}
185
186
188 BOARD_ITEM* edge, DRC_CONSTRAINT_T aConstraintType,
189 PCB_DRC_CODE aErrorCode )
190{
191 std::shared_ptr<SHAPE> shape;
192
193 if( edge->Type() == PCB_PAD_T )
194 shape = edge->GetEffectiveHoleShape();
195 else
196 shape = edge->GetEffectiveShape( Edge_Cuts );
197
198 auto constraint = m_drcEngine->EvalRules( aConstraintType, edge, item, UNDEFINED_LAYER );
199 int minClearance = constraint.GetValue().Min();
200 int actual;
201 VECTOR2I pos;
202
203 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && minClearance >= 0 )
204 {
205 if( itemShape->Collide( shape.get(), std::max( 0, minClearance - m_epsilon ), &actual, &pos ) )
206 {
207 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
208 {
209 // Edge collisions are allowed inside the holes of castellated pads
210 for( PAD* castellatedPad : m_castellatedPads )
211 {
212 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
213 return true;
214 }
215 }
216
217 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( aErrorCode );
218
219 // Only report clearance info if there is any; otherwise it's just a straight collision
220 if( minClearance > 0 )
221 {
222 drcItem->SetErrorDetail( formatMsg( _( "(%s clearance %s; actual %s)" ),
223 constraint.GetName(),
224 minClearance,
225 actual ) );
226 }
227
228 drcItem->SetItems( edge->m_Uuid, item->m_Uuid );
229 drcItem->SetViolatingRule( constraint.GetParentRule() );
230 reportTwoItemGeometry( drcItem, pos, edge, item, shapeLayer, actual );
231
232 if( aErrorCode == DRCE_SILK_EDGE_CLEARANCE )
233 {
234 std::lock_guard<std::mutex> lock( m_silkMutex );
236 }
237
238 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
239 return m_drcEngine->GetReportAllTrackErrors();
240 else
241 return false; // don't report violations with multiple edges; one is enough
242 }
243 }
244
245 return true;
246}
247
248
250{
251 if( !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE ) )
252 {
253 if( !reportPhase( _( "Checking copper to board edge clearances..." ) ) )
254 return false; // DRC cancelled
255 }
256 else if( !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE ) )
257 {
258 if( !reportPhase( _( "Checking silk to board edge clearances..." ) ) )
259 return false; // DRC cancelled
260 }
261 else
262 {
263 REPORT_AUX( wxT( "Edge clearance violations ignored. Tests not run." ) );
264 return true; // continue with other tests
265 }
266
267 m_board = m_drcEngine->GetBoard();
268 m_castellatedPads.clear();
269 m_epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
270 m_edgesTree.clear();
271 m_silkDisposition.clear();
272
273 DRC_CONSTRAINT worstClearanceConstraint;
274
275 if( m_drcEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
276 m_largestEdgeClearance = worstClearanceConstraint.GetValue().Min();
277
278 /*
279 * Build an RTree of the various edges (including NPTH holes) and margins found on the board.
280 */
281 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
282
284 [&]( BOARD_ITEM *item ) -> bool
285 {
286 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
287 STROKE_PARAMS stroke = shape->GetStroke();
288
289 if( item->IsOnLayer( Edge_Cuts ) )
290 stroke.SetWidth( 0 );
291
292 if( shape->GetShape() == SHAPE_T::RECTANGLE && !shape->IsSolidFill() )
293 {
294 // A single rectangle for the board would defeat the RTree, so convert to edges
295 if( shape->GetCornerRadius() > 0 )
296 {
297 for( SHAPE* subshape : shape->MakeEffectiveShapes( true ) )
298 {
299 if( SHAPE_SEGMENT* segment = dynamic_cast<SHAPE_SEGMENT*>( subshape ) )
300 {
301 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
302 edges.back()->SetShape( SHAPE_T::SEGMENT );
303 edges.back()->SetStart( segment->GetStart() );
304 edges.back()->SetEnd( segment->GetEnd() );
305 edges.back()->SetStroke( stroke );
306 }
307 else if( SHAPE_ARC* arc = dynamic_cast<SHAPE_ARC*>( subshape ) )
308 {
309 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
310 edges.back()->SetShape( SHAPE_T::ARC );
311 edges.back()->SetArcGeometry( arc->GetP0(), arc->GetArcMid(), arc->GetP1() );
312 edges.back()->SetStroke( stroke );
313 }
314 else
315 {
316 wxFAIL_MSG(
317 wxString::Format( "Unexpected effective shape type %d for rounded rectangle",
318 (int) subshape->Type() ) );
319 continue;
320 }
321 }
322 }
323 else
324 {
325 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
326 edges.back()->SetShape( SHAPE_T::SEGMENT );
327 edges.back()->SetEndX( shape->GetStartX() );
328 edges.back()->SetStroke( stroke );
329 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
330 edges.back()->SetShape( SHAPE_T::SEGMENT );
331 edges.back()->SetEndY( shape->GetStartY() );
332 edges.back()->SetStroke( stroke );
333 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
334 edges.back()->SetShape( SHAPE_T::SEGMENT );
335 edges.back()->SetStartX( shape->GetEndX() );
336 edges.back()->SetStroke( stroke );
337 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
338 edges.back()->SetShape( SHAPE_T::SEGMENT );
339 edges.back()->SetStartY( shape->GetEndY() );
340 edges.back()->SetStroke( stroke );
341 }
342 }
343 else if( shape->GetShape() == SHAPE_T::POLY && !shape->IsSolidFill() )
344 {
345 // A single polygon for the board would defeat the RTree, so convert to edges.
346 SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
347
348 for( size_t ii = 0; ii < poly.GetSegmentCount(); ++ii )
349 {
350 SEG seg = poly.CSegment( ii );
351 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
352 edges.back()->SetShape( SHAPE_T::SEGMENT );
353 edges.back()->SetStart( seg.A );
354 edges.back()->SetEnd( seg.B );
355 edges.back()->SetStroke( stroke );
356 }
357 }
358 else
359 {
360 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
361 edges.back()->SetStroke( stroke );
362 }
363
364 return true;
365 } );
366
367 for( const std::unique_ptr<PCB_SHAPE>& edge : edges )
368 {
369 for( PCB_LAYER_ID layer : { Edge_Cuts, Margin } )
370 {
371 if( edge->IsOnLayer( layer ) )
372 m_edgesTree.Insert( edge.get(), layer, m_largestEdgeClearance );
373 }
374 }
375
376 for( FOOTPRINT* footprint : m_board->Footprints() )
377 {
378 for( PAD* pad : footprint->Pads() )
379 {
380 if( pad->GetAttribute() == PAD_ATTRIB::NPTH && pad->HasHole() )
381 {
382 // edge-clearances are for milling tolerances (drilling tolerances are handled
383 // by hole-clearances)
384 if( pad->GetDrillSizeX() != pad->GetDrillSizeY() )
386 }
387
388 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
389 m_castellatedPads.push_back( pad );
390 }
391 }
392
393 m_edgesTree.Build();
394
395 /*
396 * Collect all testable (item, layer, shape) tuples, then test against edges in parallel.
397 * Flattening to per-layer work units ensures even distribution across threads, since
398 * zones with many layers become many separate work units rather than one heavy item.
399 * Pre-fetching shapes avoids per-zone mutex contention during parallel testing.
400 */
401 struct WORK_UNIT
402 {
403 BOARD_ITEM* item;
404 PCB_LAYER_ID shapeLayer;
405 std::shared_ptr<SHAPE> shape;
406 };
407
408 std::vector<WORK_UNIT> workUnits;
409
411 [&]( BOARD_ITEM *item ) -> bool
412 {
413 if( isInvisibleText( item ) )
414 return true;
415
416 if( item->Type() == PCB_PAD_T )
417 {
418 PAD* pad = static_cast<PAD*>( item );
419
420 if( pad->GetProperty() == PAD_PROP::CASTELLATED
421 || pad->GetAttribute() == PAD_ATTRIB::CONN )
422 {
423 return true;
424 }
425 }
426
427 std::vector<PCB_LAYER_ID> layersToTest;
428
429 switch( item->Type() )
430 {
431 case PCB_PAD_T:
432 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
433 break;
434
435 case PCB_VIA_T:
436 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
437 break;
438
439 case PCB_ZONE_T:
440 for( PCB_LAYER_ID layer : item->GetLayerSet() )
441 layersToTest.push_back( layer );
442
443 break;
444
445 default:
446 layersToTest = { UNDEFINED_LAYER };
447 }
448
449 for( PCB_LAYER_ID layer : layersToTest )
450 {
451 workUnits.push_back(
452 { item, layer, item->GetEffectiveShape( layer ) } );
453 }
454
455 return true;
456 } );
457
458 std::atomic<size_t> done( 0 );
459 size_t count = workUnits.size();
460
461 auto processWorkUnit =
462 [&]( const int idx ) -> size_t
463 {
464 if( m_drcEngine->IsCancelled() )
465 {
466 done.fetch_add( 1 );
467 return 0;
468 }
469
470 bool testCopper = !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE );
471 bool testSilk = !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE );
472
473 if( !testCopper && !testSilk )
474 {
475 done.fetch_add( 1 );
476 return 0;
477 }
478
479 WORK_UNIT& wu = workUnits[idx];
480 BOARD_ITEM* item = wu.item;
481
482 for( PCB_LAYER_ID testLayer : { Edge_Cuts, Margin } )
483 {
484 if( testCopper && item->IsOnCopperLayer() )
485 {
486 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
487 [&]( BOARD_ITEM* edge ) -> bool
488 {
489 return testAgainstEdge( item, wu.shape.get(),
490 wu.shapeLayer, edge,
491 EDGE_CLEARANCE_CONSTRAINT,
492 DRCE_EDGE_CLEARANCE );
493 },
495 }
496
497 if( testSilk
498 && ( item->IsOnLayer( F_SilkS )
499 || item->IsOnLayer( B_SilkS ) ) )
500 {
501 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
502 [&]( BOARD_ITEM* edge ) -> bool
503 {
504 return testAgainstEdge( item, wu.shape.get(),
505 wu.shapeLayer, edge,
506 SILK_CLEARANCE_CONSTRAINT,
507 DRCE_SILK_EDGE_CLEARANCE );
508 },
510 }
511 }
512
513 if( testSilk
514 && ( item->IsOnLayer( F_SilkS ) || item->IsOnLayer( B_SilkS ) ) )
515 {
516 bool needsResolution = false;
517
518 {
519 std::lock_guard<std::mutex> lock( m_silkMutex );
520 auto [it, inserted] = m_silkDisposition.try_emplace( item, RESOLVING );
521
522 if( inserted || it->second == UNKNOWN )
523 {
524 it->second = RESOLVING;
525 needsResolution = true;
526 }
527 }
528
529 if( needsResolution && m_board->BoardOutline()->HasOutline() )
530 {
531 resolveSilkDisposition( item, wu.shape.get(),
532 m_board->BoardOutline()->GetOutline() );
533 }
534 }
535
536 done.fetch_add( 1 );
537 return 1;
538 };
539
541 size_t numBlocks = count;
542 auto futures = tp.submit_loop( 0, count, processWorkUnit, numBlocks );
543
544 while( done < count )
545 {
546 reportProgress( done, count );
547
548 if( m_drcEngine->IsCancelled() )
549 {
550 for( auto& f : futures )
551 f.wait();
552
553 break;
554 }
555
556 futures.wait_for( std::chrono::milliseconds( 250 ) );
557 }
558
559 return !m_drcEngine->IsCancelled();
560}
561
562
563namespace detail
564{
566}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:268
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition board_item.h:136
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:350
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.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:288
virtual bool IsOnCopperLayer() const
Definition board_item.h:175
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
const MINOPTMAX< int > & GetValue() const
Definition drc_rule.h:196
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition drc_item.cpp:407
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition drc_rtree.h:49
void resolveSilkDisposition(BOARD_ITEM *aItem, const SHAPE *aItemShape, const SHAPE_POLY_SET &aBoardOutline)
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
virtual ~DRC_TEST_PROVIDER_EDGE_CLEARANCE()=default
std::map< BOARD_ITEM *, SILK_DISPOSITION > m_silkDisposition
virtual const wxString GetName() const override
bool testAgainstEdge(BOARD_ITEM *item, SHAPE *itemShape, PCB_LAYER_ID shapeLayer, BOARD_ITEM *other, DRC_CONSTRAINT_T aConstraintType, PCB_DRC_CODE aErrorCode)
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, const LSET &aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
void reportTwoItemGeometry(std::shared_ptr< DRC_ITEM > &aDrcItem, const VECTOR2I &aMarkerPos, const BOARD_ITEM *aItem1, const BOARD_ITEM *aItem2, PCB_LAYER_ID aLayer, int aDistance)
void reportTwoPointGeometry(std::shared_ptr< DRC_ITEM > &aDrcItem, const VECTOR2I &aMarkerPos, const VECTOR2I &ptA, const VECTOR2I &ptB, PCB_LAYER_ID aLayer)
static std::vector< KICAD_T > s_allBasicItems
bool isInvisibleText(const BOARD_ITEM *aItem) const
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
const KIID m_Uuid
Definition eda_item.h:528
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
int GetStartY() const
Definition eda_shape.h:187
int GetEndX() const
Definition eda_shape.h:230
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:390
SHAPE_POLY_SET & GetPolyShape()
SHAPE_T GetShape() const
Definition eda_shape.h:181
int GetEndY() const
Definition eda_shape.h:229
bool IsSolidFill() const
Definition eda_shape.h:129
int GetStartX() const
Definition eda_shape.h:188
int GetCornerRadius() const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:641
T Min() const
Definition minoptmax.h:33
Definition pad.h:55
STROKE_PARAMS GetStroke() const override
Definition pcb_shape.h:91
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition seg.h:42
VECTOR2I A
Definition seg.h:49
VECTOR2I B
Definition seg.h:50
SHAPE_TYPE Type() const
Return the type of the shape.
Definition shape.h:98
const std::vector< SHAPE * > & Shapes() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
virtual size_t GetSegmentCount() const override
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Represent a set of closed polygons.
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.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
An abstract shape on 2D plane.
Definition shape.h:126
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:181
virtual VECTOR2I Centre() const
Compute a center-of-mass of the shape.
Definition shape.h:232
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
constexpr extended_type SquaredDistance(const VECTOR2< T > &aVector) const
Compute the squared distance between two vectors.
Definition vector2d.h:561
The common library.
PCB_DRC_CODE
Definition drc_item.h:38
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:99
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:47
DRC_CONSTRAINT_T
Definition drc_rule.h:53
@ SILK_CLEARANCE_CONSTRAINT
Definition drc_rule.h:62
@ EDGE_CLEARANCE_CONSTRAINT
Definition drc_rule.h:59
#define REPORT_AUX(s)
#define _(s)
@ SEGMENT
Definition eda_shape.h:47
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:48
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ Edge_Cuts
Definition layer_ids.h:112
@ Margin
Definition layer_ids.h:113
@ F_SilkS
Definition layer_ids.h:100
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ B_SilkS
Definition layer_ids.h:101
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:103
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
Definition padstack.h:100
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:121
@ RPT_SEVERITY_IGNORE
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
Definition shape.h:53
int actual
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
static thread_pool * tp
BS::priority_thread_pool thread_pool
Definition thread_pool.h:31
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:105
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:84
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:95
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687