Dynamical System Framework
Loading...
Searching...
No Matches
dsf::Edge Class Referenceabstract

The Edge class represents the concept of an edge (u -> v) in the network. More...

#include <Edge.hpp>

Inheritance diagram for dsf::Edge:
dsf::mobility::Road dsf::mobility::Street

Public Member Functions

 Edge (Id id, std::pair< Node *, Node * > nodePair, geometry::PolyLine geometry={})
 Construct a new Edge object.
 Edge (Edge &&)=default
 Edge (const Edge &)=delete
void setGeometry (geometry::PolyLine geometry)
 Set the edge's geometry.
void setAttribute (std::string const &name, std::variant< std::monostate, bool, std::int64_t, double, std::string > const &value)
 Set an attribute for the edge.
void setSource (Node *pNode)
 Replace the edge's source node, e.g. when the network changes its type.
void setTarget (Node *pNode)
 Replace the edge's target node, e.g. when the network changes its type.
auto id () const
 Get the edge's id.
auto const & nodePair () const noexcept
 Get the edge's nodes.
Node * source () const noexcept
 Get the edge's source node.
Node * target () const noexcept
 Get the edge's target node.
auto const & geometry () const
 Get the edge's geometry.
auto angle () const
 Get the edge's angle, in radians, between the source and target nodes.
auto const & attributes () const
 Get the edge's attributes.
template<typename T>
std::optional< T > getAttribute (std::string const &name) const
 Get an attribute of the edge by name.
virtual bool isFull () const =0
virtual bool isActive () const
double deltaAngle (double const previousEdgeAngle) const

Protected Member Functions

void m_setAngle (geometry::Point srcNodeCoordinates, geometry::Point dstNodeCoordinates)

Protected Attributes

geometry::PolyLine m_geometry
Id m_id
std::pair< Node *, Node * > m_nodePair
double m_angle
std::unordered_map< std::string, std::variant< std::monostate, bool, std::int64_t, double, std::string > > m_attributes

Detailed Description

The Edge class represents the concept of an edge (u -> v) in the network.

An edge is linked to its source and target nodes, which it does not own.

Constructor & Destructor Documentation

◆ Edge()

dsf::Edge::Edge ( Id id,
std::pair< Node *, Node * > nodePair,
geometry::PolyLine geometry = {} )

Construct a new Edge object.

Parameters
idThe edge's id
nodePairThe edge's node pointers pair (u, v) with the edge u -> v
geometryThe edge's geometry, a vector of pairs of doubles representing the coordinates of the edge's geometry. Default is an empty vector.
Exceptions
std::invalid_argumentif a node is null

Member Function Documentation

◆ angle()

auto dsf::Edge::angle ( ) const
inline

Get the edge's angle, in radians, between the source and target nodes.

Returns
double The edge's angle, in radians

◆ attributes()

auto const & dsf::Edge::attributes ( ) const
inline

Get the edge's attributes.

Returns
std::unordered_map<std::string, std::variant<std::monostate, bool, std::int64_t, double, std::string>> The edge's attributes, where the key is the attribute's name and the value is the attribute's value

◆ geometry()

auto const & dsf::Edge::geometry ( ) const
inline

Get the edge's geometry.

Returns
dsf::geometry::PolyLine The edge's geometry, a vector of pairs of doubles representing the coordinates of the edge's geometry

◆ getAttribute()

template<typename T>
std::optional< T > dsf::Edge::getAttribute ( std::string const & name) const
inline

Get an attribute of the edge by name.

Template Parameters
TThe expected type of the attribute's value
Parameters
nameThe attribute's name
Returns
std::optional<T> The attribute's value if it exists and can be cast to the expected type, std::nullopt otherwise

◆ id()

auto dsf::Edge::id ( ) const
inline

Get the edge's id.

Returns
Id The edge's id

◆ isActive()

virtual bool dsf::Edge::isActive ( ) const
inlinevirtual

Reimplemented in dsf::mobility::Road.

◆ isFull()

virtual bool dsf::Edge::isFull ( ) const
pure virtual

Implemented in dsf::mobility::Road.

◆ nodePair()

auto const & dsf::Edge::nodePair ( ) const
inlinenoexcept

Get the edge's nodes.

Returns
std::pair<Node*, Node*> The edge's (source, target) nodes, with the edge u -> v

◆ setAttribute()

void dsf::Edge::setAttribute ( std::string const & name,
std::variant< std::monostate, bool, std::int64_t, double, std::string > const & value )

Set an attribute for the edge.

Parameters
nameThe attribute's name
valueThe attribute's value

◆ setGeometry()

void dsf::Edge::setGeometry ( geometry::PolyLine geometry)

Set the edge's geometry.

Parameters
geometrydsf::geometry::PolyLine The edge's geometry, a vector of pairs of doubles representing the coordinates of the edge's geometry

◆ setSource()

void dsf::Edge::setSource ( Node * pNode)

Replace the edge's source node, e.g. when the network changes its type.

Parameters
pNodeA pointer to the new source node
Exceptions
std::invalid_argumentif the node is null or does not have the source id

◆ setTarget()

void dsf::Edge::setTarget ( Node * pNode)

Replace the edge's target node, e.g. when the network changes its type.

Parameters
pNodeA pointer to the new target node
Exceptions
std::invalid_argumentif the node is null or does not have the target id

◆ source()

Node * dsf::Edge::source ( ) const
inlinenoexcept

Get the edge's source node.

Returns
Node* A pointer to the source node

◆ target()

Node * dsf::Edge::target ( ) const
inlinenoexcept

Get the edge's target node.

Returns
Node* A pointer to the target node

The documentation for this class was generated from the following files:
  • src/dsf/base/Edge.hpp
  • src/dsf/base/Edge.cpp