KiCad PCB EDA Suite
Loading...
Searching...
No Matches
geometry.h
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) 2018 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
24
#ifndef QA_UNIT_TEST_UTILS_GEOM__H
25
#define QA_UNIT_TEST_UTILS_GEOM__H
26
27
#include <
qa_utils/numeric.h
>
28
#include <
qa_utils/wx_utils/unit_test_utils.h
>
29
30
#include <
math/box2.h
>
31
#include <
math/vector2d.h
>
32
33
39
inline
std::ostream&
operator<<
( std::ostream& os,
const
BOX2I
& aBox )
40
{
41
os <<
"BOX[ "
<< aBox.
GetOrigin
() <<
" + "
<< aBox.
GetSize
() <<
" ]"
;
42
return
os;
43
}
44
45
namespace
KI_TEST
46
{
47
51
template
<
typename
VEC>
52
bool
IsVecWithinTol
(
const
VEC& aVec,
const
VEC& aExp,
typename
VEC::coord_type aTol )
53
{
54
return
IsWithin<typename VEC::coord_type>( aVec.x, aExp.x, aTol )
55
&& IsWithin<typename VEC::coord_type>( aVec.y, aExp.y, aTol );
56
}
57
61
template
<
typename
BOX>
62
bool
IsBoxWithinTol
(
const
BOX& aBox,
const
BOX& aExp,
typename
BOX::coord_type aTol )
63
{
64
using
VEC =
VECTOR2<typename BOX::coord_type>
;
65
return
IsVecWithinTol<VEC>( aBox.GetPosition(), aExp.GetPosition(), aTol )
66
&& IsVecWithinTol<VEC>( aBox.GetSize(), aExp.GetSize(), aTol * 2 );
67
}
68
69
}
// namespace KI_TEST
70
71
#endif
// QA_UNIT_TEST_UTILS_GEOM__H
box2.h
BOX2< VECTOR2I >
BOX2::GetOrigin
const Vec & GetOrigin() const
Definition:
box2.h:200
BOX2::GetSize
const SizeVec & GetSize() const
Definition:
box2.h:196
VECTOR2
Define a general 2D-vector/point.
Definition:
vector2d.h:70
operator<<
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
Definition:
eda_text.cpp:1170
KI_TEST
Definition:
board_construction_utils.cpp:33
KI_TEST::IsBoxWithinTol
bool IsBoxWithinTol(const BOX &aBox, const BOX &aExp, typename BOX::coord_type aTol)
Check that a box is close enough to another box.
Definition:
geometry.h:62
KI_TEST::IsVecWithinTol
bool IsVecWithinTol(const VEC &aVec, const VEC &aExp, typename VEC::coord_type aTol)
Check that both x and y of a vector are within expected error.
Definition:
geometry.h:52
numeric.h
Numerical test predicates.
unit_test_utils.h
vector2d.h
src
qa
qa_utils
include
qa_utils
geometry
geometry.h
Generated on Thu Jul 18 2024 00:04:50 for KiCad PCB EDA Suite by
1.9.6