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.dev/sumo
3 // Copyright (C) 2001-2024 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 
164  const NGEdgeList& getLinks() const {
165  return myLinkList;
166  }
167 
173  bool connected(const NGNode* const node, const bool withDir = false) const;
174 
175 
181  bool samePos(int xPos, int yPos) const {
182  return myXID == xPos && myYID == yPos;
183  }
184 
185 private:
187  int myXID;
188 
190  int myYID;
191 
194 
197 
200 
203 
206 
207 };
208 
213 typedef std::list<NGNode*> NGNodeList;
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:118
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:213
The representation of a single edge during network building.
Definition: NBEdge.h:92
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
bool connected(const NGNode *const node, const bool withDir=false) 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
NGEdgeList myLinkList
List of connected links.
Definition: NGNode.h:193
~NGNode()
Destructor.
Definition: NGNode.cpp:56
void setX(double x)
Sets a new value for x-position.
Definition: NGNode.h:111
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:181
bool myAmCenter
Information whether this is the center of a cpider-net.
Definition: NGNode.h:202
const NGEdgeList & getLinks() const
Definition: NGNode.h:164
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:196
bool myAmFringe
Information whether this is the center of a cpider-net.
Definition: NGNode.h:205
int myMaxNeighbours
The maximum number of neighbours.
Definition: NGNode.h:199
int myYID
Integer y-position (y-id)
Definition: NGNode.h:190
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
int myXID
Integer x-position (x-id)
Definition: NGNode.h:187
Base class for objects which have an id.
Definition: Named.h:54
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
void set(double x, double y)
set positions x and y
Definition: Position.h:85
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60