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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <atomic>
21#include <common.h>
22#include <pcb_shape.h>
23#include <pcb_board_outline.h>
25#include <footprint.h>
26#include <pad.h>
27#include <pcb_track.h>
28#include <zone.h>
29#include <geometry/seg.h>
31#include <drc/drc_engine.h>
32#include <drc/drc_item.h>
33#include <drc/drc_rule.h>
35#include <drc/drc_rtree.h>
36#include <thread_pool.h>
37#include <mutex>
38#include <set>
39#include <tuple>
40
41/*
42 Board edge clearance test. Checks all items for their mechanical clearances against the board
43 edge.
44 Errors generated:
45 - DRCE_EDGE_CLEARANCE
46 - DRCE_SILK_EDGE_CLEARANCE
47*/
48
56
57
59{
60public:
66
68
69 virtual bool Run() override;
70
71 virtual const wxString GetName() const override { return wxT( "edge_clearance" ); }
72
73private:
74 void resolveSilkDisposition( BOARD_ITEM* aItem, const SHAPE* aItemShape, const SHAPE_POLY_SET& aBoardOutline );
75
76 bool testAgainstEdge( BOARD_ITEM* item, SHAPE* itemShape, PCB_LAYER_ID shapeLayer, BOARD_ITEM* other,
77 DRC_CONSTRAINT_T aConstraintType, PCB_DRC_CODE aErrorCode );
78
79private:
80 std::vector<PAD*> m_castellatedPads;
84
85 std::map<BOARD_ITEM*, SILK_DISPOSITION> m_silkDisposition;
86 std::mutex m_silkMutex;
87
88 // Pads/vias with non-uniform padstacks generate one work unit per unique
89 // copper layer. For edge clearance, EvalRules is layer-agnostic
90 // (UNDEFINED_LAYER), so per-layer reports for the same (item, edge, pos)
91 // are redundant. Dedup at emission time.
92 std::set<std::tuple<KIID, KIID, VECTOR2I>> m_emittedEdgeReports;
93 std::mutex m_emittedMutex;
94};
95
96
98 const SHAPE_POLY_SET& aBoardOutline )
99{
100 SILK_DISPOSITION disposition = UNKNOWN;
101
102 if( aItemShape->Type() == SH_COMPOUND )
103 {
104 const SHAPE_COMPOUND* compound = static_cast<const SHAPE_COMPOUND*>( aItemShape );
105
106 for( const SHAPE* elem : compound->Shapes() )
107 {
108 SILK_DISPOSITION elem_disposition = aBoardOutline.Contains( elem->Centre() ) ? ON_BOARD : OFF_BOARD;
109
110 if( disposition == UNKNOWN )
111 {
112 disposition = elem_disposition;
113 }
114 else if( disposition != elem_disposition )
115 {
116 disposition = CROSSES_EDGE;
117 break;
118 }
119 }
120 }
121 else
122 {
123 disposition = aBoardOutline.Contains( aItemShape->Centre() ) ? ON_BOARD : OFF_BOARD;
124 }
125
126 {
127 std::lock_guard<std::mutex> lock( m_silkMutex );
128 m_silkDisposition[aItem] = disposition;
129 }
130
131 if( disposition == CROSSES_EDGE )
132 {
133 BOARD_ITEM* nearestEdge = nullptr;
134 VECTOR2I itemPos = aItem->GetCenter();
135 VECTOR2I nearestEdgePt = aBoardOutline.Outline( 0 ).NearestPoint( itemPos, false );
136
137 for( int outlineIdx = 1; outlineIdx < aBoardOutline.OutlineCount(); ++outlineIdx )
138 {
139 VECTOR2I otherEdgePt = aBoardOutline.Outline( outlineIdx ).NearestPoint( itemPos, false );
140
141 if( otherEdgePt.SquaredDistance( itemPos ) < nearestEdgePt.SquaredDistance( itemPos ) )
142 nearestEdgePt = otherEdgePt;
143 }
144
145 for( BOARD_ITEM* edge : m_edgesTree.GetObjectsAt( nearestEdgePt, Edge_Cuts, m_epsilon ) )
146 {
147 if( edge->HitTest( nearestEdgePt, m_epsilon ) )
148 {
149 nearestEdge = edge;
150 break;
151 }
152 }
153
154 if( !nearestEdge )
155 return;
156
157 auto constraint = m_drcEngine->EvalRules( SILK_CLEARANCE_CONSTRAINT, nearestEdge, aItem, UNDEFINED_LAYER );
158 int minClearance = constraint.GetValue().Min();
159
160 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && minClearance >= 0 )
161 {
162 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SILK_EDGE_CLEARANCE );
163
164 // Report clearance info if there is any, even though crossing is just a straight-up collision
165 if( minClearance > 0 )
166 {
167 drcItem->SetErrorDetail( formatMsg( _( "(%s clearance %s; actual %s)" ),
168 constraint.GetName(),
169 minClearance,
170 0 ) );
171 }
172
173 drcItem->SetItems( nearestEdge->m_Uuid, aItem->m_Uuid );
174 drcItem->SetViolatingRule( constraint.GetParentRule() );
175 reportTwoPointGeometry( drcItem, nearestEdgePt, nearestEdgePt, nearestEdgePt, aItem->GetLayer() );
176 }
177 }
178#if 0
179 // If you want "Silk outside board edge" errors:
180 else if( disposition == OFF_BOARD )
181 {
182 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SILK_EDGE_CLEARANCE );
183 drcItem->SetErrorMessage( _( "Silkscreen outside board edge" ) );
184
185 drcItem->SetItems( aItem->m_Uuid );
186 reportTwoPointGeometry( drcItem, aItem->GetCenter(), aItem->GetCenter(), aItem->GetCenter(),
187 aItem->GetLayer() );
188 }
189#endif
190}
191
192
194 BOARD_ITEM* edge, DRC_CONSTRAINT_T aConstraintType,
195 PCB_DRC_CODE aErrorCode )
196{
197 std::shared_ptr<SHAPE> shape = edge->GetEffectiveShape( Edge_Cuts );
198
199 auto constraint = m_drcEngine->EvalRules( aConstraintType, edge, item, UNDEFINED_LAYER );
200 int minClearance = constraint.GetValue().Min();
201 int actual;
202 VECTOR2I pos;
203
204 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && minClearance >= 0 )
205 {
206 if( itemShape->Collide( shape.get(), std::max( 0, minClearance - m_epsilon ), &actual, &pos ) )
207 {
208 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
209 {
210 // Edge collisions are allowed inside the holes of castellated pads
211 for( PAD* castellatedPad : m_castellatedPads )
212 {
213 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
214 return true;
215 }
216 }
217
218 {
219 std::lock_guard<std::mutex> lock( m_emittedMutex );
220
221 if( !m_emittedEdgeReports.insert( { item->m_Uuid, edge->m_Uuid, pos } ).second )
222 {
223 // Same (item, edge, pos) already reported from another work unit.
224 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
225 return m_drcEngine->GetReportAllTrackErrors();
226 else
227 return false;
228 }
229 }
230
231 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( aErrorCode );
232
233 // Only report clearance info if there is any; otherwise it's just a straight collision
234 if( minClearance > 0 )
235 {
236 drcItem->SetErrorDetail( formatMsg( _( "(%s clearance %s; actual %s)" ),
237 constraint.GetName(),
238 minClearance,
239 actual ) );
240 }
241
242 drcItem->SetItems( edge->m_Uuid, item->m_Uuid );
243 drcItem->SetViolatingRule( constraint.GetParentRule() );
244 reportTwoItemGeometry( drcItem, pos, edge, item, shapeLayer, actual );
245
246 if( aErrorCode == DRCE_SILK_EDGE_CLEARANCE )
247 {
248 std::lock_guard<std::mutex> lock( m_silkMutex );
250 }
251
252 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
253 return m_drcEngine->GetReportAllTrackErrors();
254 else
255 return false; // don't report violations with multiple edges; one is enough
256 }
257 }
258
259 return true;
260}
261
262
264{
265 if( !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE ) )
266 {
267 if( !reportPhase( _( "Checking copper to board edge clearances..." ) ) )
268 return false; // DRC cancelled
269 }
270 else if( !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE ) )
271 {
272 if( !reportPhase( _( "Checking silk to board edge clearances..." ) ) )
273 return false; // DRC cancelled
274 }
275 else
276 {
277 REPORT_AUX( wxT( "Edge clearance violations ignored. Tests not run." ) );
278 return true; // continue with other tests
279 }
280
281 m_board = m_drcEngine->GetBoard();
282 m_castellatedPads.clear();
283 m_epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
284 m_edgesTree.clear();
285 m_silkDisposition.clear();
286 m_emittedEdgeReports.clear();
287
288 DRC_CONSTRAINT worstClearanceConstraint;
289
290 if( m_drcEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
291 m_largestEdgeClearance = worstClearanceConstraint.GetValue().Min();
292
293 /*
294 * Build an RTree of the various edges and margins found on the board.
295 */
296 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
297
299 [&]( BOARD_ITEM *item ) -> bool
300 {
301 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
302 STROKE_PARAMS stroke = shape->GetStroke();
303
304 if( item->IsOnLayer( Edge_Cuts ) )
305 stroke.SetWidth( 0 );
306
307 if( shape->GetShape() == SHAPE_T::RECTANGLE && !shape->IsSolidFill() )
308 {
309 // A single rectangle for the board would defeat the RTree, so convert to edges
310 if( shape->GetCornerRadius() > 0 )
311 {
312 for( SHAPE* subshape : shape->MakeEffectiveShapes( true ) )
313 {
314 if( SHAPE_SEGMENT* segment = dynamic_cast<SHAPE_SEGMENT*>( subshape ) )
315 {
316 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
317 edges.back()->SetShape( SHAPE_T::SEGMENT );
318 edges.back()->SetStart( segment->GetStart() );
319 edges.back()->SetEnd( segment->GetEnd() );
320 edges.back()->SetStroke( stroke );
321 }
322 else if( SHAPE_ARC* arc = dynamic_cast<SHAPE_ARC*>( subshape ) )
323 {
324 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
325 edges.back()->SetShape( SHAPE_T::ARC );
326 edges.back()->SetArcGeometry( arc->GetP0(), arc->GetArcMid(), arc->GetP1() );
327 edges.back()->SetStroke( stroke );
328 }
329 else
330 {
331 wxFAIL_MSG(
332 wxString::Format( "Unexpected effective shape type %d for rounded rectangle",
333 (int) subshape->Type() ) );
334 continue;
335 }
336 }
337 }
338 else
339 {
340 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
341 edges.back()->SetShape( SHAPE_T::SEGMENT );
342 edges.back()->SetEndX( shape->GetStartX() );
343 edges.back()->SetStroke( stroke );
344 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
345 edges.back()->SetShape( SHAPE_T::SEGMENT );
346 edges.back()->SetEndY( shape->GetStartY() );
347 edges.back()->SetStroke( stroke );
348 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
349 edges.back()->SetShape( SHAPE_T::SEGMENT );
350 edges.back()->SetStartX( shape->GetEndX() );
351 edges.back()->SetStroke( stroke );
352 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
353 edges.back()->SetShape( SHAPE_T::SEGMENT );
354 edges.back()->SetStartY( shape->GetEndY() );
355 edges.back()->SetStroke( stroke );
356 }
357 }
358 else if( shape->GetShape() == SHAPE_T::POLY && !shape->IsSolidFill() )
359 {
360 // A single polygon for the board would defeat the RTree, so convert to edges.
361 SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
362
363 for( size_t ii = 0; ii < poly.GetSegmentCount(); ++ii )
364 {
365 SEG seg = poly.CSegment( ii );
366 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
367 edges.back()->SetShape( SHAPE_T::SEGMENT );
368 edges.back()->SetStart( seg.A );
369 edges.back()->SetEnd( seg.B );
370 edges.back()->SetStroke( stroke );
371 }
372 }
373 else
374 {
375 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
376 edges.back()->SetStroke( stroke );
377 }
378
379 return true;
380 } );
381
382 for( const std::unique_ptr<PCB_SHAPE>& edge : edges )
383 {
384 for( PCB_LAYER_ID layer : { Edge_Cuts, Margin } )
385 {
386 if( edge->IsOnLayer( layer ) )
387 m_edgesTree.Insert( edge.get(), layer, m_largestEdgeClearance );
388 }
389 }
390
391 for( FOOTPRINT* footprint : m_board->Footprints() )
392 {
393 for( PAD* pad : footprint->Pads() )
394 {
395 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
396 m_castellatedPads.push_back( pad );
397 }
398 }
399
400 m_edgesTree.Build();
401
402 /*
403 * Collect all testable (item, layer, shape) tuples, then test against edges in parallel.
404 * Flattening to per-layer work units ensures even distribution across threads, since
405 * zones with many layers become many separate work units rather than one heavy item.
406 * Pre-fetching shapes avoids per-zone mutex contention during parallel testing.
407 */
408 struct WORK_UNIT
409 {
410 BOARD_ITEM* item;
411 PCB_LAYER_ID shapeLayer;
412 std::shared_ptr<SHAPE> shape;
413 };
414
415 std::vector<WORK_UNIT> workUnits;
416
418 [&]( BOARD_ITEM *item ) -> bool
419 {
420 if( isInvisibleText( item ) )
421 return true;
422
423 if( item->Type() == PCB_ZONE_T )
424 {
425 // Rule areas have no copper and are purely logical -- skip edge clearance.
426 if( static_cast<ZONE*>( item )->GetIsRuleArea() )
427 return true;
428 }
429
430 if( item->Type() == PCB_PAD_T )
431 {
432 PAD* pad = static_cast<PAD*>( item );
433
434 if( pad->GetProperty() == PAD_PROP::CASTELLATED
435 || pad->GetAttribute() == PAD_ATTRIB::CONN )
436 {
437 return true;
438 }
439 }
440
441 std::vector<PCB_LAYER_ID> layersToTest;
442
443 switch( item->Type() )
444 {
445 case PCB_PAD_T:
446 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
447 break;
448
449 case PCB_VIA_T:
450 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
451 break;
452
453 case PCB_ZONE_T:
454 for( PCB_LAYER_ID layer : item->GetLayerSet() )
455 layersToTest.push_back( layer );
456
457 break;
458
459 default:
460 layersToTest = { UNDEFINED_LAYER };
461 }
462
463 for( PCB_LAYER_ID layer : layersToTest )
464 {
465 workUnits.push_back(
466 { item, layer, item->GetEffectiveShape( layer ) } );
467 }
468
469 return true;
470 } );
471
472 std::atomic<size_t> done( 0 );
473 size_t count = workUnits.size();
474
475 auto processWorkUnit =
476 [&]( const int idx ) -> size_t
477 {
478 if( m_drcEngine->IsCancelled() )
479 {
480 done.fetch_add( 1 );
481 return 0;
482 }
483
484 bool testCopper = !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE );
485 bool testSilk = !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE );
486
487 if( !testCopper && !testSilk )
488 {
489 done.fetch_add( 1 );
490 return 0;
491 }
492
493 WORK_UNIT& wu = workUnits[idx];
494 BOARD_ITEM* item = wu.item;
495
496 for( PCB_LAYER_ID testLayer : { Edge_Cuts, Margin } )
497 {
498 if( testCopper && item->IsOnCopperLayer() )
499 {
500 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
501 [&]( BOARD_ITEM* edge ) -> bool
502 {
503 return testAgainstEdge( item, wu.shape.get(),
504 wu.shapeLayer, edge,
505 EDGE_CLEARANCE_CONSTRAINT,
506 DRCE_EDGE_CLEARANCE );
507 },
509 }
510
511 if( testSilk
512 && ( item->IsOnLayer( F_SilkS )
513 || item->IsOnLayer( B_SilkS ) ) )
514 {
515 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
516 [&]( BOARD_ITEM* edge ) -> bool
517 {
518 return testAgainstEdge( item, wu.shape.get(),
519 wu.shapeLayer, edge,
520 SILK_CLEARANCE_CONSTRAINT,
521 DRCE_SILK_EDGE_CLEARANCE );
522 },
524 }
525 }
526
527 if( testSilk
528 && ( item->IsOnLayer( F_SilkS ) || item->IsOnLayer( B_SilkS ) ) )
529 {
530 bool needsResolution = false;
531
532 {
533 std::lock_guard<std::mutex> lock( m_silkMutex );
534 auto [it, inserted] = m_silkDisposition.try_emplace( item, RESOLVING );
535
536 if( inserted || it->second == UNKNOWN )
537 {
538 it->second = RESOLVING;
539 needsResolution = true;
540 }
541 }
542
543 if( needsResolution && m_board->BoardOutline()->HasOutline() )
544 {
545 resolveSilkDisposition( item, wu.shape.get(),
546 m_board->BoardOutline()->GetOutline() );
547 }
548 }
549
550 done.fetch_add( 1 );
551 return 1;
552 };
553
555 size_t numBlocks = count;
556 auto futures = tp.submit_loop( 0, count, processWorkUnit, numBlocks );
557
558 while( done < count )
559 {
560 reportProgress( done, count );
561
562 if( m_drcEngine->IsCancelled() )
563 {
564 for( auto& f : futures )
565 f.wait();
566
567 break;
568 }
569
570 futures.wait_for( std::chrono::milliseconds( 250 ) );
571 }
572
573 return !m_drcEngine->IsCancelled();
574}
575
576
577namespace detail
578{
580}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:83
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:295
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition board_item.h:137
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:377
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:315
virtual bool IsOnCopperLayer() const
Definition board_item.h:176
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:418
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition drc_rtree.h:45
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).
std::set< std::tuple< KIID, KIID, VECTOR2I > > m_emittedEdgeReports
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:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
int GetStartY() const
Definition eda_shape.h:191
int GetEndX() const
Definition eda_shape.h:242
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:462
SHAPE_POLY_SET & GetPolyShape()
SHAPE_T GetShape() const
Definition eda_shape.h:185
int GetEndY() const
Definition eda_shape.h:241
bool IsSolidFill() const
Definition eda_shape.h:133
int GetStartX() const
Definition eda_shape.h:192
int GetCornerRadius() const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:637
T Min() const
Definition minoptmax.h:29
Definition pad.h:61
STROKE_PARAMS GetStroke() const override
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
SHAPE_TYPE Type() const
Return the type of the shape.
Definition shape.h:96
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: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 VECTOR2I Centre() const
Compute a center-of-mass of the shape.
Definition shape.h:230
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:557
Handle a list of polygons defining a copper zone.
Definition zone.h:70
The common library.
PCB_DRC_CODE
Definition drc_item.h:35
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:97
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:44
DRC_CONSTRAINT_T
Definition drc_rule.h:49
@ SILK_CLEARANCE_CONSTRAINT
Definition drc_rule.h:58
@ EDGE_CLEARANCE_CONSTRAINT
Definition drc_rule.h:55
#define REPORT_AUX(s)
#define _(s)
@ SEGMENT
Definition eda_shape.h:46
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:47
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Edge_Cuts
Definition layer_ids.h:108
@ Margin
Definition layer_ids.h:109
@ F_SilkS
Definition layer_ids.h:96
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ B_SilkS
Definition layer_ids.h:97
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
@ 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:49
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:27
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:81
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:90
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:101
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:80
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:91
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683