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;
198
199 if( edge->Type() == PCB_PAD_T )
200 shape = edge->GetEffectiveHoleShape();
201 else
202 shape = edge->GetEffectiveShape( Edge_Cuts );
203
204 auto constraint = m_drcEngine->EvalRules( aConstraintType, edge, item, UNDEFINED_LAYER );
205 int minClearance = constraint.GetValue().Min();
206 int actual;
207 VECTOR2I pos;
208
209 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && minClearance >= 0 )
210 {
211 if( itemShape->Collide( shape.get(), std::max( 0, minClearance - m_epsilon ), &actual, &pos ) )
212 {
213 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
214 {
215 // Edge collisions are allowed inside the holes of castellated pads
216 for( PAD* castellatedPad : m_castellatedPads )
217 {
218 if( castellatedPad->GetEffectiveHoleShape()->Collide( pos ) )
219 return true;
220 }
221 }
222
223 {
224 std::lock_guard<std::mutex> lock( m_emittedMutex );
225
226 if( !m_emittedEdgeReports.insert( { item->m_Uuid, edge->m_Uuid, pos } ).second )
227 {
228 // Same (item, edge, pos) already reported from another work unit.
229 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
230 return m_drcEngine->GetReportAllTrackErrors();
231 else
232 return false;
233 }
234 }
235
236 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( aErrorCode );
237
238 // Only report clearance info if there is any; otherwise it's just a straight collision
239 if( minClearance > 0 )
240 {
241 drcItem->SetErrorDetail( formatMsg( _( "(%s clearance %s; actual %s)" ),
242 constraint.GetName(),
243 minClearance,
244 actual ) );
245 }
246
247 drcItem->SetItems( edge->m_Uuid, item->m_Uuid );
248 drcItem->SetViolatingRule( constraint.GetParentRule() );
249 reportTwoItemGeometry( drcItem, pos, edge, item, shapeLayer, actual );
250
251 if( aErrorCode == DRCE_SILK_EDGE_CLEARANCE )
252 {
253 std::lock_guard<std::mutex> lock( m_silkMutex );
255 }
256
257 if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T )
258 return m_drcEngine->GetReportAllTrackErrors();
259 else
260 return false; // don't report violations with multiple edges; one is enough
261 }
262 }
263
264 return true;
265}
266
267
269{
270 if( !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE ) )
271 {
272 if( !reportPhase( _( "Checking copper to board edge clearances..." ) ) )
273 return false; // DRC cancelled
274 }
275 else if( !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE ) )
276 {
277 if( !reportPhase( _( "Checking silk to board edge clearances..." ) ) )
278 return false; // DRC cancelled
279 }
280 else
281 {
282 REPORT_AUX( wxT( "Edge clearance violations ignored. Tests not run." ) );
283 return true; // continue with other tests
284 }
285
286 m_board = m_drcEngine->GetBoard();
287 m_castellatedPads.clear();
288 m_epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
289 m_edgesTree.clear();
290 m_silkDisposition.clear();
291 m_emittedEdgeReports.clear();
292
293 DRC_CONSTRAINT worstClearanceConstraint;
294
295 if( m_drcEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
296 m_largestEdgeClearance = worstClearanceConstraint.GetValue().Min();
297
298 /*
299 * Build an RTree of the various edges (including NPTH holes) and margins found on the board.
300 */
301 std::vector<std::unique_ptr<PCB_SHAPE>> edges;
302
304 [&]( BOARD_ITEM *item ) -> bool
305 {
306 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
307 STROKE_PARAMS stroke = shape->GetStroke();
308
309 if( item->IsOnLayer( Edge_Cuts ) )
310 stroke.SetWidth( 0 );
311
312 if( shape->GetShape() == SHAPE_T::RECTANGLE && !shape->IsSolidFill() )
313 {
314 // A single rectangle for the board would defeat the RTree, so convert to edges
315 if( shape->GetCornerRadius() > 0 )
316 {
317 for( SHAPE* subshape : shape->MakeEffectiveShapes( true ) )
318 {
319 if( SHAPE_SEGMENT* segment = dynamic_cast<SHAPE_SEGMENT*>( subshape ) )
320 {
321 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
322 edges.back()->SetShape( SHAPE_T::SEGMENT );
323 edges.back()->SetStart( segment->GetStart() );
324 edges.back()->SetEnd( segment->GetEnd() );
325 edges.back()->SetStroke( stroke );
326 }
327 else if( SHAPE_ARC* arc = dynamic_cast<SHAPE_ARC*>( subshape ) )
328 {
329 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
330 edges.back()->SetShape( SHAPE_T::ARC );
331 edges.back()->SetArcGeometry( arc->GetP0(), arc->GetArcMid(), arc->GetP1() );
332 edges.back()->SetStroke( stroke );
333 }
334 else
335 {
336 wxFAIL_MSG(
337 wxString::Format( "Unexpected effective shape type %d for rounded rectangle",
338 (int) subshape->Type() ) );
339 continue;
340 }
341 }
342 }
343 else
344 {
345 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
346 edges.back()->SetShape( SHAPE_T::SEGMENT );
347 edges.back()->SetEndX( shape->GetStartX() );
348 edges.back()->SetStroke( stroke );
349 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
350 edges.back()->SetShape( SHAPE_T::SEGMENT );
351 edges.back()->SetEndY( shape->GetStartY() );
352 edges.back()->SetStroke( stroke );
353 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
354 edges.back()->SetShape( SHAPE_T::SEGMENT );
355 edges.back()->SetStartX( shape->GetEndX() );
356 edges.back()->SetStroke( stroke );
357 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
358 edges.back()->SetShape( SHAPE_T::SEGMENT );
359 edges.back()->SetStartY( shape->GetEndY() );
360 edges.back()->SetStroke( stroke );
361 }
362 }
363 else if( shape->GetShape() == SHAPE_T::POLY && !shape->IsSolidFill() )
364 {
365 // A single polygon for the board would defeat the RTree, so convert to edges.
366 SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
367
368 for( size_t ii = 0; ii < poly.GetSegmentCount(); ++ii )
369 {
370 SEG seg = poly.CSegment( ii );
371 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
372 edges.back()->SetShape( SHAPE_T::SEGMENT );
373 edges.back()->SetStart( seg.A );
374 edges.back()->SetEnd( seg.B );
375 edges.back()->SetStroke( stroke );
376 }
377 }
378 else
379 {
380 edges.emplace_back( static_cast<PCB_SHAPE*>( shape->Clone() ) );
381 edges.back()->SetStroke( stroke );
382 }
383
384 return true;
385 } );
386
387 for( const std::unique_ptr<PCB_SHAPE>& edge : edges )
388 {
389 for( PCB_LAYER_ID layer : { Edge_Cuts, Margin } )
390 {
391 if( edge->IsOnLayer( layer ) )
392 m_edgesTree.Insert( edge.get(), layer, m_largestEdgeClearance );
393 }
394 }
395
396 for( FOOTPRINT* footprint : m_board->Footprints() )
397 {
398 for( PAD* pad : footprint->Pads() )
399 {
400 if( pad->GetAttribute() == PAD_ATTRIB::NPTH && pad->HasHole() )
401 {
402 // edge-clearances are for milling tolerances (drilling tolerances are handled
403 // by hole-clearances)
404 if( pad->GetDrillSizeX() != pad->GetDrillSizeY() )
406 }
407
408 if( pad->GetProperty() == PAD_PROP::CASTELLATED )
409 m_castellatedPads.push_back( pad );
410 }
411 }
412
413 m_edgesTree.Build();
414
415 /*
416 * Collect all testable (item, layer, shape) tuples, then test against edges in parallel.
417 * Flattening to per-layer work units ensures even distribution across threads, since
418 * zones with many layers become many separate work units rather than one heavy item.
419 * Pre-fetching shapes avoids per-zone mutex contention during parallel testing.
420 */
421 struct WORK_UNIT
422 {
423 BOARD_ITEM* item;
424 PCB_LAYER_ID shapeLayer;
425 std::shared_ptr<SHAPE> shape;
426 };
427
428 std::vector<WORK_UNIT> workUnits;
429
431 [&]( BOARD_ITEM *item ) -> bool
432 {
433 if( isInvisibleText( item ) )
434 return true;
435
436 if( item->Type() == PCB_ZONE_T )
437 {
438 // Rule areas have no copper and are purely logical -- skip edge clearance.
439 if( static_cast<ZONE*>( item )->GetIsRuleArea() )
440 return true;
441 }
442
443 if( item->Type() == PCB_PAD_T )
444 {
445 PAD* pad = static_cast<PAD*>( item );
446
447 if( pad->GetProperty() == PAD_PROP::CASTELLATED
448 || pad->GetAttribute() == PAD_ATTRIB::CONN )
449 {
450 return true;
451 }
452 }
453
454 std::vector<PCB_LAYER_ID> layersToTest;
455
456 switch( item->Type() )
457 {
458 case PCB_PAD_T:
459 layersToTest = static_cast<PAD*>( item )->Padstack().UniqueLayers();
460 break;
461
462 case PCB_VIA_T:
463 layersToTest = static_cast<PCB_VIA*>( item )->Padstack().UniqueLayers();
464 break;
465
466 case PCB_ZONE_T:
467 for( PCB_LAYER_ID layer : item->GetLayerSet() )
468 layersToTest.push_back( layer );
469
470 break;
471
472 default:
473 layersToTest = { UNDEFINED_LAYER };
474 }
475
476 for( PCB_LAYER_ID layer : layersToTest )
477 {
478 workUnits.push_back(
479 { item, layer, item->GetEffectiveShape( layer ) } );
480 }
481
482 return true;
483 } );
484
485 std::atomic<size_t> done( 0 );
486 size_t count = workUnits.size();
487
488 auto processWorkUnit =
489 [&]( const int idx ) -> size_t
490 {
491 if( m_drcEngine->IsCancelled() )
492 {
493 done.fetch_add( 1 );
494 return 0;
495 }
496
497 bool testCopper = !m_drcEngine->IsErrorLimitExceeded( DRCE_EDGE_CLEARANCE );
498 bool testSilk = !m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_EDGE_CLEARANCE );
499
500 if( !testCopper && !testSilk )
501 {
502 done.fetch_add( 1 );
503 return 0;
504 }
505
506 WORK_UNIT& wu = workUnits[idx];
507 BOARD_ITEM* item = wu.item;
508
509 for( PCB_LAYER_ID testLayer : { Edge_Cuts, Margin } )
510 {
511 if( testCopper && item->IsOnCopperLayer() )
512 {
513 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
514 [&]( BOARD_ITEM* edge ) -> bool
515 {
516 return testAgainstEdge( item, wu.shape.get(),
517 wu.shapeLayer, edge,
518 EDGE_CLEARANCE_CONSTRAINT,
519 DRCE_EDGE_CLEARANCE );
520 },
522 }
523
524 if( testSilk
525 && ( item->IsOnLayer( F_SilkS )
526 || item->IsOnLayer( B_SilkS ) ) )
527 {
528 m_edgesTree.QueryColliding( item, wu.shapeLayer, testLayer, nullptr,
529 [&]( BOARD_ITEM* edge ) -> bool
530 {
531 return testAgainstEdge( item, wu.shape.get(),
532 wu.shapeLayer, edge,
533 SILK_CLEARANCE_CONSTRAINT,
534 DRCE_SILK_EDGE_CLEARANCE );
535 },
537 }
538 }
539
540 if( testSilk
541 && ( item->IsOnLayer( F_SilkS ) || item->IsOnLayer( B_SilkS ) ) )
542 {
543 bool needsResolution = false;
544
545 {
546 std::lock_guard<std::mutex> lock( m_silkMutex );
547 auto [it, inserted] = m_silkDisposition.try_emplace( item, RESOLVING );
548
549 if( inserted || it->second == UNKNOWN )
550 {
551 it->second = RESOLVING;
552 needsResolution = true;
553 }
554 }
555
556 if( needsResolution && m_board->BoardOutline()->HasOutline() )
557 {
558 resolveSilkDisposition( item, wu.shape.get(),
559 m_board->BoardOutline()->GetOutline() );
560 }
561 }
562
563 done.fetch_add( 1 );
564 return 1;
565 };
566
568 size_t numBlocks = count;
569 auto futures = tp.submit_loop( 0, count, processWorkUnit, numBlocks );
570
571 while( done < count )
572 {
573 reportProgress( done, count );
574
575 if( m_drcEngine->IsCancelled() )
576 {
577 for( auto& f : futures )
578 f.wait();
579
580 break;
581 }
582
583 futures.wait_for( std::chrono::milliseconds( 250 ) );
584 }
585
586 return !m_drcEngine->IsCancelled();
587}
588
589
590namespace detail
591{
593}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition board_item.h:265
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition board_item.h:133
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:347
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:285
virtual bool IsOnCopperLayer() const
Definition board_item.h:172
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:417
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:34
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:96
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:43
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
@ 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: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