SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NIVissimAbstractEdge.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// -------------------
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
34
#include <map>
35
#include <cassert>
36
#include <
utils/common/MsgHandler.h
>
37
#include <
utils/common/ToString.h
>
38
#include <
utils/geom/GeomHelper.h
>
39
#include <
utils/geom/Line.h
>
40
#include <
utils/geom/GeoConvHelper.h
>
41
#include <
netimport/NILoader.h
>
42
#include "
NIVissimAbstractEdge.h
"
43
44
#ifdef CHECK_MEMORY_LEAKS
45
#include <
foreign/nvwa/debug_new.h
>
46
#endif // CHECK_MEMORY_LEAKS
47
48
49
NIVissimAbstractEdge::DictType
NIVissimAbstractEdge::myDict
;
50
51
NIVissimAbstractEdge::NIVissimAbstractEdge
(
int
id
,
52
const
PositionVector
& geom)
53
: myID(id), myNode(-1)
54
{
55
// convert/publicate geometry
56
for
(PositionVector::ContType::const_iterator i = geom.
begin
(); i != geom.
end
(); ++i) {
57
Position
p = *i;
58
if
(!
NILoader::transformCoordinates
(p)) {
59
WRITE_WARNING
(
"Unable to project coordinates for edge '"
+
toString
(
id
) +
"'."
);
60
}
61
myGeom
.
push_back_noDoublePos
(p);
62
}
63
//
64
dictionary
(
id
,
this
);
65
}
66
67
68
NIVissimAbstractEdge::~NIVissimAbstractEdge
() {}
69
70
71
bool
72
NIVissimAbstractEdge::dictionary
(
int
id
,
NIVissimAbstractEdge
* e) {
73
DictType::iterator i =
myDict
.find(
id
);
74
if
(i ==
myDict
.end()) {
75
myDict
[id] = e;
76
return
true
;
77
}
78
return
false
;
79
}
80
81
82
NIVissimAbstractEdge
*
83
NIVissimAbstractEdge::dictionary
(
int
id
) {
84
DictType::iterator i =
myDict
.find(
id
);
85
if
(i ==
myDict
.end()) {
86
return
0;
87
}
88
return
(*i).second;
89
}
90
91
92
93
Position
94
NIVissimAbstractEdge::getGeomPosition
(
SUMOReal
pos)
const
{
95
if
(
myGeom
.
length
() > pos) {
96
return
myGeom
.
positionAtLengthPosition
(pos);
97
}
else
if
(
myGeom
.
length
() == pos) {
98
return
myGeom
[-1];
99
}
else
{
100
PositionVector
g(
myGeom
);
101
SUMOReal
amount = pos -
myGeom
.
length
();
102
Position
ne =
GeomHelper::extrapolate_second
(g[-2], g[-1], amount * 2);
103
g.
pop_back
();
104
g.
push_back
(ne);
105
return
g.
positionAtLengthPosition
(pos);
106
}
107
}
108
109
110
void
111
NIVissimAbstractEdge::splitAndAssignToNodes
() {
112
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
113
NIVissimAbstractEdge
* e = (*i).second;
114
e->
splitAssigning
();
115
}
116
}
117
118
void
119
NIVissimAbstractEdge::splitAssigning
() {}
120
121
122
123
124
125
bool
126
NIVissimAbstractEdge::crossesEdge
(
NIVissimAbstractEdge
* c)
const
{
127
return
myGeom
.
intersects
(c->
myGeom
);
128
}
129
130
131
Position
132
NIVissimAbstractEdge::crossesEdgeAtPoint
(
NIVissimAbstractEdge
* c)
const
{
133
return
myGeom
.
intersectsAtPoint
(c->
myGeom
);
134
}
135
136
137
SUMOReal
138
NIVissimAbstractEdge::crossesAtPoint
(
const
Position
& p1,
139
const
Position
& p2)
const
{
140
// !!! not needed
141
Position
p =
GeomHelper::intersection_position2D
(
142
myGeom
.
getBegin
(),
myGeom
.
getEnd
(), p1, p2);
143
return
GeomHelper::nearest_position_on_line_to_point2D
(
144
myGeom
.
getBegin
(),
myGeom
.
getEnd
(), p);
145
}
146
147
148
149
std::vector<int>
150
NIVissimAbstractEdge::getWithin
(
const
AbstractPoly
& p,
SUMOReal
offset) {
151
std::vector<int> ret;
152
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
153
NIVissimAbstractEdge
* e = (*i).second;
154
if
(e->
overlapsWith
(p, offset)) {
155
ret.push_back(e->
myID
);
156
}
157
}
158
return
ret;
159
}
160
161
162
bool
163
NIVissimAbstractEdge::overlapsWith
(
const
AbstractPoly
& p,
SUMOReal
offset)
const
{
164
return
myGeom
.
overlapsWith
(p, offset);
165
}
166
167
168
bool
169
NIVissimAbstractEdge::hasNodeCluster
()
const
{
170
return
myNode
!= -1;
171
}
172
173
174
int
175
NIVissimAbstractEdge::getID
()
const
{
176
return
myID
;
177
}
178
179
void
180
NIVissimAbstractEdge::clearDict
() {
181
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
182
delete
(*i).second;
183
}
184
myDict
.clear();
185
}
186
187
188
const
PositionVector
&
189
NIVissimAbstractEdge::getGeometry
()
const
{
190
return
myGeom
;
191
}
192
193
194
void
195
NIVissimAbstractEdge::addDisturbance
(
int
disturbance) {
196
myDisturbances
.push_back(disturbance);
197
}
198
199
200
const
std::vector<int>&
201
NIVissimAbstractEdge::getDisturbances
()
const
{
202
return
myDisturbances
;
203
}
204
205
206
207
/****************************************************************************/
208
build
buildd
sumo-0.15.0~dfsg
src
netimport
vissim
tempstructs
NIVissimAbstractEdge.cpp
Generated on Wed Jul 18 2012 22:58:35 for SUMO - Simulation of Urban MObility by
1.8.1.1