KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_excellon_repeat.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
27
28#include <cstdlib>
29
30#include <boost/test/unit_test.hpp>
31
33
34#include <gerber_file_image.h>
35#include <excellon_image.h>
36#include <excellon_defaults.h>
37#include <gerber_draw_item.h>
38
39
40BOOST_AUTO_TEST_SUITE( GerbviewExcellonRepeat )
41
42
43BOOST_AUTO_TEST_CASE( RepeatHoleCommand )
44{
45 wxString path = KI_TEST::GetTestDataRootDir() + "gerbview/excellon/repeat_holes.drl";
46
48 EXCELLON_DEFAULTS defaults;
49
50 BOOST_REQUIRE( image.LoadFile( path, &defaults ) );
51
52 // The R lines used to each add an "Unexpected symbol 0x52" message.
53 BOOST_CHECK_EQUAL( image.GetMessages().GetCount(), 0u );
54
55 // T01: 5 rows of a hole plus R07X5000 -> 8 holes each = 40 holes
56 // rows: items 0..7, 8..15, 16..23, 24..31, 32..39
57 // T02: one hole plus R03Y5000 -> 4 holes = items 40..43
58 BOOST_REQUIRE_EQUAL( image.GetItemsCount(), 44 );
59
60 const GERBER_DRAW_ITEMS& items = image.GetItems();
61
62 // Step of the X repeat, taken from the first row. Checks are on deltas only,
63 // so they are independent of the internal unit scale.
64 VECTOR2I stepX = items[1]->GetPosition() - items[0]->GetPosition();
65 BOOST_CHECK( stepX.x != 0 );
66 BOOST_CHECK_EQUAL( stepX.y, 0 );
67
68 // All 8 holes in each of the 5 rows are evenly spaced by stepX.
69 for( int row = 0; row < 5; ++row )
70 {
71 for( int col = 0; col < 7; ++col )
72 {
73 int i = row * 8 + col;
74 BOOST_CHECK( ( items[i + 1]->GetPosition() - items[i]->GetPosition() ) == stepX );
75 }
76 }
77
78 // Rows are one explicit 5 mm Y move apart. That move must match the R X step
79 // magnitude, which ties the repeat step to a non-repeat move of known size.
80 VECTOR2I rowStep = items[8]->GetPosition() - items[0]->GetPosition();
81 BOOST_CHECK_EQUAL( rowStep.x, 0 );
82 BOOST_CHECK_EQUAL( std::abs( rowStep.y ), std::abs( stepX.x ) );
83
84 // T02 column: R03Y5000 gives 4 evenly spaced holes stepping in Y only, same
85 // 5 mm magnitude as the X repeat.
86 VECTOR2I stepY = items[41]->GetPosition() - items[40]->GetPosition();
87 BOOST_CHECK_EQUAL( stepY.x, 0 );
88 BOOST_CHECK_EQUAL( std::abs( stepY.y ), std::abs( stepX.x ) );
89 BOOST_CHECK( ( items[42]->GetPosition() - items[41]->GetPosition() ) == stepY );
90 BOOST_CHECK( ( items[43]->GetPosition() - items[42]->GetPosition() ) == stepY );
91}
92
93
Handle a drill image.
std::vector< GERBER_DRAW_ITEM * > GERBER_DRAW_ITEMS
std::string GetTestDataRootDir()
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
management of default values used to read a Excellon (.nc) drill file Some important parameters are n...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
std::string path
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683