From 3c0cf959b3e22641761a8ae1f9aa5e704d6ca641 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 27 Jan 2016 14:16:16 +0100
Subject: [PATCH] Node containing edges can be sepcified by the user.

---
 include/hpp/manipulation/graph/edge.hh | 24 ++++++++++++++++++------
 src/graph/edge.cc                      |  8 +-------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/include/hpp/manipulation/graph/edge.hh b/include/hpp/manipulation/graph/edge.hh
index 7c78acfc..8426a219 100644
--- a/include/hpp/manipulation/graph/edge.hh
+++ b/include/hpp/manipulation/graph/edge.hh
@@ -85,17 +85,29 @@ namespace hpp {
           NodePtr_t from () const;
 
           /// Get the node in which path is.
-          virtual NodePtr_t node () const;
+          NodePtr_t node () const
+          {
+            return node_.lock();
+          }
+
+          void node (NodePtr_t node)
+          {
+            node_ = node;
+          }
 
-          void isInNodeFrom (bool iinf)
+          /// \deprecated use node(NodePtr_t) instead.
+          void isInNodeFrom (bool iinf) HPP_MANIPULATION_DEPRECATED
           {
-            isInNodeFrom_ = iinf;
+            if (iinf) node_ = from_;
+            else      node_ = to_;
           }
 
-          bool isInNodeFrom () const
+          /// \deprecated see NodePtr_t node() const
+          bool isInNodeFrom () const HPP_MANIPULATION_DEPRECATED
           {
-            return isInNodeFrom_;
+            return node_.lock() == from_.lock();
           }
+
 	  /// Get steering method associated to the edge.
 	  const core::SteeringMethodPtr_t& steeringMethod () const
 	  {
@@ -158,7 +170,7 @@ namespace hpp {
           NodeWkPtr_t from_, to_;
 
           /// True if this path is in node from, False if in node to
-          bool isInNodeFrom_;
+          NodeWkPtr_t node_;
 
 	  /// Steering method used to create paths associated to the edge
 	  SteeringMethod_t* steeringMethod_;
diff --git a/src/graph/edge.cc b/src/graph/edge.cc
index 78fad10c..bcef230e 100644
--- a/src/graph/edge.cc
+++ b/src/graph/edge.cc
@@ -57,12 +57,6 @@ namespace hpp {
         return from_.lock();
       }
 
-      NodePtr_t Edge::node () const
-      {
-        if (isInNodeFrom_) return from ();
-        else return to ();
-      }
-
       bool Edge::direction (const core::PathPtr_t& path) const
       {
         Configuration_t q0 = path->initial (),
@@ -169,7 +163,7 @@ namespace hpp {
         wkPtr_ = weak;
         from_ = from;
         to_ = to;
-        isInNodeFrom_ = false;
+        node_ = to;
       }
 
       std::ostream& Edge::print (std::ostream& os) const
-- 
GitLab