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.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 // The class storing the generated network
18 /****************************************************************************/
19 #ifndef NGNet_h
20 #define NGNet_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include "NGEdge.h"
29 #include "NGNode.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class NBNetBuilder;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
49 class NGNet {
50 public:
52  NGNet(NBNetBuilder& nb);
53 
54 
56  ~NGNet();
57 
58 
68  NGNode* findNode(int xPos, int yPos);
69 
70 
78  std::string getNextFreeID();
79 
80 
87  double radialToX(double radius, double phi);
88 
89 
96  double radialToY(double radius, double phi);
97 
98 
115  void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength);
116 
117 
135  void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter);
136 
137 
155  void toNB() const;
156 
157 
164  void add(NGNode* node);
165 
166 
173  void add(NGEdge* edge);
174 
175 
180  int nodeNo() const;
181 
182 
183 private:
192  void connect(NGNode* node1, NGNode* node2);
193 
195  std::string alphabeticalCode(int i, int iMax);
196 
197 
198 private:
200  int myLastID;
201 
203  const bool myAlphaIDs;
204 
207 
210 
213 
214 private:
216  NGNet(const NGNet&);
217 
219  NGNet& operator=(const NGNet&);
220 
221 };
222 
223 
224 #endif
225 
226 /****************************************************************************/
227 
NBNetBuilder & myNetBuilder
The builder used to build NB*-structures.
Definition: NGNet.h:206
NGNet(NBNetBuilder &nb)
Constructor.
Definition: NGNet.cpp:46
std::string alphabeticalCode(int i, int iMax)
return a letter code for the given integer index
Definition: NGNet.cpp:80
A netgen-representation of an edge.
Definition: NGEdge.h:55
double radialToX(double radius, double phi)
Returns the x-position resulting from the given radius and angle.
Definition: NGNet.cpp:146
void connect(NGNode *node1, NGNode *node2)
Connects both nodes with two edges, one for each direction.
Definition: NGNet.cpp:207
void toNB() const
Converts the stored network into its netbuilder-representation.
Definition: NGNet.cpp:218
NGNode * findNode(int xPos, int yPos)
Returns the node at the given position.
Definition: NGNet.cpp:70
double radialToY(double radius, double phi)
Returns the y-position resulting from the given radius and angle.
Definition: NGNet.cpp:152
int nodeNo() const
Returns the number of stored nodes.
Definition: NGNet.cpp:309
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:119
NGEdgeList myEdgeList
The list of links.
Definition: NGNet.h:212
NGNet & operator=(const NGNet &)
Invalidated assignment operator.
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:208
std::string getNextFreeID()
Returns the next free id.
Definition: NGNet.cpp:64
NGNodeList myNodeList
The list of nodes.
Definition: NGNet.h:209
The class storing the generated network.
Definition: NGNet.h:49
int myLastID
The last ID given to node or link.
Definition: NGNet.h:200
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
void createSpiderWeb(int numRadDiv, int numCircles, double spaceRad, bool hasCenter)
Creates a spider network.
Definition: NGNet.cpp:158
void createChequerBoard(int numX, int numY, double spaceX, double spaceY, double attachLength)
Creates a grid network.
Definition: NGNet.cpp:93
A netgen-representation of a node.
Definition: NGNode.h:51
const bool myAlphaIDs
Whether to use alphanumericalIDs.
Definition: NGNet.h:203
~NGNet()
Destructor.
Definition: NGNet.cpp:53
void add(NGNode *node)
Adds the given node to the network.
Definition: NGNet.cpp:297