protected override void Do() { edges = stitcher.FindClosestEdgePair(cycles[0], cycles[1]); }
private Directions JoinTwoCycles(Directions firstCycle, Directions secondCycle, EdgePair edges) { var firstRoute = firstCycle.GetRoute(edges.FirstCycleEdge); var secondRoute = secondCycle.GetRoute(edges.SecondCycleEdge); var closest = graph.PickClosestPoint(firstRoute.From, edges.SecondCycleEdge.Vertices); firstCycle.AddRoute(firstRoute.From, closest); var otherEndOfSecondRoute = secondRoute.From.Equals(secondRoute.To) ? secondRoute.To : secondRoute.Points.Single(p => !p.Equals(closest)); firstCycle.AddRoute(otherEndOfSecondRoute, firstRoute.To); firstCycle.Merge(secondCycle); firstCycle.RemoveRoute(firstRoute); firstCycle.RemoveRoute(secondRoute); return firstCycle; }