KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2024 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 <core/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 ) :
118 m_limit( aLimit )
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 ) ) != nullptr )
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 if( a->z != b->z )
256 return a->z < b->z;
257
258 if( a->x != b->x )
259 return a->x < b->x;
260
261 if( a->y != b->y )
262 return a->y < b->y;
263
264 return a->i < b->i;
265 } );
266
267 Vertex* prev_elem = nullptr;
268
269 for( Vertex* elem : queue )
270 {
271 if( prev_elem )
272 prev_elem->nextZ = elem;
273
274 elem->prevZ = prev_elem;
275 prev_elem = elem;
276 }
277
278 prev_elem->nextZ = nullptr;
279 }
280
281 const int i;
282 const double x;
283 const double y;
285
286 // previous and next vertices nodes in a polygon ring
287 Vertex* prev = nullptr;
288 Vertex* next = nullptr;
289
290 // z-order curve value
291 int32_t z = 0;
292
293 // previous and next nodes in z-order
294 Vertex* prevZ = nullptr;
295 Vertex* nextZ = nullptr;
296 };
297
303 int32_t zOrder( const double aX, const double aY ) const
304 {
305 int32_t x = static_cast<int32_t>( 32767.0 * ( aX - m_bbox.GetX() ) / m_bbox.GetWidth() );
306 int32_t y = static_cast<int32_t>( 32767.0 * ( aY - m_bbox.GetY() ) / m_bbox.GetHeight() );
307
308 x = ( x | ( x << 8 ) ) & 0x00FF00FF;
309 x = ( x | ( x << 4 ) ) & 0x0F0F0F0F;
310 x = ( x | ( x << 2 ) ) & 0x33333333;
311 x = ( x | ( x << 1 ) ) & 0x55555555;
312
313 y = ( y | ( y << 8 ) ) & 0x00FF00FF;
314 y = ( y | ( y << 4 ) ) & 0x0F0F0F0F;
315 y = ( y | ( y << 2 ) ) & 0x33333333;
316 y = ( y | ( y << 1 ) ) & 0x55555555;
317
318 return x | ( y << 1 );
319 }
320
321 constexpr bool same_point( const Vertex* aA, const Vertex* aB ) const
322 {
323 return aA && aB && aA->x == aB->x && aA->y == aB->y;
324 }
325
326 Vertex* getNextOutlineVertex( const Vertex* aPt ) const
327 {
328 Vertex* nz = aPt->nextZ;
329 Vertex* pz = aPt->prevZ;
330
331 // If we hit a fracture point, we want to continue around the
332 // edge we are working on and not switch to the pair edge
333 // However, this will depend on which direction the initial
334 // fracture hit is. If we find that we skip directly to
335 // a new fracture point, then we know that we are proceeding
336 // in the wrong direction from the fracture and should
337 // fall through to the next point
338 if( same_point( aPt, nz ) && same_point( aPt->next, nz->prev )
339 && aPt->y == aPt->next->y )
340 {
341 return nz->next;
342 }
343
344 if( same_point( aPt, pz ) && same_point( aPt->next, pz->prev )
345 && aPt->y == aPt->next->y )
346 {
347 return pz->next;
348 }
349
350 return aPt->next;
351 }
352
353 Vertex* getPrevOutlineVertex( const Vertex* aPt ) const
354 {
355 Vertex* nz = aPt->nextZ;
356 Vertex* pz = aPt->prevZ;
357
358 // If we hit a fracture point, we want to continue around the
359 // edge we are working on and not switch to the pair edge
360 // However, this will depend on which direction the initial
361 // fracture hit is. If we find that we skip directly to
362 // a new fracture point, then we know that we are proceeding
363 // in the wrong direction from the fracture and should
364 // fall through to the next point
365 if( same_point( aPt, nz )
366 && aPt->y == aPt->prev->y)
367 {
368 return nz->prev;
369 }
370
371 if( same_point( aPt, pz )
372 && aPt->y == aPt->prev->y )
373 {
374 return pz->prev;
375 }
376
377 return aPt->prev;
378
379 }
380
389 bool isSubstantial( const Vertex* aA, const Vertex* aB ) const
390 {
391 bool x_change = false;
392 bool y_change = false;
393
394 // This is a failsafe in case of invalid lists. Never check
395 // more than the total number of points in m_vertices
396 size_t checked = 0;
397 size_t total_pts = m_vertices.size();
398
399 const Vertex* p0 = aA;
400 const Vertex* p = getNextOutlineVertex( p0 );
401
402 while( !same_point( p, aB ) // We've reached the other inflection point
403 && !same_point( p, aA ) // We've gone around in a circle
404 && checked < total_pts // Fail-safe for invalid lists
405 && !( x_change && y_change ) ) // We've found a substantial change in both directions
406 {
407 double diff_x = std::abs( p->x - p0->x );
408 double diff_y = std::abs( p->y - p0->y );
409
410 // Check for a substantial change in the x or y direction
411 // This is measured by the set value of the minimum connection width
412 if( diff_x > m_limit )
413 x_change = true;
414
415 if( diff_y > m_limit )
416 y_change = true;
417
418 p = getNextOutlineVertex( p );
419
420 ++checked;
421 }
422
423 wxCHECK_MSG( checked < total_pts, false, wxT( "Invalid polygon detected. Missing points to check" ) );
424
425 if( !same_point( p, aA ) && ( !x_change || !y_change ) )
426 return false;
427
428 p = getPrevOutlineVertex( p0 );
429
430 x_change = false;
431 y_change = false;
432 checked = 0;
433
434 while( !same_point( p, aB ) // We've reached the other inflection point
435 && !same_point( p, aA ) // We've gone around in a circle
436 && checked < total_pts // Fail-safe for invalid lists
437 && !( x_change && y_change ) ) // We've found a substantial change in both directions
438 {
439 double diff_x = std::abs( p->x - p0->x );
440 double diff_y = std::abs( p->y - p0->y );
441
442 // Floating point zeros can have a negative sign, so we need to
443 // ensure that only substantive diversions count for a direction
444 // change
445 if( diff_x > m_limit )
446 x_change = true;
447
448 if( diff_y > m_limit )
449 y_change = true;
450
451 p = getPrevOutlineVertex( p );
452
453 ++checked;
454 }
455
456 wxCHECK_MSG( checked < total_pts, false, wxT( "Invalid polygon detected. Missing points to check" ) );
457
458 return ( same_point( p, aA ) || ( x_change && y_change ) );
459 }
460
465 {
466 Vertex* tail = nullptr;
467 double sum = 0.0;
468
469 // Check for winding order
470 for( int i = 0; i < points.PointCount(); i++ )
471 {
472 VECTOR2D p1 = points.CPoint( i );
473 VECTOR2D p2 = points.CPoint( i + 1 );
474
475 sum += ( ( p2.x - p1.x ) * ( p2.y + p1.y ) );
476 }
477
478 if( sum > 0.0 )
479 {
480 for( int i = points.PointCount() - 1; i >= 0; i--)
481 tail = insertVertex( i, points.CPoint( i ), tail );
482 }
483 else
484 {
485 for( int i = 0; i < points.PointCount(); i++ )
486 tail = insertVertex( i, points.CPoint( i ), tail );
487 }
488
489 if( tail && ( *tail == *tail->next ) )
490 {
491 tail->next->remove();
492 }
493
494 return tail;
495 }
496
497 Vertex* getKink( Vertex* aPt ) const
498 {
499 // The point needs to be at a concave surface
500 if( locallyInside( aPt->prev, aPt->next ) )
501 return nullptr;
502
503 // z-order range for the current point ± limit bounding box
504 const int32_t maxZ = zOrder( aPt->x + m_limit, aPt->y + m_limit );
505 const int32_t minZ = zOrder( aPt->x - m_limit, aPt->y - m_limit );
506 const SEG::ecoord limit2 = SEG::Square( m_limit );
507
508 // first look for points in increasing z-order
509 Vertex* p = aPt->nextZ;
510 SEG::ecoord min_dist = std::numeric_limits<SEG::ecoord>::max();
511 Vertex* retval = nullptr;
512
513 while( p && p->z <= maxZ )
514 {
515 int delta_i = std::abs( p->i - aPt->i );
516 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
517 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
518
519 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0
520 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) && isSubstantial( aPt, p ) )
521 {
522 min_dist = dist2;
523 retval = p;
524 }
525
526 p = p->nextZ;
527 }
528
529 p = aPt->prevZ;
530
531 while( p && p->z >= minZ )
532 {
533 int delta_i = std::abs( p->i - aPt->i );
534 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
535 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
536
537 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0
538 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) && isSubstantial( aPt, p ) )
539 {
540 min_dist = dist2;
541 retval = p;
542 }
543
544 p = p->prevZ;
545 }
546 return retval;
547 }
548
549
553 double area( const Vertex* p, const Vertex* q, const Vertex* r ) const
554 {
555 return ( q->y - p->y ) * ( r->x - q->x ) - ( q->x - p->x ) * ( r->y - q->y );
556 }
557
558
568 bool locallyInside( const Vertex* a, const Vertex* b ) const
569 {
570 const Vertex* an = getNextOutlineVertex( a );
571 const Vertex* ap = getPrevOutlineVertex( a );
572
573 if( area( ap, a, an ) < 0 )
574 return area( a, b, an ) >= 0 && area( a, ap, b ) >= 0;
575 else
576 return area( a, b, ap ) < 0 || area( a, an, b ) < 0;
577 }
578
585 Vertex* insertVertex( int aIndex, const VECTOR2I& pt, Vertex* last )
586 {
587 m_vertices.emplace_back( aIndex, pt.x, pt.y, this );
588
589 Vertex* p = &m_vertices.back();
590
591 if( !last )
592 {
593 p->prev = p;
594 p->next = p;
595 }
596 else
597 {
598 p->next = last->next;
599 p->prev = last;
600 last->next->prev = p;
601 last->next = p;
602 }
603 return p;
604 }
605
606private:
609 std::deque<Vertex> m_vertices;
610 std::set<std::pair<int, int>> m_hits;
611};
612
613
615{
616 return wxString::Format( wxT( "(%s)" ), m_drcEngine->GetBoard()->GetLayerName( aLayer ) );
617}
618
619
621{
623 return true; // Continue with other tests
624
625 if( !reportPhase( _( "Checking nets for minimum connection width..." ) ) )
626 return false; // DRC cancelled
627
628 LSET copperLayerSet = m_drcEngine->GetBoard()->GetEnabledLayers() & LSET::AllCuMask();
629 LSEQ copperLayers = copperLayerSet.Seq();
630 BOARD* board = m_drcEngine->GetBoard();
631
632 /*
633 * Build a set of distinct minWidths specified by various DRC rules. We'll run a test for
634 * each distinct minWidth, and then decide if any copper which failed that minWidth actually
635 * was required to abide by it or not.
636 */
637 std::set<int> distinctMinWidths
639
640 if( m_drcEngine->IsCancelled() )
641 return false; // DRC cancelled
642
643 struct ITEMS_POLY
644 {
645 std::set<BOARD_ITEM*> Items;
646 SHAPE_POLY_SET Poly;
647 };
648
649 std::unordered_map<NETCODE_LAYER_CACHE_KEY, ITEMS_POLY> dataset;
650 std::atomic<size_t> done( 1 );
651
652 auto calc_effort =
653 [&]( const std::set<BOARD_ITEM*>& items, PCB_LAYER_ID aLayer ) -> size_t
654 {
655 size_t effort = 0;
656
657 for( BOARD_ITEM* item : items )
658 {
659 if( item->Type() == PCB_ZONE_T )
660 {
661 ZONE* zone = static_cast<ZONE*>( item );
662 effort += zone->GetFilledPolysList( aLayer )->FullPointCount();
663 }
664 else
665 {
666 effort += 4;
667 }
668 }
669
670 return effort;
671 };
672
673 /*
674 * For each net, on each layer, build a polygonSet which contains all the copper associated
675 * with that net on that layer.
676 */
677 auto build_netlayer_polys =
678 [&]( int aNetcode, const PCB_LAYER_ID aLayer ) -> size_t
679 {
680 if( m_drcEngine->IsCancelled() )
681 return 0;
682
683 ITEMS_POLY& itemsPoly = dataset[ { aNetcode, aLayer } ];
684
685 for( BOARD_ITEM* item : itemsPoly.Items )
686 {
687 item->TransformShapeToPolygon( itemsPoly.Poly, aLayer, 0, ARC_HIGH_DEF,
689 }
690
691 itemsPoly.Poly.Fracture( SHAPE_POLY_SET::PM_FAST );
692
693 done.fetch_add( calc_effort( itemsPoly.Items, aLayer ) );
694
695 return 1;
696 };
697
698 /*
699 * Examine all necks in a given polygonSet which fail a given minWidth.
700 */
701 auto min_checker =
702 [&]( const ITEMS_POLY& aItemsPoly, const PCB_LAYER_ID aLayer, int aMinWidth ) -> size_t
703 {
704 if( m_drcEngine->IsCancelled() )
705 return 0;
706
707 POLYGON_TEST test( aMinWidth );
708
709 for( int ii = 0; ii < aItemsPoly.Poly.OutlineCount(); ++ii )
710 {
711 const SHAPE_LINE_CHAIN& chain = aItemsPoly.Poly.COutline( ii );
712
713 test.FindPairs( chain );
714 auto& ret = test.GetVertices();
715
716 for( const std::pair<int, int>& pt : ret )
717 {
718 /*
719 * We've found a neck that fails the given aMinWidth. We now need to know
720 * if the objects the produced the copper at this location are required to
721 * abide by said aMinWidth or not. (If so, we have a violation.)
722 *
723 * We find the contributingItems by hit-testing at the choke point (the
724 * centre point of the neck), and then run the rules engine on those
725 * contributingItems. If the reported constraint matches aMinWidth, then
726 * we've got a violation.
727 */
728 SEG span( chain.CPoint( pt.first ), chain.CPoint( pt.second ) );
729 VECTOR2I location = ( span.A + span.B ) / 2;
730 int dist = ( span.A - span.B ).EuclideanNorm();
731
732 std::vector<BOARD_ITEM*> contributingItems;
733
734 for( auto* item : board->m_CopperItemRTreeCache->GetObjectsAt( location,
735 aLayer,
736 aMinWidth ) )
737 {
738 if( item->HitTest( location, aMinWidth ) )
739 contributingItems.push_back( item );
740 }
741
742 for( auto& [ zone, rtree ] : board->m_CopperZoneRTreeCache )
743 {
744 if( !rtree.get() )
745 continue;
746
747 auto obj_list = rtree->GetObjectsAt( location, aLayer, aMinWidth );
748
749 if( !obj_list.empty() && zone->HitTestFilledArea( aLayer, location, aMinWidth ) )
750 {
751 contributingItems.push_back( zone );
752 }
753 }
754
755 if( !contributingItems.empty() )
756 {
757 BOARD_ITEM* item1 = contributingItems[0];
758 BOARD_ITEM* item2 = contributingItems.size() > 1 ? contributingItems[1]
759 : nullptr;
761 item1, item2, aLayer );
762
763 if( c.Value().Min() == aMinWidth + board->GetDesignSettings().GetDRCEpsilon() )
764 {
766 wxString msg;
767
768 msg = formatMsg( _( "(%s minimum connection width %s; actual %s)" ),
769 c.GetName(),
770 c.Value().Min(),
771 dist );
772
773 msg += wxS( " " ) + layerDesc( aLayer );
774
775 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
776 drce->SetViolatingRule( c.GetParentRule() );
777
778 for( BOARD_ITEM* item : contributingItems )
779 drce->AddItem( item );
780
781 reportViolation( drce, location, aLayer );
782 }
783 }
784 }
785 }
786
787 done.fetch_add( calc_effort( aItemsPoly.Items, aLayer ) );
788
789 return 1;
790 };
791
792 for( PCB_LAYER_ID layer : copperLayers )
793 {
794 for( ZONE* zone : board->m_DRCCopperZones )
795 {
796 if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
797 dataset[ { zone->GetNetCode(), layer } ].Items.emplace( zone );
798 }
799
800 for( PCB_TRACK* track : board->Tracks() )
801 {
802 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( track ) )
803 {
804 if( via->FlashLayer( static_cast<int>( layer ) ) )
805 dataset[ { via->GetNetCode(), layer } ].Items.emplace( via );
806 }
807 else if( track->IsOnLayer( layer ) )
808 {
809 dataset[ { track->GetNetCode(), layer } ].Items.emplace( track );
810 }
811 }
812
813 for( FOOTPRINT* fp : board->Footprints() )
814 {
815 for( PAD* pad : fp->Pads() )
816 {
817 if( pad->FlashLayer( static_cast<int>( layer ) ) )
818 dataset[ { pad->GetNetCode(), layer } ].Items.emplace( pad );
819 }
820
821 // Footprint zones are also in the m_DRCCopperZones cache
822 }
823 }
824
826 std::vector<std::future<size_t>> returns;
827 size_t total_effort = 0;
828
829 for( const auto& [ netLayer, itemsPoly ] : dataset )
830 total_effort += calc_effort( itemsPoly.Items, netLayer.Layer );
831
832 total_effort += std::max( (size_t) 1, total_effort ) * distinctMinWidths.size();
833
834 returns.reserve( dataset.size() );
835
836 for( const auto& [ netLayer, itemsPoly ] : dataset )
837 {
838 returns.emplace_back( tp.submit( build_netlayer_polys, netLayer.Netcode, netLayer.Layer ) );
839 }
840
841 for( std::future<size_t>& ret : returns )
842 {
843 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
844
845 while( status != std::future_status::ready )
846 {
847 reportProgress( done, total_effort );
848 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
849 }
850 }
851
852 returns.clear();
853 returns.reserve( dataset.size() * distinctMinWidths.size() );
854 int epsilon = board->GetDesignSettings().GetDRCEpsilon();
855
856 for( const auto& [ netLayer, itemsPoly ] : dataset )
857 {
858 for( int minWidth : distinctMinWidths )
859 {
860 if( ( minWidth -= epsilon ) <= 0 )
861 continue;
862
863 returns.emplace_back( tp.submit( min_checker, itemsPoly, netLayer.Layer, minWidth ) );
864 }
865 }
866
867 for( std::future<size_t>& ret : returns )
868 {
869 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
870
871 while( status != std::future_status::ready )
872 {
873 reportProgress( done, total_effort );
874 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
875 }
876 }
877
878 return true;
879}
880
881
882namespace detail
883{
885}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:120
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
Definition: board_item.cpp:205
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:677
std::vector< ZONE * > m_DRCCopperZones
Definition: board.h:1274
const FOOTPRINTS & Footprints() const
Definition: board.h:323
const TRACKS & Tracks() const
Definition: board.h:321
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition: board.h:1268
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:564
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1267
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:794
size_type GetHeight() const
Definition: box2.h:205
size_type GetWidth() const
Definition: box2.h:204
coord_type GetY() const
Definition: box2.h:198
coord_type GetX() const
Definition: box2.h:197
wxString GetName() const
Definition: drc_rule.h:149
MINOPTMAX< int > & Value()
Definition: drc_rule.h:142
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:145
BOARD * GetBoard() const
Definition: drc_engine.h:89
std::set< int > QueryDistinctConstraints(DRC_CONSTRAINT_T aConstraintId)
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:652
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:338
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_ITEM and posi...
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, double aConstraint, double aActual)
virtual bool reportPhase(const wxString &aStageName)
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
DRC_ENGINE * m_drcEngine
virtual bool reportProgress(size_t aCount, size_t aSize, size_t aDelta=1)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:521
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
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:418
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:863
T Min() const
Definition: minoptmax.h:33
Definition: pad.h:53
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)
Vertex * getNextOutlineVertex(const Vertex *aPt) const
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.
Vertex * getPrevOutlineVertex(const Vertex *aPt) const
std::set< std::pair< int, int > > & GetVertices()
std::set< std::pair< int, int > > m_hits
bool isSubstantial(const Vertex *aA, const Vertex *aB) const
Checks to see if there is a "substantial" protrusion in each polygon produced by the cut from aA to a...
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
constexpr bool same_point(const Vertex *aA, const Vertex *aB) 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...
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.
extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition: vector2d.h:276
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:710
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:615
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:337
@ DRCE_CONNECTION_WIDTH
Definition: drc_item.h:56
@ CONNECTION_WIDTH_CONSTRAINT
Definition: drc_rule.h:73
#define _(s)
@ ERROR_OUTSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
static DRC_REGISTER_TEST_PROVIDER< DRC_TEST_PROVIDER_ANNULAR_WIDTH > dummy
STL namespace.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:424
const double epsilon
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
static thread_pool * tp
Definition: thread_pool.cpp:30
BS::thread_pool thread_pool
Definition: thread_pool.h:30
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition: thread_pool.cpp:32
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:128
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107