21#include <boost/test/data/test_case.hpp>
52 double aMinArea,
const wxString& aLabel )
54 for(
int ii = 0; ii < aFill->OutlineCount(); ++ii )
56 const double area =
std::abs( aFill->Outline( ii ).Area() );
58 BOOST_CHECK_MESSAGE( area >= aMinArea,
59 wxString::Format(
"%s %d area %.0f IU^2 below %.0f IU^2; partial "
60 "stamps should not survive.",
61 aLabel, ii, area, aMinArea ) );
91 for(
PAD*
pad : m_board->Footprints()[0]->Pads() )
93 if(
pad->GetNumber() ==
"2" ||
pad->GetNumber() ==
"4" ||
pad->GetNumber() ==
"6" )
101 for(
PCB_TRACK* track : m_board->Tracks() )
109 arc8 = track->m_Uuid;
110 track->SetWidth( track->GetWidth() +
delta +
delta );
114 arc12 = track->m_Uuid;
120 bool foundPad2Error =
false;
121 bool foundPad4Error =
false;
122 bool foundPad6Error =
false;
123 bool foundArc8Error =
false;
124 bool foundArc12Error =
false;
125 bool foundOtherError =
false;
130 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
131 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
135 BOARD_ITEM* item_a = m_board->ResolveItem( aItem->GetMainItemID() );
136 PAD* pad_a =
dynamic_cast<PAD*
>( item_a );
139 BOARD_ITEM* item_b = m_board->ResolveItem( aItem->GetAuxItemID() );
140 PAD* pad_b =
dynamic_cast<PAD*
>( item_b );
143 if( pad_a && pad_a->
GetNumber() ==
"2" ) foundPad2Error =
true;
144 else if( pad_a && pad_a->
GetNumber() ==
"4" ) foundPad4Error =
true;
145 else if( pad_a && pad_a->
GetNumber() ==
"6" ) foundPad6Error =
true;
146 else if( pad_b && pad_b->
GetNumber() ==
"2" ) foundPad2Error =
true;
147 else if( pad_b && pad_b->
GetNumber() ==
"4" ) foundPad4Error =
true;
148 else if( pad_b && pad_b->
GetNumber() ==
"6" ) foundPad6Error =
true;
149 else if( trk_a && trk_a->
m_Uuid == arc8 ) foundArc8Error =
true;
150 else if( trk_a && trk_a->
m_Uuid == arc12 ) foundArc12Error =
true;
151 else if( trk_b && trk_b->
m_Uuid == arc8 ) foundArc8Error =
true;
152 else if( trk_b && trk_b->
m_Uuid == arc12 ) foundArc12Error =
true;
153 else foundOtherError =
true;
183 for(
ZONE* zone : m_board->Zones() )
185 if( zone->GetLayerSet().Contains(
F_Cu ) )
222 std::vector<DRC_ITEM> violations;
225 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
226 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
229 violations.push_back( *aItem );
234 if( violations.empty() )
243 std::map<KIID, EDA_ITEM*> itemMap;
244 m_board->FillItemMap( itemMap );
246 for(
const DRC_ITEM& item : violations )
249 BOOST_ERROR( wxString::Format(
"Zone fill regression: %s failed", relPath ) );
256 KI_TEST::LoadBoard( m_settingsManager,
"line_ending_zone_flood/line_ending_zone_flood", m_board );
262 std::vector<DRC_ITEM> violations;
265 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
270 violations.push_back( *aItem );
277 if( violations.empty() )
284 std::map<KIID, EDA_ITEM*> itemMap;
285 m_board->FillItemMap( itemMap );
287 for(
const DRC_ITEM& item : violations )
290 BOOST_ERROR( wxString::Format(
"Zone fill line-ending regression failed with %d clearance/shorting violations",
291 (
int) violations.size() ) );
313 ~ScopeGuard() { ref = orig; }
316 auto runDrcClearanceCheck =
317 [
this](
bool aIterative ) ->
int
328 std::vector<DRC_ITEM> violations;
330 std::map<KIID, EDA_ITEM*> itemMap;
331 m_board->FillItemMap( itemMap );
335 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
336 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
340 BOARD_ITEM* itemA = m_board->ResolveItem( aItem->GetMainItemID() );
341 BOARD_ITEM* itemB = m_board->ResolveItem( aItem->GetAuxItemID() );
343 if(
dynamic_cast<ZONE*
>( itemA ) &&
dynamic_cast<ZONE*
>( itemB ) )
345 violations.push_back( *aItem );
355 return static_cast<int>( violations.size() );
358 int iterativeViolations = runDrcClearanceCheck(
true );
360 BOOST_CHECK_MESSAGE( iterativeViolations == 0,
361 wxString::Format(
"Iterative refill produced %d zone-to-zone clearance "
362 "violations (expected 0)", iterativeViolations ) );
364 int nonIterativeViolations = runDrcClearanceCheck(
false );
366 BOOST_CHECK_MESSAGE( nonIterativeViolations == 0,
367 wxString::Format(
"Non-iterative refill produced %d zone-to-zone clearance "
368 "violations (expected 0)", nonIterativeViolations ) );
386 std::vector<DRC_ITEM> violations;
389 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
390 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
393 violations.push_back( *aItem );
398 if( violations.empty() )
401 BOOST_TEST_MESSAGE( wxString::Format(
"Zone fill copper sliver regression: %s passed", relPath ) );
407 std::map<KIID, EDA_ITEM*> itemMap;
408 m_board->FillItemMap( itemMap );
410 for(
const DRC_ITEM& item : violations )
413 BOOST_ERROR( wxString::Format(
"Zone fill copper sliver regression: %s failed", relPath ) );
419 {
"teardrop_issue_JPC2", 5 },
426 const wxString& relPath =
test.first;
427 const int count =
test.second;
434 for(
ZONE* zone : m_board->Zones() )
436 if( zone->IsTeardropArea() )
440 BOOST_CHECK_MESSAGE( zoneCount == count,
"Expected " << count <<
" teardrop zones in " << relPath <<
", found "
448 std::vector<wxString> tests = { {
"issue19956/issue19956" }
451 for(
const wxString& relPath : tests )
456 for(
ZONE* zone : m_board->Zones() )
460 std::shared_ptr<SHAPE> a_shape( zone->GetEffectiveShape( layer ) );
462 for(
PAD*
pad : m_board->GetPads() )
464 std::shared_ptr<SHAPE> pad_shape(
pad->GetEffectiveShape( layer ) );
465 int clearance = pad_shape->GetClearance( a_shape.get() );
466 BOOST_CHECK_MESSAGE(
pad->GetNetCode() == zone->GetNetCode() ||
clearance != 0,
467 wxString::Format(
"Pad %s from Footprint %s has net code %s and "
468 "is connected to zone with net code %s",
470 pad->GetParentFootprint()->GetReferenceAsString(),
472 zone->GetNetname() ) );
506 ~ScopeGuard() { ref = orig; }
514 ZONE* gndZone =
nullptr;
516 for(
ZONE* zone : m_board->Zones() )
518 if( zone->GetNetname() ==
"GND" )
525 BOOST_REQUIRE_MESSAGE( gndZone !=
nullptr,
"GND zone not found in test board" );
529 bool hasOutline = m_board->GetBoardPolygonOutlines( boardOutline,
true );
530 BOOST_REQUIRE_MESSAGE( hasOutline,
"Board outline not found" );
532 double boardArea = 0.0;
543 double fillRatio = gndFilledArea / boardArea;
545 BOOST_TEST_MESSAGE( wxString::Format(
"Board area: %.2f sq mm, GND filled area: %.2f sq mm, Fill ratio: %.1f%%",
548 fillRatio * 100.0 ) );
550 BOOST_CHECK_MESSAGE( fillRatio >= 0.25,
551 wxString::Format(
"GND zone fill ratio %.1f%% is less than expected 25%%. This indicates "
552 "issue 21746 - lower priority zones not filling areas where higher "
553 "priority isolated islands were removed.",
554 fillRatio * 100.0 ) );
579 int viasWithUnreachableFlashing = 0;
580 int totalConditionalVias = 0;
582 PCB_LAYER_ID in1Cu = m_board->GetLayerID( wxT(
"In1.Cu" ) );
583 PCB_LAYER_ID in2Cu = m_board->GetLayerID( wxT(
"In2.Cu" ) );
585 for(
PCB_TRACK* track : m_board->Tracks() )
592 if( !
via->GetRemoveUnconnected() )
595 totalConditionalVias++;
598 bool flashedOnIn1 =
via->FlashLayer( in1Cu );
599 bool flashedOnIn2 =
via->FlashLayer( in2Cu );
601 if( !flashedOnIn1 && !flashedOnIn2 )
605 int holeRadius =
via->GetDrillValue() / 2;
608 bool zoneReachesVia =
false;
610 for(
ZONE* zone : m_board->Zones() )
612 if( zone->GetIsRuleArea() )
615 if( zone->GetNetCode() !=
via->GetNetCode() )
620 if( !zone->IsOnLayer( layer ) )
623 if( !zone->HasFilledPolysForLayer( layer ) )
626 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
628 if( fill->Contains( viaCenter, -1, holeRadius ) )
630 zoneReachesVia =
true;
640 if( !zoneReachesVia && ( flashedOnIn1 || flashedOnIn2 ) )
641 viasWithUnreachableFlashing++;
644 BOOST_TEST_MESSAGE( wxString::Format(
"Total conditional vias: %d, Vias with unreachable flashing: %d",
645 totalConditionalVias,
646 viasWithUnreachableFlashing ) );
648 BOOST_CHECK_MESSAGE( viasWithUnreachableFlashing == 0,
649 wxString::Format(
"Found %d vias flashed on zone layers where the zone fill doesn't "
650 "actually reach them. This indicates issue 22010 is not fixed.",
651 viasWithUnreachableFlashing ) );
673 int viasShortingZones = 0;
674 int totalConditionalVias = 0;
676 for(
PCB_TRACK* track : m_board->Tracks() )
683 if( !
via->GetRemoveUnconnected() )
686 totalConditionalVias++;
690 for(
ZONE* zone : m_board->Zones() )
692 if( zone->GetIsRuleArea() )
695 if( zone->GetNetCode() ==
via->GetNetCode() )
700 if( !
via->FlashLayer( layer ) )
703 if( !zone->HasFilledPolysForLayer( layer ) )
706 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
707 int viaRadius =
via->GetWidth( layer ) / 2;
709 if( fill->Contains( viaCenter, -1, viaRadius ) )
711 BOOST_TEST_MESSAGE( wxString::Format(
"Via at (%d, %d) on net %s is flashing on layer %s where "
712 "zone net %s is filled - this creates a short!",
713 viaCenter.
x, viaCenter.
y,
715 m_board->GetLayerName( layer ),
716 zone->GetNetname() ) );
723 BOOST_TEST_MESSAGE( wxString::Format(
"Total conditional vias: %d, Vias shorting zones: %d",
724 totalConditionalVias,
725 viasShortingZones ) );
727 BOOST_CHECK_MESSAGE( viasShortingZones == 0,
728 wxString::Format(
"Found %d vias flashed on layers where they short to zones with "
729 "different nets. This indicates issue 12964 is not fixed.",
730 viasShortingZones ) );
748 KI_TEST::LoadBoard( m_settingsManager,
"hatch_thermal_connectivity/hatch_thermal_connectivity",
753 m_board->BuildConnectivity();
755 int unconnectedCount = m_board->GetConnectivity()->GetUnconnectedCount(
false );
757 BOOST_CHECK_MESSAGE( unconnectedCount == 0,
758 wxString::Format(
"Found %d unconnected items after zone fill. Hatch zone thermal "
759 "reliefs should maintain connectivity even with large hatch gaps.",
760 unconnectedCount ) );
784 PCB_LAYER_ID in1Cu = m_board->GetLayerID( wxT(
"In1.Cu" ) );
786 ZONE* gndZone =
nullptr;
788 for(
ZONE* zone : m_board->Zones() )
790 if( zone->GetNetname() ==
"GND" && zone->IsOnLayer( in1Cu ) )
797 BOOST_REQUIRE_MESSAGE( gndZone !=
nullptr,
"GND zone on In1.Cu not found in test board" );
812 double zoneOutlineArea = gndZone->
Outline()->
Area();
814 BOOST_REQUIRE_MESSAGE( zoneOutlineArea > 0.0,
"Zone outline area must be positive" );
816 double fillArea = 0.0;
818 for(
int i = 0; i < fill->OutlineCount(); i++ )
819 fillArea +=
std::abs( fill->Outline( i ).Area() );
821 double fillRatio = fillArea / zoneOutlineArea;
825 BOOST_CHECK_GE( fillRatio, 0.90 );
852 ~ScopeGuard() { ref = orig; }
860 std::vector<ZONE*> keepouts;
862 for(
ZONE* zone : m_board->Zones() )
864 if( zone->GetIsRuleArea() && zone->GetDoNotAllowZoneFills() )
865 keepouts.push_back( zone );
868 BOOST_REQUIRE_MESSAGE( !keepouts.empty(),
"No zone keepouts found in test board" );
871 int violationCount = 0;
873 for(
ZONE* keepout : keepouts )
875 for(
PCB_LAYER_ID layer : keepout->GetLayerSet().Seq() )
880 for(
ZONE* zone : m_board->Zones() )
882 if( zone->GetIsRuleArea() )
885 if( !zone->IsOnLayer( layer ) )
888 if( !zone->HasFilledPolysForLayer( layer ) )
891 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
899 double intersectionArea = 0;
905 if( intersectionArea > 1e6 )
907 BOOST_TEST_MESSAGE( wxString::Format(
"Zone %s fill on layer %s overlaps keepout by %.2f sq mm",
909 m_board->GetLayerName( layer ),
910 intersectionArea / 1e6 ) );
918 BOOST_CHECK_MESSAGE( violationCount == 0,
919 wxString::Format(
"Found %d zone fills overlapping keepout areas. This indicates "
920 "issue 22809 - iterative refiller ignores zone keepouts.",
944 PCB_LAYER_ID in2Cu = m_board->GetLayerID( wxT(
"In2.Cu" ) );
945 int padsWithMissingFlashing = 0;
946 int totalConditionalPads = 0;
948 for(
FOOTPRINT* footprint : m_board->Footprints() )
950 for(
PAD*
pad : footprint->Pads() )
952 if( !
pad->GetRemoveUnconnected() )
955 if( !
pad->HasHole() )
958 if(
pad->GetNetname() !=
"VBUS_DUT" &&
pad->GetNetname() !=
"VBUS_DBG" )
961 totalConditionalPads++;
964 bool shouldFlash =
false;
966 for(
ZONE* zone : m_board->Zones() )
968 if( zone->GetIsRuleArea() )
971 if( zone->GetNetCode() !=
pad->GetNetCode() )
974 if( !zone->IsOnLayer( in2Cu ) )
977 if( zone->Outline()->Contains(
pad->GetPosition() ) )
984 if( shouldFlash && !
pad->FlashLayer( in2Cu ) )
986 BOOST_TEST_MESSAGE( wxString::Format(
"Pad %s at (%d, %d) on net %s is inside zone but not flashing "
989 pad->GetPosition().x,
990 pad->GetPosition().y,
991 pad->GetNetname() ) );
992 padsWithMissingFlashing++;
997 BOOST_TEST_MESSAGE( wxString::Format(
"Total conditional pads: %d, Pads with missing flashing: %d",
998 totalConditionalPads,
999 padsWithMissingFlashing ) );
1001 BOOST_CHECK_MESSAGE( padsWithMissingFlashing == 0,
1002 wxString::Format(
"Found %d TH pads that should flash on inner layers but don't. This "
1003 "indicates issue 22826 is not fixed.",
1004 padsWithMissingFlashing ) );
1023 const PCB_LAYER_ID innerLayers[] = { m_board->GetLayerID( wxT(
"In1.Cu" ) ),
1024 m_board->GetLayerID( wxT(
"In2.Cu" ) ) };
1026 int padsWithMissingFlashing = 0;
1027 int totalConditionalPads = 0;
1029 for(
FOOTPRINT* footprint : m_board->Footprints() )
1031 for(
PAD*
pad : footprint->Pads() )
1033 if( !
pad->GetRemoveUnconnected() || !
pad->HasHole() )
1038 bool shouldFlash =
false;
1040 for(
ZONE* zone : m_board->Zones() )
1042 if( zone->GetIsRuleArea() || zone->GetNetCode() !=
pad->GetNetCode() )
1045 if( !zone->IsOnLayer( layer ) )
1048 if( zone->Outline()->Contains(
pad->GetPosition() ) )
1058 totalConditionalPads++;
1060 if( !
pad->FlashLayer( layer ) )
1063 wxString::Format(
"Pad %s (drill %.2f mm, spoke angle %.0f deg) on net %s is inside the "
1064 "zone but not flashing on %s",
1067 pad->GetThermalSpokeAngle().AsDegrees(),
1069 m_board->GetLayerName( layer ) ) );
1070 padsWithMissingFlashing++;
1076 BOOST_TEST_MESSAGE( wxString::Format(
"Pads inside inner-layer zones: %d, missing flashing: %d",
1077 totalConditionalPads,
1078 padsWithMissingFlashing ) );
1080 BOOST_CHECK_MESSAGE( padsWithMissingFlashing == 0,
1081 wxString::Format(
"Found %d TH pads inside a same-net inner-layer zone that lost their "
1082 "annular ring after fill. This indicates issue 24865 is not fixed.",
1083 padsWithMissingFlashing ) );
1101 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1111 if( !commit.
Empty() )
1115 int teardropCount = 0;
1116 bool foundBadTeardrop =
false;
1118 for(
ZONE* zone : m_board->Zones() )
1120 if( !zone->IsTeardropArea() )
1137 int concaveCount = 0;
1139 for(
int i = 0; i <
chain.PointCount(); i++ )
1141 int prev = ( i == 0 ) ?
chain.PointCount() - 1 : i - 1;
1142 int next = ( i + 1 ) %
chain.PointCount();
1148 int64_t cross = (int64_t)
v1.x *
v2.y - (int64_t)
v1.y *
v2.x;
1158 if( concaveCount > 5 )
1160 BOOST_TEST_MESSAGE( wxString::Format(
"Teardrop has %d concave vertices, indicating possible corner "
1163 foundBadTeardrop =
true;
1167 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone" );
1169 BOOST_CHECK_MESSAGE( !foundBadTeardrop,
"Found teardrop with excessive concave vertices, indicating "
1170 "issue 19405 - teardrop curve intersecting rounded rectangle corner" );
1184 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1193 if( !commit.
Empty() )
1196 int teardropCount = 0;
1197 bool foundSpike =
false;
1199 const int maxError = m_board->GetDesignSettings().m_MaxError;
1201 for(
ZONE* zone : m_board->Zones() )
1203 if( !zone->IsTeardropArea() )
1209 int netcode = zone->GetNetCode();
1217 for(
FOOTPRINT* fp : m_board->Footprints() )
1219 for(
PAD*
pad : fp->Pads() )
1221 if(
pad->GetNetCode() == netcode &&
pad->IsOnLayer( layer ) )
1222 pad->TransformShapeToPolygon( corridor, layer, 0, maxError,
ERROR_OUTSIDE );
1226 for(
PCB_TRACK* track : m_board->Tracks() )
1228 if( track->GetNetCode() == netcode && track->IsOnLayer( layer ) )
1229 track->TransformShapeToPolygon( corridor, layer, 0, maxError,
ERROR_OUTSIDE );
1241 double tdArea =
std::abs( zone->Outline()->Area() );
1243 double ratio = tdArea > 0 ? outArea / tdArea : 0.0;
1245 BOOST_TEST_MESSAGE( wxString::Format(
"Teardrop on layer %d: area %.0f, area outside corridor %.0f (%.1f%%)",
1254 BOOST_TEST_MESSAGE( wxString::Format(
"Teardrop on layer %d sweeps %.1f%% of its area outside the "
1255 "track/pad corridor (spike)",
1261 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone" );
1262 BOOST_CHECK_MESSAGE( !foundSpike,
"A teardrop vertex spikes outside the track/pad corridor it should follow" );
1279 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1288 if( !commit.
Empty() )
1295 for(
FOOTPRINT* fp : m_board->Footprints() )
1297 for(
PAD*
pad : fp->Pads() )
1302 maxReach = std::max( maxReach, prms.
m_TdMaxLen + std::min( size.
x, size.
y ) );
1308 int teardropCount = 0;
1309 bool foundSpike =
false;
1311 for(
ZONE* zone : m_board->Zones() )
1313 if( !zone->IsTeardropArea() )
1320 for(
const VECTOR2I& pt : zone->Outline()->Outline( 0 ).CPoints() )
1322 SEG::ecoord bestSq = std::numeric_limits<SEG::ecoord>::max();
1324 for(
PCB_TRACK* track : m_board->Tracks() )
1326 if( !track->IsOnLayer( layer ) )
1329 bestSq = std::min( bestSq,
SEG( track->GetStart(), track->GetEnd() ).
SquaredDistance( pt ) );
1332 double dist = std::sqrt( (
double) bestSq );
1334 if( dist > maxReach )
1337 BOOST_TEST_MESSAGE( wxString::Format(
"Teardrop vertex (%.4f, %.4f) is %.4f mm from the nearest "
1338 "track, max allowed %.4f mm",
1348 BOOST_CHECK_MESSAGE( teardropCount == 2, wxString::Format(
"Expected a teardrop on each of the two pads covering "
1349 "the track end, found %d",
1351 BOOST_CHECK_MESSAGE( !foundSpike,
"A teardrop reaches far past its anchor track, indicating it was built around "
1352 "the custom pad's anchor position instead of the copper the track enters" );
1361 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1370 if( !commit.
Empty() )
1374 BOOST_REQUIRE( !m_board->Footprints().front()->Pads().empty() );
1376 PAD*
pad = m_board->Footprints().front()->Pads().front();
1378 const int minEdgeLen = 2 * m_board->GetDesignSettings().m_MaxError;
1380 int teardropCount = 0;
1382 for(
ZONE* zone : m_board->Zones() )
1384 if( !zone->IsTeardropArea() )
1394 for(
int ii = 0; ii <
chain.SegmentCount(); ii++ )
1398 if( seg.
Length() < minEdgeLen )
1403 if( distSq > bestSq )
1412 for(
const VECTOR2I& pt : { throat.
A, throat.
B } )
1414 bool onTrack =
false;
1416 for(
PCB_TRACK* track : m_board->Tracks() )
1417 onTrack |= track->HitTest( pt, 0 );
1419 BOOST_CHECK_MESSAGE( onTrack, wxString::Format(
"Teardrop anchor (%.6f, %.6f) mm is off the "
1425 BOOST_CHECK_MESSAGE( teardropCount == 1, wxString::Format(
"Expected 1 teardrop zone, found %d", teardropCount ) );
1442 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1452 if( !commit.
Empty() )
1456 int teardropCount = 0;
1457 bool foundBadTeardrop =
false;
1459 for(
ZONE* zone : m_board->Zones() )
1461 if( !zone->IsTeardropArea() )
1475 int concaveCount = 0;
1477 for(
int i = 0; i <
chain.PointCount(); i++ )
1479 int prev = ( i == 0 ) ?
chain.PointCount() - 1 : i - 1;
1480 int next = ( i + 1 ) %
chain.PointCount();
1485 int64_t cross = (int64_t)
v1.x *
v2.y - (int64_t)
v1.y *
v2.x;
1491 if( concaveCount > 5 )
1493 BOOST_TEST_MESSAGE( wxString::Format(
"Oval teardrop has %d concave vertices", concaveCount ) );
1494 foundBadTeardrop =
true;
1498 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone" );
1500 BOOST_CHECK_MESSAGE( !foundBadTeardrop,
"Found teardrop with excessive concave vertices on oval pad, "
1501 "indicating curve is not tangent to semicircular end" );
1518 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
1528 if( !commit.
Empty() )
1532 PAD* largePad =
nullptr;
1534 for(
FOOTPRINT* fp : m_board->Footprints() )
1536 for(
PAD*
pad : fp->Pads() )
1546 BOOST_REQUIRE_MESSAGE( largePad !=
nullptr,
"Expected a circular pad in test board" );
1552 int teardropCount = 0;
1553 bool foundBadTeardrop =
false;
1555 for(
ZONE* zone : m_board->Zones() )
1557 if( !zone->IsTeardropArea() )
1570 int concaveCount = 0;
1572 for(
int i = 0; i <
chain.PointCount(); i++ )
1574 int prev = ( i == 0 ) ?
chain.PointCount() - 1 : i - 1;
1575 int next = ( i + 1 ) %
chain.PointCount();
1580 int64_t cross = (int64_t)
v1.x *
v2.y - (int64_t)
v1.y *
v2.x;
1586 if( concaveCount > 5 )
1588 BOOST_TEST_MESSAGE( wxString::Format(
"Large circle teardrop has %d concave vertices", concaveCount ) );
1589 foundBadTeardrop =
true;
1594 int maxError = m_board->GetDesignSettings().m_MaxError;
1596 for(
int i = 0; i <
chain.PointCount(); i++ )
1599 double dist = ( pt - padCenter ).EuclideanNorm();
1602 if( dist > padRadius * 0.5 && dist < padRadius * 1.5 )
1604 double deviation =
std::abs( dist - padRadius );
1607 if( deviation > maxError * 5 && deviation < padRadius * 0.2 )
1610 "Teardrop point at distance %.2f from pad center (radius %.2f), "
1611 "deviation %.2f exceeds tolerance",
1612 dist / 1000.0, padRadius / 1000.0, deviation / 1000.0 ) );
1618 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone" );
1620 BOOST_CHECK_MESSAGE( !foundBadTeardrop,
1621 "Found teardrop with excessive concave vertices on large circle, "
1622 "indicating anchor points may not be on circle edge" );
1646 for(
ZONE* zone : m_board->Zones() )
1648 if( zone->GetIsRuleArea() )
1653 if( !zone->HasFilledPolysForLayer( layer ) )
1656 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
1658 for(
PAD*
pad : m_board->GetPads() )
1660 if( !
pad->IsOnLayer( layer ) )
1663 if(
pad->GetNetCode() == zone->GetNetCode() )
1666 std::shared_ptr<SHAPE> padShape =
pad->GetEffectiveShape( layer );
1667 int clearance = padShape->GetClearance( fill.get() );
1672 "Pad %s (net %s) at (%d, %d) has zero clearance to zone %s "
1674 pad->GetNumber(),
pad->GetNetname(),
1675 pad->GetPosition().x,
pad->GetPosition().y,
1676 zone->GetNetname(), m_board->GetLayerName( layer ) ) );
1683 BOOST_CHECK_MESSAGE( violations == 0,
1684 wxString::Format(
"Found %d pads with missing zone clearance. "
1685 "Coincident pads with different nets must not be "
1686 "deduplicated in zone fill knockout.",
1708 std::vector<DRC_ITEM> violations;
1713 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
1714 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
1718 BOARD_ITEM* item_a = m_board->ResolveItem( aItem->GetMainItemID() );
1719 BOARD_ITEM* item_b = m_board->ResolveItem( aItem->GetAuxItemID() );
1721 ZONE* zone_a =
dynamic_cast<ZONE*
>( item_a );
1722 ZONE* zone_b =
dynamic_cast<ZONE*
>( item_b );
1724 if( zone_a || zone_b )
1725 violations.push_back( *aItem );
1752 ZONE* hvZone =
nullptr;
1753 ZONE* lvZone =
nullptr;
1755 for(
ZONE* zone : m_board->Zones() )
1757 if( zone->GetNetname() ==
"HV_NET" )
1759 else if( zone->GetNetname() ==
"LV_NET" )
1770 <<
" (expected " <<
pcbIUScale.mmToIU( 4.6 ) <<
")" );
1777 <<
" (expected " <<
pcbIUScale.mmToIU( 2.3 ) <<
")" );
1784 std::vector<DRC_ITEM> violations;
1789 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
1790 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
1794 BOARD_ITEM* item_a = m_board->ResolveItem( aItem->GetMainItemID() );
1795 BOARD_ITEM* item_b = m_board->ResolveItem( aItem->GetAuxItemID() );
1797 ZONE* zone_a =
dynamic_cast<ZONE*
>( item_a );
1798 ZONE* zone_b =
dynamic_cast<ZONE*
>( item_b );
1800 if( zone_a && zone_b )
1803 << aLayer <<
": " << aItem->GetErrorMessage(
true ) );
1804 violations.push_back( *aItem );
1817 KI_TEST::LoadBoard( m_settingsManager,
"issue23332_min_width/issue23332_min_width", m_board );
1823 for(
ZONE* zone : m_board->Zones() )
1825 int half_min_width = zone->GetMinThickness() / 2;
1832 if( !zone->HasFilledPolysForLayer( layer ) )
1835 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
1837 if( !fill || fill->OutlineCount() == 0 )
1842 for(
int ii = 0; ii < fill->OutlineCount(); ii++ )
1847 for(
int jj = 0; jj < fill->HoleCount( ii ); jj++ )
1848 island.
AddHole( fill->Hole( ii, jj ) );
1850 double originalArea = island.
Area();
1852 if( originalArea <= 0 )
1861 double prunedArea =
test.Area();
1862 double areaLoss = ( originalArea - prunedArea ) / originalArea;
1864 BOOST_TEST_MESSAGE( wxString::Format(
"Zone %s layer %d island %d: area=%.0f, loss=%.4f%%",
1866 static_cast<int>( layer ),
1869 areaLoss * 100.0 ) );
1871 BOOST_CHECK_MESSAGE( areaLoss < 0.01,
1872 wxString::Format(
"Zone %s layer %d island %d lost %.2f%% area from "
1873 "min-width pruning (min_width=%.3fmm)",
1875 static_cast<int>( layer ),
1878 zone->GetMinThickness() / (
double)
pcbIUScale.IU_PER_MM ) );
1893 for(
ZONE* zone : m_board->Zones() )
1895 int half_min_width = zone->GetMinThickness() / 2;
1902 if( !zone->HasFilledPolysForLayer( layer ) )
1905 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
1907 if( !fill || fill->OutlineCount() == 0 )
1910 for(
int ii = 0; ii < fill->OutlineCount(); ii++ )
1915 for(
int jj = 0; jj < fill->HoleCount( ii ); jj++ )
1916 island.
AddHole( fill->Hole( ii, jj ) );
1918 double originalArea = island.
Area();
1920 if( originalArea <= 0 )
1929 double prunedArea =
test.Area();
1930 double areaLoss = ( originalArea - prunedArea ) / originalArea;
1932 BOOST_CHECK_MESSAGE( areaLoss < 0.01,
1933 wxString::Format(
"Zone %s (priority %d) layer %d island %d lost %.2f%% area "
1934 "from min-width pruning, suggesting degenerate geometry "
1935 "from overlapping same-net zones",
1937 zone->GetAssignedPriority(),
1938 static_cast<int>( layer ),
1940 areaLoss * 100.0 ) );
1956 ~ScopeGuard() { ref = orig; }
1959 auto runAreaLossCheck =
1960 [
this](
bool aIterative )
1970 for(
ZONE* zone : m_board->Zones() )
1972 int half_min_width = zone->GetMinThickness() / 2;
1979 if( !zone->HasFilledPolysForLayer( layer ) )
1982 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
1984 if( !fill || fill->OutlineCount() == 0 )
1987 for(
int ii = 0; ii < fill->OutlineCount(); ii++ )
1992 for(
int jj = 0; jj < fill->HoleCount( ii ); jj++ )
1993 island.
AddHole( fill->Hole( ii, jj ) );
1995 double originalArea = island.
Area();
1997 if( originalArea <= 0 )
2008 double prunedArea =
test.Area();
2009 double areaLoss = ( originalArea - prunedArea ) / originalArea;
2011 BOOST_CHECK_MESSAGE( areaLoss < 0.01,
2012 wxString::Format(
"Zone %s (priority %d) layer %d island %d lost "
2013 "%.2f%% area (iterative=%d), suggesting degenerate "
2014 "geometry from different-net zone knockouts",
2016 zone->GetAssignedPriority(),
2017 static_cast<int>( layer ),
2026 runAreaLossCheck(
false );
2027 runAreaLossCheck(
true );
2056 ~ScopeGuard() { ref = orig; }
2059 KI_TEST::LoadBoard( m_settingsManager,
"issue23535_minimal/issue23535_minimal", m_board );
2063 ZONE* gndZone =
nullptr;
2065 for(
ZONE* zone : m_board->Zones() )
2067 if( zone->GetNetname() ==
"GND" )
2085 bool hasSpokeToNowhere = gndFill->Contains( spokeTestPoint );
2087 BOOST_CHECK_MESSAGE( !hasSpokeToNowhere,
"GND zone fill contains copper at the thermal gap test point (7.4, 5.0), "
2088 "indicating a thermal relief spoke to nowhere (issue 23535)." );
2095 bool hasValidSpoke = gndFill->Contains( validSpokePoint );
2097 BOOST_CHECK_MESSAGE( hasValidSpoke,
"GND zone fill does not contain copper at the valid spoke test point "
2098 "(5.6, 5.0). The fix may have incorrectly removed valid spokes." );
2116 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2125 if( !commit.
Empty() )
2133 int teardropCount = 0;
2135 for(
ZONE* zone : m_board->Zones() )
2137 if( !zone->IsTeardropArea() )
2155 for(
int i = 0; i <
chain.PointCount(); i++ )
2157 int dy =
chain.CPoint( i ).y - trackY;
2160 maxAbove = std::max( maxAbove, -dy );
2162 maxBelow = std::max( maxBelow, dy );
2166 BOOST_CHECK_MESSAGE( maxAbove > 0 && maxBelow > 0,
2167 "Teardrop should extend on both sides of the track axis" );
2169 if( maxAbove > 0 && maxBelow > 0 )
2173 double ratio =
static_cast<double>( std::min( maxAbove, maxBelow ) )
2174 /
static_cast<double>( std::max( maxAbove, maxBelow ) );
2176 BOOST_CHECK_MESSAGE( ratio > 0.7,
2177 wxString::Format(
"Teardrop asymmetry ratio %.2f is too low (above=%d, below=%d). "
2178 "Expected roughly symmetric about the track axis.",
2185 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone for off-center track" );
2202 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2211 if( !commit.
Empty() )
2217 PAD* testPad =
nullptr;
2219 for(
FOOTPRINT* fp : m_board->Footprints() )
2221 for(
PAD*
pad : fp->Pads() )
2223 if(
pad->GetNumber() ==
"7" )
2231 BOOST_REQUIRE_MESSAGE( testPad !=
nullptr,
"Could not find pad 7 in test board" );
2234 int tolerance = std::max( m_board->GetDesignSettings().m_MaxError,
pcbIUScale.mmToIU( 0.001 ) );
2239 int teardropCount = 0;
2241 for(
ZONE* zone : m_board->Zones() )
2243 if( !zone->IsTeardropArea() )
2248 BOOST_REQUIRE_MESSAGE( outline && outline->
OutlineCount() > 0,
"Teardrop zone has no outline" );
2262 for(
int i = 0; i <
chain.PointCount(); i++ )
2265 double distToPad = (
VECTOR2D( pt ) -
VECTOR2D( padCenter ) ).EuclideanNorm();
2266 double distToTrack = (
VECTOR2D( pt ) -
VECTOR2D( trackAnchor ) ).EuclideanNorm();
2269 if( distToPad < distToTrack )
2271 BOOST_CHECK_MESSAGE( padPoly.
Contains( pt ),
2272 wxString::Format(
"Teardrop vertex (%d, %d) is outside the pad outline with "
2280 BOOST_CHECK_MESSAGE( teardropCount > 0,
"Expected at least one teardrop zone for elongated pad" );
2295 [&](
bool aCurvedEdges )
2299 for(
PCB_TRACK* track : m_board->Tracks() )
2303 static_cast<PCB_VIA*
>( track )->SetTeardropCurved( aCurvedEdges );
2309 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2318 if( !commit.
Empty() )
2321 int teardropCount = 0;
2322 bool foundSelfIntersection =
false;
2324 for(
ZONE* zone : m_board->Zones() )
2326 if( !zone->IsTeardropArea() )
2337 int n =
chain.PointCount();
2339 for(
int i = 0; i < n && !foundSelfIntersection; i++ )
2341 SEG segA(
chain.CPoint( i ),
chain.CPoint( ( i + 1 ) % n ) );
2343 for(
int j = i + 2; j < n; j++ )
2345 if( i == 0 && j == n - 1 )
2348 SEG segB(
chain.CPoint( j ),
chain.CPoint( ( j + 1 ) % n ) );
2351 if( hit.has_value() )
2354 "%d and %d (curved=%s)",
2358 aCurvedEdges ?
"yes" :
"no" ) );
2360 for(
int k = 0; k < n; k++ )
2363 chain.CPoint( k ).x,
chain.CPoint( k ).y ) );
2366 foundSelfIntersection =
true;
2373 BOOST_CHECK_MESSAGE( teardropCount > 0,
2374 wxString::Format(
"Expected at least one teardrop zone (curved=%s)",
2375 aCurvedEdges ?
"yes" :
"no" ) );
2377 BOOST_CHECK_MESSAGE( !foundSelfIntersection,
2378 wxString::Format(
"Teardrop polygon has self-intersecting edges (curved=%s)",
2379 aCurvedEdges ?
"yes" :
"no" ) );
2383 runVariant(
false );
2407 auto runVariant = [&](
bool aCurvedEdges )
2414 for(
PCB_TRACK* track : m_board->Tracks() )
2420 via->SetTeardropCurved( aCurvedEdges );
2421 viaPos =
via->GetPosition();
2430 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2439 if( !commit.
Empty() )
2444 const double maxBackSideDist = viaRadius * 1.2;
2445 int teardropCount = 0;
2446 int spikingPoints = 0;
2448 double worstDistance = 0.0;
2450 for(
ZONE* zone : m_board->Zones() )
2452 if( !zone->IsTeardropArea() )
2464 for(
int i = 0; i <
chain.PointCount(); i++ )
2475 if( dist > maxBackSideDist )
2479 if( dist > worstDistance )
2481 worstDistance = dist;
2488 BOOST_CHECK_MESSAGE( teardropCount == 0,
2489 wxString::Format(
"Expected no teardrop on grazing-entry track (emergence below "
2490 "track width), got %d (curved=%s)",
2492 aCurvedEdges ?
"yes" :
"no" ) );
2494 BOOST_CHECK_MESSAGE( spikingPoints == 0,
2495 wxString::Format(
"Found %d teardrop polygon vertex/vertices outside the expected "
2496 "envelope (worst at (%d, %d), %f mm from via center; curved=%s)",
2498 worstPoint.
x, worstPoint.
y,
2500 aCurvedEdges ?
"yes" :
"no" ) );
2504 runVariant(
false );
2521 auto runVariant = [&](
bool aCurvedEdges )
2525 for(
PCB_TRACK* track : m_board->Tracks() )
2529 static_cast<PCB_VIA*
>( track )->SetTeardropCurved( aCurvedEdges );
2535 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2544 if( !commit.
Empty() )
2547 int teardropCount = 0;
2548 int selfIntersectingCount = 0;
2551 for(
ZONE* zone : m_board->Zones() )
2553 if( !zone->IsTeardropArea() )
2564 int n =
chain.PointCount();
2565 bool intersected =
false;
2567 for(
int i = 0; i < n && !intersected; i++ )
2569 SEG segA(
chain.CPoint( i ),
chain.CPoint( ( i + 1 ) % n ) );
2571 for(
int j = i + 2; j < n; j++ )
2573 if( i == 0 && j == n - 1 )
2576 SEG segB(
chain.CPoint( j ),
chain.CPoint( ( j + 1 ) % n ) );
2579 if( hit.has_value() )
2581 BOOST_TEST_MESSAGE( wxString::Format(
"Teardrop polygon self-intersection at (%d, %d) "
2582 "between edges %d and %d (curved=%s)",
2586 aCurvedEdges ?
"yes" :
"no" ) );
2588 worstPoint = hit.value();
2596 selfIntersectingCount++;
2599 BOOST_CHECK_MESSAGE( teardropCount > 0,
2600 wxString::Format(
"Expected at least one teardrop zone (curved=%s)",
2601 aCurvedEdges ?
"yes" :
"no" ) );
2603 BOOST_CHECK_MESSAGE( selfIntersectingCount == 0,
2604 wxString::Format(
"%d of %d teardrop polygon(s) self-intersect (worst at (%d, %d); "
2606 selfIntersectingCount,
2608 worstPoint.
x, worstPoint.
y,
2609 aCurvedEdges ?
"yes" :
"no" ) );
2613 runVariant(
false );
2621 auto runVariant = [&](
const wxString& aFixture,
bool aCurvedEdges )
2625 for(
PCB_TRACK* track : m_board->Tracks() )
2628 static_cast<PCB_VIA*
>( track )->SetTeardropCurved( aCurvedEdges );
2631 for(
FOOTPRINT* footprint : m_board->Footprints() )
2633 for(
PAD*
pad : footprint->Pads() )
2634 pad->SetTeardropCurved( aCurvedEdges );
2638 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr,
nullptr );
2647 if( !commit.
Empty() )
2650 int teardropCount = 0;
2651 VECTOR2I padPos = ( *m_board->Footprints().begin() )->Pads()[0]->GetPosition();
2652 bool padHasTeardrop =
false;
2654 for(
ZONE* zone : m_board->Zones() )
2656 if( !zone->IsTeardropArea() )
2661 if( zone->Outline()->Contains( padPos ) )
2662 padHasTeardrop =
true;
2665 BOOST_CHECK_MESSAGE( padHasTeardrop,
2666 wxString::Format(
"Expected the pad-anchored teardrop on the short track joining the "
2667 "pad and the close via in %s, got %d teardrop(s) (curved=%s)",
2670 aCurvedEdges ?
"yes" :
"no" ) );
2673 runVariant(
"teardrop_close_via",
true );
2674 runVariant(
"teardrop_close_via",
false );
2675 runVariant(
"teardrop_close_via_rotated_pad",
true );
2676 runVariant(
"teardrop_close_via_rotated_pad",
false );
2696 ~ScopeGuard() { ref = orig; }
2699 auto getTotalFilledArea =
2704 for(
ZONE* zone : m_board->Zones() )
2706 if( zone->GetIsRuleArea() )
2711 if( !zone->HasFilledPolysForLayer( layer ) )
2714 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
2724 auto refillAndMeasure =
2725 [
this, &cfg, &getTotalFilledArea](
bool aIterative ) ->
double
2731 double storedArea = getTotalFilledArea();
2733 BOOST_REQUIRE_MESSAGE( storedArea > 0,
"Stored v9 fill has zero area" );
2736 return getTotalFilledArea();
2741 double storedArea = getTotalFilledArea();
2743 BOOST_REQUIRE_MESSAGE( storedArea > 0,
"Stored v9 fill has zero area" );
2745 double nonIterativeArea = refillAndMeasure(
false );
2746 double iterativeArea = refillAndMeasure(
true );
2747 double nonIterativeAreaRatio = nonIterativeArea / storedArea;
2748 double iterativeAreaRatio = iterativeArea / storedArea;
2750 BOOST_CHECK_MESSAGE( nonIterativeAreaRatio > 0.99999,
2751 wxString::Format(
"Non-iterative refill lost %.4f%% versus stored v9 fill "
2752 "(stored=%.2f mm^2, non-iterative=%.2f mm^2). This suggests "
2753 "missing pieces near keepout boundaries (issue 23515).",
2754 ( 1.0 - nonIterativeAreaRatio ) * 100.0,
2756 nonIterativeArea / 1e6 ) );
2758 BOOST_CHECK_MESSAGE( iterativeAreaRatio > 0.99999,
2759 wxString::Format(
"Iterative refill lost %.4f%% versus stored v9 fill "
2760 "(stored=%.2f mm^2, iterative=%.2f mm^2). "
2761 "This suggests missing pieces near keepout boundaries (issue 23515).",
2762 ( 1.0 - iterativeAreaRatio ) * 100.0,
2764 iterativeArea / 1e6 ) );
2778 m_board = std::make_unique<BOARD>();
2781 m_board->SetCopperLayerCount( 2 );
2790 m_board->Add( gndNet );
2802 int hatchThickness =
pcbIUScale.mmToIU( 0.3 );
2812 via->SetPosition( viaPos );
2814 via->SetDrill( viaDrill );
2816 via->SetNetCode( gndNetCode );
2817 m_board->Add(
via );
2821 auto makeHatchZone =
2824 ZONE* zone =
new ZONE( m_board.get() );
2843 m_board->Add( zone );
2850 m_board->BuildConnectivity();
2851 auto drcEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
2852 drcEngine->InitEngine( wxFileName() );
2864 double fullFillArea = 0.0;
2865 double thermalFillArea = 0.0;
2876 "Zone should have fill on F.Cu with FULL connection" );
2880 for(
int i = 0; i < fill->OutlineCount(); i++ )
2881 fullFillArea +=
std::abs( fill->Outline( i ).Area() );
2883 m_board->Remove(
via );
2884 m_board->Remove( zone );
2898 "Zone should have fill on F.Cu with THERMAL connection" );
2902 for(
int i = 0; i < fill->OutlineCount(); i++ )
2903 thermalFillArea +=
std::abs( fill->Outline( i ).Area() );
2905 m_board->Remove(
via );
2906 m_board->Remove( zone );
2915 double areaThreshold = 0.2 * iuPerMM * iuPerMM;
2917 double areaIU2toMM2 = 1.0 / ( iuPerMM * iuPerMM );
2919 BOOST_CHECK_MESSAGE( thermalFillArea > fullFillArea + areaThreshold,
2920 wxString::Format(
"THERMAL connection fill area (%.2f sq mm) should be larger than "
2921 "FULL fill area (%.2f sq mm) by at least 0.2 sq mm. If they are "
2922 "equal or FULL is larger, thermal ring was not added for THERMAL "
2923 "connection, or thermal ring was incorrectly added for FULL connection "
2924 "(issue 23516 regression).",
2925 thermalFillArea * areaIU2toMM2,
2926 fullFillArea * areaIU2toMM2 ) );
2938 m_board = std::make_unique<BOARD>();
2939 m_board->SetCopperLayerCount( 2 );
2946 m_board->Add( gndNet );
2955 int hatchThickness =
pcbIUScale.mmToIU( 0.3 );
2957 auto makeHatchZone = [&]() ->
ZONE*
2959 ZONE* zone =
new ZONE( m_board.get() );
2976 m_board->Add( zone );
2982 const int steps = 8;
2983 const double startMM = 9.0;
2984 const double stepMM = 2.3 / steps;
2986 int isolatedCount = 0;
2987 int testedCount = 0;
2989 for(
int ix = 0; ix < steps; ix++ )
2991 for(
int iy = 0; iy < steps; iy++ )
2997 via->SetPosition( viaPos );
2999 via->SetDrill( viaDrill );
3001 via->SetNetCode( gndNetCode );
3002 m_board->Add(
via );
3004 ZONE* zone = makeHatchZone();
3006 m_board->BuildConnectivity();
3007 auto drcEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
3008 drcEngine->InitEngine( wxFileName() );
3016 std::shared_ptr<SHAPE> viaShape =
via->GetEffectiveShape(
F_Cu );
3020 if( !fill->Collide( viaShape.get(), 0 ) )
3025 m_board->Remove(
via );
3026 m_board->Remove( zone );
3032 BOOST_CHECK_MESSAGE( isolatedCount == 0, wxString::Format(
"%d of %d FULL-connection via positions were left "
3033 "isolated from the hatch fill (issue 24559).",
3034 isolatedCount, testedCount ) );
3065 ~ScopeGuard() { ref = orig; }
3071 const std::vector<std::string> checkedNames = {
"hi1",
"hi2",
"hi3",
"hi4",
"hi5",
"hi6",
"hi7",
3072 "lo1",
"lo2",
"lo3",
"lo4",
"lo5",
"lo6" };
3073 std::map<std::string, ZONE*> zoneByName;
3075 for(
ZONE* zone : m_board->Zones() )
3076 zoneByName[zone->GetZoneName().ToStdString()] = zone;
3078 for(
const std::string&
name : checkedNames )
3080 BOOST_REQUIRE_MESSAGE( zoneByName.count(
name ),
"Zone '" +
name +
"' not found in test board" );
3081 BOOST_REQUIRE_MESSAGE( zoneByName[
name]->HasFilledPolysForLayer(
F_Cu ),
3082 "Zone '" +
name +
"' has no fill on F.Cu" );
3086 for(
const std::string&
name : {
"hi3",
"hi5",
"hi7" } )
3088 int islands = zoneByName[
name]->GetFilledPolysList(
F_Cu )->OutlineCount();
3090 BOOST_CHECK_MESSAGE( islands == 2, wxString::Format(
"Zone '%s' should have 2 filled islands but has %d. "
3091 "Cascading island removal did not converge correctly.",
3096 for(
const std::string&
name : {
"lo1",
"lo2",
"lo3",
"lo4",
"lo5",
"lo6",
"hi2",
"hi4",
"hi6" } )
3098 int islands = zoneByName[
name]->GetFilledPolysList(
F_Cu )->OutlineCount();
3100 BOOST_CHECK_MESSAGE( islands == 1, wxString::Format(
"Zone '%s' should have 1 filled island but has %d. "
3101 "Iterative refill may have incorrectly blocked or "
3102 "expanded this zone.",
3119 ZONE* thievingZone =
nullptr;
3121 for(
ZONE* z : m_board->Zones() )
3138 BOOST_CHECK_GE( fill->OutlineCount(), 2 );
3141 BOX2I fillBox = fill->BBox();
3148 BOOST_CHECK_GT( fill->TotalVertices(), 200 );
3174 ~ScopeGuard() { ref = orig; }
3183 BOOST_CHECK_MESSAGE( countingLog.
GetCount() > 0,
"Expected a wxLogWarning when iterative refill hits the iteration "
3184 "limit, but none was emitted. The convergence-limit board may no "
3185 "longer trigger the cap, or the warning path has changed." );
3196 m_board = std::make_unique<BOARD>();
3198 ZONE* zone =
new ZONE( m_board.get() );
3212 m_board->Add( zone );
3221 BOOST_CHECK_GT( fill->OutlineCount(), 5 );
3234 m_board = std::make_unique<BOARD>();
3235 m_board->SetCopperLayerCount( 2 );
3238 ZONE* zone =
new ZONE( m_board.get() );
3258 m_board->Add( zone );
3264 BOOST_REQUIRE_GT( fill->OutlineCount(), 0 );
3268 BOOST_CHECK_GE( fill->OutlineCount(), 6 );
3269 BOOST_CHECK_LE( fill->OutlineCount(), 12 );
3272 const double fullDotArea =
M_PI * std::pow(
pcbIUScale.mmToIU( 0.25 ), 2 );
3285 auto countDots = [](
bool stagger ) ->
int
3287 auto board = std::make_unique<BOARD>();
3288 board->SetCopperLayerCount( 2 );
3290 ZONE* zone =
new ZONE( board.get() );
3311 int plain = countDots(
false );
3312 int staggered = countDots(
true );
3318 BOOST_CHECK_NE( plain, staggered );
3319 BOOST_CHECK_GE( staggered, plain / 2 );
3320 BOOST_CHECK_LE( staggered, plain * 2 );
3331 m_board = std::make_unique<BOARD>();
3332 m_board->SetCopperLayerCount( 2 );
3334 ZONE* zone =
new ZONE( m_board.get() );
3348 m_board->Add( zone );
3354 BOOST_REQUIRE_GT( fill->OutlineCount(), 0 );
3358 BOOST_CHECK_GE( fill->OutlineCount(), 6 );
3359 BOOST_CHECK_LE( fill->OutlineCount(), 12 );
3361 const double fullSquareArea = std::pow(
pcbIUScale.mmToIU( 0.6 ), 2 );
3376 m_board = std::make_unique<BOARD>();
3377 m_board->SetCopperLayerCount( 2 );
3379 ZONE* zone =
new ZONE( m_board.get() );
3393 m_board->Add( zone );
3395 auto start = std::chrono::steady_clock::now();
3397 auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
3398 std::chrono::steady_clock::now() - start )
3407#if !defined( KICAD_SANITIZE_THREADS ) && !defined( KICAD_SANITIZE_ADDRESS )
3410 BOOST_CHECK_LT( elapsed, 30000 );
3423 m_board = std::make_unique<BOARD>();
3424 m_board->SetCopperLayerCount( 2 );
3426 ZONE* zone =
new ZONE( m_board.get() );
3440 m_board->Add( zone );
3446 BOOST_REQUIRE_GT( fill->TotalVertices(), 0 );
3456 BOX2I fillBox = fill->BBox();
3464 BOOST_CHECK_GT( fill->TotalVertices(), 30 );
3484 for(
ZONE* zone : m_board->Zones() )
3486 if( zone->GetIsRuleArea() )
3491 if( !zone->HasFilledPolysForLayer( layer ) )
3494 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
3497 total += fill->OutlineCount();
3504 int storedIslands = countIslands();
3506 BOOST_REQUIRE_MESSAGE( storedIslands >= 3,
3507 wxString::Format(
"Stored v9 fill should have at least 3 silk islands; "
3513 int refilledIslands = countIslands();
3515 BOOST_CHECK_MESSAGE( refilledIslands == storedIslands,
3516 wxString::Format(
"Refill lost silk islands: stored=%d, refilled=%d. "
3517 "Outline 0 of every non-copper multi-island zone "
3518 "was being incorrectly removed (issue 24089).",
3519 storedIslands, refilledIslands ) );
3530 m_board = std::make_unique<BOARD>();
3531 m_board->SetCopperLayerCount( 4 );
3538 m_board->Add( gndNet );
3542 m_board->Add( vccNet );
3545 ZONE* gndZone =
new ZONE( m_board.get() );
3562 m_board->Add( gndZone );
3564 ZONE* vccZone =
new ZONE( m_board.get() );
3588 m_board->Add( vccZone );
3592 auto footprint = std::make_unique<FOOTPRINT>( m_board.get() );
3602 pad->SetNetCode( gndNetCode );
3604 footprint->Add(
pad );
3605 footprint->SetPosition(
VECTOR2I( 0, 0 ) );
3606 m_board->Add( footprint.release() );
3608 m_board->BuildConnectivity();
3609 auto drcEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
3610 drcEngine->InitEngine( wxFileName() );
3618 "VCC outline must contain the pad position to reproduce issue 24175." );
3620 "VCC zone should still have fill in its right lobe." );
3625 BOOST_REQUIRE_MESSAGE( !vccFill->Contains(
pad->GetPosition() ),
3626 "VCC fill should NOT contain the pad position (corridor must be "
3627 "pruned by min-thickness for the test to exercise issue 24175)." );
3632 BOOST_CHECK_MESSAGE(
pad->FlashLayer(
In1_Cu ),
3633 "PTH pad inside higher-priority different-net zone must still flash "
3634 "when a same-net lower-priority zone covers it (issue 24175)." );
3637 "GND zone should have fill on In1.Cu" );
3644 bool foundCopperAround =
false;
3646 for(
int i = 0; i < samples; i++ )
3648 double angle = ( 2.0 *
M_PI * i ) / samples;
3650 pad->GetPosition().y +
KiROUND( sampleR * std::sin( angle ) ) );
3652 if( gndFill->Contains( p ) )
3654 foundCopperAround =
true;
3659 BOOST_CHECK_MESSAGE( foundCopperAround,
3660 "Lower-priority GND zone should have copper around GND pad even when "
3661 "a higher-priority different-net zone outline contains the pad "
3684 PCB_LAYER_ID targetLayer = m_board->GetLayerID( wxT(
"B.Cu" ) );
3685 std::vector<ZONE*> toFill;
3687 for(
ZONE* zone : m_board->Zones() )
3689 if( zone->GetIsRuleArea() )
3692 if( !zone->IsOnLayer( targetLayer ) )
3695 if( zone->IsFilled() )
3698 toFill.push_back( zone );
3701 BOOST_REQUIRE_MESSAGE( !toFill.empty(),
3702 "Expected at least one unfilled B.Cu zone to exercise the API path." );
3709 BOOST_CHECK_NO_THROW( filler.
Fill( toFill ) );
3728 ~ScopeGuard() { ref = orig; }
3737 const int margin =
pcbIUScale.mmToIU( 0.05 );
3739 std::map<int, SHAPE_POLY_SET> mergedByNet;
3741 for(
ZONE* zone : m_board->Zones() )
3743 if( zone->GetIsRuleArea() || !zone->HasFilledPolysForLayer( layer ) )
3746 mergedByNet[zone->GetNetCode()].BooleanAdd( *zone->GetFilledPolysList( layer ) );
3751 auto buildLegitVoids =
3757 for(
ZONE* other : m_board->Zones() )
3759 if( !other->GetLayerSet().Contains( layer ) )
3762 if( other->GetIsRuleArea() )
3764 if( other->GetDoNotAllowZoneFills() )
3770 if( other->GetNetCode() == aLower->
GetNetCode()
3772 || other->GetAssignedPriority() <= aHigher->GetAssignedPriority()
3773 || !other->HasFilledPolysForLayer( layer ) )
3786 std::vector<ZONE*> zones;
3788 for(
ZONE* zone : m_board->Zones() )
3790 if( !zone->GetIsRuleArea() && zone->GetNetCode() > 0 && zone->GetLayerSet().Contains( layer ) )
3791 zones.push_back( zone );
3794 int checkedPairs = 0;
3796 for(
size_t i = 0; i < zones.size(); ++i )
3798 for(
size_t j = i + 1; j < zones.size(); ++j )
3813 const ZONE* higher = ( lower == a ) ? b : a;
3826 double uncoveredArea =
3829 BOOST_CHECK_MESSAGE( uncoveredArea < 0.01,
3830 wxString::Format(
"Same-net zones (priorities %d and %d) left %.4f mm^2 of "
3831 "their overlap unfilled; overlapping same-net zones must "
3832 "merge (issue 23790).",
3839 BOOST_CHECK_MESSAGE( checkedPairs >= 2,
3840 wxString::Format(
"Expected at least two overlapping same-net zone pairs "
3841 "to exercise the merge, found %d.", checkedPairs ) );
3855 ~ScopeGuard() { ref = orig; }
3858 for(
bool iterative : {
true,
false } )
3866 ZONE* hatched =
nullptr;
3867 ZONE* solid =
nullptr;
3869 for(
ZONE* zone : m_board->Zones() )
3898 double leakedArea = leaked.
Area() / mm2;
3900 BOOST_CHECK_MESSAGE( leakedArea < 0.01,
3901 wxString::Format(
"%s: lower-priority zone poured %.3f mm^2 inside the "
3902 "higher-priority hatched zone (issue 24935).",
3903 iterative ? wxS(
"iterative refill" ) : wxS(
"single pass" ),
3923 ~ScopeGuard() { ref = orig; }
3932 for(
int pass = 0; pass < 64; ++pass )
3940 for(
ZONE* zone : m_board->Zones() )
3942 if( zone->GetIsRuleArea() || !zone->HasFilledPolysForLayer( layer ) )
3945 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
3951 BOOST_CHECK_MESSAGE( merged.
Area() > 0.0,
3952 wxString::Format(
"Fill pass %d produced no copper.", pass ) );
3966 auto outlineNoArcs =
3974 int checkedPairs = 0;
3976 for(
ZONE* hatch : m_board->Zones() )
3979 || !hatch->HasFilledPolysForLayer( layer ) )
3987 for(
ZONE* other : m_board->Zones() )
3989 if( other == hatch || other->GetIsRuleArea() || !other->GetLayerSet().Contains( layer )
3990 || other->GetAssignedPriority() <= hatch->GetAssignedPriority() )
4013 if( band.
Area() <= 0 )
4019 double coverage = covered.
Area() / band.
Area();
4022 BOOST_CHECK_MESSAGE( coverage >= 0.85,
4023 wxString::Format(
"Hatch zone %s carved by %s: border ring only %.0f%% filled; "
4024 "the hatch border was not re-established around the carved "
4025 "area (issue 24758).",
4026 hatch->GetZoneName(), other->GetZoneName(),
4027 coverage * 100.0 ) );
4031 BOOST_CHECK_MESSAGE( checkedPairs >= 3,
4032 wxString::Format(
"Expected at least three carved hatch borders to check, "
4033 "found %d.", checkedPairs ) );
4041 m_board = std::make_unique<BOARD>();
4052 m_board->Add( netA );
4053 m_board->Add( netB );
4059 const int sep =
clearance + extraMargin + maxError / 2;
4060 const int ax =
pcbIUScale.mmToIU( 100 ) + sep;
4062 ZONE* zoneA =
new ZONE( m_board.get() );
4070 m_board->Add( zoneA );
4074 ZONE* zoneB =
new ZONE( m_board.get() );
4083 for(
int ii = 0; ii < 1000; ++ii )
4091 m_board->Add( zoneB );
4103 BOOST_CHECK_MESSAGE( !fillA->Collide( fillB.get(),
clearance + extraMargin + maxError * 3 / 4 ),
4104 "Lower-priority zone filled before the higher-priority knockout was "
4105 "published; the fill depends on thread scheduling." );
4130 std::vector<DRC_ITEM> violations;
4133 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
4134 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
4137 violations.push_back( *aItem );
4142 if( !violations.empty() )
4146 std::map<KIID, EDA_ITEM*> itemMap;
4147 m_board->FillItemMap( itemMap );
4149 for(
const DRC_ITEM& item : violations )
4153 BOOST_CHECK_MESSAGE( violations.empty(),
4154 wxString::Format(
"Zone fill produced %zu connection_width violations; "
4155 "expected 0 (issue 24312).",
4156 violations.size() ) );
4169 ~ScopeGuard() { ref = orig; }
4187 double localCopperArea = 0.0;
4189 for(
ZONE* zone : m_board->Zones() )
4191 if( !zone->IsOnLayer( layer ) )
4194 std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
4207 localCopperArea = std::max( localCopperArea,
std::abs( local.
Area() ) );
4212 BOOST_CHECK_MESSAGE( localCopperArea > minimumLocalCopperArea,
4213 wxString::Format(
"Expected copper around the bridge on %s; the "
4214 "bridge must be widened, not removed.",
4218 std::vector<DRC_ITEM> violations;
4221 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
4225 violations.push_back( *aItem );
4230 BOOST_CHECK_MESSAGE( violations.empty(),
4231 wxString::Format(
"Iterative refill produced %zu connection_width "
4232 "violations; expected full-width bridges (issue 24835).",
4233 violations.size() ) );
4248 ~ScopeGuard() { ref = orig; }
4254 [&](
bool aIterativeRefill, std::unique_ptr<BOARD>& aBoard )
4261 std::unique_ptr<BOARD> incremental;
4262 std::unique_ptr<BOARD> oneShot;
4264 fill(
true, incremental );
4265 fill(
false, oneShot );
4267 std::map<KIID, SHAPE_POLY_SET> incrementalFills;
4269 for(
ZONE* zone : incremental->Zones() )
4271 if( !zone->GetIsRuleArea() && zone->HasFilledPolysForLayer( layer ) )
4272 incrementalFills[zone->m_Uuid] = *zone->GetFilledPolysList( layer );
4278 auto sameNetBorderBand =
4288 for(
ZONE* other : oneShot->Zones() )
4290 if( other == aZone || other->GetIsRuleArea()
4291 || other->GetNetCode() != aZone->GetNetCode()
4292 || !other->GetLayerSet().Contains( layer ) )
4309 int checkedZones = 0;
4311 for(
ZONE* zone : oneShot->Zones() )
4313 if( zone->GetIsRuleArea() || zone->GetNetCode() <= 0
4314 || !zone->HasFilledPolysForLayer( layer ) )
4324 auto incrementalIt = incrementalFills.find( zone->m_Uuid );
4326 BOOST_REQUIRE_MESSAGE( incrementalIt != incrementalFills.end(),
4327 wxString::Format(
"Zone %s is missing from the incremental fill.",
4328 zone->m_Uuid.AsString() ) );
4331 difference.
BooleanXor( incrementalIt->second );
4334 const double differenceArea = difference.
Area() / sqMM;
4336 BOOST_CHECK_MESSAGE( differenceArea < 0.01,
4337 wxString::Format(
"Zone %s (priority %d) fills %.4f mm^2 differently along a "
4338 "shared same-net border depending on the fill mode; the two "
4339 "must agree there (issue 23790).",
4340 zone->m_Uuid.AsString(), zone->GetAssignedPriority(),
4345 BOOST_REQUIRE_MESSAGE( checkedZones >= 3,
4346 wxString::Format(
"Expected at least three zones sharing a same-net "
4347 "border, found %d.", checkedZones ) );
4360 for(
ZONE* zone : m_board->Zones() )
4362 if( !zone->GetIsRuleArea() )
4366 PAD* overriddenPad =
nullptr;
4367 ZONE* hostZone =
nullptr;
4370 for(
FOOTPRINT* footprint : m_board->Footprints() )
4372 for(
PAD*
pad : footprint->Pads() )
4374 for(
ZONE* zone : m_board->Zones() )
4376 if( zone->GetIsRuleArea() || zone->GetNetCode() !=
pad->GetNetCode() )
4381 if( !
pad->IsOnLayer( layer ) || !
pad->FlashLayer( layer ) )
4384 if( !zone->Outline()->Contains(
pad->GetPosition() ) )
4387 overriddenPad =
pad;
4405 BOOST_REQUIRE_MESSAGE( overriddenPad,
"No same-net pad sits inside a zone on this board." );
4413 BOOST_REQUIRE_MESSAGE( fill && !fill->IsEmpty(),
4414 wxString::Format(
"Zone on %s did not fill.",
4415 m_board->GetLayerName( hostLayer ) ) );
4418 std::shared_ptr<SHAPE> padShape = overriddenPad->
GetEffectiveShape( hostLayer );
4420 BOOST_CHECK_MESSAGE( fill->Collide( padShape.get(), 0 ),
4421 wxString::Format(
"Pad %s on net %s overrides the zone to a thermal "
4422 "connection, but the fill no longer reaches it on %s.",
4425 m_board->GetLayerName( hostLayer ) ) );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
wxString GetNetname() const
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
const MINOPTMAX< int > & GetValue() const
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints, BOARD_COMMIT *aCommit=nullptr)
Run the DRC tests.
void SetViolationHandler(DRC_VIOLATION_HANDLER aHandler)
Set an optional DRC violation handler (receives DRC_ITEMs and positions).
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
void ClearViolationHandler()
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
A scoped application of a wxLog target that counts error-level messages.
unsigned GetCount() const
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
void SetClearance(int aClearance)
Handle the data for a net.
std::shared_ptr< NETCLASS > GetDefaultNetclass() const
Gets the default netclass for the project.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
const wxString & GetNumber() const
VECTOR2I GetPosition() const override
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
void SetLocalZoneConnection(ZONE_CONNECTION aType)
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
int Length() const
Return the length (this).
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
double Area(bool aAbsolute=true) const
Return the area of this chain.
Represent a set of closed polygons.
void BooleanXor(const SHAPE_POLY_SET &b)
Perform boolean polyset exclusive or.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
double Area()
Return the area of this poly set.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
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.
SHAPE_POLY_SET CloneDropTriangulation() const
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) ...
void UpdateTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
Update teardrops on a list of items.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
bool Fill(const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
Handle a list of polygons defining a copper zone.
void SetHatchThickness(int aThickness)
bool AppendCorner(const VECTOR2I &aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
void SetMinThickness(int aMinThickness)
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
bool SetNetCode(int aNetCode, bool aNoAssert) override
Override that clamps the netcode to 0 when this zone is in copper-thieving fill mode.
void SetFillMode(ZONE_FILL_MODE aFillMode)
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
void SetThievingSettings(const THIEVING_SETTINGS &aSettings)
void SetNet(NETINFO_ITEM *aNetInfo) override
Override that drops aNetInfo when this zone is in copper-thieving fill mode.
void SetThermalReliefGap(int aThermalReliefGap)
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
void SetAssignedPriority(unsigned aPriority)
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void SetHatchGap(int aStep)
unsigned GetAssignedPriority() const
bool SameNet(const ZONE *aOther) const
@ CHAMFER_ALL_CORNERS
All angles are chamfered.
@ ROUND_ALL_CORNERS
All angles are rounded.
static constexpr EDA_ANGLE ANGLE_0
bool m_ZoneFillIterativeRefill
Enable iterative zone filling to handle isolated islands in higher priority zones.
PCB_LAYER_ID
A quick note on layer IDs:
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ PTH
Plated through hole pad.
@ REMOVE_EXCEPT_START_AND_END
std::optional< VECTOR2I > OPT_VECTOR2I
Parameters that drive copper-thieving fill generation.
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
const SHAPE_LINE_CHAIN chain
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")
static const std::vector< wxString > RegressionZoneFillTests_tests
static const std::vector< std::pair< wxString, int > > RegressionTeardropFill_tests
BOOST_DATA_TEST_CASE_F(ZONE_FILL_TEST_FIXTURE, RegressionZoneFillTests, boost::unit_test::data::make(RegressionZoneFillTests_tests), relPath)
static void CheckAllOutlineAreasAtLeast(const std::shared_ptr< SHAPE_POLY_SET > &aFill, double aMinArea, const wxString &aLabel)
Assert every outline in aFill has at least aMinArea — used to verify thieving stamps survived the fil...
static const std::vector< wxString > RegressionSliverZoneFillTests_tests
BOOST_FIXTURE_TEST_CASE(BasicZoneFills, ZONE_FILL_TEST_FIXTURE)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
ZONE_CONNECTION
How pads are covered by copper in zone.
@ THERMAL
Use thermal relief for pads.
@ FULL
pads are covered by copper