Eclipse 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-2019 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 /****************************************************************************/
16 // A netgen-representation of a node
17 /****************************************************************************/
18 #ifndef NGNode_h
19 #define NGNode_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <list>
28 #include <utils/common/Named.h>
29 #include <utils/geom/Position.h>
30 #include <utils/geom/GeomHelper.h>
32 #include "NGEdge.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class NBNode;
39 class NBEdge;
40 class NBNetBuilder;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 class NGNode : public Named {
51 public:
56  NGNode(const std::string& id);
57 
58 
65  NGNode(const std::string& id, int xPos, int yPos);
66 
67 
75  NGNode(const std::string& id, int xID, int yID, bool amCenter);
76 
77 
79  ~NGNode();
80 
81 
86  const Position& getPosition() const {
87  return myPosition;
88  }
89 
90 
96  return myMaxNeighbours;
97  }
98 
99 
104  void setMaxNeighbours(int value) {
105  myMaxNeighbours = value;
106  }
107 
108 
113  void setX(double x) {
114  myPosition.set(x, myPosition.y());
115  }
116 
117 
122  void setY(double y) {
123  myPosition.set(myPosition.x(), y);
124  }
125 
126 
142  NBNode* buildNBNode(NBNetBuilder& nb, const Position& perturb) const;
143 
144 
149  void addLink(NGEdge* link);
150 
151 
159  void removeLink(NGEdge* link);
160 
161 
167  bool connected(NGNode* node) const;
168 
169 
175  bool samePos(int xPos, int yPos) const {
176  return xID == xPos && yID == yPos;
177  }
178 
179  // NGRandomNetBuilder needs access to links
180  friend class NGRandomNetBuilder;
181 
182 private:
184  int xID;
185 
187  int yID;
188 
191 
194 
197 
200 
201 };
202 
207 typedef std::list<NGNode*> NGNodeList;
208 
209 
210 
211 #endif
212 
213 /****************************************************************************/
214 
NGNode::yID
int yID
Integer y-position (y-id)
Definition: NGNode.h:187
Named
Base class for objects which have an id.
Definition: Named.h:56
NBNetBuilder
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
NGNode::~NGNode
~NGNode()
Destructor.
Definition: NGNode.cpp:57
NGNode::LinkList
NGEdgeList LinkList
List of connected links.
Definition: NGNode.h:190
NGNodeList
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:207
NGEdge
A netgen-representation of an edge.
Definition: NGEdge.h:54
NGNode::connected
bool connected(NGNode *node) const
Returns whether the other node is connected.
Definition: NGNode.cpp:115
NGNode::xID
int xID
Integer x-position (x-id)
Definition: NGNode.h:184
NGNode::removeLink
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:109
NGNode::NGNode
NGNode(const std::string &id)
Constructor.
Definition: NGNode.cpp:45
NGNode::getPosition
const Position & getPosition() const
Returns this node's position.
Definition: NGNode.h:86
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NGRandomNetBuilder
A class that builds random network using an algorithm by Markus Hartinger.
Definition: NGRandomNetBuilder.h:41
NGNode::addLink
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:103
Position::set
void set(double x, double y)
set positions x and y
Definition: Position.h:86
Named.h
NGNode::myMaxNeighbours
int myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:196
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
UtilExceptions.h
NGNode::myAmCenter
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:199
NGNode::myPosition
Position myPosition
The position of the node.
Definition: NGNode.h:193
Position.h
NGNode::getMaxNeighbours
int getMaxNeighbours()
Returns this node's maximum neighbour number.
Definition: NGNode.h:95
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
NGEdgeList
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:118
config.h
NGNode::samePos
bool samePos(int xPos, int yPos) const
Returns whether the node has the given position.
Definition: NGNode.h:175
GeomHelper.h
NGNode::setMaxNeighbours
void setMaxNeighbours(int value)
Sets this node's maximum neighbour number.
Definition: NGNode.h:104
NBNode
Represents a single node (junction) during network building.
Definition: NBNode.h:67
NGNode::setY
void setY(double y)
Sets a new value for y-position.
Definition: NGNode.h:122
NGNode::buildNBNode
NBNode * buildNBNode(NBNetBuilder &nb, const Position &perturb) const
Builds and returns this node's netbuild-representation.
Definition: NGNode.cpp:67
NGNode
A netgen-representation of a node.
Definition: NGNode.h:50
NGEdge.h
NGNode::setX
void setX(double x)
Sets a new value for x-position.
Definition: NGNode.h:113