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 std::unique_ptr<BOARD> board = KI_TEST::RequireBoardFromPcbnewQAData( "issue24177/silk_rule_area.kicad_pcb" );
53
54 // Zero violations is also what an empty board reports, so pin down the
55 // geometry that has to be present for the counts below to mean anything.
56 BOOST_REQUIRE_EQUAL( board->Zones().size(), 1u );
57 BOOST_REQUIRE( board->Zones().front()->GetIsRuleArea() );
58
59 const auto isSilk =
60 []( const BOARD_ITEM* aItem )
61 {
62 return aItem->Type() == PCB_SHAPE_T && aItem->GetLayer() == F_SilkS;
63 };
64
65 BOOST_REQUIRE( std::any_of( board->Drawings().begin(), board->Drawings().end(), isSilk ) );
66
67 BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
68
69 // The QA loader does not wire up the DRC engine the way board_loader.cpp does.
70 if( !bds.m_DRCEngine )
71 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
72
73 bds.m_DRCEngine->InitEngine( wxFileName() );
74
75 // Focus the run on the providers we changed.
76 for( int code = 0; code < DRCE_LAST; ++code )
78
83
84 int silkClearance = 0;
85 int silkMaskClearance = 0;
86 int silkEdgeClearance = 0;
87 int solderMaskBridge = 0;
88
90 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2I& /*aPos*/, int /*aLayer*/,
91 const std::function<void( PCB_MARKER* )>& /*aPathGenerator*/ )
92 {
93 switch( aItem->GetErrorCode() )
94 {
95 case DRCE_SILK_CLEARANCE: ++silkClearance; break;
96 case DRCE_SILK_MASK_CLEARANCE: ++silkMaskClearance; break;
97 case DRCE_SILK_EDGE_CLEARANCE: ++silkEdgeClearance; break;
98 case DRCE_SOLDERMASK_BRIDGE: ++solderMaskBridge; break;
99 default: break;
100 }
101 } );
102
103 bds.m_DRCEngine->RunTests( EDA_UNITS::MM, true, false );
104
106
107 BOOST_CHECK_EQUAL( silkClearance, 0 );
108 BOOST_CHECK_EQUAL( silkMaskClearance, 0 );
109 BOOST_CHECK_EQUAL( silkEdgeClearance, 0 );
110 BOOST_CHECK_EQUAL( solderMaskBridge, 0 );
111}
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:85
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:113
@ DRCE_SILK_MASK_CLEARANCE
Definition drc_item.h:111
@ DRCE_SOLDERMASK_BRIDGE
Definition drc_item.h:108
@ DRCE_SILK_CLEARANCE
Definition drc_item.h:114
@ DRCE_LAST
Definition drc_item.h:144
@ F_SilkS
Definition layer_ids.h:96
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_ERROR
@ RPT_SEVERITY_IGNORE
BOOST_AUTO_TEST_CASE(RuleAreaDoesNotCauseSilkOrMaskViolationsIssue24177)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
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:708