KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_drc_tuner_agreement.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
31
34#include <board.h>
35#include <pcb_track.h>
39
40
48
49
54BOOST_FIXTURE_TEST_CASE( LengthCalculationIncludesAllWidths, TUNER_DRC_TEST_FIXTURE )
55{
56 // Load a board that has tracks with different widths on the same net
57 KI_TEST::LoadBoard( m_settingsManager, "issue18045/test_proj", m_board );
58
59 LENGTH_DELAY_CALCULATION* lengthCalc = m_board->GetLengthCalculation();
60
61 // Find a net that has tracks with different widths
62 NETINFO_ITEM* testNet = m_board->FindNet( "/TEST1_P" );
63 BOOST_REQUIRE( testNet != nullptr );
64
65 // Collect all tracks on this net and verify they have multiple widths
66 std::vector<LENGTH_DELAY_CALCULATION_ITEM> lengthItems;
67 std::set<int> widths;
68
69 for( PCB_TRACK* track : m_board->Tracks() )
70 {
71 if( track->GetNetCode() != testNet->GetNetCode() )
72 continue;
73
74 if( track->Type() == PCB_TRACE_T )
75 widths.insert( track->GetWidth() );
76
78
79 if( item.Type() != LENGTH_DELAY_CALCULATION_ITEM::TYPE::UNKNOWN )
80 lengthItems.emplace_back( item );
81 }
82
83 BOOST_TEST_MESSAGE( wxString::Format( "Found %zu different track widths on net /TEST1_P", widths.size() ) );
84
85 // The test board should have at least 2 different widths to be a valid test case
86 BOOST_REQUIRE_GE( widths.size(), 2 );
87
88 // Calculate total length including all track widths
89 constexpr PATH_OPTIMISATIONS opts = {
90 .OptimiseViaLayers = true, .MergeTracks = true, .OptimiseTracesInPads = true, .InferViaInPad = false
91 };
92 LENGTH_DELAY_STATS stats = lengthCalc->CalculateLengthDetails( lengthItems, opts, nullptr, nullptr,
95
96 BOOST_TEST_MESSAGE( wxString::Format( "Total track length: %lld nm", stats.TrackLength ) );
97 BOOST_CHECK_GT( stats.TrackLength, 0 );
98
99 // Verify that all track segments contributed to the length
100 BOOST_CHECK_GT( lengthItems.size(), 0 );
101}
Lightweight class which holds a pad, via, or a routed trace outline.
TYPE Type() const
Gets the routing item type.
Class which calculates lengths (and associated routing statistics) in a BOARD context.
LENGTH_DELAY_CALCULATION_ITEM GetLengthCalculationItem(const BOARD_CONNECTED_ITEM *aBoardItem) const
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
LENGTH_DELAY_STATS CalculateLengthDetails(std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr, LENGTH_DELAY_LAYER_OPT aLayerOpt=LENGTH_DELAY_LAYER_OPT::NO_LAYER_DETAIL, LENGTH_DELAY_DOMAIN_OPT aDomain=LENGTH_DELAY_DOMAIN_OPT::NO_DELAY_DETAIL) const
Calculates the electrical length of the given items.
Handle the data for a net.
Definition netinfo.h:54
int GetNetCode() const
Definition netinfo.h:106
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
Holds length measurement result details and statistics.
Struct to control which optimisations the length calculation code runs on the given path objects.
std::unique_ptr< BOARD > m_board
BOOST_FIXTURE_TEST_CASE(LengthCalculationIncludesAllWidths, TUNER_DRC_TEST_FIXTURE)
Verify that length calculation includes all segments regardless of track width.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:96