KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_drc_copper_thieving.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 The KiCad Developers, see AUTHORS.txt for contributors.
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 2
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, see <https://www.gnu.org/licenses/>.
18 */
19
22#include <board.h>
24#include <drc/drc_engine.h>
25#include <drc/drc_item.h>
26#include <pcb_marker.h>
28#include <zone.h>
30
31
39
40
47BOOST_FIXTURE_TEST_CASE( ThievingZoneProducesNoIsolatedCopperViolations,
49{
50 m_board = KI_TEST::RequireBoardFromPcbnewQAData( "drc_copper_thieving/copper_thieving.kicad_pcb" );
51
52 // A board with no thieving fill also reports no isolated copper, so confirm
53 // the stamps the exclusion has to cover are actually present.
54 BOOST_REQUIRE_EQUAL( m_board->Zones().size(), 1u );
55
56 const ZONE* zone = m_board->Zones().front();
57
59 BOOST_REQUIRE_GT( zone->GetFilledPolysList( F_Cu )->OutlineCount(), 1 );
60
61 int isolatedCount = 0;
62 BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
63
64 // The QA loader does not wire up the DRC engine the way board_loader.cpp does.
65 if( !bds.m_DRCEngine )
66 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
67
68 bds.m_DRCEngine->InitEngine( wxFileName() );
69
70 // Disable all DRC checks except the one we care about so the test focuses on
71 // the isolated-copper path.
72 for( int code = 0; code < DRCE_LAST; ++code )
73 {
74 if( code != DRCE_ISOLATED_COPPER )
76 }
77
79 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& /*aPos*/, int /*aLayer*/,
80 const std::function<void( PCB_MARKER* )>& /*aPathGenerator*/ )
81 {
82 if( aItem->GetErrorCode() == DRCE_ISOLATED_COPPER )
83 ++isolatedCount;
84 } );
85
86 bds.m_DRCEngine->RunTests( EDA_UNITS::MM, true, false );
87
88 BOOST_CHECK_EQUAL( isolatedCount, 0 );
89}
General utilities for PCB file IO for QA programs.
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
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).
Definition drc_engine.h:164
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
int OutlineCount() const
Return the number of outlines in the set.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
std::shared_ptr< SHAPE_POLY_SET > GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition zone.h:699
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:238
@ DRCE_ISOLATED_COPPER
Definition drc_item.h:57
@ DRCE_LAST
Definition drc_item.h:144
@ F_Cu
Definition layer_ids.h:60
std::unique_ptr< BOARD > RequireBoardFromPcbnewQAData(const std::filesystem::path &aFilename)
Require a board from the path relative to the pcbnew QA data directory.
@ RPT_SEVERITY_IGNORE
BOOST_FIXTURE_TEST_CASE(ThievingZoneProducesNoIsolatedCopperViolations, DRC_COPPER_THIEVING_FIXTURE)
A copper-thieving zone produces a grid of intentionally-isolated stamps.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708