From 763b692fb33d6253e05e7905de4c3cef45823794 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 26 Jul 2017 13:51:41 +0200
Subject: [PATCH] Fix Edge::direction

---
 src/graph/edge.cc | 38 ++++++++++----------------------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/src/graph/edge.cc b/src/graph/edge.cc
index f0fad668..ee6453a3 100644
--- a/src/graph/edge.cc
+++ b/src/graph/edge.cc
@@ -69,20 +69,6 @@ namespace hpp {
         const bool dst_contains_q0 = to  ()->contains (q0);
         const bool src_contains_q1 = from()->contains (q1);
         const bool dst_contains_q1 = to  ()->contains (q1);
-        if (!(
-              (src_contains_q0 && dst_contains_q1)
-              || (src_contains_q1 && dst_contains_q0)
-              )) {
-          if (src_contains_q0) {
-            assert (state ()->contains (q1));
-            return false;
-          } else if (src_contains_q1) {
-            assert (state ()->contains (q0));
-            return true;
-          }
-          throw std::runtime_error ("This path does not seem to have been "
-              "generated by this edge.");
-        }
         // Karnaugh table:
         // 1 = forward, 0 = reverse, ? = I don't know, * = 0 or 1
         // s0s1 \ d0d1 | 00 | 01 | 11 | 10
@@ -92,6 +78,11 @@ namespace hpp {
         // 10          |  ? |  1 |  1 |  1
         // 
         /// true if reverse
+        if (   (!src_contains_q0 && !src_contains_q1)
+            || (!dst_contains_q0 && !dst_contains_q1)
+            || (!src_contains_q0 && !dst_contains_q0))
+          throw std::runtime_error ("This path does not seem to have been "
+              "generated by this edge.");
         return !(src_contains_q0 && (!src_contains_q1 || dst_contains_q1));
       }
 
@@ -103,23 +94,14 @@ namespace hpp {
         const bool dst_contains_q0 = to  ()->contains (q0);
         const bool src_contains_q1 = waypoints_.back().second->contains (q1);
         const bool dst_contains_q1 = to  ()->contains (q1);
-        if (!(
-              (src_contains_q0 && dst_contains_q1)
-              || (src_contains_q1 && dst_contains_q0)
-              )) {
-          if (src_contains_q0) {
-            assert (state ()->contains (q1));
-            return false;
-          } else if (src_contains_q1) {
-            assert (state ()->contains (q0));
-            return true;
-          }
-          throw std::runtime_error ("This path does not seem to have been "
-              "generated by this edge.");
-        }
 
         /// See Edge::direction for Karnaugh table
         /// true if reverse
+        if (   (!src_contains_q0 && !src_contains_q1)
+            || (!dst_contains_q0 && !dst_contains_q1)
+            || (!src_contains_q0 && !dst_contains_q0))
+          throw std::runtime_error ("This path does not seem to have been "
+              "generated by this edge.");
         return !(src_contains_q0 && (!src_contains_q1 || dst_contains_q1));
       }
 
-- 
GitLab