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
/****************************************************************************/
16
// A class to realise a uniform n:m - relationship using the
17
/****************************************************************************/
18
19
20
// ===========================================================================
21
// included modules
22
// ===========================================================================
23
#include <
config.h
>
24
25
#include <iostream>
26
#include <
utils/common/StdDefs.h
>
27
#include "
Bresenham.h
"
28
29
30
// ===========================================================================
31
// method definitions
32
// ===========================================================================
33
void
34
Bresenham::compute
(
BresenhamCallBack
* callBack,
const
int
val1,
const
int
val2) {
35
const
int
smaller =
MIN2
(val1, val2);
36
const
int
greater =
MAX2
(val1, val2);
37
int
pos = 0;
38
int
c = smaller;
39
for
(
int
i = 0; i < greater; i++) {
40
if
(smaller == val1) {
41
callBack->
execute
(pos, i);
42
}
else
{
43
callBack->
execute
(i, pos);
44
}
45
c += 2 * smaller;
46
if
(c >= 2 * greater) {
47
pos++;
48
c -= 2 * greater;
49
}
50
}
51
}
52
53
54
55
/****************************************************************************/
56
MIN2
T MIN2(T a, T b)
Definition:
StdDefs.h:74
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:80
Bresenham::compute
static void compute(BresenhamCallBack *callBack, const int val1, const int val2)
Definition:
Bresenham.cpp:34
config.h
StdDefs.h
Bresenham::BresenhamCallBack
Definition:
Bresenham.h:44
src
utils
geom
Bresenham.cpp
Generated on Wed Jan 15 2020 15:04:13 for Eclipse SUMO - Simulation of Urban MObility by
1.8.16