Fawkes API Fawkes Development Version
fawkes::NavGraphEdge Class Reference

Topological graph edge. More...

#include <>>

Public Member Functions

 NavGraphEdge ()
 Constructor for an invalid edge. More...
 
 NavGraphEdge (const std::string &from, const std::string &to, std::map< std::string, std::string > properties, bool directed=false)
 Constructor. More...
 
 NavGraphEdge (const std::string &from, const std::string &to, bool directed=false)
 Constructor. More...
 
const std::string & from () const
 Get edge originating node name. More...
 
const std::string & to () const
 Get edge target node name. More...
 
const NavGraphNodefrom_node () const
 Get edge originating node. More...
 
const NavGraphNodeto_node () const
 Get edge target node. More...
 
fawkes::cart_coord_2d_t closest_point_on_edge (float x, float y) const
 Get the point on edge closest to a given point. More...
 
float distance (float x, float y) const
 Get distance of point to closest point on edge. More...
 
bool intersects (float x1, float y1, float x2, float y2) const
 Check if the edge intersects with another line segment. More...
 
bool intersection (float x1, float y1, float x2, float y2, fawkes::cart_coord_2d_t &ip) const
 Check if the edge intersects with another line segment. More...
 
void set_from (const std::string &from)
 Set originating node name. More...
 
void set_to (const std::string &to)
 Set target node name. More...
 
void set_directed (bool directed)
 Set directed state. More...
 
const std::map< std::string, std::string > & properties () const
 Get all properties. More...
 
bool has_property (const std::string &property) const
 Check if node has specified property. More...
 
void set_properties (const std::map< std::string, std::string > &properties)
 Overwrite properties with given ones. More...
 
void set_property (const std::string &property, const std::string &value)
 Set property. More...
 
void set_property (const std::string &property, const char *value)
 Set property. More...
 
void set_property (const std::string &property, float value)
 Set property. More...
 
void set_property (const std::string &property, int value)
 Set property. More...
 
void set_property (const std::string &property, bool value)
 Set property. More...
 
float property_as_float (const std::string &prop) const
 Get property converted to float. More...
 
int property_as_int (const std::string &prop) const
 Get property converted to int. More...
 
bool property_as_bool (const std::string &prop) const
 Get property converted to bol. More...
 
bool is_valid () const
 Check if edge is valid. More...
 
bool is_directed () const
 Check if edge is directed. More...
 
std::string property (const std::string &prop) const
 Get specified property as string. More...
 
float property_as_float (const std::string &prop)
 Get property converted to float. More...
 
int property_as_int (const std::string &prop)
 Get property converted to int. More...
 
bool property_as_bool (const std::string &prop)
 Get property converted to bol. More...
 
bool operator== (const NavGraphEdge &e) const
 Check edges for equality. More...
 
bool operator< (const NavGraphEdge &e) const
 Less than operator based on node from and to names. More...
 
 operator bool () const
 Check of edge is valid. More...
 
void set_nodes (const NavGraphNode &from_node, const NavGraphNode &to_node)
 Set nodes. More...
 

Detailed Description

Topological graph edge.

Author
Tim Niemueller

Definition at line 37 of file navgraph_edge.h.

Constructor & Destructor Documentation

◆ NavGraphEdge() [1/3]

fawkes::NavGraphEdge::NavGraphEdge ( )

Constructor for an invalid edge.

Definition at line 49 of file navgraph_edge.cpp.

◆ NavGraphEdge() [2/3]

fawkes::NavGraphEdge::NavGraphEdge ( const std::string &  from,
const std::string &  to,
std::map< std::string, std::string >  properties,
bool  directed = false 
)

Constructor.

Parameters
fromoriginating node name
totarget node name
propertiesproperties of the new node
directedtrue if the edge is directed, false for bidirectional edges

Definition at line 60 of file navgraph_edge.cpp.

References from(), properties(), and to().

◆ NavGraphEdge() [3/3]

fawkes::NavGraphEdge::NavGraphEdge ( const std::string &  from,
const std::string &  to,
bool  directed = false 
)

Constructor.

Parameters
fromoriginating node name
totarget node name
directedtrue if the edge is directed, false for bidirectional edges

Definition at line 76 of file navgraph_edge.cpp.

References from(), and to().

Member Function Documentation

◆ closest_point_on_edge()

cart_coord_2d_t fawkes::NavGraphEdge::closest_point_on_edge ( float  x,
float  y 
) const

Get the point on edge closest to a given point.

The method determines a line perpendicular to the edge which goes through the given point, i.e. the point must be within the imaginary line segment. Then the point on the edge which crosses with that perpendicular line is returned.

Parameters
xX coordinate of point to get point on edge for
yY coordinate of point to get point on edge for
Returns
coordinate of point on edge closest to given point
Exceptions
Exceptionthrown if the point is out of the line segment and no line perpendicular to the edge going through the given point can be found.

Definition at line 219 of file navgraph_edge.cpp.

References fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().

Referenced by fawkes::NavGraph::connect_node_to_closest_edge(), and distance().

◆ distance()

float fawkes::NavGraphEdge::distance ( float  x,
float  y 
) const

Get distance of point to closest point on edge.

Parameters
xX coordinate of point to get distance to closest point on edge for
yY coordinate of point to get distance to closest point on edge for
Returns
distance to the closest point on the edge

Definition at line 244 of file navgraph_edge.cpp.

References closest_point_on_edge(), fawkes::cart_coord_2d_struct::x, and fawkes::cart_coord_2d_struct::y.

◆ from()

const std::string & fawkes::NavGraphEdge::from ( ) const
inline

◆ from_node()

const NavGraphNode & fawkes::NavGraphEdge::from_node ( ) const
inline

Get edge originating node.

Returns
edge originating node

Definition at line 70 of file navgraph_edge.h.

Referenced by fawkes::NavGraph::closest_edge(), and set_nodes().

◆ has_property()

bool fawkes::NavGraphEdge::has_property ( const std::string &  property) const
inline

Check if node has specified property.

Parameters
propertyproperty key
Returns
true if node has specified property, false otherwise

Definition at line 106 of file navgraph_edge.h.

References property().

Referenced by fawkes::load_yaml_navgraph(), and fawkes::save_yaml_navgraph().

◆ intersection()

bool fawkes::NavGraphEdge::intersection ( float  x1,
float  y1,
float  x2,
float  y2,
fawkes::cart_coord_2d_t ip 
) const

Check if the edge intersects with another line segment.

Parameters
x1X coordinate of first point of line segment to test
y1Y coordinate of first point of line segment to test
x2X coordinate of first point of line segment to test
y2Y coordinate of first point of line segment to test
ipupon returning true contains intersection point, not modified is return value is false
Returns
true if the edge intersects with the line segment, false otherwise

Definition at line 266 of file navgraph_edge.cpp.

References fawkes::line_segm_intersection(), fawkes::NavGraphNode::x(), fawkes::cart_coord_2d_struct::x, fawkes::NavGraphNode::y(), and fawkes::cart_coord_2d_struct::y.

◆ intersects()

bool fawkes::NavGraphEdge::intersects ( float  x1,
float  y1,
float  x2,
float  y2 
) const

Check if the edge intersects with another line segment.

Parameters
x1X coordinate of first point of line segment to test
y1Y coordinate of first point of line segment to test
x2X coordinate of first point of line segment to test
y2Y coordinate of first point of line segment to test
Returns
true if the edge intersects with the line segment, false otherwise

Definition at line 295 of file navgraph_edge.cpp.

References fawkes::line_segm_intersect(), fawkes::NavGraphNode::x(), and fawkes::NavGraphNode::y().

◆ is_directed()

bool fawkes::NavGraphEdge::is_directed ( ) const
inline

Check if edge is directed.

Returns
true if edge is directed, false otherwise.

Definition at line 162 of file navgraph_edge.h.

Referenced by fawkes::save_yaml_navgraph().

◆ is_valid()

bool fawkes::NavGraphEdge::is_valid ( ) const
inline

Check if edge is valid.

An edge is valid iff it has originating and target node name values.

Returns
true if edge is valid, false otherwise

Definition at line 153 of file navgraph_edge.h.

◆ operator bool()

fawkes::NavGraphEdge::operator bool ( ) const
inline

Check of edge is valid.

An edge is valid if both the originating and the target node name is set to a non-empty string.

Returns
true if the node is valid, false otherwise

Definition at line 227 of file navgraph_edge.h.

◆ operator<()

bool fawkes::NavGraphEdge::operator< ( const NavGraphEdge e) const
inline

Less than operator based on node from and to names.

One edge is less than another if this is true for their respective names.

Parameters
eedge to compare with
Returns
true if this edge is less than the given one

Definition at line 216 of file navgraph_edge.h.

◆ operator==()

bool fawkes::NavGraphEdge::operator== ( const NavGraphEdge e) const
inline

Check edges for equality.

Edges are equal if they have the same origination and destination nodes and the same directed status.

Parameters
eedge to compare with
Returns
true if the node is the same as this one, false otherwise

Definition at line 206 of file navgraph_edge.h.

◆ properties()

const std::map< std::string, std::string > & fawkes::NavGraphEdge::properties ( ) const
inline

Get all properties.

Returns
property map

Definition at line 96 of file navgraph_edge.h.

Referenced by fawkes::NavGraph::connect_node_to_closest_edge(), NavGraphEdge(), and set_properties().

◆ property()

std::string fawkes::NavGraphEdge::property ( const std::string &  prop) const

Get specified property as string.

Parameters
propproperty key
Returns
property value as string

Definition at line 137 of file navgraph_edge.cpp.

Referenced by has_property(), fawkes::load_yaml_navgraph(), property_as_bool(), property_as_float(), property_as_int(), fawkes::save_yaml_navgraph(), and set_property().

◆ property_as_bool() [1/2]

bool fawkes::NavGraphEdge::property_as_bool ( const std::string &  prop)
inline

Get property converted to bol.

Parameters
propproperty key
Returns
property value

Definition at line 194 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_bool().

◆ property_as_bool() [2/2]

bool fawkes::NavGraphEdge::property_as_bool ( const std::string &  prop) const
inline

Get property converted to bol.

Parameters
propproperty key
Returns
property value

Definition at line 143 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_bool().

◆ property_as_float() [1/2]

float fawkes::NavGraphEdge::property_as_float ( const std::string &  prop)
inline

Get property converted to float.

Parameters
propproperty key
Returns
property value

Definition at line 174 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_float().

◆ property_as_float() [2/2]

float fawkes::NavGraphEdge::property_as_float ( const std::string &  prop) const
inline

Get property converted to float.

Parameters
propproperty key
Returns
property value

Definition at line 123 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_float().

◆ property_as_int() [1/2]

int fawkes::NavGraphEdge::property_as_int ( const std::string &  prop)
inline

Get property converted to int.

Parameters
propproperty key
Returns
property value

Definition at line 184 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_int().

◆ property_as_int() [2/2]

int fawkes::NavGraphEdge::property_as_int ( const std::string &  prop) const
inline

Get property converted to int.

Parameters
propproperty key
Returns
property value

Definition at line 133 of file navgraph_edge.h.

References property(), and fawkes::StringConversions::to_int().

◆ set_directed()

void fawkes::NavGraphEdge::set_directed ( bool  directed)

Set directed state.

Parameters
directedtrue if the edge is directed, false for bidirectional edges

Definition at line 127 of file navgraph_edge.cpp.

Referenced by fawkes::operator>>().

◆ set_from()

void fawkes::NavGraphEdge::set_from ( const std::string &  from)

Set originating node name.

Parameters
fromoriginating node name

Definition at line 87 of file navgraph_edge.cpp.

References from().

Referenced by fawkes::operator>>().

◆ set_nodes()

void fawkes::NavGraphEdge::set_nodes ( const NavGraphNode from_node,
const NavGraphNode to_node 
)

Set nodes.

Parameters
from_nodeoriginating node
to_nodetarget node

Definition at line 106 of file navgraph_edge.cpp.

References from_node(), fawkes::NavGraphNode::name(), and to_node().

◆ set_properties()

void fawkes::NavGraphEdge::set_properties ( const std::map< std::string, std::string > &  properties)

Overwrite properties with given ones.

Parameters
propertiesmap of properties to set

Definition at line 151 of file navgraph_edge.cpp.

References properties().

Referenced by fawkes::NavGraph::connect_node_to_closest_edge().

◆ set_property() [1/5]

void fawkes::NavGraphEdge::set_property ( const std::string &  property,
bool  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 201 of file navgraph_edge.cpp.

References property().

◆ set_property() [2/5]

void fawkes::NavGraphEdge::set_property ( const std::string &  property,
const char *  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 171 of file navgraph_edge.cpp.

References property().

◆ set_property() [3/5]

void fawkes::NavGraphEdge::set_property ( const std::string &  property,
const std::string &  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 161 of file navgraph_edge.cpp.

References property().

Referenced by fawkes::NavGraph::connect_node_to_closest_edge(), fawkes::NavGraph::connect_node_to_closest_node(), and fawkes::operator>>().

◆ set_property() [4/5]

void fawkes::NavGraphEdge::set_property ( const std::string &  property,
float  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 181 of file navgraph_edge.cpp.

References property(), and fawkes::StringConversions::to_string().

◆ set_property() [5/5]

void fawkes::NavGraphEdge::set_property ( const std::string &  property,
int  value 
)

Set property.

Parameters
propertyproperty key
valueproperty value

Definition at line 191 of file navgraph_edge.cpp.

References property(), and fawkes::StringConversions::to_string().

◆ set_to()

void fawkes::NavGraphEdge::set_to ( const std::string &  to)

Set target node name.

Parameters
totarget node name

Definition at line 96 of file navgraph_edge.cpp.

References to().

Referenced by fawkes::operator>>().

◆ to()

const std::string & fawkes::NavGraphEdge::to ( ) const
inline

◆ to_node()

const NavGraphNode & fawkes::NavGraphEdge::to_node ( ) const
inline

Get edge target node.

Returns
edge target node

Definition at line 78 of file navgraph_edge.h.

Referenced by fawkes::NavGraph::closest_edge(), and set_nodes().


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