KiCad PCB EDA Suite
Loading...
Searching...
No Matches
range.h
Go to the documentation of this file.
1
/*
2
* KiRouter - a push-and-(sometimes-)shove PCB router
3
*
4
* Copyright (C) 2013-2014 CERN
5
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6
* Author: Tomasz Wlostowski <
[email protected]
>
7
*
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License as published by the
10
* Free Software Foundation, either version 3 of the License, or (at your
11
* option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License along
19
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef __RANGE_H
23
#define __RANGE_H
24
25
template
<
class
T>
26
class
RANGE
27
{
28
public
:
29
RANGE
( T aMin, T aMax ) :
30
m_min
( aMin ),
31
m_max
( aMax ),
32
m_defined
( true ) {}
33
34
RANGE
():
35
m_defined
( false ) {}
36
37
T
MinV
()
const
38
{
39
return
m_min
;
40
}
41
42
T
MaxV
()
const
43
{
44
return
m_max
;
45
}
46
47
void
Set
( T aMin, T aMax )
const
48
{
49
m_max
= aMax;
50
m_min
= aMin;
51
}
52
53
void
Grow
( T aValue )
54
{
55
if
( !
m_defined
)
56
{
57
m_min
= aValue;
58
m_max
= aValue;
59
m_defined
=
true
;
60
}
61
else
62
{
63
m_min
= std::min(
m_min
, aValue );
64
m_max
= std::max(
m_max
, aValue );
65
}
66
}
67
68
bool
Inside
(
const
T& aValue )
const
69
{
70
if
( !
m_defined
)
71
return
true
;
72
73
return
aValue >=
m_min
&& aValue <=
m_max
;
74
}
75
76
bool
Overlaps
(
const
RANGE<T>
& aOther )
const
77
{
78
if
( !
m_defined
|| !aOther.
m_defined
)
79
return
true
;
80
81
return
m_max
>= aOther.
m_min
&&
m_min
<= aOther.
m_max
;
82
}
83
84
bool
Defined
()
const
85
{
86
return
m_defined
;
87
}
88
89
private
:
90
T
m_min
,
m_max
;
91
bool
m_defined
;
92
};
93
94
#endif
RANGE
Definition:
range.h:27
RANGE::Grow
void Grow(T aValue)
Definition:
range.h:53
RANGE::RANGE
RANGE()
Definition:
range.h:34
RANGE::m_min
T m_min
Definition:
range.h:90
RANGE::Defined
bool Defined() const
Definition:
range.h:84
RANGE::m_defined
bool m_defined
Definition:
range.h:91
RANGE::MinV
T MinV() const
Definition:
range.h:37
RANGE::Set
void Set(T aMin, T aMax) const
Definition:
range.h:47
RANGE::Inside
bool Inside(const T &aValue) const
Definition:
range.h:68
RANGE::RANGE
RANGE(T aMin, T aMax)
Definition:
range.h:29
RANGE::MaxV
T MaxV() const
Definition:
range.h:42
RANGE::Overlaps
bool Overlaps(const RANGE< T > &aOther) const
Definition:
range.h:76
RANGE::m_max
T m_max
Definition:
range.h:90
src
pcbnew
router
range.h
Generated on Wed Jan 22 2025 00:05:00 for KiCad PCB EDA Suite by
1.9.6