KiCad PCB EDA Suite
drc_test_provider_connection_width.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 (C) 2022 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 3
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/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 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 <algorithm>
25#include <atomic>
26#include <deque>
27#include <optional>
28#include <utility>
29
30#include <wx/debug.h>
31
32#include <board.h>
35#include <drc/drc_rule.h>
36#include <drc/drc_item.h>
38#include <drc/drc_rtree.h>
40#include <footprint.h>
41#include <geometry/seg.h>
43#include <math/box2.h>
44#include <math/vector2d.h>
45#include <pcb_shape.h>
46#include <progress_reporter.h>
47#include <thread_pool.h>
48#include <pcb_track.h>
49#include <pad.h>
50#include <zone.h>
51
52/*
53 Checks for copper connections that are less than the specified minimum width
54
55 Errors generated:
56 - DRCE_CONNECTION_WIDTH
57*/
58
60{
63
64 bool operator==(const NETCODE_LAYER_CACHE_KEY& other) const
65 {
66 return Netcode == other.Netcode && Layer == other.Layer;
67 }
68};
69
70
71namespace std
72{
73 template <>
75 {
76 std::size_t operator()( const NETCODE_LAYER_CACHE_KEY& k ) const
77 {
78 constexpr std::size_t prime = 19937;
79
80 return hash<int>()( k.Netcode ) ^ ( hash<int>()( k.Layer ) * prime );
81 }
82 };
83}
84
85
87{
88public:
90 {
91 }
92
94 {
95 }
96
97 virtual bool Run() override;
98
99 virtual const wxString GetName() const override
100 {
101 return wxT( "copper width" );
102 };
103
104 virtual const wxString GetDescription() const override
105 {
106 return wxT( "Checks copper nets for connections less than a specified minimum" );
107 }
108
109private:
110 wxString layerDesc( PCB_LAYER_ID aLayer );
111};
112
113
115{
116public:
117 POLYGON_TEST( int aLimit, int aErrorLimit ) :
118 m_limit( aLimit ), m_max_error( aErrorLimit )
119 {
120 };
121
122 bool FindPairs( const SHAPE_LINE_CHAIN& aPoly )
123 {
124 m_hits.clear();
125 m_vertices.clear();
126 m_bbox = aPoly.BBox();
127
128 createList( aPoly );
129
130 m_vertices.front().updateList();
131
132 Vertex* p = m_vertices.front().next;
133 std::set<Vertex*> all_hits;
134
135 while( p != &m_vertices.front() )
136 {
137 Vertex* match = nullptr;
138
139 // Only run the expensive search if we don't already have a match for the point
140 if( ( all_hits.empty() || all_hits.count( p ) == 0 ) && ( match = getKink( p ) ) )
141 {
142 if( !all_hits.count( match ) && m_hits.emplace( p->i, match->i ).second )
143 {
144 all_hits.emplace( p );
145 all_hits.emplace( match );
146 all_hits.emplace( p->next );
147 all_hits.emplace( p->prev );
148 all_hits.emplace( match->next );
149 all_hits.emplace( match->prev );
150 }
151 }
152
153 p = p->next;
154 }
155
156 return !m_hits.empty();
157 }
158
159 std::set<std::pair<int, int>>& GetVertices()
160 {
161 return m_hits;
162 }
163
164
165private:
166 struct Vertex
167 {
168 Vertex( int aIndex, double aX, double aY, POLYGON_TEST* aParent ) :
169 i( aIndex ),
170 x( aX ),
171 y( aY ),
172 parent( aParent )
173 {
174 }
175
176 Vertex& operator=( const Vertex& ) = delete;
177 Vertex& operator=( Vertex&& ) = delete;
178
179 bool operator==( const Vertex& rhs ) const
180 {
181 return this->x == rhs.x && this->y == rhs.y;
182 }
183 bool operator!=( const Vertex& rhs ) const { return !( *this == rhs ); }
184
188 void remove()
189 {
190 next->prev = prev;
191 prev->next = next;
192
193 if( prevZ )
194 prevZ->nextZ = nextZ;
195
196 if( nextZ )
197 nextZ->prevZ = prevZ;
198
199 next = nullptr;
200 prev = nullptr;
201 nextZ = nullptr;
202 prevZ = nullptr;
203 }
204
206 {
207 if( !z )
208 z = parent->zOrder( x, y );
209 }
210
216 {
217 Vertex* p = next;
218
219 while( p != this )
220 {
224 if( *p == *p->next )
225 {
226 p = p->prev;
227 p->next->remove();
228
229 if( p == p->next )
230 break;
231 }
232
233 p->updateOrder();
234 p = p->next;
235 };
236
237 updateOrder();
238 zSort();
239 }
240
244 void zSort()
245 {
246 std::deque<Vertex*> queue;
247
248 queue.push_back( this );
249
250 for( Vertex* p = next; p && p != this; p = p->next )
251 queue.push_back( p );
252
253 std::sort( queue.begin(), queue.end(), []( const Vertex* a, const Vertex* b )
254 {
255 return a->z < b->z;
256 } );
257
258 Vertex* prev_elem = nullptr;
259
260 for( Vertex* elem : queue )
261 {
262 if( prev_elem )
263 prev_elem->nextZ = elem;
264
265 elem->prevZ = prev_elem;
266 prev_elem = elem;
267 }
268
269 prev_elem->nextZ = nullptr;
270 }
271
272 const int i;
273 const double x;
274 const double y;
276
277 // previous and next vertices nodes in a polygon ring
278 Vertex* prev = nullptr;
279 Vertex* next = nullptr;
280
281 // z-order curve value
282 int32_t z = 0;
283
284 // previous and next nodes in z-order
285 Vertex* prevZ = nullptr;
286 Vertex* nextZ = nullptr;
287 };
288
294 int32_t zOrder( const double aX, const double aY ) const
295 {
296 int32_t x = static_cast<int32_t>( 32767.0 * ( aX - m_bbox.GetX() ) / m_bbox.GetWidth() );
297 int32_t y = static_cast<int32_t>( 32767.0 * ( aY - m_bbox.GetY() ) / m_bbox.GetHeight() );
298
299 x = ( x | ( x << 8 ) ) & 0x00FF00FF;
300 x = ( x | ( x << 4 ) ) & 0x0F0F0F0F;
301 x = ( x | ( x << 2 ) ) & 0x33333333;
302 x = ( x | ( x << 1 ) ) & 0x55555555;
303
304 y = ( y | ( y << 8 ) ) & 0x00FF00FF;
305 y = ( y | ( y << 4 ) ) & 0x0F0F0F0F;
306 y = ( y | ( y << 2 ) ) & 0x33333333;
307 y = ( y | ( y << 1 ) ) & 0x55555555;
308
309 return x | ( y << 1 );
310 }
311
320 bool isSubstantial( Vertex* aA, Vertex* aB ) const
321 {
322 // `directions` is a bitfield where
323 // bit 0 = pos y
324 // bit 1 = neg y
325 // bit 2 = pos x
326 // bit 3 = neg x
327 // So, once directions = 15, we have all directions
328 int directions = 0;
329
330 // This is a failsafe in case of invalid lists. Never check
331 // more than the total number of points in m_vertices
332 size_t checked = 0;
333 size_t total_pts = m_vertices.size();
334
335 Vertex* p0 = aA;
336 Vertex* p;
337 Vertex* nz = p0->nextZ;
338 Vertex* pz = p0->prevZ;
339
340 auto same_point =
341 []( const Vertex* a, const Vertex* b ) -> bool
342 {
343 return a && b && a->x == b->x && a->y == b->y;
344 };
345
346 // If we hit a fracture point, we want to continue around the
347 // edge we are working on and not switch to the pair edge
348 // However, this will depend on which direction the initial
349 // fracture hit is. If we find that we skip directly to
350 // a new fracture point, then we know that we are proceeding
351 // in the wrong direction from the fracture and should
352 // fall through to the next point
353 if( same_point( p0, nz )
354 && !( same_point( nz->next, nz->next->prevZ ) || same_point( nz->next, nz->next->nextZ ) ) )
355 {
356 p = nz->next;
357 }
358 else if( same_point( p0, pz )
359 && !( same_point( pz->next, pz->next->prevZ ) || same_point( pz->next, pz->next->nextZ ) ) )
360 {
361 p = pz->next;
362 }
363 else
364 {
365 p = p0->next;
366 }
367
368 while( p0 != aB && checked < total_pts && directions != 0b1111 )
369 {
370 double diff_x = std::abs( p->x - p0->x );
371 double diff_y = std::abs( p->y - p0->y );
372
373 // Floating point zeros can have a negative sign, so we need to
374 // ensure that only substantive diversions count for a direction
375 // change
376 if( diff_x > m_max_error )
377 directions |= ( 1 << ( 2 + std::signbit( p->x - p0->x ) ) );
378
379 if( diff_y > m_max_error )
380 directions |= ( 1 << std::signbit( p->y - p0->y ) );
381
382 // In the case of a circle, we need to eventually get the direction
383 // so keep the p0 at the same point
384 if( diff_x > m_max_error || diff_y > m_max_error || p == aB )
385 p0 = p;
386
387 if( same_point( p, p->nextZ ) )
388 p = p->nextZ->next;
389 else if( same_point( p, p->prevZ ) )
390 p = p->prevZ->next;
391 else
392 p = p->next;
393
394 ++checked;
395 }
396
397 wxCHECK_MSG( checked < total_pts, false, wxT( "Invalid polygon detected. Missing points to check" ) );
398
399 if( directions != 15 )
400 return false;
401
402 p0 = aA;
403 nz = p0->nextZ;
404 pz = p0->prevZ;
405
406 if( nz && same_point( p0, nz )
407 && !( same_point( nz->prev, nz->prev->nextZ ) || same_point( nz->prev, nz->prev->prevZ ) ) )
408 {
409 p = nz->prev;
410 }
411 else if( pz && same_point( p0, pz )
412 && !( same_point( pz->prev, pz->prev->nextZ ) || same_point( pz->prev, pz->prev->prevZ ) ) )
413 {
414 p = pz->prev;
415 }
416 else
417 {
418 p = p0->prev;
419 }
420
421 directions = 0;
422 checked = 0;
423
424 while( p0 != aB && checked < total_pts && directions != 0b1111 )
425 {
426 double diff_x = std::abs( p->x - p0->x );
427 double diff_y = std::abs( p->y - p0->y );
428
429 // Floating point zeros can have a negative sign, so we need to
430 // ensure that only substantive diversions count for a direction
431 // change
432 if( diff_x > m_max_error )
433 directions |= ( 1 << ( 2 + std::signbit( p->x - p0->x ) ) );
434
435 if( diff_y > m_max_error )
436 directions |= ( 1 << std::signbit( p->y - p0->y ) );
437
438 // In the case of a circle, we need to eventually get the direction
439 // so keep the p0 at the same point
440 if( diff_x > m_max_error || diff_y > m_max_error || p == aB )
441 p0 = p;
442
443 if( same_point( p, p->nextZ ) )
444 p = p->nextZ->prev;
445 else if( same_point( p, p->prevZ ) )
446 p = p->prevZ->prev;
447 else
448 p = p->prev;
449
450 ++checked;
451 }
452
453 wxCHECK_MSG( checked < total_pts, false, wxT( "Invalid polygon detected. Missing points to check" ) );
454
455 return ( directions == 15 );
456 }
457
462 {
463 Vertex* tail = nullptr;
464 double sum = 0.0;
465
466 // Check for winding order
467 for( int i = 0; i < points.PointCount(); i++ )
468 {
469 VECTOR2D p1 = points.CPoint( i );
470 VECTOR2D p2 = points.CPoint( i + 1 );
471
472 sum += ( ( p2.x - p1.x ) * ( p2.y + p1.y ) );
473 }
474
475 if( sum > 0.0 )
476 {
477 for( int i = points.PointCount() - 1; i >= 0; i--)
478 tail = insertVertex( i, points.CPoint( i ), tail );
479 }
480 else
481 {
482 for( int i = 0; i < points.PointCount(); i++ )
483 tail = insertVertex( i, points.CPoint( i ), tail );
484 }
485
486 if( tail && ( *tail == *tail->next ) )
487 {
488 tail->next->remove();
489 }
490
491 return tail;
492 }
493
494 Vertex* getKink( Vertex* aPt ) const
495 {
496 // The point needs to be at a concave surface
497 if( locallyInside( aPt->prev, aPt->next ) )
498 return nullptr;
499
500 // z-order range for the current point ± limit bounding box
501 const int32_t maxZ = zOrder( aPt->x + m_limit, aPt->y + m_limit );
502 const int32_t minZ = zOrder( aPt->x - m_limit, aPt->y - m_limit );
503 const SEG::ecoord limit2 = SEG::Square( m_limit );
504
505 // first look for points in increasing z-order
506 Vertex* p = aPt->nextZ;
507 SEG::ecoord min_dist = std::numeric_limits<SEG::ecoord>::max();
508 Vertex* retval = nullptr;
509
510 while( p && p->z <= maxZ )
511 {
512 int delta_i = std::abs( p->i - aPt->i );
513 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
514 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
515
516 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0.0
517 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) )
518 {
519 min_dist = dist2;
520 retval = p;
521 }
522
523 p = p->nextZ;
524 }
525
526 p = aPt->prevZ;
527
528 while( p && p->z >= minZ )
529 {
530 int delta_i = std::abs( p->i - aPt->i );
531 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
532 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
533
534 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0.0
535 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) )
536 {
537 min_dist = dist2;
538 retval = p;
539 }
540
541 p = p->prevZ;
542 }
543 return retval;
544 }
545
546
550 double area( const Vertex* p, const Vertex* q, const Vertex* r ) const
551 {
552 return ( q->y - p->y ) * ( r->x - q->x ) - ( q->x - p->x ) * ( r->y - q->y );
553 }
554
555
565 bool locallyInside( const Vertex* a, const Vertex* b ) const
566 {
567 if( area( a->prev, a, a->next ) < 0 )
568 return area( a, b, a->next ) >= 0 && area( a, a->prev, b ) >= 0;
569 else
570 return area( a, b, a->prev ) < 0 || area( a, a->next, b ) < 0;
571 }
572
579 Vertex* insertVertex( int aIndex, const VECTOR2I& pt, Vertex* last )
580 {
581 m_vertices.emplace_back( aIndex, pt.x, pt.y, this );
582
583 Vertex* p = &m_vertices.back();
584
585 if( !last )
586 {
587 p->prev = p;
588 p->next = p;
589 }
590 else
591 {
592 p->next = last->next;
593 p->prev = last;
594 last->next->prev = p;
595 last->next = p;
596 }
597 return p;
598 }
599
600private:
604 std::deque<Vertex> m_vertices;
605 std::set<std::pair<int, int>> m_hits;
606};
607
608
610{
611 return wxString::Format( wxT( "(%s)" ), m_drcEngine->GetBoard()->GetLayerName( aLayer ) );
612}
613
614
616{
618 return true; // Continue with other tests
619
620 if( !reportPhase( _( "Checking nets for minimum connection width..." ) ) )
621 return false; // DRC cancelled
622
623 LSET copperLayerSet = m_drcEngine->GetBoard()->GetEnabledLayers() & LSET::AllCuMask();
624 LSEQ copperLayers = copperLayerSet.Seq();
625 BOARD* board = m_drcEngine->GetBoard();
626
627 /*
628 * Build a set of distinct minWidths specified by various DRC rules. We'll run a test for
629 * each distinct minWidth, and then decide if any copper which failed that minWidth actually
630 * was required to abide by it or not.
631 */
632 std::set<int> distinctMinWidths
634
635 if( m_drcEngine->IsCancelled() )
636 return false; // DRC cancelled
637
638 struct ITEMS_POLY
639 {
640 std::set<BOARD_ITEM*> Items;
641 SHAPE_POLY_SET Poly;
642 };
643
644 std::unordered_map<NETCODE_LAYER_CACHE_KEY, ITEMS_POLY> dataset;
645 std::atomic<size_t> done( 1 );
646
647 auto calc_effort =
648 [&]( const std::set<BOARD_ITEM*>& items, PCB_LAYER_ID aLayer ) -> size_t
649 {
650 size_t effort = 0;
651
652 for( BOARD_ITEM* item : items )
653 {
654 if( item->Type() == PCB_ZONE_T )
655 {
656 ZONE* zone = static_cast<ZONE*>( item );
657 effort += zone->GetFilledPolysList( aLayer )->FullPointCount();
658 }
659 else
660 {
661 effort += 4;
662 }
663 }
664
665 return effort;
666 };
667
668 /*
669 * For each net, on each layer, build a polygonSet which contains all the copper associated
670 * with that net on that layer.
671 */
672 auto build_netlayer_polys =
673 [&]( int aNetcode, const PCB_LAYER_ID aLayer ) -> size_t
674 {
675 if( m_drcEngine->IsCancelled() )
676 return 0;
677
678 ITEMS_POLY& itemsPoly = dataset[ { aNetcode, aLayer } ];
679
680 for( BOARD_ITEM* item : itemsPoly.Items )
681 {
682 item->TransformShapeWithClearanceToPolygon( itemsPoly.Poly, aLayer, 0,
684 }
685
686 itemsPoly.Poly.Fracture( SHAPE_POLY_SET::PM_FAST );
687
688 done.fetch_add( calc_effort( itemsPoly.Items, aLayer ) );
689
690 return 1;
691 };
692
693 /*
694 * Examine all necks in a given polygonSet which fail a given minWidth.
695 */
696 auto min_checker =
697 [&]( const ITEMS_POLY& aItemsPoly, const PCB_LAYER_ID aLayer, int aMinWidth ) -> size_t
698 {
699 if( m_drcEngine->IsCancelled() )
700 return 0;
701
703
704 for( int ii = 0; ii < aItemsPoly.Poly.OutlineCount(); ++ii )
705 {
706 const SHAPE_LINE_CHAIN& chain = aItemsPoly.Poly.COutline( ii );
707
708 test.FindPairs( chain );
709 auto& ret = test.GetVertices();
710
711 for( const std::pair<int, int>& pt : ret )
712 {
713 /*
714 * We've found a neck that fails the given aMinWidth. We now need to know
715 * if the objects the produced the copper at this location are required to
716 * abide by said aMinWidth or not. (If so, we have a violation.)
717 *
718 * We find the contributingItems by hit-testing at the choke point (the
719 * centre point of the neck), and then run the rules engine on those
720 * contributingItems. If the reported constraint matches aMinWidth, then
721 * we've got a violation.
722 */
723 SEG span( chain.CPoint( pt.first ), chain.CPoint( pt.second ) );
724 VECTOR2I location = ( span.A + span.B ) / 2;
725 int dist = ( span.A - span.B ).EuclideanNorm();
726
727 std::vector<BOARD_ITEM*> contributingItems;
728
729 for( auto* item : board->m_CopperItemRTreeCache->GetObjectsAt( location,
730 aLayer,
731 aMinWidth ) )
732 {
733 if( item->HitTest( location, aMinWidth ) )
734 contributingItems.push_back( item );
735 }
736
737 for( auto& [ zone, rtree ] : board->m_CopperZoneRTreeCache )
738 {
739 if( !rtree->GetObjectsAt( location, aLayer, aMinWidth ).empty()
740 && zone->HitTestFilledArea( aLayer, location, aMinWidth ) )
741 {
742 contributingItems.push_back( zone );
743 }
744 }
745
746 if( !contributingItems.empty() )
747 {
748 BOARD_ITEM* item1 = contributingItems[0];
749 BOARD_ITEM* item2 = contributingItems.size() > 1 ? contributingItems[1]
750 : nullptr;
752 item1, item2, aLayer );
753
754 if( c.Value().Min() == aMinWidth )
755 {
757 wxString msg;
758
759 msg.Printf( _( "Minimum connection width %s; actual %s" ),
760 MessageTextFromValue( aMinWidth ),
761 MessageTextFromValue( dist ) );
762
763 drce->SetErrorMessage( msg + wxS( " " ) + layerDesc( aLayer ) );
764 drce->SetViolatingRule( c.GetParentRule() );
765
766 for( BOARD_ITEM* item : contributingItems )
767 drce->AddItem( item );
768
769 reportViolation( drce, location, aLayer );
770 }
771 }
772 }
773 }
774
775 done.fetch_add( calc_effort( aItemsPoly.Items, aLayer ) );
776
777 return 1;
778 };
779
780 for( PCB_LAYER_ID layer : copperLayers )
781 {
782 for( ZONE* zone : board->m_DRCCopperZones )
783 {
784 if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
785 dataset[ { zone->GetNetCode(), layer } ].Items.emplace( zone );
786 }
787
788 for( PCB_TRACK* track : board->Tracks() )
789 {
790 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( track ) )
791 {
792 if( via->FlashLayer( static_cast<int>( layer ) ) )
793 dataset[ { via->GetNetCode(), layer } ].Items.emplace( via );
794 }
795 else if( track->IsOnLayer( layer ) )
796 {
797 dataset[ { track->GetNetCode(), layer } ].Items.emplace( track );
798 }
799 }
800
801 for( FOOTPRINT* fp : board->Footprints() )
802 {
803 for( PAD* pad : fp->Pads() )
804 {
805 if( pad->FlashLayer( static_cast<int>( layer ) ) )
806 dataset[ { pad->GetNetCode(), layer } ].Items.emplace( pad );
807 }
808
809 // Footprint zones are also in the m_DRCCopperZones cache
810 }
811 }
812
814 std::vector<std::future<size_t>> returns;
815 size_t total_effort = 0;
816
817 for( const auto& [ netLayer, itemsPoly ] : dataset )
818 total_effort += calc_effort( itemsPoly.Items, netLayer.Layer );
819
820 total_effort += std::max( (size_t) 1, total_effort ) * distinctMinWidths.size();
821
822 returns.reserve( dataset.size() );
823
824 for( const auto& [ netLayer, itemsPoly ] : dataset )
825 {
826 returns.emplace_back( tp.submit( build_netlayer_polys, netLayer.Netcode, netLayer.Layer ) );
827 }
828
829 for( std::future<size_t>& ret : returns )
830 {
831 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
832
833 while( status != std::future_status::ready )
834 {
835 m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
836 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
837 }
838 }
839
840 returns.clear();
841 returns.reserve( dataset.size() * distinctMinWidths.size() );
842
843 for( const auto& [ netLayer, itemsPoly ] : dataset )
844 {
845 for( int minWidth : distinctMinWidths )
846 returns.emplace_back( tp.submit( min_checker, itemsPoly, netLayer.Layer, minWidth ) );
847 }
848
849 for( std::future<size_t>& ret : returns )
850 {
851 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
852
853 while( status != std::future_status::ready )
854 {
855 m_drcEngine->ReportProgress( static_cast<double>( done ) / total_effort );
856 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
857 }
858 }
859
860 return true;
861}
862
863
864namespace detail
865{
867}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
virtual void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
Definition: board_item.cpp:172
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:500
std::vector< ZONE * > m_DRCCopperZones
Definition: board.h:1157
FOOTPRINTS & Footprints()
Definition: board.h:307
std::unique_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition: board.h:1153
TRACKS & Tracks()
Definition: board.h:304
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:399
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1152
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
coord_type GetX() const
Definition: box2.h:180
MINOPTMAX< int > & Value()
Definition: drc_rule.h:140
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:143
BOARD * GetBoard() const
Definition: drc_engine.h:89
std::set< int > QueryDistinctConstraints(DRC_CONSTRAINT_T aConstraintId)
bool ReportProgress(double aProgress)
BOARD_DESIGN_SETTINGS * GetDesignSettings() const
Definition: drc_engine.h:92
bool IsErrorLimitExceeded(int error_code)
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
Definition: drc_engine.cpp:671
bool IsCancelled() const
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:325
virtual const wxString GetDescription() const override
virtual const wxString GetName() const override
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out #DRC_ITEMs and po...
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
DRC_ENGINE * m_drcEngine
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
T Min() const
Definition: minoptmax.h:33
Definition: pad.h:58
bool isSubstantial(Vertex *aA, Vertex *aB) const
Checks to see if there is a "substantial" protrusion in each polygon produced by the cut from aA to a...
Vertex * createList(const SHAPE_LINE_CHAIN &points)
Take a SHAPE_LINE_CHAIN and links each point into a circular, doubly-linked list.
bool FindPairs(const SHAPE_LINE_CHAIN &aPoly)
int32_t zOrder(const double aX, const double aY) const
Calculate the Morton code of the Vertex http://www.graphics.stanford.edu/~seander/bithacks....
double area(const Vertex *p, const Vertex *q, const Vertex *r) const
Return the twice the signed area of the triangle formed by vertices p, q, and r.
std::set< std::pair< int, int > > & GetVertices()
std::set< std::pair< int, int > > m_hits
bool locallyInside(const Vertex *a, const Vertex *b) const
Check whether the segment from vertex a -> vertex b is inside the polygon around the immediate area o...
Vertex * getKink(Vertex *aPt) const
Vertex * insertVertex(int aIndex, const VECTOR2I &pt, Vertex *last)
Create an entry in the vertices lookup and optionally inserts the newly created vertex into an existi...
POLYGON_TEST(int aLimit, int aErrorLimit)
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I::extended_type ecoord
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:50
static SEG::ecoord Square(int a)
Definition: seg.h:123
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Represent a set of closed polygons.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition: vector2d.h:300
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:691
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:596
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:303
@ DRCE_CONNECTION_WIDTH
Definition: drc_item.h:56
@ CONNECTION_WIDTH_CONSTRAINT
Definition: drc_rule.h:72
#define _(s)
E_SERIE r
Definition: eserie.cpp:41
@ ERROR_OUTSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
bool signbit(T v)
Integral version of std::signbit that works all compilers.
Definition: kicad_algo.h:197
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
Definition: bitmap.cpp:64
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool operator==(const NETCODE_LAYER_CACHE_KEY &other) const
Vertex & operator=(Vertex &&)=delete
void remove()
Remove the node from the linked list and z-ordered linked list.
void zSort()
Sort all vertices in this vertex's list by their Morton code.
Vertex & operator=(const Vertex &)=delete
void updateList()
After inserting or changing nodes, this function should be called to remove duplicate vertices and en...
Vertex(int aIndex, double aX, double aY, POLYGON_TEST *aParent)
bool operator!=(const Vertex &rhs) const
bool operator==(const Vertex &rhs) const
std::size_t operator()(const NETCODE_LAYER_CACHE_KEY &k) const
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition: thread_pool.cpp:32
static thread_pool * tp
Definition: thread_pool.cpp:30
BS::thread_pool thread_pool
Definition: thread_pool.h:30
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112