private static void FixDirectionRecursively(ICollection <Subpath> subpaths, IEnumerable <TreeNode <Subpath> > children, SubpathDirection?parentDirection)
 {
     foreach (var node in children)
     {
         var child = node.AssociatedObject;
         SubpathDirection?childDirection = SubpathDirectionCalculator.CalculateDirection(child);
         if (parentDirection != null)
         {
             if (childDirection == parentDirection)
             {
                 subpaths.Remove(child);
                 subpaths.Add(SubpathDirectionReverser.ReverseDirection(child));
             }
             childDirection = null;
         }
         FixDirectionRecursively(subpaths, node.Children, childDirection);
     }
 }
Example #2
0
 public static bool EqualsIgnoreDirection(this Subpath subpath1, Subpath subpath2)
 {
     if (subpath1.Segments.Count != subpath2.Segments.Count ||
         subpath1.IsClosed != subpath2.IsClosed)
     {
         return(false);
     }
     if (subpath1.StartPoint == subpath2.StartPoint &&
         subpath1.EndPoint == subpath2.EndPoint &&
         Equals(subpath1, subpath2))
     {
         return(true);
     }
     if (subpath1.StartPoint == subpath2.EndPoint &&
         subpath1.EndPoint == subpath2.StartPoint &&
         Equals(subpath1, SubpathDirectionReverser.ReverseDirection(subpath2)))
     {
         return(true);
     }
     return(false);
 }
Example #3
0
 public void Add(Subpath subpath)
 {
     _subpaths.Add(subpath);
     _reverseSubpaths.Add(SubpathDirectionReverser.ReverseDirection(subpath));
 }