SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NGNode.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A netgen-representation of a node
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 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 #ifndef NGNode_h
23 #define NGNode_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <list>
36 #include <utils/common/Named.h>
37 #include <utils/geom/Position.h>
38 #include <utils/geom/GeomHelper.h>
40 #include "NGEdge.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class NBNode;
47 class NBEdge;
48 class NBNetBuilder;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class NGNode : public Named {
59 public:
64  NGNode(const std::string& id);
65 
66 
73  NGNode(const std::string& id, int xPos, int yPos);
74 
75 
83  NGNode(const std::string& id, int xID, int yID, bool amCenter);
84 
85 
87  ~NGNode();
88 
89 
94  const Position& getPosition() const {
95  return myPosition;
96  }
97 
98 
104  return myMaxNeighbours;
105  }
106 
107 
113  myMaxNeighbours = value;
114  }
115 
116 
121  void setX(SUMOReal x) {
122  myPosition.set(x, myPosition.y());
123  }
124 
125 
130  void setY(SUMOReal y) {
131  myPosition.set(myPosition.x(), y);
132  }
133 
134 
150  NBNode* buildNBNode(NBNetBuilder& nb) const;
151 
152 
157  void addLink(NGEdge* link);
158 
159 
167  void removeLink(NGEdge* link);
168 
169 
175  bool connected(NGNode* node) const;
176 
177 
183  bool samePos(int xPos, int yPos) const {
184  return xID == xPos && yID == yPos;
185  }
186 
187  // NGRandomNetBuilder needs access to links
188  friend class NGRandomNetBuilder;
189 
190 private:
192  int xID;
193 
195  int yID;
196 
199 
202 
205 
208 
209 };
210 
215 typedef std::list<NGNode*> NGNodeList;
216 
217 
218 
219 #endif
220 
221 /****************************************************************************/
222 
void setX(SUMOReal x)
Sets a new value for x-position.
Definition: NGNode.h:121
A netgen-representation of an edge.
Definition: NGEdge.h:62
int xID
Integer x-position (x-id)
Definition: NGNode.h:192
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:207
bool connected(NGNode *node) const
Returns whether the other node is connected.
Definition: NGNode.cpp:127
The representation of a single edge during network building.
Definition: NBEdge.h:71
int yID
Integer y-position (y-id)
Definition: NGNode.h:195
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:121
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:126
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
SUMOReal getMaxNeighbours()
Returns this node's maximum neighbour number.
Definition: NGNode.h:103
NBNode * buildNBNode(NBNetBuilder &nb) const
Builds and returns this node's netbuild-representation.
Definition: NGNode.cpp:79
~NGNode()
Destructor.
Definition: NGNode.cpp:69
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:215
SUMOReal myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:204
void setMaxNeighbours(SUMOReal value)
Sets this node's maximum neighbour number.
Definition: NGNode.h:112
Base class for objects which have an id.
Definition: Named.h:45
Position myPosition
The position of the node.
Definition: NGNode.h:201
const Position & getPosition() const
Returns this node's position.
Definition: NGNode.h:94
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
NGNode(const std::string &id)
Constructor.
Definition: NGNode.cpp:57
bool samePos(int xPos, int yPos) const
Returns whether the node has the given position.
Definition: NGNode.h:183
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
void set(SUMOReal x, SUMOReal y)
Definition: Position.h:78
Represents a single node (junction) during network building.
Definition: NBNode.h:74
#define SUMOReal
Definition: config.h:215
A class that builds random network using an algorithm by Markus Hartinger.
void setY(SUMOReal y)
Sets a new value for y-position.
Definition: NGNode.h:130
A netgen-representation of a node.
Definition: NGNode.h:58
NGEdgeList LinkList
List of connected links.
Definition: NGNode.h:198
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:115