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