KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue25650_collinear_arc.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
22
23#include <board.h>
24#include <pcb_shape.h>
26#include <trigo.h>
27
28BOOST_AUTO_TEST_SUITE( Issue25650 )
29
30
31BOOST_AUTO_TEST_CASE( CollinearArcLoadsAsSegment )
32{
33 SETTINGS_MANAGER settingsManager;
34 std::unique_ptr<BOARD> board;
35
36 KI_TEST::LoadBoard( settingsManager, "issue25650/issue25650", board );
37
38 BOOST_REQUIRE_EQUAL( board->Drawings().size(), 1u );
39
40 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( *board->Drawings().begin() );
41
42 BOOST_CHECK( shape->GetShape() == SHAPE_T::SEGMENT );
43 BOOST_CHECK_LT( shape->GetBoundingBox().GetHeight(), 1'000'000 );
44}
45
46
47BOOST_AUTO_TEST_CASE( ShallowArcIsNotStraight )
48{
49 // Radius of about 1 m puts the center in range, so the bow must survive
50 BOOST_CHECK( !IsStraightArc( VECTOR2I( 0, 0 ), VECTOR2I( pcbIUScale.mmToIU( 100 ), pcbIUScale.mmToIU( 5 ) ),
51 VECTOR2I( pcbIUScale.mmToIU( 200 ), 0 ) ) );
52
53 // Radius of about 5 m puts the center out of range
54 BOOST_CHECK( IsStraightArc( VECTOR2I( 0, 0 ), VECTOR2I( pcbIUScale.mmToIU( 100 ), pcbIUScale.mmToIU( 1 ) ),
55 VECTOR2I( pcbIUScale.mmToIU( 200 ), 0 ) ) );
56 BOOST_CHECK( IsStraightArc( VECTOR2I( 0, 0 ), VECTOR2I( 50, 50 ), VECTOR2I( 100, 100 ) ) );
57}
58
59
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr size_type GetHeight() const
Definition box2.h:212
SHAPE_T GetShape() const
Definition eda_shape.h:177
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
@ SEGMENT
Definition eda_shape.h:56
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(CollinearArcLoadsAsSegment)
bool IsStraightArc(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Definition trigo.cpp:549
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708