Eclipse SUMO - Simulation of Urban MObility
NGNet Class Reference

The class storing the generated network. More...

#include <NGNet.h>

Collaboration diagram for NGNet:
[legend]

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 xAttachLength, double yAttachLength)
 Creates a grid network. More...
 
void createSpiderWeb (int numRadDiv, int numCircles, double spaceRad, bool hasCenter, double attachLength)
 Creates a spider network. More...
 
NGNodefindNode (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...
 
NGNetoperator= (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...
 
NBNetBuildermyNetBuilder
 The builder used to build NB*-structures. More...
 
NGNodeList myNodeList
 The list of nodes. More...
 

Detailed Description

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().

Definition at line 47 of file NGNet.h.

Constructor & Destructor Documentation

◆ NGNet() [1/2]

NGNet::NGNet ( NBNetBuilder nb)

Constructor.

Definition at line 46 of file NGNet.cpp.

◆ ~NGNet()

NGNet::~NGNet ( )

Destructor.

Definition at line 53 of file NGNet.cpp.

References myEdgeList, and myNodeList.

◆ NGNet() [2/2]

NGNet::NGNet ( const NGNet )
private

Invalidated copy constructor.

Member Function Documentation

◆ add() [1/2]

void NGNet::add ( NGEdge edge)

Adds the given edge to the network.

The edge is added to myEdgeList.

Parameters
[in]edgeThe edge to add

Definition at line 319 of file NGNet.cpp.

References myEdgeList.

◆ add() [2/2]

void NGNet::add ( NGNode node)

Adds the given node to the network.

The node is added to myNodeList.

Parameters
[in]nodeThe node to add

Definition at line 313 of file NGNet.cpp.

References myNodeList.

Referenced by NGRandomNetBuilder::createNet(), and NGRandomNetBuilder::createNewNode().

Here is the caller graph for this function:

◆ alphabeticalCode()

std::string NGNet::alphabeticalCode ( int  i,
int  iMax 
)
private

return a letter code for the given integer index

Definition at line 80 of file NGNet.cpp.

Referenced by createChequerBoard(), and createSpiderWeb().

Here is the caller graph for this function:

◆ connect()

void NGNet::connect ( NGNode node1,
NGNode node2 
)
private

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>.

Parameters
[in]node1The first node to connect
[in]node2The second node to connect

Definition at line 221 of file NGNet.cpp.

References Named::getID(), myAlphaIDs, and myEdgeList.

Referenced by createChequerBoard(), and createSpiderWeb().

Here is the caller graph for this function:

◆ createChequerBoard()

void NGNet::createChequerBoard ( int  numX,
int  numY,
double  spaceX,
double  spaceY,
double  xAttachLength,
double  yAttachLength 
)

Creates a grid network.

Performs a double-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.

Parameters
[in]numXThe number of nodes in x-direction
[in]numYThe number of nodes in y-direction
[in]spaceXThe space between nodes in x-direction
[in]spaceYThe space between nodes in y-direction
[in]xAttachLengthThe length of streets attached at the border in x-direction
[in]yAttachLengthThe length of streets attached at the border in y-direction
See also
NGNet::connect

Definition at line 93 of file NGNet.cpp.

References alphabeticalCode(), connect(), findNode(), myAlphaIDs, myNodeList, NGNode::setFringe(), NGNode::setX(), NGNode::setY(), and toString().

Referenced by buildNetwork().

Here is the caller graph for this function:

◆ createSpiderWeb()

void NGNet::createSpiderWeb ( int  numRadDiv,
int  numCircles,
double  spaceRad,
bool  hasCenter,
double  attachLength 
)

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.

Parameters
[in]numRadDivThe number of arms to build
[in]numCirclesThe number of circles to build
[in]spaceRadThe distance between the circles
[in]hasCenterInformation whether a center node shall be built
See also
NGNet::connect
Todo:
consolidate the name of the center node

Definition at line 164 of file NGNet.cpp.

References alphabeticalCode(), connect(), findNode(), M_PI, myAlphaIDs, myNodeList, radialToX(), radialToY(), NGNode::setX(), and NGNode::setY().

Referenced by buildNetwork().

Here is the caller graph for this function:

◆ findNode()

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.

Parameters
[in]xPosThe x-position of the searched node
[in]yPosThe y-position of the searched node
Returns
The node with the given position, or 0 if no such node exists

Definition at line 70 of file NGNet.cpp.

References myNodeList.

Referenced by createChequerBoard(), and createSpiderWeb().

Here is the caller graph for this function:

◆ getDistribution()

Distribution_Parameterized NGNet::getDistribution ( const std::string &  option)
staticprivate

get distribution from option

Definition at line 229 of file NGNet.cpp.

References OptionsCont::getOptions(), OptionsCont::getString(), and StringUtils::toDouble().

Referenced by toNB().

Here is the caller graph for this function:

◆ getNextFreeID()

std::string NGNet::getNextFreeID ( )

Returns the next free id.

Uses the value of myLastID to return a new (numeric) id. Increases myLastID.

Returns
A new, unique numerical id

Definition at line 64 of file NGNet.cpp.

References myLastID.

Referenced by NGRandomNetBuilder::createNet(), and NGRandomNetBuilder::createNewNode().

Here is the caller graph for this function:

◆ nodeNo()

int NGNet::nodeNo ( ) const

Returns the number of stored nodes.

Returns
The number of stored nodes

Definition at line 325 of file NGNet.cpp.

References myNodeList.

Referenced by NGRandomNetBuilder::createNet().

Here is the caller graph for this function:

◆ operator=()

NGNet& NGNet::operator= ( const NGNet )
private

Invalidated assignment operator.

◆ radialToX()

double NGNet::radialToX ( double  radius,
double  phi 
)

Returns the x-position resulting from the given radius and angle.

Parameters
[in]radiusThe radius of the circle
[in]phiThe angle the position is located at
Returns
The x-position at the described circle at angle phi

Definition at line 152 of file NGNet.cpp.

Referenced by createSpiderWeb().

Here is the caller graph for this function:

◆ radialToY()

double NGNet::radialToY ( double  radius,
double  phi 
)

Returns the y-position resulting from the given radius and angle.

Parameters
[in]radiusThe radius of the circle
[in]phiThe angle the position is located at
Returns
The y-position at the described circle at angle phi

Definition at line 158 of file NGNet.cpp.

Referenced by createSpiderWeb().

Here is the caller graph for this function:

◆ toNB()

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.

Exceptions
ProcessErrorIf a built tls logic could not be added (should never happen)
Todo:
Check whether throwing an exception is really necessary, here

Definition at line 240 of file NGNet.cpp.

References NBEdgeCont::begin(), NBEdgeCont::end(), OptionsCont::getBool(), getDistribution(), NBNetBuilder::getDistrictCont(), NBNetBuilder::getEdgeCont(), OptionsCont::getFloat(), NBEdge::getFromNode(), NBEdge::getGeometry(), NBNode::getIncomingEdges(), OptionsCont::getInt(), NBNetBuilder::getNodeCont(), OptionsCont::getOptions(), OptionsCont::getString(), NBNetBuilder::getTLLogicCont(), NBNodeCont::insert(), NBEdgeCont::insert(), MAX2(), PositionVector::move2side(), myEdgeList, myNetBuilder, myNodeList, NBEdgeCont::processSplits(), RandHelper::rand(), Distribution_Parameterized::sample(), NBEdge::setGeometry(), Position::sety(), Position::setz(), split(), and toString().

Referenced by main().

Here is the caller graph for this function:

Field Documentation

◆ myAlphaIDs

const bool NGNet::myAlphaIDs
private

Whether to use alphanumericalIDs.

Definition at line 204 of file NGNet.h.

Referenced by connect(), createChequerBoard(), and createSpiderWeb().

◆ myEdgeList

NGEdgeList NGNet::myEdgeList
private

The list of links.

Definition at line 213 of file NGNet.h.

Referenced by add(), connect(), toNB(), and ~NGNet().

◆ myLastID

int NGNet::myLastID
private

The last ID given to node or link.

Definition at line 201 of file NGNet.h.

Referenced by getNextFreeID().

◆ myNetBuilder

NBNetBuilder& NGNet::myNetBuilder
private

The builder used to build NB*-structures.

Definition at line 207 of file NGNet.h.

Referenced by toNB().

◆ myNodeList

NGNodeList NGNet::myNodeList
private

The list of nodes.

Definition at line 210 of file NGNet.h.

Referenced by add(), createChequerBoard(), createSpiderWeb(), findNode(), nodeNo(), toNB(), and ~NGNet().


The documentation for this class was generated from the following files: