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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A netgen-representation of a node
18 /****************************************************************************/
19 #ifndef NGNode_h
20 #define NGNode_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <list>
29 #include <utils/common/Named.h>
30 #include <utils/geom/Position.h>
31 #include <utils/geom/GeomHelper.h>
33 #include "NGEdge.h"
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class NBNode;
40 class NBEdge;
41 class NBNetBuilder;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
51 class NGNode : public Named {
52 public:
57  NGNode(const std::string& id);
58 
59 
66  NGNode(const std::string& id, int xPos, int yPos);
67 
68 
76  NGNode(const std::string& id, int xID, int yID, bool amCenter);
77 
78 
80  ~NGNode();
81 
82 
87  const Position& getPosition() const {
88  return myPosition;
89  }
90 
91 
97  return myMaxNeighbours;
98  }
99 
100 
105  void setMaxNeighbours(int value) {
106  myMaxNeighbours = value;
107  }
108 
109 
114  void setX(double x) {
115  myPosition.set(x, myPosition.y());
116  }
117 
118 
123  void setY(double y) {
124  myPosition.set(myPosition.x(), y);
125  }
126 
127 
143  NBNode* buildNBNode(NBNetBuilder& nb, const Position& perturb) const;
144 
145 
150  void addLink(NGEdge* link);
151 
152 
160  void removeLink(NGEdge* link);
161 
162 
168  bool connected(NGNode* node) const;
169 
170 
176  bool samePos(int xPos, int yPos) const {
177  return xID == xPos && yID == yPos;
178  }
179 
180  // NGRandomNetBuilder needs access to links
181  friend class NGRandomNetBuilder;
182 
183 private:
185  int xID;
186 
188  int yID;
189 
192 
195 
198 
201 
202 };
203 
208 typedef std::list<NGNode*> NGNodeList;
209 
210 
211 
212 #endif
213 
214 /****************************************************************************/
215 
A netgen-representation of an edge.
Definition: NGEdge.h:55
int xID
Integer x-position (x-id)
Definition: NGNode.h:185
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:200
double y() const
Returns the y-position.
Definition: Position.h:62
The representation of a single edge during network building.
Definition: NBEdge.h:65
int yID
Integer y-position (y-id)
Definition: NGNode.h:188
double x() const
Returns the x-position.
Definition: Position.h:57
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:110
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:119
void set(double x, double y)
set positions x and y
Definition: Position.h:87
~NGNode()
Destructor.
Definition: NGNode.cpp:58
void setX(double x)
Sets a new value for x-position.
Definition: NGNode.h:114
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
bool connected(NGNode *node) const
Returns whether the other node is connected.
Definition: NGNode.cpp:116
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:208
int getMaxNeighbours()
Returns this node&#39;s maximum neighbour number.
Definition: NGNode.h:96
Base class for objects which have an id.
Definition: Named.h:58
Position myPosition
The position of the node.
Definition: NGNode.h:194
int myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:197
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
NGNode(const std::string &id)
Constructor.
Definition: NGNode.cpp:46
bool samePos(int xPos, int yPos) const
Returns whether the node has the given position.
Definition: NGNode.h:176
Represents a single node (junction) during network building.
Definition: NBNode.h:68
void setMaxNeighbours(int value)
Sets this node&#39;s maximum neighbour number.
Definition: NGNode.h:105
const Position & getPosition() const
Returns this node&#39;s position.
Definition: NGNode.h:87
A class that builds random network using an algorithm by Markus Hartinger.
A netgen-representation of a node.
Definition: NGNode.h:51
void setY(double y)
Sets a new value for y-position.
Definition: NGNode.h:123
NBNode * buildNBNode(NBNetBuilder &nb, const Position &perturb) const
Builds and returns this node&#39;s netbuild-representation.
Definition: NGNode.cpp:68
NGEdgeList LinkList
List of connected links.
Definition: NGNode.h:191
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:104