KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue24735.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
23#include <board.h>
24#include <footprint.h>
25#include <zone.h>
26
28{
30 std::unique_ptr<BOARD> m_board;
31};
32
33
34BOOST_FIXTURE_TEST_SUITE( Issue24735, ISSUE24735_FIXTURE )
35
36// A v10 board stores footprint-embedded zone outlines in board frame. On load
37// the parser converts them to the footprint lib frame, but the border hatch
38// lines were generated from the board-frame outline beforehand. Without a
39// regeneration GetHatchLines() applies the footprint transform a second time
40// and the rule area's hatched border renders far from the footprint.
41BOOST_AUTO_TEST_CASE( EmbeddedZoneHatchFollowsFootprint )
42{
43 KI_TEST::LoadBoard( m_settingsManager, "issue24735/issue24735", m_board );
44
45 int checkedZones = 0;
46 int checkedHatches = 0;
47
48 for( const FOOTPRINT* fp : m_board->Footprints() )
49 {
50 for( const ZONE* zone : fp->Zones() )
51 {
52 BOX2I zoneBBox = zone->GetBoundingBox();
53
54 BOOST_CHECK_MESSAGE( fp->GetBoundingBox().Intersects( zoneBBox ),
55 "Embedded zone of " << fp->GetReference()
56 << " is separated from its footprint" );
57
58 for( const SEG& hatch : zone->GetHatchLines() )
59 {
60 checkedHatches++;
61
62 BOOST_CHECK_MESSAGE( zoneBBox.Contains( hatch.A ) && zoneBBox.Contains( hatch.B ),
63 "Hatch line of " << fp->GetReference()
64 << " lies outside the zone outline" );
65 }
66
67 checkedZones++;
68 }
69 }
70
71 BOOST_CHECK_GT( checkedZones, 0 );
72 BOOST_CHECK_GT( checkedHatches, 0 );
73}
74
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:164
Definition seg.h:38
Handle a list of polygons defining a copper zone.
Definition zone.h:70
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< BOARD > m_board
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")