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
507 // Subtract 1 to account for rounding inaccuracies in SquaredEuclideanNorm()
508 // below. We would usually test for rounding in the final value but since we
509 // are working in squared integers here, we allow the 1nm slop rather than
510 // force a separate calculation
511 const SEG::ecoord limit2 = SEG::Square( m_limit - 1 );
512
513 // first look for points in increasing z-order
514 Vertex* p = aPt->nextZ;
515 SEG::ecoord min_dist = std::numeric_limits<SEG::ecoord>::max();
516 Vertex* retval = nullptr;
517
518 while( p && p->z <= maxZ )
519 {
520 int delta_i = std::abs( p->i - aPt->i );
521 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
522 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
523
524 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0.0
525 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) && isSubstantial( aPt, p ) )
526 {
527 min_dist = dist2;
528 retval = p;
529 }
530
531 p = p->nextZ;
532 }
533
534 p = aPt->prevZ;
535
536 while( p && p->z >= minZ )
537 {
538 int delta_i = std::abs( p->i - aPt->i );
539 VECTOR2D diff( p->x - aPt->x, p->y - aPt->y );
540 SEG::ecoord dist2 = diff.SquaredEuclideanNorm();
541
542 if( delta_i > 1 && dist2 < limit2 && dist2 < min_dist && dist2 > 0.0
543 && locallyInside( p, aPt ) && isSubstantial( p, aPt ) && isSubstantial( aPt, p ) )
544 {
545 min_dist = dist2;
546 retval = p;
547 }
548
549 p = p->prevZ;
550 }
551 return retval;
552 }
553
554
558 double area( const Vertex* p, const Vertex* q, const Vertex* r ) const
559 {
560 return ( q->y - p->y ) * ( r->x - q->x ) - ( q->x - p->x ) * ( r->y - q->y );
561 }
562
563
573 bool locallyInside( const Vertex* a, const Vertex* b ) const
574 {
575 const Vertex* an = getNextOutlineVertex( a );
576 const Vertex* ap = getPrevOutlineVertex( a );
577
578 if( area( ap, a, an ) < 0 )
579 return area( a, b, an ) >= 0 && area( a, ap, b ) >= 0;
580 else
581 return area( a, b, ap ) < 0 || area( a, an, b ) < 0;
582 }
583
590 Vertex* insertVertex( int aIndex, const VECTOR2I& pt, Vertex* last )
591 {
592 m_vertices.emplace_back( aIndex, pt.x, pt.y, this );
593
594 Vertex* p = &m_vertices.back();
595
596 if( !last )
597 {
598 p->prev = p;
599 p->next = p;
600 }
601 else
602 {
603 p->next = last->next;
604 p->prev = last;
605 last->next->prev = p;
606 last->next = p;
607 }
608 return p;
609 }
610
611private:
614 std::deque<Vertex> m_vertices;
615 std::set<std::pair<int, int>> m_hits;
616};
617
618
620{
621 return wxString::Format( wxT( "(%s)" ), m_drcEngine->GetBoard()->GetLayerName( aLayer ) );
622}
623
624
626{
628 return true; // Continue with other tests
629
630 if( !reportPhase( _( "Checking nets for minimum connection width..." ) ) )
631 return false; // DRC cancelled
632
633 LSET copperLayerSet = m_drcEngine->GetBoard()->GetEnabledLayers() & LSET::AllCuMask();
634 LSEQ copperLayers = copperLayerSet.Seq();
635 BOARD* board = m_drcEngine->GetBoard();
636
637 /*
638 * Build a set of distinct minWidths specified by various DRC rules. We'll run a test for
639 * each distinct minWidth, and then decide if any copper which failed that minWidth actually
640 * was required to abide by it or not.
641 */
642 std::set<int> distinctMinWidths
644
645 if( m_drcEngine->IsCancelled() )
646 return false; // DRC cancelled
647
648 struct ITEMS_POLY
649 {
650 std::set<BOARD_ITEM*> Items;
651 SHAPE_POLY_SET Poly;
652 };
653
654 std::unordered_map<NETCODE_LAYER_CACHE_KEY, ITEMS_POLY> dataset;
655 std::atomic<size_t> done( 1 );
656
657 auto calc_effort =
658 [&]( const std::set<BOARD_ITEM*>& items, PCB_LAYER_ID aLayer ) -> size_t
659 {
660 size_t effort = 0;
661
662 for( BOARD_ITEM* item : items )
663 {
664 if( item->Type() == PCB_ZONE_T )
665 {
666 ZONE* zone = static_cast<ZONE*>( item );
667 effort += zone->GetFilledPolysList( aLayer )->FullPointCount();
668 }
669 else
670 {
671 effort += 4;
672 }
673 }
674
675 return effort;
676 };
677
678 /*
679 * For each net, on each layer, build a polygonSet which contains all the copper associated
680 * with that net on that layer.
681 */
682 auto build_netlayer_polys =
683 [&]( int aNetcode, const PCB_LAYER_ID aLayer ) -> size_t
684 {
685 if( m_drcEngine->IsCancelled() )
686 return 0;
687
688 ITEMS_POLY& itemsPoly = dataset[ { aNetcode, aLayer } ];
689
690 for( BOARD_ITEM* item : itemsPoly.Items )
691 {
692 item->TransformShapeToPolygon( itemsPoly.Poly, aLayer, 0, ARC_HIGH_DEF,
694 }
695
696 itemsPoly.Poly.Fracture( SHAPE_POLY_SET::PM_FAST );
697
698 done.fetch_add( calc_effort( itemsPoly.Items, aLayer ) );
699
700 return 1;
701 };
702
703 /*
704 * Examine all necks in a given polygonSet which fail a given minWidth.
705 */
706 auto min_checker =
707 [&]( const ITEMS_POLY& aItemsPoly, const PCB_LAYER_ID aLayer, int aMinWidth ) -> size_t
708 {
709 if( m_drcEngine->IsCancelled() )
710 return 0;
711
712 POLYGON_TEST test( aMinWidth );
713
714 for( int ii = 0; ii < aItemsPoly.Poly.OutlineCount(); ++ii )
715 {
716 const SHAPE_LINE_CHAIN& chain = aItemsPoly.Poly.COutline( ii );
717
718 test.FindPairs( chain );
719 auto& ret = test.GetVertices();
720
721 for( const std::pair<int, int>& pt : ret )
722 {
723 /*
724 * We've found a neck that fails the given aMinWidth. We now need to know
725 * if the objects the produced the copper at this location are required to
726 * abide by said aMinWidth or not. (If so, we have a violation.)
727 *
728 * We find the contributingItems by hit-testing at the choke point (the
729 * centre point of the neck), and then run the rules engine on those
730 * contributingItems. If the reported constraint matches aMinWidth, then
731 * we've got a violation.
732 */
733 SEG span( chain.CPoint( pt.first ), chain.CPoint( pt.second ) );
734 VECTOR2I location = ( span.A + span.B ) / 2;
735 int dist = ( span.A - span.B ).EuclideanNorm();
736
737 std::vector<BOARD_ITEM*> contributingItems;
738
739 for( auto* item : board->m_CopperItemRTreeCache->GetObjectsAt( location,
740 aLayer,
741 aMinWidth ) )
742 {
743 if( item->HitTest( location, aMinWidth ) )
744 contributingItems.push_back( item );
745 }
746
747 for( auto& [ zone, rtree ] : board->m_CopperZoneRTreeCache )
748 {
749 if( !rtree.get() )
750 continue;
751
752 auto obj_list = rtree->GetObjectsAt( location, aLayer, aMinWidth );
753
754 if( !obj_list.empty() && zone->HitTestFilledArea( aLayer, location, aMinWidth ) )
755 {
756 contributingItems.push_back( zone );
757 }
758 }
759
760 if( !contributingItems.empty() )
761 {
762 BOARD_ITEM* item1 = contributingItems[0];
763 BOARD_ITEM* item2 = contributingItems.size() > 1 ? contributingItems[1]
764 : nullptr;
766 item1, item2, aLayer );
767
768 if( c.Value().Min() == aMinWidth )
769 {
771 wxString msg;
772
773 msg = formatMsg( _( "(%s minimum connection width %s; actual %s)" ),
774 c.GetName(),
775 aMinWidth,
776 dist );
777
778 msg += wxS( " " ) + layerDesc( aLayer );
779
780 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
781 drce->SetViolatingRule( c.GetParentRule() );
782
783 for( BOARD_ITEM* item : contributingItems )
784 drce->AddItem( item );
785
786 reportViolation( drce, location, aLayer );
787 }
788 }
789 }
790 }
791
792 done.fetch_add( calc_effort( aItemsPoly.Items, aLayer ) );
793
794 return 1;
795 };
796
797 for( PCB_LAYER_ID layer : copperLayers )
798 {
799 for( ZONE* zone : board->m_DRCCopperZones )
800 {
801 if( !zone->GetIsRuleArea() && zone->IsOnLayer( layer ) )
802 dataset[ { zone->GetNetCode(), layer } ].Items.emplace( zone );
803 }
804
805 for( PCB_TRACK* track : board->Tracks() )
806 {
807 if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( track ) )
808 {
809 if( via->FlashLayer( static_cast<int>( layer ) ) )
810 dataset[ { via->GetNetCode(), layer } ].Items.emplace( via );
811 }
812 else if( track->IsOnLayer( layer ) )
813 {
814 dataset[ { track->GetNetCode(), layer } ].Items.emplace( track );
815 }
816 }
817
818 for( FOOTPRINT* fp : board->Footprints() )
819 {
820 for( PAD* pad : fp->Pads() )
821 {
822 if( pad->FlashLayer( static_cast<int>( layer ) ) )
823 dataset[ { pad->GetNetCode(), layer } ].Items.emplace( pad );
824 }
825
826 // Footprint zones are also in the m_DRCCopperZones cache
827 }
828 }
829
831 std::vector<std::future<size_t>> returns;
832 size_t total_effort = 0;
833
834 for( const auto& [ netLayer, itemsPoly ] : dataset )
835 total_effort += calc_effort( itemsPoly.Items, netLayer.Layer );
836
837 total_effort += std::max( (size_t) 1, total_effort ) * distinctMinWidths.size();
838
839 returns.reserve( dataset.size() );
840
841 for( const auto& [ netLayer, itemsPoly ] : dataset )
842 {
843 returns.emplace_back( tp.submit( build_netlayer_polys, netLayer.Netcode, netLayer.Layer ) );
844 }
845
846 for( std::future<size_t>& ret : returns )
847 {
848 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
849
850 while( status != std::future_status::ready )
851 {
852 reportProgress( done, total_effort );
853 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
854 }
855 }
856
857 returns.clear();
858 returns.reserve( dataset.size() * distinctMinWidths.size() );
859
860 for( const auto& [ netLayer, itemsPoly ] : dataset )
861 {
862 for( int minWidth : distinctMinWidths )
863 returns.emplace_back( tp.submit( min_checker, itemsPoly, netLayer.Layer, minWidth ) );
864 }
865
866 for( std::future<size_t>& ret : returns )
867 {
868 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
869
870 while( status != std::future_status::ready )
871 {
872 reportProgress( done, total_effort );
873 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
874 }
875 }
876
877 return true;
878}
879
880
881namespace detail
882{
884}
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:281
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:680
std::vector< ZONE * > m_DRCCopperZones
Definition: board.h:1272
const FOOTPRINTS & Footprints() const
Definition: board.h:322
const TRACKS & Tracks() const
Definition: board.h:320
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition: board.h:1267
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:567
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1266
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:675
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:331
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:520
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:574
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:59
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:272
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
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