KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_teardrop_shorts.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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
27#include <board.h>
28#include <board_commit.h>
30#include <footprint.h>
31#include <pad.h>
32#include <zone.h>
35#include <teardrop/teardrop.h>
36#include <tool/tool_manager.h>
37
38
44BOOST_AUTO_TEST_CASE( NoTeardropOnZoneConnectedThermalPad )
45{
46 SETTINGS_MANAGER settingsManager;
47 std::unique_ptr<BOARD> board;
48
49 KI_TEST::LoadBoard( settingsManager, "teardrop_qfn_thermal_pad_zone", board );
50 KI_TEST::FillZones( board.get() );
51 board->BuildConnectivity();
52
53 TOOL_MANAGER toolMgr;
54 toolMgr.SetEnvironment( board.get(), nullptr, nullptr, nullptr, nullptr );
55
57 toolMgr.RegisterTool( dummyTool );
58
59 BOARD_COMMIT commit( dummyTool );
60 TEARDROP_MANAGER teardropMgr( board.get(), &toolMgr );
61
62 teardropMgr.UpdateTeardrops( commit, nullptr, nullptr, true );
63
64 if( !commit.Empty() )
65 commit.Push( wxT( "Add teardrops" ), SKIP_UNDO | SKIP_SET_DIRTY );
66
67 PAD* exposedPad = nullptr;
68
69 for( FOOTPRINT* footprint : board->Footprints() )
70 {
71 for( PAD* pad : footprint->Pads() )
72 {
73 // The footprint splits the exposed pad into eleven sub-pads all numbered 33.
74 if( footprint->GetReference() == wxT( "U2" ) && pad->GetNumber() == wxT( "33" )
75 && pad->GetSize( F_Cu ).x > pcbIUScale.mmToIU( 3.0 ) )
76 {
77 exposedPad = pad;
78 }
79 }
80 }
81
82 BOOST_REQUIRE( exposedPad );
83
84 SHAPE_POLY_SET padPoly;
85 int teardropsOnPad = 0;
86
87 exposedPad->TransformShapeToPolygon( padPoly, F_Cu, 0,
88 board->GetDesignSettings().m_MaxError, ERROR_INSIDE );
89
90 for( ZONE* zone : board->Zones() )
91 {
92 if( !zone->IsTeardropArea() || zone->GetFirstLayer() != F_Cu )
93 continue;
94
95 SHAPE_POLY_SET overlap = *zone->Outline();
96 overlap.BooleanIntersection( padPoly );
97
98 if( !overlap.IsEmpty() )
99 teardropsOnPad++;
100 }
101
102 BOOST_CHECK_EQUAL( teardropsOnPad, 0 );
103}
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
bool Empty() const
Definition commit.h:142
Definition pad.h:61
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3010
Represent a set of closed polygons.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) ...
Definition teardrop.h:86
void UpdateTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
Update teardrops on a list of items.
Definition teardrop.cpp:422
Master controller class:
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
Handle a list of polygons defining a copper zone.
Definition zone.h:70
@ F_Cu
Definition layer_ids.h:60
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
void FillZones(BOARD *m_board)
#define SKIP_SET_DIRTY
Definition sch_commit.h:40
#define SKIP_UNDO
Definition sch_commit.h:38
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_CASE(NoTeardropOnZoneConnectedThermalPad)
The U2 corner of demos/royalblue54L_feather.
BOOST_CHECK_EQUAL(result, "25.4")