![]() |
Eclipse SUMO - Simulation of Urban MObility
|
The class storing the generated network. More...
#include <NGNet.h>
Public Member Functions | |
void | add (NGEdge *edge) |
Adds the given edge to the network. More... | |
void | add (NGNode *node) |
Adds the given node to the network. More... | |
void | createChequerBoard (int numX, int numY, double spaceX, double spaceY, double attachLength) |
Creates a grid network. More... | |
void | createSpiderWeb (int numRadDiv, int numCircles, double spaceRad, bool hasCenter) |
Creates a spider network. More... | |
NGNode * | findNode (int xPos, int yPos) |
Returns the node at the given position. More... | |
std::string | getNextFreeID () |
Returns the next free id. More... | |
NGNet (NBNetBuilder &nb) | |
Constructor. More... | |
int | nodeNo () const |
Returns the number of stored nodes. More... | |
double | radialToX (double radius, double phi) |
Returns the x-position resulting from the given radius and angle. More... | |
double | radialToY (double radius, double phi) |
Returns the y-position resulting from the given radius and angle. More... | |
void | toNB () const |
Converts the stored network into its netbuilder-representation. More... | |
~NGNet () | |
Destructor. More... | |
Private Member Functions | |
std::string | alphabeticalCode (int i, int iMax) |
return a letter code for the given integer index More... | |
void | connect (NGNode *node1, NGNode *node2) |
Connects both nodes with two edges, one for each direction. More... | |
NGNet (const NGNet &) | |
Invalidated copy constructor. More... | |
NGNet & | operator= (const NGNet &) |
Invalidated assignment operator. More... | |
Static Private Member Functions | |
static Distribution_Parameterized | getDistribution (const std::string &option) |
get distribution from option More... | |
Private Attributes | |
const bool | myAlphaIDs |
Whether to use alphanumericalIDs. More... | |
NGEdgeList | myEdgeList |
The list of links. More... | |
int | myLastID |
The last ID given to node or link. More... | |
NBNetBuilder & | myNetBuilder |
The builder used to build NB*-structures. More... | |
NGNodeList | myNodeList |
The list of nodes. More... | |
The class storing the generated network.
An instance of this class stores both the edges and the nodes build during the generation of a network (using any type of generation algorithm). These instances are later transformed into netbuild-structures using toNB().
NGNet::NGNet | ( | NBNetBuilder & | nb | ) |
NGNet::~NGNet | ( | ) |
|
private |
Invalidated copy constructor.
void NGNet::add | ( | NGEdge * | edge | ) |
Adds the given edge to the network.
The edge is added to myEdgeList.
[in] | edge | The edge to add |
Definition at line 323 of file NGNet.cpp.
References myEdgeList.
void NGNet::add | ( | NGNode * | node | ) |
Adds the given node to the network.
The node is added to myNodeList.
[in] | node | The node to add |
Definition at line 317 of file NGNet.cpp.
References myNodeList.
Referenced by NGRandomNetBuilder::createNet(), and NGRandomNetBuilder::createNewNode().
|
private |
return a letter code for the given integer index
Definition at line 81 of file NGNet.cpp.
Referenced by createChequerBoard(), and createSpiderWeb().
Connects both nodes with two edges, one for each direction.
Builds one link for each direction and appends the links to myEdgeList. The name of a link is as following: <FROM_NODE_ID>to<TO_NODE_ID>.
[in] | node1 | The first node to connect |
[in] | node2 | The second node to connect |
Definition at line 208 of file NGNet.cpp.
References Named::getID(), myAlphaIDs, and myEdgeList.
Referenced by createChequerBoard(), and createSpiderWeb().
void NGNet::createChequerBoard | ( | int | numX, |
int | numY, | ||
double | spaceX, | ||
double | spaceY, | ||
double | attachLength | ||
) |
Creates a grid network.
Performs a souble-loop over numX, then numY. Builds NGNodes at the according positions and connects them using NGNet::connect. Stores both the nodes and the edges within the internal container.
The nodes get an id using <RUNNING_X>/<RUNNING_Y>. The ids of the links are set in NGNet::connect.
[in] | numX | The number of nodes in x-direction |
[in] | numY | The number of nodes in y-direction |
[in] | spaceX | The space between nodes in x-direction |
[in] | spaceY | The space between nodes in y-direction |
[in] | attachLength | The length of streets attached at the border |
Definition at line 94 of file NGNet.cpp.
References alphabeticalCode(), connect(), findNode(), myAlphaIDs, myNodeList, NGNode::setX(), NGNode::setY(), and toString().
Referenced by buildNetwork().
void NGNet::createSpiderWeb | ( | int | numRadDiv, |
int | numCircles, | ||
double | spaceRad, | ||
bool | hasCenter | ||
) |
Creates a spider network.
Creates a spider web by going through all arms and then all circles in a loop. Builds the NGNodes at the positions obtained using radialToX and radialToY and connects them using NGNet::connect. Builds optionally a center node, and connects it, too.
The nodes get an id using <RUNNING_ARM_NUMBER>/<RUNNING_CIRCLE_NUMBER>. The ids of the links are set in NGNet::connect.
[in] | numRadDiv | The number of arms to build |
[in] | numCircles | The number of circles to build |
[in] | spaceRad | The distance between the circles |
[in] | hasCenter | Information whether a center node shall be built |
Definition at line 159 of file NGNet.cpp.
References alphabeticalCode(), connect(), findNode(), M_PI, myAlphaIDs, myNodeList, radialToX(), radialToY(), NGNode::setX(), and NGNode::setY().
Referenced by buildNetwork().
NGNode * NGNet::findNode | ( | int | xPos, |
int | yPos | ||
) |
Returns the node at the given position.
Searches for a node with the given position within myNodeList. Returns the matching node, if one exists, or 0 otherwise.
[in] | xPos | The x-position of the searched node |
[in] | yPos | The y-position of the searched node |
Definition at line 71 of file NGNet.cpp.
References myNodeList.
Referenced by createChequerBoard(), and createSpiderWeb().
|
staticprivate |
get distribution from option
Definition at line 218 of file NGNet.cpp.
References OptionsCont::getOptions(), OptionsCont::getString(), Distribution_Parameterized::parse(), and StringUtils::toDouble().
Referenced by toNB().
std::string NGNet::getNextFreeID | ( | ) |
Returns the next free id.
Uses the value of myLastID to return a new (numeric) id. Increases myLastID.
Definition at line 65 of file NGNet.cpp.
References myLastID.
Referenced by NGRandomNetBuilder::createNet(), and NGRandomNetBuilder::createNewNode().
int NGNet::nodeNo | ( | ) | const |
Returns the number of stored nodes.
Definition at line 329 of file NGNet.cpp.
References myNodeList.
Referenced by NGRandomNetBuilder::createNet().
double NGNet::radialToX | ( | double | radius, |
double | phi | ||
) |
Returns the x-position resulting from the given radius and angle.
[in] | radius | The radius of the circle |
[in] | phi | The angle the position is located at |
Definition at line 147 of file NGNet.cpp.
Referenced by createSpiderWeb().
double NGNet::radialToY | ( | double | radius, |
double | phi | ||
) |
Returns the y-position resulting from the given radius and angle.
[in] | radius | The radius of the circle |
[in] | phi | The angle the position is located at |
Definition at line 153 of file NGNet.cpp.
Referenced by createSpiderWeb().
void NGNet::toNB | ( | ) | const |
Converts the stored network into its netbuilder-representation.
Goes through all stored nodes, first, converts them into their netbuilder representations using NGNode::buildNBNode, and stores the built NBNodes into the net builder myNetBuilder.
Then, the method goes through all edges, converts them into their netbuilder representations using NGEdge::buildNBEdge, and stores the built NBEdges into the net builder myNetBuilder.
If one of the nodes is controlled by a tls and the built logic could not be added to net builder's storage, a ProcessError is thrown. This in fact may only happen when two same ids occur, what is not possible.
ProcessError | If a built tls logic could not be added (should never happen) |
Definition at line 230 of file NGNet.cpp.
References NBEdgeCont::begin(), NBEdgeCont::end(), OptionsCont::getBool(), NBNode::getConnectionTo(), getDistribution(), NBNetBuilder::getDistrictCont(), NBNetBuilder::getEdgeCont(), OptionsCont::getFloat(), NBEdge::getFromNode(), NBEdge::getGeometry(), NBNode::getIncomingEdges(), OptionsCont::getInt(), NBNetBuilder::getNodeCont(), OptionsCont::getOptions(), NBTypeCont::getSpeed(), OptionsCont::getString(), NBNetBuilder::getTLLogicCont(), NBNetBuilder::getTypeCont(), NBTypeCont::getWidth(), NBNodeCont::insert(), NBEdgeCont::insert(), MAX2(), PositionVector::move2side(), myEdgeList, myNetBuilder, myNodeList, NBEdgeCont::processSplits(), RandHelper::rand(), Distribution_Parameterized::sample(), NBEdge::setGeometry(), split(), toString(), and NBEdge::UNSPECIFIED_OFFSET.
Referenced by main().
|
private |
Whether to use alphanumericalIDs.
Definition at line 205 of file NGNet.h.
Referenced by connect(), createChequerBoard(), and createSpiderWeb().
|
private |
|
private |
The last ID given to node or link.
Definition at line 202 of file NGNet.h.
Referenced by getNextFreeID().
|
private |
|
private |
The list of nodes.
Definition at line 211 of file NGNet.h.
Referenced by add(), createChequerBoard(), createSpiderWeb(), findNode(), nodeNo(), toNB(), and ~NGNet().