diff --git a/src/dsf/base/Edge.cpp b/src/dsf/base/Edge.cpp index 45aef7fd4..e9f8a446b 100644 --- a/src/dsf/base/Edge.cpp +++ b/src/dsf/base/Edge.cpp @@ -28,8 +28,6 @@ namespace dsf { assert(!(std::abs(m_angle) > 2 * std::numbers::pi)); } - void Edge::resetId(Id newId) { m_id = newId; } - void Edge::setGeometry(geometry::PolyLine geometry) { m_geometry = std::move(geometry); if (m_geometry.size() > 1) { @@ -46,16 +44,10 @@ namespace dsf { m_weight = weight; } - Id Edge::id() const { return m_id; } - Id Edge::source() const { return m_nodePair.first; } - Id Edge::target() const { return m_nodePair.second; } - std::pair const& Edge::nodePair() const { return m_nodePair; } - double Edge::angle() const { return m_angle; } double Edge::weight() const { return m_weight.has_value() ? *m_weight : throw std::runtime_error("Edge weight is not set."); } - geometry::PolyLine const& Edge::geometry() const { return m_geometry; } double Edge::deltaAngle(double const previousEdgeAngle) const { double deltaAngle{m_angle - previousEdgeAngle}; diff --git a/src/dsf/base/Edge.hpp b/src/dsf/base/Edge.hpp index bf5caa904..8e414459b 100644 --- a/src/dsf/base/Edge.hpp +++ b/src/dsf/base/Edge.hpp @@ -32,30 +32,34 @@ namespace dsf { Edge(const Edge&) = delete; virtual ~Edge() = default; - void resetId(Id newId); + /// @brief Set the edge's geometry + /// @param geometry dsf::geometry::PolyLine The edge's geometry, a vector of pairs of doubles representing the coordinates of the edge's geometry void setGeometry(geometry::PolyLine geometry); + /// @brief Set the edge's weight + /// @param weight The edge's weight + /// @throws std::invalid_argument if the weight is less or equal to 0 void setWeight(double const weight); /// @brief Get the edge's id /// @return Id The edge's id - Id id() const; + inline auto id() const { return m_id; } /// @brief Get the edge's source node id /// @return Id The edge's source node id - Id source() const; + inline auto source() const { return m_nodePair.first; } /// @brief Get the edge's target node id /// @return Id The edge's target node id - Id target() const; + inline auto target() const { return m_nodePair.second; } /// @brief Get the edge's node pair /// @return std::pair The edge's node pair, where the first element is the source node id and the second /// element is the target node id. The pair is (u, v) with the edge u -> v. - std::pair const& nodePair() const; + inline auto const& nodePair() const { return m_nodePair; } /// @brief Get the edge's geometry /// @return dsf::geometry::PolyLine The edge's geometry, a vector of pairs of doubles representing the coordinates of the edge's geometry - geometry::PolyLine const& geometry() const; + inline auto const& geometry() const { return m_geometry; } /// @brief Get the edge's angle, in radians, between the source and target nodes /// @return double The edge's angle, in radians - double angle() const; + inline auto angle() const { return m_angle; } /// @brief Get the edge's weight /// @return double The edge's weight double weight() const; diff --git a/src/dsf/base/Node.hpp b/src/dsf/base/Node.hpp index 8ea42d1da..43e9249fb 100644 --- a/src/dsf/base/Node.hpp +++ b/src/dsf/base/Node.hpp @@ -72,7 +72,9 @@ namespace dsf { /// @brief Set the node's name /// @param name The node's name inline void setName(const std::string& name) noexcept { m_name = name; } - + /// @brief Add an ingoing edge to the node + /// @param edgeId The edge's id + /// @throws std::invalid_argument if the edge already exists in the ingoing edges inline void addIngoingEdge(Id edgeId) { if (std::find(m_ingoingEdges.cbegin(), m_ingoingEdges.cend(), edgeId) != m_ingoingEdges.cend()) { @@ -83,7 +85,9 @@ namespace dsf { } m_ingoingEdges.push_back(edgeId); } - + /// @brief Add an outgoing edge to the node + /// @param edgeId The edge's id + /// @throws std::invalid_argument if the edge already exists in the outgoing edges inline void addOutgoingEdge(Id edgeId) { if (std::find(m_outgoingEdges.cbegin(), m_outgoingEdges.cend(), edgeId) != m_outgoingEdges.cend()) { diff --git a/src/dsf/utility/queue.hpp b/src/dsf/utility/queue.hpp index f7f9c5bca..abe200faf 100644 --- a/src/dsf/utility/queue.hpp +++ b/src/dsf/utility/queue.hpp @@ -1,4 +1,3 @@ - #pragma once #include