Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal
2.0.0
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
x
Variables
a
b
d
e
f
h
i
l
m
n
o
p
s
t
v
w
x
Typedefs
a
b
c
d
e
i
k
l
n
o
p
r
s
u
v
z
Enumerations
Enumerator
a
b
c
d
e
g
h
i
j
n
o
p
s
t
u
z
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
c
d
e
f
h
l
m
n
o
p
r
s
t
u
Enumerator
a
b
c
d
e
f
g
l
m
o
p
r
s
t
u
v
x
y
z
Related Symbols
a
b
c
d
e
f
g
i
k
l
m
o
p
s
t
u
Examples
DGtal
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
Rect.cpp
1
/* -*- mode: c++ -*- */
9
/*
10
* \@copyright This File is part of the Board library which is
11
* licensed under the terms of the GNU Lesser General Public Licence.
12
* See the LICENCE file for further details.
13
*/
14
15
#include "Board/Rect.h"
16
17
namespace
LibBoard
{
18
19
Rect
20
operator||
(
const
Rect
& rectA,
const
Rect
& rectB )
21
{
22
Rect
rect;
23
rect.
top
= ( rectA.
top
> rectB.
top
) ? rectA.
top
: rectB.
top
;
24
rect.
left
= (rectA.
left
< rectB.
left
) ? rectA.
left
: rectB.
left
;
25
if
( rectA.
left
+ rectA.
width
> rectB.
left
+ rectB.
width
)
26
rect.
width
= rectA.
left
+ rectA.
width
- rect.
left
;
27
else
28
rect.
width
= rectB.
left
+ rectB.
width
- rect.
left
;
29
if
( rectA.
top
- rectA.
height
< rectB.
top
- rectB.
height
)
30
rect.
height
= rect.
top
- ( rectA.
top
- rectA.
height
);
31
else
32
rect.
height
= rect.
top
- ( rectB.
top
- rectB.
height
);
33
return
rect;
34
}
20
operator||
(
const
Rect
& rectA,
const
Rect
& rectB ) {
…
}
35
36
Rect
37
operator&&
(
const
Rect
& rectA,
const
Rect
& rectB )
38
{
39
Rect
rect;
40
rect.
top
= ( rectA.
top
< rectB.
top
) ? rectA.
top
: rectB.
top
;
41
rect.
left
= (rectA.
left
> rectB.
left
) ? rectA.
left
: rectB.
left
;
42
if
( rectA.
left
+ rectA.
width
< rectB.
left
+ rectB.
width
)
43
rect.
width
= rectA.
left
+ rectA.
width
- rect.
left
;
44
else
45
rect.
width
= rectB.
left
+ rectB.
width
- rect.
left
;
46
if
( rectA.
top
- rectA.
height
> rectB.
top
- rectB.
height
)
47
rect.
height
= rect.
top
- ( rectA.
top
- rectA.
height
);
48
else
49
rect.
height
= rect.
top
- ( rectB.
top
- rectB.
height
);
50
if
( rect.
height
< 0 ) rect.
height
= 0;
51
if
( rect.
width
< 0 ) rect.
width
= 0;
52
return
rect;
53
}
37
operator&&
(
const
Rect
& rectA,
const
Rect
& rectB ) {
…
}
54
55
}
// namespace LibBoard
56
57
std::ostream &
58
operator<<( std::ostream & out,
const
LibBoard::Rect
& rect )
59
{
60
out <<
"Rect("
61
<< rect.
left
<<
","
<< rect.
top
62
<<
"+"
<< rect.
width
<<
"x"
<< rect.
height
<<
")"
;
63
return
out;
64
}
LibBoard
Definition
Board.cpp:86
LibBoard::operator&&
Rect operator&&(const Rect &rectA, const Rect &rectB)
Definition
Rect.cpp:37
LibBoard::operator||
Rect operator||(const Rect &rectA, const Rect &rectB)
Definition
Rect.cpp:20
LibBoard::Rect
Struct representing a rectangle on the plane.
Definition
Rect.h:26
LibBoard::Rect::height
double height
Definition
Rect.h:31
LibBoard::Rect::width
double width
Definition
Rect.h:30
LibBoard::Rect::left
double left
Definition
Rect.h:28
LibBoard::Rect::top
double top
Definition
Rect.h:29
src
Board
Rect.cpp
Generated on
for DGtal by
1.14.0