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
NBNode.h
Go to the documentation of this file.
1
/****************************************************************************/
10
// The representation of a single node
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
#ifndef NBNode_h
24
#define NBNode_h
25
26
27
// ===========================================================================
28
// included modules
29
// ===========================================================================
30
#ifdef _MSC_VER
31
#include <
windows_config.h
>
32
#else
33
#include <
config.h
>
34
#endif
35
36
#include <vector>
37
#include <deque>
38
#include <utility>
39
#include <string>
40
#include <set>
41
#include <
utils/common/Named.h
>
42
#include <
utils/geom/Bresenham.h
>
43
#include <
utils/common/VectorHelper.h
>
44
#include <
utils/geom/Position.h
>
45
#include <
utils/geom/Line.h
>
46
#include <
utils/geom/PositionVector.h
>
47
#include <
utils/xml/SUMOXMLDefinitions.h
>
48
#include "
NBEdge.h
"
49
#include "
NBConnection.h
"
50
#include "
NBConnectionDefs.h
"
51
#include "
NBContHelper.h
"
52
53
54
// ===========================================================================
55
// class declarations
56
// ===========================================================================
57
class
NBRequest
;
58
class
NBDistrict
;
59
class
OptionsCont
;
60
class
NBTrafficLightDefinition
;
61
class
NBTypeCont
;
62
class
NBTrafficLightLogicCont
;
63
class
NBDistrictCont
;
64
class
OutputDevice
;
65
66
67
// ===========================================================================
68
// class definitions
69
// ===========================================================================
74
class
NBNode
:
public
Named
{
75
friend
class
NBNodeCont
;
76
friend
class
GNEJunction
;
// < used for visualization (NETEDIT)
77
friend
class
NBNodesEdgesSorter
;
// < sorts the edges
78
friend
class
NBNodeTypeComputer
;
// < computes type
79
friend
class
NBEdgePriorityComputer
;
// < computes priorities of edges per intersection
80
81
public
:
93
class
ApproachingDivider
:
public
Bresenham::BresenhamCallBack
{
94
private
:
96
EdgeVector
*
myApproaching
;
97
99
NBEdge
*
myCurrentOutgoing
;
100
101
public
:
106
ApproachingDivider
(
EdgeVector
* approaching,
107
NBEdge
* currentOutgoing) ;
108
110
~ApproachingDivider
() ;
111
113
void
execute
(
const
unsigned
int
src,
const
unsigned
int
dest) ;
114
117
std::deque<int> *
spread
(
const
std::vector<int> &approachingLanes,
int
dest)
const
;
118
119
};
120
121
public
:
126
NBNode
(
const
std::string&
id
,
const
Position
& position) ;
127
128
134
NBNode
(
const
std::string&
id
,
const
Position
& position,
SumoXMLNodeType
type) ;
135
136
142
NBNode
(
const
std::string&
id
,
const
Position
& position,
NBDistrict
* district) ;
143
144
146
~NBNode
() ;
147
148
155
void
reinit
(
const
Position
& position,
SumoXMLNodeType
type,
156
bool
updateEdgeGeometries =
false
);
157
158
161
165
const
Position
&
getPosition
()
const
{
166
return
myPosition
;
167
}
168
169
173
const
EdgeVector
&
getIncomingEdges
()
const
{
174
return
myIncomingEdges
;
175
}
176
177
181
const
EdgeVector
&
getOutgoingEdges
()
const
{
182
return
myOutgoingEdges
;
183
}
184
185
189
const
EdgeVector
&
getEdges
()
const
{
190
return
myAllEdges
;
191
}
192
193
198
SumoXMLNodeType
getType
()
const
{
199
return
myType
;
200
}
202
203
204
207
211
void
addTrafficLight
(
NBTrafficLightDefinition
* tlDef) ;
212
214
void
removeTrafficLight
(
NBTrafficLightDefinition
* tlDef) ;
215
218
void
removeTrafficLights
() ;
219
220
224
bool
isTLControlled
()
const
{
225
return
myTrafficLights
.size() != 0;
226
}
227
228
232
bool
isJoinedTLSControlled
()
const
;
233
234
238
const
std::set<NBTrafficLightDefinition*> &
getControllingTLS
()
const
{
239
return
myTrafficLights
;
240
}
242
243
244
247
257
unsigned
int
removeSelfLoops
(
NBDistrictCont
& dc,
NBEdgeCont
& ec,
NBTrafficLightLogicCont
& tc);
259
260
261
264
269
void
reshiftPosition
(
SUMOReal
xoff,
SUMOReal
yoff);
271
272
273
275
void
addIncomingEdge
(
NBEdge
* edge);
276
278
void
addOutgoingEdge
(
NBEdge
* edge);
279
280
281
282
284
void
computeLanes2Lanes
();
285
287
void
computeLogic
(
const
NBEdgeCont
& ec,
OptionsCont
& oc);
288
291
bool
writeLogic
(
OutputDevice
& into)
const
;
292
295
Position
getEmptyDir
()
const
;
296
297
302
bool
hasIncoming
(
const
NBEdge
*
const
e)
const
;
303
304
309
bool
hasOutgoing
(
const
NBEdge
*
const
e)
const
;
310
311
312
NBEdge
*
getOppositeIncoming
(
NBEdge
* e)
const
;
313
void
invalidateIncomingConnections
();
314
void
invalidateOutgoingConnections
();
315
316
void
removeDoubleEdges
();
317
NBEdge
*
getConnectionTo
(
NBNode
* n)
const
;
318
319
320
void
addSortedLinkFoes
(
const
NBConnection
& mayDrive,
321
const
NBConnection
& mustStop);
322
323
NBEdge
*
getPossiblySplittedIncoming
(
const
std::string& edgeid);
324
NBEdge
*
getPossiblySplittedOutgoing
(
const
std::string& edgeid);
325
328
void
removeEdge
(
NBEdge
* edge,
bool
removeFromConnections =
true
);
329
339
bool
isLeftMover
(
const
NBEdge
*
const
from,
const
NBEdge
*
const
to)
const
;
340
341
348
bool
mustBrake
(
const
NBEdge
*
const
from,
const
NBEdge
*
const
to,
int
toLane)
const
;
349
350
359
bool
forbids
(
const
NBEdge
*
const
possProhibitorFrom,
const
NBEdge
*
const
possProhibitorTo,
360
const
NBEdge
*
const
possProhibitedFrom,
const
NBEdge
*
const
possProhibitedTo,
361
bool
regardNonSignalisedLowerPriority)
const
;
362
363
371
bool
foes
(
const
NBEdge
*
const
from1,
const
NBEdge
*
const
to1,
372
const
NBEdge
*
const
from2,
const
NBEdge
*
const
to2)
const
;
373
374
380
LinkDirection
getDirection
(
const
NBEdge
*
const
incoming,
const
NBEdge
*
const
outgoing)
const
;
381
382
std::string
stateCode
(
const
NBEdge
* incoming,
NBEdge
* outgoing,
int
fromLane,
bool
mayDefinitelyPass)
const
;
383
384
void
computeNodeShape
(
bool
leftHand);
385
386
387
const
PositionVector
&
getShape
()
const
;
388
389
bool
checkIsRemovable
()
const
;
390
391
392
std::vector<std::pair<NBEdge*, NBEdge*> >
getEdgesToJoin
()
const
;
393
394
SUMOReal
getMaxEdgeWidth
()
const
;
395
396
friend
class
NBNodeShapeComputer
;
397
398
bool
isNearDistrict
()
const
;
399
bool
isDistrict
()
const
;
400
401
bool
needsCont
(
NBEdge
* fromE,
NBEdge
* toE,
NBEdge
* otherFromE,
NBEdge
* otherToE,
const
NBEdge::Connection
& c)
const
;
402
411
PositionVector
computeInternalLaneShape
(
412
NBEdge
* fromE,
int
fromL,
NBEdge
* toE,
int
toL,
int
numPoints = 5)
const
;
413
414
417
void
replaceIncoming
(
NBEdge
* which,
NBEdge
* by,
unsigned
int
laneOff);
418
421
void
replaceIncoming
(
const
EdgeVector
& which,
NBEdge
* by);
422
425
void
replaceOutgoing
(
NBEdge
* which,
NBEdge
* by,
unsigned
int
laneOff);
426
429
void
replaceOutgoing
(
const
EdgeVector
& which,
NBEdge
* by);
430
431
void
buildInnerEdges
();
432
433
const
NBConnectionProhibits
&
getProhibitions
() {
434
return
myBlockedConnections
;
435
}
436
441
class
nodes_by_id_sorter
{
442
public
:
444
explicit
nodes_by_id_sorter
() { }
445
448
int
operator()
(
NBNode
* n1,
NBNode
* n2)
const
{
449
return
n1->
getID
() < n2->
getID
();
450
}
451
452
};
453
454
private
:
455
bool
isSimpleContinuation
()
const
;
456
458
void
setPriorityJunctionPriorities
();
459
462
EdgeVector
*
getEdgesThatApproach
(
NBEdge
* currentOutgoing);
463
464
465
466
467
void
replaceInConnectionProhibitions
(
NBEdge
* which,
NBEdge
* by,
468
unsigned
int
whichLaneOff,
unsigned
int
byLaneOff);
469
470
471
void
remapRemoved
(
NBTrafficLightLogicCont
& tc,
472
NBEdge
* removed,
const
EdgeVector
& incoming,
const
EdgeVector
& outgoing);
473
474
475
private
:
477
Position
myPosition
;
478
480
EdgeVector
myIncomingEdges
;
481
483
EdgeVector
myOutgoingEdges
;
484
486
EdgeVector
myAllEdges
;
487
489
SumoXMLNodeType
myType
;
490
492
NBConnectionProhibits
myBlockedConnections
;
493
495
NBDistrict
*
myDistrict
;
496
498
PositionVector
myPoly
;
499
500
NBRequest
*
myRequest
;
501
502
std::set<NBTrafficLightDefinition*>
myTrafficLights
;
503
504
private
:
506
NBNode
(
const
NBNode
& s);
507
509
NBNode
&
operator=
(
const
NBNode
& s);
510
511
512
};
513
514
515
#endif
516
517
/****************************************************************************/
518
build
buildd
sumo-0.15.0~dfsg
src
netbuild
NBNode.h
Generated on Wed Jul 18 2012 22:58:34 for SUMO - Simulation of Urban MObility by
1.8.1.1