KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_meander_corner_radius.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
33#include <boost/test/unit_test.hpp>
34
35#include <router/pns_meander.h>
36
37BOOST_AUTO_TEST_SUITE( MeanderCornerRadius )
38
39
42BOOST_AUTO_TEST_CASE( DefaultSettings )
43{
44 PNS::MEANDER_SETTINGS settings;
45
46 // Default should be round corners
48
49 // Corner radius percentage default is 80%
51
52 // Default spacing
53 BOOST_CHECK_EQUAL( settings.m_spacing, 600000 ); // 0.6mm
54
55 // Minimum amplitude should be set
56 BOOST_CHECK_GT( settings.m_minAmplitude, 0 );
57}
58
66BOOST_AUTO_TEST_CASE( MinCornerRadiusThreshold )
67{
68 // Test the minimum corner radius calculation logic
69 // The threshold should be width / 2 to ensure visibly rounded corners
70
71 std::vector<int> widths = { 100000, 150000, 200000, 250000, 400000 };
72
73 for( int width : widths )
74 {
75 // The minimum acceptable corner radius is half the width
76 int minCornerRadius = width / 2;
77
78 // Verify the threshold is reasonable (not too large, not too small)
79 BOOST_CHECK_GT( minCornerRadius, 0 );
80 BOOST_CHECK_LE( minCornerRadius, width );
81
82 BOOST_TEST_MESSAGE( wxString::Format( "Width %d: minCornerRadius=%d",
83 width, minCornerRadius ) );
84 }
85}
86
97BOOST_AUTO_TEST_CASE( GeometricConstraints )
98{
99 int width = 250000; // 0.25mm track
100 int minCornerRadius = width / 2; // 0.125mm
101
102 // For corner radius to be at least minCornerRadius:
103 // 1. amplitude / 2 >= minCornerRadius => amplitude >= width
104 // 2. spacing / 2 >= minCornerRadius => spacing >= width
105
106 // Test various amplitude/spacing combinations
107 struct TestCase
108 {
109 int amplitude;
110 int spacing;
111 bool shouldFit;
112 };
113
114 std::vector<TestCase> testCases = {
115 { 500000, 600000, true }, // 0.5mm amp, 0.6mm spacing - plenty of room
116 { 250000, 600000, true }, // 0.25mm amp, 0.6mm spacing - minimum amplitude
117 { 500000, 250000, true }, // 0.5mm amp, 0.25mm spacing - minimum spacing
118 { 250000, 250000, true }, // 0.25mm amp, 0.25mm spacing - both at minimum
119 { 200000, 600000, false }, // 0.2mm amp < width - amplitude too small
120 { 500000, 200000, false }, // 0.2mm spacing < width - spacing too small
121 };
122
123 for( const auto& tc : testCases )
124 {
125 // Calculate maximum corner radius based on amplitude and spacing
126 int maxCrFromAmp = tc.amplitude / 2;
127 int maxCrFromSpacing = tc.spacing / 2;
128 int maxCr = std::min( maxCrFromAmp, maxCrFromSpacing );
129
130 bool wouldFit = maxCr >= minCornerRadius;
131
132 BOOST_CHECK_EQUAL( wouldFit, tc.shouldFit );
133
134 BOOST_TEST_MESSAGE( wxString::Format(
135 "amp=%d, spacing=%d: maxCr=%d, minRequired=%d, fits=%s (expected %s)",
136 tc.amplitude, tc.spacing, maxCr, minCornerRadius,
137 wouldFit ? "yes" : "no", tc.shouldFit ? "yes" : "no" ) );
138 }
139}
140
Dimensions for the meandering algorithm.
Definition pns_meander.h:70
int m_minAmplitude
Maximum meandering amplitude.
Definition pns_meander.h:95
int m_cornerRadiusPercentage
Place meanders on one side.
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
int m_spacing
Amplitude/spacing adjustment step.
@ MEANDER_STYLE_ROUND
Definition pns_meander.h:54
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DefaultSettings)
Test that MEANDER_SETTINGS has correct defaults for corner style.
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
BOOST_CHECK_EQUAL(result, "25.4")