Eclipse SUMO - Simulation of Urban MObility
Bresenham.cpp
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials
5
// are made available under the terms of the Eclipse Public License v2.0
6
// which accompanies this distribution, and is available at
7
// http://www.eclipse.org/legal/epl-v20.html
8
// SPDX-License-Identifier: EPL-2.0
9
/****************************************************************************/
15
// A class to realise a uniform n:m - relationship using the
16
/****************************************************************************/
17
18
19
// ===========================================================================
20
// included modules
21
// ===========================================================================
22
#include <
config.h
>
23
24
#include <iostream>
25
#include <
utils/common/StdDefs.h
>
26
#include "
Bresenham.h
"
27
28
29
// ===========================================================================
30
// method definitions
31
// ===========================================================================
32
void
33
Bresenham::compute
(
BresenhamCallBack
* callBack,
const
int
val1,
const
int
val2) {
34
const
int
smaller =
MIN2
(val1, val2);
35
const
int
greater =
MAX2
(val1, val2);
36
int
pos = 0;
37
int
c = smaller;
38
for
(
int
i = 0; i < greater; i++) {
39
if
(smaller == val1) {
40
callBack->
execute
(pos, i);
41
}
else
{
42
callBack->
execute
(i, pos);
43
}
44
c += 2 * smaller;
45
if
(c >= 2 * greater) {
46
pos++;
47
c -= 2 * greater;
48
}
49
}
50
}
51
52
53
54
/****************************************************************************/
55
MIN2
T MIN2(T a, T b)
Definition:
StdDefs.h:73
Bresenham::BresenhamCallBack::execute
virtual void execute(const int val1, const int val2)=0
Bresenham.h
MAX2
T MAX2(T a, T b)
Definition:
StdDefs.h:79
Bresenham::compute
static void compute(BresenhamCallBack *callBack, const int val1, const int val2)
Definition:
Bresenham.cpp:33
config.h
StdDefs.h
Bresenham::BresenhamCallBack
Definition:
Bresenham.h:43
src
utils
geom
Bresenham.cpp
Generated on Thu Jan 16 2020 21:12:23 for Eclipse SUMO - Simulation of Urban MObility by
1.8.16