SUMO - Simulation of Urban MObility
NGNode.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A netgen-representation of a node
20 /****************************************************************************/
21 #ifndef NGNode_h
22 #define NGNode_h
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 <list>
35 #include <utils/common/Named.h>
36 #include <utils/geom/Position.h>
37 #include <utils/geom/GeomHelper.h>
39 #include "NGEdge.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class NBNode;
46 class NBEdge;
47 class NBNetBuilder;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
57 class NGNode : public Named {
58 public:
63  NGNode(const std::string& id);
64 
65 
72  NGNode(const std::string& id, int xPos, int yPos);
73 
74 
82  NGNode(const std::string& id, int xID, int yID, bool amCenter);
83 
84 
86  ~NGNode();
87 
88 
93  const Position& getPosition() const {
94  return myPosition;
95  }
96 
97 
103  return myMaxNeighbours;
104  }
105 
106 
111  void setMaxNeighbours(int value) {
112  myMaxNeighbours = value;
113  }
114 
115 
120  void setX(double x) {
121  myPosition.set(x, myPosition.y());
122  }
123 
124 
129  void setY(double y) {
130  myPosition.set(myPosition.x(), y);
131  }
132 
133 
149  NBNode* buildNBNode(NBNetBuilder& nb) const;
150 
151 
156  void addLink(NGEdge* link);
157 
158 
166  void removeLink(NGEdge* link);
167 
168 
174  bool connected(NGNode* node) const;
175 
176 
182  bool samePos(int xPos, int yPos) const {
183  return xID == xPos && yID == yPos;
184  }
185 
186  // NGRandomNetBuilder needs access to links
187  friend class NGRandomNetBuilder;
188 
189 private:
191  int xID;
192 
194  int yID;
195 
198 
201 
204 
207 
208 };
209 
214 typedef std::list<NGNode*> NGNodeList;
215 
216 
217 
218 #endif
219 
220 /****************************************************************************/
221 
A netgen-representation of an edge.
Definition: NGEdge.h:61
int xID
Integer x-position (x-id)
Definition: NGNode.h:191
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:206
double y() const
Returns the y-position.
Definition: Position.h:67
The representation of a single edge during network building.
Definition: NBEdge.h:70
int yID
Integer y-position (y-id)
Definition: NGNode.h:194
double x() const
Returns the x-position.
Definition: Position.h:62
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:116
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:125
void set(double x, double y)
set positions x and y
Definition: Position.h:92
~NGNode()
Destructor.
Definition: NGNode.cpp:64
void setX(double x)
Sets a new value for x-position.
Definition: NGNode.h:120
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
bool connected(NGNode *node) const
Returns whether the other node is connected.
Definition: NGNode.cpp:122
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:214
int getMaxNeighbours()
Returns this node&#39;s maximum neighbour number.
Definition: NGNode.h:102
Base class for objects which have an id.
Definition: Named.h:45
Position myPosition
The position of the node.
Definition: NGNode.h:200
int myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:203
Instance responsible for building networks.
Definition: NBNetBuilder.h:115
NGNode(const std::string &id)
Constructor.
Definition: NGNode.cpp:52
bool samePos(int xPos, int yPos) const
Returns whether the node has the given position.
Definition: NGNode.h:182
Represents a single node (junction) during network building.
Definition: NBNode.h:74
void setMaxNeighbours(int value)
Sets this node&#39;s maximum neighbour number.
Definition: NGNode.h:111
const Position & getPosition() const
Returns this node&#39;s position.
Definition: NGNode.h:93
A class that builds random network using an algorithm by Markus Hartinger.
A netgen-representation of a node.
Definition: NGNode.h:57
void setY(double y)
Sets a new value for y-position.
Definition: NGNode.h:129
NGEdgeList LinkList
List of connected links.
Definition: NGNode.h:197
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:110
NBNode * buildNBNode(NBNetBuilder &nb) const
Builds and returns this node&#39;s netbuild-representation.
Definition: NGNode.cpp:74