25#include <boost/test/data/test_case.hpp>
65 for(
PAD*
pad : m_board->Footprints()[0]->Pads() )
67 if(
pad->GetNumber() ==
"2" ||
pad->GetNumber() ==
"4" ||
pad->GetNumber() ==
"6" )
78 for(
PCB_TRACK* track : m_board->Tracks() )
87 track->SetWidth( track->GetWidth() +
delta +
delta );
91 arc12 = track->m_Uuid;
97 bool foundPad2Error =
false;
98 bool foundPad4Error =
false;
99 bool foundPad6Error =
false;
100 bool foundArc8Error =
false;
101 bool foundArc12Error =
false;
102 bool foundOtherError =
false;
107 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
108 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
112 BOARD_ITEM* item_a = m_board->ResolveItem( aItem->GetMainItemID() );
113 PAD* pad_a =
dynamic_cast<PAD*
>( item_a );
116 BOARD_ITEM* item_b = m_board->ResolveItem( aItem->GetAuxItemID() );
117 PAD* pad_b =
dynamic_cast<PAD*
>( item_b );
120 if( pad_a && pad_a->
GetNumber() ==
"2" ) foundPad2Error =
true;
121 else if( pad_a && pad_a->
GetNumber() ==
"4" ) foundPad4Error =
true;
122 else if( pad_a && pad_a->
GetNumber() ==
"6" ) foundPad6Error =
true;
123 else if( pad_b && pad_b->
GetNumber() ==
"2" ) foundPad2Error =
true;
124 else if( pad_b && pad_b->
GetNumber() ==
"4" ) foundPad4Error =
true;
125 else if( pad_b && pad_b->
GetNumber() ==
"6" ) foundPad6Error =
true;
126 else if( trk_a && trk_a->
m_Uuid == arc8 ) foundArc8Error =
true;
127 else if( trk_a && trk_a->
m_Uuid == arc12 ) foundArc12Error =
true;
128 else if( trk_b && trk_b->
m_Uuid == arc8 ) foundArc8Error =
true;
129 else if( trk_b && trk_b->
m_Uuid == arc12 ) foundArc12Error =
true;
130 else foundOtherError =
true;
160 for(
ZONE* zone : m_board->Zones() )
162 if( zone->GetLayerSet().Contains(
F_Cu ) )
199 std::vector<DRC_ITEM> violations;
202 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
203 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
206 violations.push_back( *aItem );
211 if( violations.empty() )
220 std::map<KIID, EDA_ITEM*> itemMap;
221 m_board->FillItemMap( itemMap );
223 for(
const DRC_ITEM& item : violations )
226 BOOST_ERROR( wxString::Format(
"Zone fill regression: %s failed", relPath ) );
246 std::vector<DRC_ITEM> violations;
249 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I& aPos,
int aLayer,
250 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
253 violations.push_back( *aItem );
258 if( violations.empty() )
261 BOOST_TEST_MESSAGE( wxString::Format(
"Zone fill copper sliver regression: %s passed", relPath ) );
267 std::map<KIID, EDA_ITEM*> itemMap;
268 m_board->FillItemMap( itemMap );
270 for(
const DRC_ITEM& item : violations )
273 BOOST_ERROR( wxString::Format(
"Zone fill copper sliver regression: %s failed", relPath ) );
279 {
"teardrop_issue_JPC2", 5 },
286 const wxString& relPath =
test.first;
287 const int count =
test.second;
297 for(
ZONE* zone : m_board->Zones() )
299 if( zone->IsTeardropArea() )
303 BOOST_CHECK_MESSAGE( zoneCount == count,
"Expected " << count <<
" teardrop zones in "
304 << relPath <<
", found "
312 std::vector<wxString> tests = { {
"issue19956/issue19956" }
315 for(
const wxString& relPath : tests )
321 for(
ZONE* zone : m_board->Zones() )
325 std::shared_ptr<SHAPE> a_shape( zone->GetEffectiveShape( layer ) );
327 for(
PAD*
pad : m_board->GetPads() )
329 std::shared_ptr<SHAPE> pad_shape(
pad->GetEffectiveShape( layer ) );
330 int clearance = pad_shape->GetClearance( a_shape.get() );
331 BOOST_CHECK_MESSAGE(
pad->GetNetCode() == zone->GetNetCode() ||
clearance != 0,
332 wxString::Format(
"Pad %s from Footprint %s has net code %s and "
333 "is connected to zone with net code %s",
335 pad->GetParentFootprint()->GetReferenceAsString(),
337 zone->GetNetname() ) );
367 struct ScopeGuard {
bool& ref;
bool orig; ~ScopeGuard() { ref = orig; } } guard{ cfg.
m_ZoneFillIterativeRefill, originalIterativeRefill };
374 ZONE* gndZone =
nullptr;
376 for(
ZONE* zone : m_board->Zones() )
378 if( zone->GetNetname() ==
"GND" )
385 BOOST_REQUIRE_MESSAGE( gndZone !=
nullptr,
"GND zone not found in test board" );
389 bool hasOutline = m_board->GetBoardPolygonOutlines( boardOutline,
true );
390 BOOST_REQUIRE_MESSAGE( hasOutline,
"Board outline not found" );
392 double boardArea = 0.0;
403 double fillRatio = gndFilledArea / boardArea;
405 BOOST_TEST_MESSAGE( wxString::Format(
"Board area: %.2f sq mm, GND filled area: %.2f sq mm, "
406 "Fill ratio: %.1f%%",
407 boardArea / 1e6, gndFilledArea / 1e6,
408 fillRatio * 100.0 ) );
410 BOOST_CHECK_MESSAGE( fillRatio >= 0.25,
411 wxString::Format(
"GND zone fill ratio %.1f%% is less than expected 25%%. "
412 "This indicates issue 21746 - lower priority zones not "
413 "filling areas where higher priority isolated islands "
415 fillRatio * 100.0 ) );
440 int viasWithUnreachableFlashing = 0;
441 int totalConditionalVias = 0;
443 PCB_LAYER_ID in1Cu = m_board->GetLayerID( wxT(
"In1.Cu" ) );
444 PCB_LAYER_ID in2Cu = m_board->GetLayerID( wxT(
"In2.Cu" ) );
446 for(
PCB_TRACK* track : m_board->Tracks() )
453 if( !
via->GetRemoveUnconnected() )
456 totalConditionalVias++;
459 bool flashedOnIn1 =
via->FlashLayer( in1Cu );
460 bool flashedOnIn2 =
via->FlashLayer( in2Cu );
462 if( !flashedOnIn1 && !flashedOnIn2 )
466 int holeRadius =
via->GetDrillValue() / 2;
469 bool zoneReachesVia =
false;
471 for(
ZONE* zone : m_board->Zones() )
473 if( zone->GetIsRuleArea() )
476 if( zone->GetNetCode() !=
via->GetNetCode() )
481 if( !zone->IsOnLayer( layer ) )
484 if( !zone->HasFilledPolysForLayer( layer ) )
487 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
489 if( fill->Contains( viaCenter, -1, holeRadius ) )
491 zoneReachesVia =
true;
501 if( !zoneReachesVia && ( flashedOnIn1 || flashedOnIn2 ) )
502 viasWithUnreachableFlashing++;
505 BOOST_TEST_MESSAGE( wxString::Format(
"Total conditional vias: %d, Vias with unreachable "
506 "flashing: %d", totalConditionalVias,
507 viasWithUnreachableFlashing ) );
509 BOOST_CHECK_MESSAGE( viasWithUnreachableFlashing == 0,
510 wxString::Format(
"Found %d vias flashed on zone layers where the zone "
511 "fill doesn't actually reach them. This indicates "
512 "issue 22010 is not fixed.",
513 viasWithUnreachableFlashing ) );
535 int viasShortingZones = 0;
536 int totalConditionalVias = 0;
538 for(
PCB_TRACK* track : m_board->Tracks() )
545 if( !
via->GetRemoveUnconnected() )
548 totalConditionalVias++;
552 for(
ZONE* zone : m_board->Zones() )
554 if( zone->GetIsRuleArea() )
557 if( zone->GetNetCode() ==
via->GetNetCode() )
562 if( !
via->FlashLayer( layer ) )
565 if( !zone->HasFilledPolysForLayer( layer ) )
568 const std::shared_ptr<SHAPE_POLY_SET>& fill = zone->GetFilledPolysList( layer );
569 int viaRadius =
via->GetWidth( layer ) / 2;
571 if( fill->Contains( viaCenter, -1, viaRadius ) )
574 "Via at (%d, %d) on net %s is flashing on layer %s where zone "
575 "net %s is filled - this creates a short!",
576 viaCenter.
x, viaCenter.
y,
via->GetNetname(),
577 m_board->GetLayerName( layer ), zone->GetNetname() ) );
584 BOOST_TEST_MESSAGE( wxString::Format(
"Total conditional vias: %d, Vias shorting zones: %d",
585 totalConditionalVias, viasShortingZones ) );
587 BOOST_CHECK_MESSAGE( viasShortingZones == 0,
588 wxString::Format(
"Found %d vias flashed on layers where they short to "
589 "zones with different nets. This indicates issue 12964 "
591 viasShortingZones ) );
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.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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).
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
const wxString & GetNumber() const
double Area(bool aAbsolute=true) const
Return the area of this chain.
Represent a set of closed polygons.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int OutlineCount() const
Return the number of outlines in the set.
Handle a list of polygons defining a copper zone.
double GetFilledArea()
This area is cached from the most recent call to CalculateFilledArea().
double CalculateFilledArea()
Compute the area currently occupied by the zone fill.
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)
std::unique_ptr< BOARD > m_board
SETTINGS_MANAGER m_settingsManager
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 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