SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NGEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // A netgen-representation of an edge
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2003-2016 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>
41 #include <netbuild/NBNetBuilder.h>
43 #include <utils/common/ToString.h>
46 #include <utils/options/Option.h>
47 #include "NGEdge.h"
48 #include "NGNode.h"
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 // ===========================================================================
56 // method definitions
57 // ===========================================================================
58 // ---------------------------------------------------------------------------
59 // NGEdge-definitions
60 // ---------------------------------------------------------------------------
61 NGEdge::NGEdge(const std::string& id, NGNode* startNode, NGNode* endNode)
62  : Named(id), myStartNode(startNode), myEndNode(endNode) {
63  myStartNode->addLink(this);
64  myEndNode->addLink(this);
65 }
66 
67 
69  myStartNode->removeLink(this);
70  myEndNode->removeLink(this);
71 }
72 
73 
74 NBEdge*
76  return new NBEdge(
77  myID,
78  nb.getNodeCont().retrieve(myStartNode->getID()), // from
79  nb.getNodeCont().retrieve(myEndNode->getID()), // to
80  "", nb.getTypeCont().getSpeed(""), nb.getTypeCont().getNumLanes(""),
82  );
83 }
84 
85 
86 /****************************************************************************/
87 
~NGEdge()
Destructor.
Definition: NGEdge.cpp:68
NBTypeCont & getTypeCont()
Returns the type container.
Definition: NBNetBuilder.h:169
The representation of a single edge during network building.
Definition: NBEdge.h:71
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:121
NGEdge(const std::string &id, NGNode *startNode, NGNode *endNode)
Constructor.
Definition: NGEdge.cpp:61
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:240
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:221
const std::string & getID() const
Returns the id.
Definition: Named.h:66
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:185
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:179
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:191
Base class for objects which have an id.
Definition: Named.h:46
std::string myID
The name of the object.
Definition: Named.h:136
NBEdge * buildNBEdge(NBNetBuilder &nb) const
Builds and returns this link's netbuild-representation.
Definition: NGEdge.cpp:75
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:161
NGNode * myEndNode
The node the edge ends at.
Definition: NGEdge.h:117
Instance responsible for building networks.
Definition: NBNetBuilder.h:112
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
A netgen-representation of a node.
Definition: NGNode.h:58
NGNode * myStartNode
The node the edge starts at.
Definition: NGEdge.h:114
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:115