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{
51 KI_TEST::GetPcbnewTestDataDir() + "drc_copper_thieving/copper_thieving.kicad_pcb" );
52
53 BOOST_REQUIRE( m_board );
54
55 // A board with no thieving fill also reports no isolated copper, so confirm
56 // the stamps the exclusion has to cover are actually present.
57 BOOST_REQUIRE_EQUAL( m_board->Zones().size(), 1u );
58
59 const ZONE* zone = m_board->Zones().front();
60
62 BOOST_REQUIRE_GT( zone->GetFilledPolysList( F_Cu )->OutlineCount(), 1 );
63
64 int isolatedCount = 0;
65 BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
66
67 // The QA loader does not wire up the DRC engine the way board_loader.cpp does.
68 if( !bds.m_DRCEngine )
69 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( m_board.get(), &bds );
70
71 bds.m_DRCEngine->InitEngine( wxFileName() );
72
73 // Disable all DRC checks except the one we care about so the test focuses on
74 // the isolated-copper path.
75 for( int code = 0; code < DRCE_LAST; ++code )
76 {
77 if( code != DRCE_ISOLATED_COPPER )
79 }
80
82 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& /*aPos*/, int /*aLayer*/,
83 const std::function<void( PCB_MARKER* )>& /*aPathGenerator*/ )
84 {
85 if( aItem->GetErrorCode() == DRCE_ISOLATED_COPPER )
86 ++isolatedCount;
87 } );
88
89 bds.m_DRCEngine->RunTests( EDA_UNITS::MM, true, false );
90
91 BOOST_CHECK_EQUAL( isolatedCount, 0 );
92}
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:692
ZONE_FILL_MODE GetFillMode() const
Definition zone.h:238
@ DRCE_ISOLATED_COPPER
Definition drc_item.h:46
@ DRCE_LAST
Definition drc_item.h:131
@ F_Cu
Definition layer_ids.h:60
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
@ 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:683