Eclipse SUMO - Simulation of Urban MObility
NGNet.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 // The class storing the generated network
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
26 #include "NGEdge.h"
27 #include "NGNode.h"
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class NBNetBuilder;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
47 class NGNet {
48 public:
50  NGNet(NBNetBuilder& nb);
51 
52 
54  ~NGNet();
55 
56 
66  NGNode* findNode(int xPos, int yPos);
67 
68 
76  std::string getNextFreeID();
77 
78 
85  double radialToX(double radius, double phi);
86 
87 
94  double radialToY(double radius, double phi);
95 
96 
114  void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double xAttachLength, double yAttachLength);
115 
116 
134  void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter, double attachLength);
135 
136 
154  void toNB() const;
155 
156 
163  void add(NGNode* node);
164 
165 
172  void add(NGEdge* edge);
173 
174 
179  int nodeNo() const;
180 
181 
182 private:
191  void connect(NGNode* node1, NGNode* node2);
192 
194  std::string alphabeticalCode(int i, int iMax);
195 
197  static Distribution_Parameterized getDistribution(const std::string& option);
198 
199 private:
201  int myLastID;
202 
204  const bool myAlphaIDs;
205 
208 
211 
214 
215 private:
217  NGNet(const NGNet&);
218 
221 
222 };
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
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
A netgen-representation of an edge.
Definition: NGEdge.h:52
The class storing the generated network.
Definition: NGNet.h:47
double radialToX(double radius, double phi)
Returns the x-position resulting from the given radius and angle.
Definition: NGNet.cpp:152
int myLastID
The last ID given to node or link.
Definition: NGNet.h:201
void toNB() const
Converts the stored network into its netbuilder-representation.
Definition: NGNet.cpp:240
void connect(NGNode *node1, NGNode *node2)
Connects both nodes with two edges, one for each direction.
Definition: NGNet.cpp:221
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double xAttachLength, double yAttachLength)
Creates a grid network.
Definition: NGNet.cpp:93
void add(NGNode *node)
Adds the given node to the network.
Definition: NGNet.cpp:313
NGNet(NBNetBuilder &nb)
Constructor.
Definition: NGNet.cpp:46
int nodeNo() const
Returns the number of stored nodes.
Definition: NGNet.cpp:325
void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter, double attachLength)
Creates a spider network.
Definition: NGNet.cpp:164
double radialToY(double radius, double phi)
Returns the y-position resulting from the given radius and angle.
Definition: NGNet.cpp:158
NGNode * findNode(int xPos, int yPos)
Returns the node at the given position.
Definition: NGNet.cpp:70
std::string alphabeticalCode(int i, int iMax)
return a letter code for the given integer index
Definition: NGNet.cpp:80
std::string getNextFreeID()
Returns the next free id.
Definition: NGNet.cpp:64
static Distribution_Parameterized getDistribution(const std::string &option)
get distribution from option
Definition: NGNet.cpp:229
NGNodeList myNodeList
The list of nodes.
Definition: NGNet.h:210
const bool myAlphaIDs
Whether to use alphanumericalIDs.
Definition: NGNet.h:204
NGNet & operator=(const NGNet &)
Invalidated assignment operator.
NBNetBuilder & myNetBuilder
The builder used to build NB*-structures.
Definition: NGNet.h:207
NGNet(const NGNet &)
Invalidated copy constructor.
NGEdgeList myEdgeList
The list of links.
Definition: NGNet.h:213
~NGNet()
Destructor.
Definition: NGNet.cpp:53
A netgen-representation of a node.
Definition: NGNode.h:48