diff --git a/src/graph/edge.cc b/src/graph/edge.cc index cf709af8cc828b7fafee93310c5cca84fbe6bc59..90aea426bf0b5c6b50f053049999eb52bc74e5ac 100644 --- a/src/graph/edge.cc +++ b/src/graph/edge.cc @@ -69,10 +69,30 @@ 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); - assert ((src_contains_q0 && dst_contains_q1) - || (src_contains_q1 && dst_contains_q0)); + if (!( + (src_contains_q0 && dst_contains_q1) + || (src_contains_q1 && dst_contains_q0) + )) { + if (src_contains_q0) { + assert (node ()->contains (q1)); + return false; + } else if (src_contains_q1) { + assert (node ()->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 + // 00 | ? | ? | ? | ? + // 01 | ? | ? | 0 | 0 + // 11 | ? | 1 | * | 0 + // 10 | ? | 1 | 1 | 1 + // /// true if reverse - return !dst_contains_q1; + return !(src_contains_q0 && (!src_contains_q1 || dst_contains_q1)); } bool WaypointEdge::direction (const core::PathPtr_t& path) const @@ -83,10 +103,24 @@ namespace hpp { const bool dst_contains_q0 = to ()->contains (q0); const bool src_contains_q1 = waypoint_.second->contains (q1); const bool dst_contains_q1 = to ()->contains (q1); - assert ((src_contains_q0 && dst_contains_q1) - || (src_contains_q1 && dst_contains_q0)); + if (!( + (src_contains_q0 && dst_contains_q1) + || (src_contains_q1 && dst_contains_q0) + )) { + if (src_contains_q0) { + assert (node ()->contains (q1)); + return false; + } else if (src_contains_q1) { + assert (node ()->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 - return !dst_contains_q1; + return !(src_contains_q0 && (!src_contains_q1 || dst_contains_q1)); } bool Edge::intersectionConstraint (const EdgePtr_t& other,