NGNode Class Reference

#include <NGNode.h>


Detailed Description

A netgen-representation of a node.

Definition at line 54 of file NGNode.h.


Public Member Functions

void addLink (NGEdge *link) throw ()
 Adds the given link to the internal list.
NBNodebuildNBNode (NBNetBuilder &nb) const throw (ProcessError)
 Builds and returns this node's netbuild-representation.
bool connected (NGNode *node) const throw ()
 Returns whether the other node is connected.
const std::string & getID () const throw ()
 Returns this node's id.
SUMOReal getMaxNeighbours () throw ()
 Returns this node's maximum neighbour number.
const Position2DgetPosition () const throw ()
 Returns this node's position.
 NGNode (const std::string &id, int xID, int yID, bool amCenter) throw ()
 Constructor.
 NGNode (const std::string &id, int xPos, int yPos) throw ()
 Constructor.
 NGNode (const std::string &id) throw ()
 Constructor.
 NGNode () throw ()
 Constructor.
void removeLink (NGEdge *link) throw ()
 Removes the given link.
bool samePos (int xPos, int yPos) const throw ()
 Returns whether the node has the given position.
void setMaxNeighbours (SUMOReal value) throw ()
 Sets this node's maximum neighbour number.
void setX (SUMOReal x) throw ()
 Sets a new value for x-position.
void setY (SUMOReal y) throw ()
 Sets a new value for y-position.
 ~NGNode () throw ()
 Destructor.

Private Attributes

NGEdgeList LinkList
 List of connected links.
bool myAmCenter
 Information whether this is the center of a cpider-net.
std::string myID
 The id of the node.
SUMOReal myMaxNeighbours
 The maximum number of neighbours.
Position2D myPosition
 The position of the node.
int xID
 Integer x-position (x-id).
int yID
 Integer y-position (y-id).

Friends

class NGRandomNetBuilder

Constructor & Destructor Documentation

NGNode::NGNode (  )  throw ()

Constructor.

Definition at line 53 of file NGNode.cpp.

00054         : xID(-1), yID(-1), myID(""), myAmCenter(false) {}

NGNode::NGNode ( const std::string &  id  )  throw ()

Constructor.

Parameters:
[in] id The id of the node

Definition at line 57 of file NGNode.cpp.

00058         : xID(-1), yID(-1), myID(id), myAmCenter(false) {}

NGNode::NGNode ( const std::string &  id,
int  xPos,
int  yPos 
) throw ()

Constructor.

Parameters:
[in] id The id of the node
[in] xPos The x-position of the node
[in] yPos The y-position of the node

Definition at line 61 of file NGNode.cpp.

00062         : xID(xIDa), yID(yIDa), myID(id), myAmCenter(false) {}

NGNode::NGNode ( const std::string &  id,
int  xID,
int  yID,
bool  amCenter 
) throw ()

Constructor.

Parameters:
[in] id The id of the node
[in] xPos The x-position of the node
[in] yPos The y-position of the node
[in] amCenter Information whether this is the center-node of a spider-net

Definition at line 65 of file NGNode.cpp.

00066         : xID(xIDa), yID(yIDa), myID(id), myAmCenter(amCenter) {}

NGNode::~NGNode (  )  throw ()

Destructor.

Definition at line 69 of file NGNode.cpp.

References LinkList.

00069                         {
00070     NGEdgeList::iterator li;
00071     while (LinkList.size() != 0) {
00072         li = LinkList.begin();
00073         delete(*li);
00074     }
00075 }


Member Function Documentation

void NGNode::addLink ( NGEdge link  )  throw ()

Adds the given link to the internal list.

Parameters:
[in] link The link to add

Definition at line 112 of file NGNode.cpp.

References LinkList.

00112                                     {
00113     LinkList.push_back(link);
00114 }

NBNode * NGNode::buildNBNode ( NBNetBuilder nb  )  const throw (ProcessError)

Builds and returns this node's netbuild-representation.

The position of the node is transformed to cartesian using GeoConvHelper::x2cartesian, first. If this node is the center node of a spider net, a node of the type NBNode::NODETYPE_NOJUNCTION is returned. Otherwise, a plain node is built and it is checked whether the options indicate building one of the tls node-types. In this case, a logic is built and stored. A ProcessError is thrown if this fails (should never happen, in fact).

Parameters:
[in] nb The netbuilder to retrieve the tls-container from
Returns:
The built node
Exceptions:
ProcessError If the built tls logic could not be added (should never happen)
Todo:
There is no interaction with explicite node setting options? Where is this done?
Todo:
Check whether throwing an exception is really necessary, here

Definition at line 79 of file NGNode.cpp.

References OptionsCont::getOptions(), OptionsCont::getString(), OptionsCont::isSet(), myAmCenter, myID, myPosition, NBNode::NODETYPE_NOJUNCTION, NBNode::NODETYPE_PRIORITY_JUNCTION, NBNode::NODETYPE_RIGHT_BEFORE_LEFT, and GeoConvHelper::x2cartesian().

00079                                                               {
00080     Position2D pos(myPosition);
00081     GeoConvHelper::x2cartesian(pos);
00082     // the center will have no logic!
00083     if (myAmCenter) {
00084         return new NBNode(myID, pos, NBNode::NODETYPE_NOJUNCTION);
00085     }
00086     //
00087     // check whether it is a traffic light junction
00088     std::string nodeType = OptionsCont::getOptions().isSet("default-junction-type")
00089                            ? OptionsCont::getOptions().getString("default-junction-type")
00090                            : "";
00091     NBNode *node = 0;
00092     if (nodeType=="") {
00093         node = new NBNode(myID, pos);
00094     } else if (nodeType=="priority") {
00095         node = new NBNode(myID, pos, NBNode::NODETYPE_PRIORITY_JUNCTION);
00096     } else if (nodeType=="right_before_left") {
00097         node = new NBNode(myID, pos, NBNode::NODETYPE_RIGHT_BEFORE_LEFT);
00098     } else if (nodeType=="traffic_light") {
00099         node = new NBNode(myID, pos, NBNode::NODETYPE_PRIORITY_JUNCTION);
00100         NBTrafficLightDefinition *tlDef = new NBOwnTLDef(myID, node);
00101         if (!nb.getTLLogicCont().insert(tlDef)) {
00102             // actually, nothing should fail here
00103             delete tlDef;
00104             throw ProcessError();
00105         }
00106     }
00107     return node;
00108 }

bool NGNode::connected ( NGNode node  )  const throw ()

Returns whether the other node is connected.

Parameters:
[in] node The link to check whether it is connected
Returns:
Whether the given node is connected

Definition at line 124 of file NGNode.cpp.

References LinkList.

00124                                             {
00125     for (NGEdgeList::const_iterator i=LinkList.begin(); i!=LinkList.end(); i++) {
00126         if (find(node->LinkList.begin(), node->LinkList.end(), *i)!=node->LinkList.end()) {
00127             return true;
00128         }
00129     }
00130     return false;
00131 }

const std::string& NGNode::getID (  )  const throw () [inline]

Returns this node's id.

Returns:
The id of the node

Definition at line 94 of file NGNode.h.

References myID.

Referenced by NGEdge::buildNBEdge().

00094                                            {
00095         return myID;
00096     }

SUMOReal NGNode::getMaxNeighbours (  )  throw () [inline]

Returns this node's maximum neighbour number.

Returns:
The maximum neighbour number of the node

Definition at line 112 of file NGNode.h.

References myMaxNeighbours.

Referenced by NGRandomNetBuilder::createNet().

00112                                         {
00113         return myMaxNeighbours;
00114     }

const Position2D& NGNode::getPosition (  )  const throw () [inline]

Returns this node's position.

Returns:
The position of the node

Definition at line 103 of file NGNode.h.

References myPosition.

Referenced by NGRandomNetBuilder::checkAngles().

00103                                                   {
00104         return myPosition;
00105     }

void NGNode::removeLink ( NGEdge link  )  throw ()

Removes the given link.

The given pointer is compared to those in the list. A matching pointer is removed, not other same connections.

Parameters:
[in] link The link to remove

Definition at line 118 of file NGNode.cpp.

References LinkList.

Referenced by NGEdge::~NGEdge().

00118                                        {
00119     LinkList.remove(link);
00120 }

bool NGNode::samePos ( int  xPos,
int  yPos 
) const throw () [inline]

Returns whether the node has the given position.

Parameters:
[in] node The link to check whether it is connected
Returns:
Whether the given node is connected

Definition at line 192 of file NGNode.h.

00192                                                    {
00193         return xID==xPos && yID==yPos;
00194     }

void NGNode::setMaxNeighbours ( SUMOReal  value  )  throw () [inline]

Sets this node's maximum neighbour number.

Parameters:
[in] value The new maximum neighbour number of the node

Definition at line 121 of file NGNode.h.

References myMaxNeighbours.

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

00121                                                   {
00122         myMaxNeighbours = value;
00123     }

void NGNode::setX ( SUMOReal  x  )  throw () [inline]

Sets a new value for x-position.

Parameters:
[in] value The new x-position of this node

Definition at line 130 of file NGNode.h.

References myPosition, Position2D::set(), and Position2D::y().

Referenced by NGNet::createChequerBoard(), NGRandomNetBuilder::createNet(), NGRandomNetBuilder::createNewNode(), and NGNet::createSpiderWeb().

00130                                   {
00131         myPosition.set(x, myPosition.y());
00132     }

void NGNode::setY ( SUMOReal  y  )  throw () [inline]

Sets a new value for y-position.

Parameters:
[in] value The new y-position of this node

Definition at line 139 of file NGNode.h.

References myPosition, Position2D::set(), and Position2D::x().

Referenced by NGNet::createChequerBoard(), NGRandomNetBuilder::createNet(), NGRandomNetBuilder::createNewNode(), and NGNet::createSpiderWeb().

00139                                   {
00140         myPosition.set(myPosition.x(), y);
00141     }


Friends And Related Function Documentation

friend class NGRandomNetBuilder [friend]

Definition at line 197 of file NGNode.h.


Field Documentation

List of connected links.

Definition at line 207 of file NGNode.h.

Referenced by addLink(), connected(), NGRandomNetBuilder::createNet(), removeLink(), and ~NGNode().

Information whether this is the center of a cpider-net.

Definition at line 219 of file NGNode.h.

Referenced by buildNBNode().

std::string NGNode::myID [private]

The id of the node.

Definition at line 210 of file NGNode.h.

Referenced by buildNBNode(), and getID().

SUMOReal NGNode::myMaxNeighbours [private]

The maximum number of neighbours.

Definition at line 216 of file NGNode.h.

Referenced by getMaxNeighbours(), and setMaxNeighbours().

The position of the node.

Definition at line 213 of file NGNode.h.

Referenced by buildNBNode(), getPosition(), setX(), and setY().

int NGNode::xID [private]

Integer x-position (x-id).

Definition at line 201 of file NGNode.h.

int NGNode::yID [private]

Integer y-position (y-id).

Definition at line 204 of file NGNode.h.


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

Generated on Wed May 5 00:06:52 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6