SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NGEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A netgen-representation of an edge
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
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 #include <algorithm>
34 #include <netbuild/NBNode.h>
35 #include <netbuild/NBNodeCont.h>
36 #include <netbuild/NBEdge.h>
37 #include <netbuild/NBOwnTLDef.h>
38 #include <netbuild/NBTypeCont.h>
40 #include <netbuild/NBNetBuilder.h>
42 #include <utils/common/ToString.h>
45 #include <utils/options/Option.h>
46 #include "NGEdge.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 // ---------------------------------------------------------------------------
58 // NGEdge-definitions
59 // ---------------------------------------------------------------------------
60 NGEdge::NGEdge(const std::string& id, NGNode* startNode, NGNode* endNode)
61  : Named(id), myStartNode(startNode), myEndNode(endNode) {
62  myStartNode->addLink(this);
63  myEndNode->addLink(this);
64 }
65 
66 
68  myStartNode->removeLink(this);
69  myEndNode->removeLink(this);
70 }
71 
72 
73 NBEdge*
75  return new NBEdge(
76  myID,
77  nb.getNodeCont().retrieve(myStartNode->getID()), // from
78  nb.getNodeCont().retrieve(myEndNode->getID()), // to
79  "", nb.getTypeCont().getSpeed(""), nb.getTypeCont().getNumLanes(""),
81  );
82 }
83 
84 
85 /****************************************************************************/
86 
~NGEdge()
Destructor.
Definition: NGEdge.cpp:67
NBTypeCont & getTypeCont()
Returns the type container.
Definition: NBNetBuilder.h:170
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:60
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:198
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m/s].
Definition: NBTypeCont.cpp:134
const std::string & getID() const
Returns the id.
Definition: Named.h:60
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:104
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:98
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:110
Base class for objects which have an id.
Definition: Named.h:45
std::string myID
The name of the object.
Definition: Named.h:121
NBEdge * buildNBEdge(NBNetBuilder &nb) const
Builds and returns this link&#39;s netbuild-representation.
Definition: NGEdge.cpp:74
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:162
NGNode * myEndNode
The node the edge ends at.
Definition: NGEdge.h:117
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:129
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