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
NGNode.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// A netgen-representation of a node
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2001-2014 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
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <algorithm>
35
#include <
netbuild/NBNode.h
>
36
#include <
netbuild/NBNodeCont.h
>
37
#include <
netbuild/NBEdge.h
>
38
#include <
netbuild/NBOwnTLDef.h
>
39
#include <
netbuild/NBTypeCont.h
>
40
#include <
netbuild/NBTrafficLightLogicCont.h
>
41
#include <
netbuild/NBNetBuilder.h
>
42
#include <
utils/common/UtilExceptions.h
>
43
#include <
utils/common/ToString.h
>
44
#include <
utils/geom/GeoConvHelper.h
>
45
#include <
utils/options/OptionsCont.h
>
46
#include <
utils/options/Option.h
>
47
#include "
NGNode.h
"
48
49
#ifdef CHECK_MEMORY_LEAKS
50
#include <
foreign/nvwa/debug_new.h
>
51
#endif // CHECK_MEMORY_LEAKS
52
53
54
// ===========================================================================
55
// method definitions
56
// ===========================================================================
57
NGNode::NGNode
(
const
std::string&
id
)
58
:
Named
(id), xID(-1), yID(-1), myAmCenter(false) {}
59
60
61
NGNode::NGNode
(
const
std::string&
id
,
int
xIDa,
int
yIDa)
62
:
Named
(id), xID(xIDa), yID(yIDa), myAmCenter(false) {}
63
64
65
NGNode::NGNode
(
const
std::string&
id
,
int
xIDa,
int
yIDa,
bool
amCenter)
66
:
Named
(id), xID(xIDa), yID(yIDa), myAmCenter(amCenter) {}
67
68
69
NGNode::~NGNode
() {
70
NGEdgeList::iterator li;
71
while
(
LinkList
.size() != 0) {
72
li =
LinkList
.begin();
73
delete
(*li);
74
}
75
}
76
77
78
NBNode
*
79
NGNode::buildNBNode
(
NBNetBuilder
& nb)
const
{
80
Position
pos(
myPosition
);
81
GeoConvHelper::getProcessing
().
x2cartesian
(pos);
82
// the center will have no logic!
83
if
(
myAmCenter
) {
84
return
new
NBNode
(
myID
, pos,
NODETYPE_NOJUNCTION
);
85
}
86
NBNode
* node = 0;
87
std::string typeS =
OptionsCont::getOptions
().
isSet
(
"default-junction-type"
) ?
88
OptionsCont::getOptions
().
getString
(
"default-junction-type"
) :
""
;
89
90
if
(
SUMOXMLDefinitions::NodeTypes
.hasString(typeS)) {
91
SumoXMLNodeType
type =
SUMOXMLDefinitions::NodeTypes
.
get
(typeS);
92
node =
new
NBNode
(
myID
, pos, type);
93
94
// check whether it is a traffic light junction
95
if
(type ==
NODETYPE_TRAFFIC_LIGHT
|| type ==
NODETYPE_TRAFFIC_LIGHT_NOJUNCTION
) {
96
TrafficLightType
type =
SUMOXMLDefinitions::TrafficLightTypes
.
get
(
97
OptionsCont::getOptions
().getString(
"tls.default-type"
));
98
NBTrafficLightDefinition
* tlDef =
new
NBOwnTLDef
(
myID
, node, 0, type);
99
if
(!nb.
getTLLogicCont
().
insert
(tlDef)) {
100
// actually, nothing should fail here
101
delete
tlDef;
102
throw
ProcessError
();
103
}
104
}
105
}
else
{
106
// otherwise netbuild may guess NODETYPE_TRAFFIC_LIGHT without actually building one
107
node =
new
NBNode
(
myID
, pos,
NODETYPE_PRIORITY
);
108
}
109
110
return
node;
111
}
112
113
114
void
115
NGNode::addLink
(
NGEdge
* link) {
116
LinkList
.push_back(link);
117
}
118
119
120
void
121
NGNode::removeLink
(
NGEdge
* link) {
122
LinkList
.remove(link);
123
}
124
125
126
bool
127
NGNode::connected
(
NGNode
* node)
const
{
128
for
(NGEdgeList::const_iterator i =
LinkList
.begin(); i !=
LinkList
.end(); ++i) {
129
if
(find(node->
LinkList
.begin(), node->
LinkList
.end(), *i) != node->
LinkList
.end()) {
130
return
true
;
131
}
132
}
133
return
false
;
134
}
135
136
137
/****************************************************************************/
138
tmp
buildd
sumo-0.21.0+dfsg
src
netgen
NGNode.cpp
Generated on Thu Nov 20 2014 19:49:56 for SUMO - Simulation of Urban MObility by
1.8.1.2