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-2013 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
// convert/publicate geometry
55
for
(PositionVector::const_iterator i = geom.begin(); i != geom.end(); ++i) {
56
Position
p = *i;
57
if
(!
NILoader::transformCoordinates
(p)) {
58
WRITE_WARNING
(
"Unable to project coordinates for edge '"
+
toString
(
id
) +
"'."
);
59
}
60
myGeom
.
push_back_noDoublePos
(p);
61
}
62
//
63
dictionary
(
id
,
this
);
64
}
65
66
67
NIVissimAbstractEdge::~NIVissimAbstractEdge
() {}
68
69
70
bool
71
NIVissimAbstractEdge::dictionary
(
int
id
,
NIVissimAbstractEdge
* e) {
72
DictType::iterator i =
myDict
.find(
id
);
73
if
(i ==
myDict
.end()) {
74
myDict
[id] = e;
75
return
true
;
76
}
77
return
false
;
78
}
79
80
81
NIVissimAbstractEdge
*
82
NIVissimAbstractEdge::dictionary
(
int
id
) {
83
DictType::iterator i =
myDict
.find(
id
);
84
if
(i ==
myDict
.end()) {
85
return
0;
86
}
87
return
(*i).second;
88
}
89
90
91
92
Position
93
NIVissimAbstractEdge::getGeomPosition
(
SUMOReal
pos)
const
{
94
if
(
myGeom
.
length
() > pos) {
95
return
myGeom
.
positionAtOffset
(pos);
96
}
else
if
(
myGeom
.
length
() == pos) {
97
return
myGeom
[-1];
98
}
else
{
99
PositionVector
g(
myGeom
);
100
SUMOReal
amount = pos -
myGeom
.
length
();
101
Position
ne =
GeomHelper::extrapolate_second
(g[-2], g[-1], amount * 2);
102
g.pop_back();
103
g.
push_back
(ne);
104
return
g.
positionAtOffset
(pos);
105
}
106
}
107
108
109
void
110
NIVissimAbstractEdge::splitAndAssignToNodes
() {
111
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
112
NIVissimAbstractEdge
* e = (*i).second;
113
e->
splitAssigning
();
114
}
115
}
116
117
void
118
NIVissimAbstractEdge::splitAssigning
() {}
119
120
121
122
123
124
bool
125
NIVissimAbstractEdge::crossesEdge
(
NIVissimAbstractEdge
* c)
const
{
126
return
myGeom
.
intersects
(c->
myGeom
);
127
}
128
129
130
Position
131
NIVissimAbstractEdge::crossesEdgeAtPoint
(
NIVissimAbstractEdge
* c)
const
{
132
return
myGeom
.
intersectsAtPoint
(c->
myGeom
);
133
}
134
135
136
SUMOReal
137
NIVissimAbstractEdge::crossesAtPoint
(
const
Position
& p1,
138
const
Position
& p2)
const
{
139
// !!! not needed
140
Position
p =
GeomHelper::intersection_position2D
(
141
myGeom
.front(),
myGeom
.back(), p1, p2);
142
return
GeomHelper::nearest_offset_on_line_to_point2D
(
143
myGeom
.front(),
myGeom
.back(), p);
144
}
145
146
147
148
std::vector<int>
149
NIVissimAbstractEdge::getWithin
(
const
AbstractPoly
& p,
SUMOReal
offset) {
150
std::vector<int> ret;
151
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
152
NIVissimAbstractEdge
* e = (*i).second;
153
if
(e->
overlapsWith
(p, offset)) {
154
ret.push_back(e->
myID
);
155
}
156
}
157
return
ret;
158
}
159
160
161
bool
162
NIVissimAbstractEdge::overlapsWith
(
const
AbstractPoly
& p,
SUMOReal
offset)
const
{
163
return
myGeom
.
overlapsWith
(p, offset);
164
}
165
166
167
bool
168
NIVissimAbstractEdge::hasNodeCluster
()
const
{
169
return
myNode
!= -1;
170
}
171
172
173
int
174
NIVissimAbstractEdge::getID
()
const
{
175
return
myID
;
176
}
177
178
void
179
NIVissimAbstractEdge::clearDict
() {
180
for
(DictType::iterator i =
myDict
.begin(); i !=
myDict
.end(); i++) {
181
delete
(*i).second;
182
}
183
myDict
.clear();
184
}
185
186
187
const
PositionVector
&
188
NIVissimAbstractEdge::getGeometry
()
const
{
189
return
myGeom
;
190
}
191
192
193
void
194
NIVissimAbstractEdge::addDisturbance
(
int
disturbance) {
195
myDisturbances
.push_back(disturbance);
196
}
197
198
199
const
std::vector<int>&
200
NIVissimAbstractEdge::getDisturbances
()
const
{
201
return
myDisturbances
;
202
}
203
204
205
206
/****************************************************************************/
207
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
netimport
vissim
tempstructs
NIVissimAbstractEdge.cpp
Generated on Sun Jun 16 2013 07:08:01 for SUMO - Simulation of Urban MObility by
1.8.1.2