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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A netgen-representation of a node
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <list>
26 #include <utils/common/Named.h>
27 #include <utils/geom/Position.h>
28 #include <utils/geom/GeomHelper.h>
30 #include "NGEdge.h"
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class NBNode;
37 class NBEdge;
38 class NBNetBuilder;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class NGNode : public Named {
49 public:
54  NGNode(const std::string& id);
55 
56 
63  NGNode(const std::string& id, int xPos, int yPos);
64 
65 
73  NGNode(const std::string& id, int xID, int yID, bool amCenter);
74 
75 
77  ~NGNode();
78 
79 
84  const Position& getPosition() const {
85  return myPosition;
86  }
87 
88 
94  return myMaxNeighbours;
95  }
96 
97 
102  void setMaxNeighbours(int value) {
103  myMaxNeighbours = value;
104  }
105 
106 
111  void setX(double x) {
112  myPosition.set(x, myPosition.y());
113  }
114 
115 
120  void setY(double y) {
121  myPosition.set(myPosition.x(), y);
122  }
123 
125  void setFringe() {
126  myAmFringe = true;
127  }
128 
144  NBNode* buildNBNode(NBNetBuilder& nb, const Position& perturb) const;
145 
146 
151  void addLink(NGEdge* link);
152 
153 
161  void removeLink(NGEdge* link);
162 
163 
169  bool connected(NGNode* node) const;
170 
171 
177  bool samePos(int xPos, int yPos) const {
178  return xID == xPos && yID == yPos;
179  }
180 
181  // NGRandomNetBuilder needs access to links
182  friend class NGRandomNetBuilder;
183 
184 private:
186  int xID;
187 
189  int yID;
190 
193 
196 
199 
202 
205 
206 };
207 
212 typedef std::list<NGNode*> NGNodeList;
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:116
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:212
The representation of a single edge during network building.
Definition: NBEdge.h:91
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
Represents a single node (junction) during network building.
Definition: NBNode.h:66
A netgen-representation of an edge.
Definition: NGEdge.h:52
A netgen-representation of a node.
Definition: NGNode.h:48
const Position & getPosition() const
Returns this node's position.
Definition: NGNode.h:84
int xID
Integer x-position (x-id)
Definition: NGNode.h:186
bool connected(NGNode *node) const
Returns whether the other node is connected.
Definition: NGNode.cpp:117
void setFringe()
mark node as fringe
Definition: NGNode.h:125
void setY(double y)
Sets a new value for y-position.
Definition: NGNode.h:120
~NGNode()
Destructor.
Definition: NGNode.cpp:56
void setX(double x)
Sets a new value for x-position.
Definition: NGNode.h:111
int yID
Integer y-position (y-id)
Definition: NGNode.h:189
NGNode(const std::string &id)
Constructor.
Definition: NGNode.cpp:44
NBNode * buildNBNode(NBNetBuilder &nb, const Position &perturb) const
Builds and returns this node's netbuild-representation.
Definition: NGNode.cpp:66
bool samePos(int xPos, int yPos) const
Returns whether the node has the given position.
Definition: NGNode.h:177
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:201
void setMaxNeighbours(int value)
Sets this node's maximum neighbour number.
Definition: NGNode.h:102
Position myPosition
The position of the node.
Definition: NGNode.h:195
bool myAmFringe
Information whether this is the center of a cpider-net.
Definition: NGNode.h:204
int myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:198
void addLink(NGEdge *link)
Adds the given link to the internal list.
Definition: NGNode.cpp:105
void removeLink(NGEdge *link)
Removes the given link.
Definition: NGNode.cpp:111
int getMaxNeighbours()
Returns this node's maximum neighbour number.
Definition: NGNode.h:93
NGEdgeList LinkList
List of connected links.
Definition: NGNode.h:192
A class that builds random network using an algorithm by Markus Hartinger.
Base class for objects which have an id.
Definition: Named.h:53
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
void set(double x, double y)
set positions x and y
Definition: Position.h:84
double x() const
Returns the x-position.
Definition: Position.h:54
double y() const
Returns the y-position.
Definition: Position.h:59