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
359 && !shape->IsSolidFill()
360 && !shape->GetPolyShape().IsEmpty() )
361 {
362 // A single polygon for the board would defeat the RTree, so convert to edges.
363 SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
364
365 for( int ii = 0; ii < (int) poly.GetSegmentCount(); ++ii )
366 {
367 SEG seg = poly.CSegment( ii );
368 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
369 edges.back()->SetShape( SHAPE_T::SEGMENT );
370 edges.back()->SetStart( seg.A );
371 edges.back()->SetEnd( seg.B );
372 edges.back()->SetStroke( stroke );
373 }
374 }
375 else
376 {
377 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
378 edges.back()->SetStroke( stroke );
379 }
380
381 return true;
382 } );
383
384 for( const std::unique_ptr<PCB_SHAPE>& edge : edges )
385 {
386 for( PCB_LAYER_ID layer : { Edge_Cuts, Margin } )
387 {
388 if( edge->IsOnLayer( layer ) )
390 }
391 }
392
393 for( FOOTPRINT* footprint : m_board->Footprints() )
394 {
395 for( PAD* pad : footprint->Pads() )
396 {
397 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
398 m_castellatedPads.push_back( pad );
399 }
400 }
401
402 m_edgesTree.Build();
403
404 /*
405 * Collect all testable (item, layer, shape) tuples, then test against edges in parallel.
406 * Flattening to per-layer work units ensures even distribution across threads, since
407 * zones with many layers become many separate work units rather than one heavy item.
408 * Pre-fetching shapes avoids per-zone mutex contention during parallel testing.
409 */
410 struct WORK_UNIT
411 {
412 BOARD_ITEM* item;
413 PCB_LAYER_ID shapeLayer;
414 std::shared_ptr<SHAPE> shape;
415 };
416
417 std::vector<WORK_UNIT> workUnits;
418
420 [&]( BOARD_ITEM *item ) -> bool
421 {
422 if( isInvisibleText( item ) )
423 return true;
424
425 if( item->Type() == PCB_ZONE_T )
426 {
427 // Rule areas have no copper and are purely logical -- skip edge clearance.
428 if( static_cast<ZONE*>( item )->GetIsRuleArea() )
429 return true;
430 }
431
432 if( item->Type() == PCB_PAD_T )
433 {
434 PAD* pad = static_cast<PAD*>( item );
435
436 if( pad->GetProperty() == PAD_PROP::CASTELLATED
437 || pad->GetAttribute() == PAD_ATTRIB::CONN )
438 {
439 return true;
440 }
441 }
442
443 std::vector<PCB_LAYER_ID> layersToTest;
444
445 switch( item->Type() )
446 {
447 case PCB_PAD_T:
448 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
449 break;
450
451 case PCB_VIA_T:
452 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
453 break;
454
455 case PCB_ZONE_T:
456 for( PCB_LAYER_ID layer : item->GetLayerSet() )
457 layersToTest.push_back( layer );
458
459 break;
460
461 default:
462 layersToTest = { UNDEFINED_LAYER };
463 }
464
465 for( PCB_LAYER_ID layer : layersToTest )
466 {
467 workUnits.push_back(
468 { item, layer, item->GetEffectiveShape( layer ) } );
469 }
470
471 return true;
472 } );
473
474 std::atomic<size_t> done( 0 );
475 size_t count = workUnits.size();
476
477 auto processWorkUnit =
478 [&]( const int idx ) -> size_t
479 {
480 if( m_drcEngine->IsCancelled() )
481 {
482 done.fetch_add( 1 );
483 return 0;
484 }
485
486 bool testCopper = !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE );
487 bool testSilk = !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE );
488
489 if( !testCopper && !testSilk )
490 {
491 done.fetch_add( 1 );
492 return 0;
493 }
494
495 WORK_UNIT& wu = workUnits[idx];
496 BOARD_ITEM* item = wu.item;
497
498 for( PCB_LAYER_ID testLayer : { Edge_Cuts, Margin } )
499 {
500 if( testCopper && item->IsOnCopperLayer() )
501 {
502 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
503 [&]( BOARD_ITEM* edge ) -> bool
504 {
505 return testAgainstEdge( item, wu.shape.get(),
506 wu.shapeLayer, edge,
507 EDGE_CLEARANCE_CONSTRAINT,
508 DRCE_EDGE_CLEARANCE );
509 },
511 }
512
513 if( testSilk
514 && ( item->IsOnLayer( F_SilkS )
515 || item->IsOnLayer( B_SilkS ) ) )
516 {
517 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
518 [&]( BOARD_ITEM* edge ) -> bool
519 {
520 return testAgainstEdge( item, wu.shape.get(),
521 wu.shapeLayer, edge,
522 SILK_CLEARANCE_CONSTRAINT,
523 DRCE_SILK_EDGE_CLEARANCE );
524 },
526 }
527 }
528
529 if( testSilk
530 && ( item->IsOnLayer( F_SilkS ) || item->IsOnLayer( B_SilkS ) ) )
531 {
532 bool needsResolution = false;
533
534 {
535 std::lock_guard<std::mutex> lock( m_silkMutex );
536 auto [it, inserted] = m_silkDisposition.try_emplace( item, RESOLVING );
537
538 if( inserted || it->second == UNKNOWN )
539 {
540 it->second = RESOLVING;
541 needsResolution = true;
542 }
543 }
544
545 if( needsResolution && m_board->BoardOutline()->HasOutline() )
546 {
547 resolveSilkDisposition( item, wu.shape.get(),
548 m_board->BoardOutline()->GetOutline() );
549 }
550 }
551
552 done.fetch_add( 1 );
553 return 1;
554 };
555
557 size_t numBlocks = count;
558 auto futures = tp.submit_loop( 0, count, processWorkUnit, numBlocks );
559
560 while( done < count )
561 {
562 reportProgress( done, count );
563
564 if( m_drcEngine->IsCancelled() )
565 {
566 for( auto& f : futures )
567 f.wait();
568
569 break;
570 }
571
572 futures.wait_for( std::chrono::milliseconds( 250 ) );
573 }
574
575 return !m_drcEngine->IsCancelled();
576}
577
578
579namespace detail
580{
582}
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.
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition board_item.h:150
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:409
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition board_item.h:346
virtual bool IsOnCopperLayer() const
Definition board_item.h:189
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
const MINOPTMAX< int > & GetValue() const
Definition drc_rule.h:204
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition drc_item.cpp:444
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition drc_rtree.h:46
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:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
int GetStartY() const
Definition eda_shape.h:276
int GetEndX() const
Definition eda_shape.h:327
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition eda_shape.h:551
SHAPE_POLY_SET & GetPolyShape()
SHAPE_T GetShape() const
Definition eda_shape.h:175
int GetEndY() const
Definition eda_shape.h:326
bool IsSolidFill() const
Definition eda_shape.h:123
int GetStartX() const
Definition eda_shape.h:277
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.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
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:181
virtual VECTOR2I Centre() const
Compute a center-of-mass of the shape.
Definition shape.h:242
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:582
Handle a list of polygons defining a copper zone.
Definition zone.h:70
PCB_DRC_CODE
Definition drc_item.h:35
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:102
@ 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:56
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:57
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:99
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:120
@ 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:80
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708