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