SUMO - Simulation of Urban MObility
NGRandomNetBuilder.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Additional structures for building random nets
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NGRandomNetBuilder_h
23 #define NGRandomNetBuilder_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include "NGNet.h"
36 #include <map>
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
47 public:
56  void add(int numNeighbours, SUMOReal ratio);
57 
58 
64  int num();
65 
66 
67 private:
69  std::map<int, SUMOReal> myNeighbours;
70 
71 };
72 
73 
81 public:
92  NGRandomNetBuilder(NGNet& net, SUMOReal minAngle, SUMOReal minDistance, SUMOReal maxDistance, SUMOReal connectivity,
93  int numTries, const TNeighbourDistribution& neighborDist);
94 
95 
96 
102  void createNet(int numNodes);
103 
104 
105 private:
110  void removeOuterNode(NGNode* node);
111 
112 
120  bool checkAngles(NGNode* node);
121 
122 
132  bool canConnect(NGNode* baseNode, NGNode* newNode);
133 
134 
142  bool createNewNode(NGNode* baseNode);
143 
144 
150  void findPossibleOuterNodes(NGNode* node);
151 
152 
153 private:
156 
159 
162 
163  // list of possible new connections
165 
166 
168 
169 
172 
175 
178 
182 
183 
186 
189 
192 
193 private:
196 
199 
200 };
201 
202 
203 #endif
204 
205 /****************************************************************************/
206 
void add(int numNeighbours, SUMOReal ratio)
adds a neighbour item to list
NGNodeList myOuterNodes
The list of outer nodes.
void findPossibleOuterNodes(NGNode *node)
finds possible connections between Node and OuterNodes complying with restrictions ...
void createNet(int numNodes)
Builds a NGNet using the set values.
TNeighbourDistribution myNeighbourDistribution
The distrubtion of number of neighbours.
SUMOReal myConnectivity
Probability of connecting to a existing node if possible.
SUMOReal myMaxDistance
Maximum distance allowed between two nodes.
int num()
Get random number of neighbours.
std::list< NGEdge * > NGEdgeList
A list of edges (edge pointers)
Definition: NGEdge.h:126
bool checkAngles(NGNode *node)
Checks whether the angle of this node's connections are valid.
bool canConnect(NGNode *baseNode, NGNode *newNode)
Checks whether connecting the given two nodes complies with the set restrictions. ...
std::list< NGNode * > NGNodeList
A list of nodes (node pointers)
Definition: NGNode.h:215
int myNumNodes
Number of nodes to be created.
The class storing the generated network.
Definition: NGNet.h:56
NGRandomNetBuilder & operator=(const NGRandomNetBuilder &)
Invalidated assignment operator.
std::map< int, SUMOReal > myNeighbours
A map from neighbor number to their probabilities.
void removeOuterNode(NGNode *node)
Removes the given node from the list of outer nodes.
NGEdgeList myOuterLinks
The list of outer links.
#define SUMOReal
Definition: config.h:215
SUMOReal myMinDistance
Minimum distance allowed between two nodes.
A class that builds random network using an algorithm by Markus Hartinger.
SUMOReal myMinLinkAngle
Minimum angle allowed between two links.
A netgen-representation of a node.
Definition: NGNode.h:58
bool createNewNode(NGNode *baseNode)
Creates new random node.
NGRandomNetBuilder(NGNet &net, SUMOReal minAngle, SUMOReal minDistance, SUMOReal maxDistance, SUMOReal connectivity, int numTries, const TNeighbourDistribution &neighborDist)
Constructor.
int myNumTries
Number of tries to create a new node.
NGNet & myNet
The network to fill.