KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_drc_silk_rule_area_issue24177.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
35
36#include <algorithm>
37
39
40#include <board.h>
42#include <pcb_shape.h>
44#include <zone.h>
45#include <drc/drc_engine.h>
46#include <drc/drc_item.h>
48
49
50BOOST_AUTO_TEST_CASE( RuleAreaDoesNotCauseSilkOrMaskViolationsIssue24177 )
51{
52 const std::string path = KI_TEST::GetPcbnewTestDataDir()
53 + "issue24177/silk_rule_area.kicad_pcb";
54
55 std::unique_ptr<BOARD> board = KI_TEST::ReadBoardFromFileOrStream( path );
56
57 BOOST_REQUIRE( board );
58
59 // Zero violations is also what an empty board reports, so pin down the
60 // geometry that has to be present for the counts below to mean anything.
61 BOOST_REQUIRE_EQUAL( board->Zones().size(), 1u );
62 BOOST_REQUIRE( board->Zones().front()->GetIsRuleArea() );
63
64 const auto isSilk =
65 []( const BOARD_ITEM* aItem )
66 {
67 return aItem->Type() == PCB_SHAPE_T && aItem->GetLayer() == F_SilkS;
68 };
69
70 BOOST_REQUIRE( std::any_of( board->Drawings().begin(), board->Drawings().end(), isSilk ) );
71
72 BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
73
74 // The QA loader does not wire up the DRC engine the way board_loader.cpp does.
75 if( !bds.m_DRCEngine )
76 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
77
78 bds.m_DRCEngine->InitEngine( wxFileName() );
79
80 // Focus the run on the providers we changed.
81 for( int code = 0; code < DRCE_LAST; ++code )
83
88
89 int silkClearance = 0;
90 int silkMaskClearance = 0;
91 int silkEdgeClearance = 0;
92 int solderMaskBridge = 0;
93
95 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& /*aPos*/, int /*aLayer*/,
96 const std::function<void( PCB_MARKER* )>& /*aPathGenerator*/ )
97 {
98 switch( aItem->GetErrorCode() )
99 {
100 case DRCE_SILK_CLEARANCE: ++silkClearance; break;
101 case DRCE_SILK_MASK_CLEARANCE: ++silkMaskClearance; break;
102 case DRCE_SILK_EDGE_CLEARANCE: ++silkEdgeClearance; break;
103 case DRCE_SOLDERMASK_BRIDGE: ++solderMaskBridge; break;
104 default: break;
105 }
106 } );
107
108 bds.m_DRCEngine->RunTests( EDA_UNITS::MM, true, false );
109
111
112 BOOST_CHECK_EQUAL( silkClearance, 0 );
113 BOOST_CHECK_EQUAL( silkMaskClearance, 0 );
114 BOOST_CHECK_EQUAL( silkEdgeClearance, 0 );
115 BOOST_CHECK_EQUAL( solderMaskBridge, 0 );
116}
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
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
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 ClearViolationHandler()
Definition drc_engine.h:169
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:102
@ DRCE_SILK_MASK_CLEARANCE
Definition drc_item.h:100
@ DRCE_SOLDERMASK_BRIDGE
Definition drc_item.h:97
@ DRCE_SILK_CLEARANCE
Definition drc_item.h:103
@ DRCE_LAST
Definition drc_item.h:131
@ F_SilkS
Definition layer_ids.h:96
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_ERROR
@ RPT_SEVERITY_IGNORE
BOOST_AUTO_TEST_CASE(RuleAreaDoesNotCauseSilkOrMaskViolationsIssue24177)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
std::string path
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683