KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_shape_compound_collision.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 (C) 2017 CERN
5 * @author Alejandro GarcĂ­a Montoro <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
22
25
26#include "fixtures_geometry.h"
27
33{
34 // Structure to store the common data.
36
37 // Vectors containing colliding and non-colliding points
38 std::vector<SHAPE*> shapesA, shapesB, shapesC;
39
43
48 {
49 shapesA.push_back( new SHAPE_CIRCLE( VECTOR2I( 0, 0 ), 100 ) );
50 shapesA.push_back( new SHAPE_CIRCLE( VECTOR2I( 80, 0 ), 100 ) );
51
52 shapesB.push_back( new SHAPE_CIRCLE( VECTOR2I( 0, 80 ), 100 ) );
53 shapesB.push_back( new SHAPE_CIRCLE( VECTOR2I( 80, 80 ), 100 ) );
54
55 shapesC.push_back( new SHAPE_CIRCLE( VECTOR2I( 0, 280 ), 100 ) );
56 shapesC.push_back( new SHAPE_CIRCLE( VECTOR2I( 80, 280 ), 100 ) );
57
61 }
62
64 {
65 delete compoundA;
66 delete compoundB;
67 delete compoundC;
68 }
69};
70
71
75BOOST_FIXTURE_TEST_SUITE( SCompoundCollision, ShapeCompoundCollisionFixture )
76
77
78
82BOOST_AUTO_TEST_CASE( ShapeCompoundCollide )
83{
84 int actual;
85 // Check points on corners
86 BOOST_CHECK( compoundA->Collide( compoundB, 0, &actual ) );
87 BOOST_TEST( actual == 0 );
88
89 BOOST_CHECK( !compoundA->Collide( compoundC, 0, &actual ) );
90 BOOST_TEST( actual == 0 );
91
92 BOOST_CHECK( compoundA->Collide( compoundC, 100, &actual ) );
93 BOOST_TEST( actual == 80 );
94
95 BOOST_CHECK( shapesA[0]->Collide( compoundB, 0 ) );
96 BOOST_CHECK( shapesA[1]->Collide( compoundB, 0 ) );
97 BOOST_CHECK( compoundB->Collide( shapesA[0], 0 ) );
98 BOOST_CHECK( compoundB->Collide( shapesA[1], 0 ) );
99
100 BOOST_CHECK( shapesB[0]->Collide( compoundA, 0 ) );
101 BOOST_CHECK( shapesB[1]->Collide( compoundA, 0 ) );
102 BOOST_CHECK( compoundA->Collide( shapesB[0], 0 ) );
103 BOOST_CHECK( compoundA->Collide( shapesB[1], 0 ) );
104
105 BOOST_CHECK( ! shapesC[0]->Collide( compoundA, 0 ) );
106 BOOST_CHECK( ! shapesC[1]->Collide( compoundA, 0 ) );
107 BOOST_CHECK( ! compoundA->Collide( shapesC[0], 0 ) );
108 BOOST_CHECK( ! compoundA->Collide( shapesC[1], 0 ) );
109
110 BOOST_CHECK( ! shapesA[0]->Collide( compoundC, 0 ) );
111 BOOST_CHECK( ! shapesA[1]->Collide( compoundC, 0 ) );
112 BOOST_CHECK( ! compoundC->Collide( shapesA[0], 0 ) );
113 BOOST_CHECK( ! compoundC->Collide( shapesA[1], 0 ) );
114
115 BOOST_CHECK( shapesC[0]->Collide( compoundA, 100, &actual ) );
116 BOOST_TEST( actual == 80 );
117 BOOST_CHECK( shapesC[1]->Collide( compoundA, 100, &actual ) );
118 BOOST_TEST( actual == 80 );
119 BOOST_CHECK( compoundA->Collide( shapesC[0], 100, &actual ) );
120 BOOST_TEST( actual == 80 );
121 BOOST_CHECK( compoundA->Collide( shapesC[1], 100, &actual ) );
122 BOOST_TEST( actual == 80 );
123}
124
125
static bool Collide(const SHAPE_CIRCLE &aA, const SHAPE_CIRCLE &aB, int aClearance, int *aActual, VECTOR2I *aLocation, VECTOR2I *aMTV)
Common data for some of the SHAPE_POLY_SET tests:
Fixture for the Collision test suite.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST(netlist.find("R_G1 ARM_OUT1 DIE_B R='0.001 / ((SW_STATE)") !=std::string::npos)
int actual
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683