コード例 #1
0
 public LinkedAvidNode(AvidModelWindow window, LinkedAvidNode previousNode, AvidModelLink linkUsed)
 {
     Window = window;
     PreviousNode = previousNode;
     LinkUsed = linkUsed;
     UpdateTransitionsCount();
 }
コード例 #2
0
 public LinkedAvidNode(AvidModelWindow window, LinkedAvidNode previousNode, AvidModelLink linkUsed)
 {
     Window       = window;
     PreviousNode = previousNode;
     LinkUsed     = linkUsed;
     UpdateTransitionsCount();
 }
コード例 #3
0
 public static string AvidLinkToString(AvidModelLink link)
 {
     return string.Format("{0} -> {1} ({2}{3}:{4})",
                          link.EndpointA,
                          link.EndpointB,
                          link.IsDiagonal ? "Dg" : "St",
                          link.IsAbovePlane ? "+" : "-",
                          link.Weight);
 }
コード例 #4
0
        private bool CanDoTransition(LinkedAvidNode currentNode, AvidModelLink proposedLink, AvidPathingOptions options)
        {
            if (!proposedLink.IsDiagonal && !proposedLink.IsPolarDiagonal)
            {
                return true;
            }

            //if (currentNode.NodeDepth == 5 && currentNode.Window.Direction == AvidDirection.CD && currentNode.Window.Ring == AvidRing.Blue)
            //{
            //    var result = TracePath(currentNode, null, null);
            //    if (result.PathNodes[2].Window.Direction == AvidDirection.B && result.PathNodes[2].Window.Ring == AvidRing.Blue)
            //    {
                    
            //    }
            //}

            switch (options)
            {
                case AvidPathingOptions.DiagonalTransitionsIgnored:
                    return !proposedLink.IsDiagonal;
                case AvidPathingOptions.DiagonalTransitionsUnlimited:
                    return true;
                case AvidPathingOptions.DiagonalTransitionsTotalLimit:
                    return !proposedLink.IsDiagonal || currentNode.TotalDiagonalTransitions < (currentNode.NodeDistance / 2 + 1) / 6 + 1;
                case AvidPathingOptions.DiagonalTransitionsLimitPerHemisphere:
                    return !proposedLink.IsDiagonal || 
                           proposedLink.IsAbovePlane ?
                               currentNode.UpperHemisphereDiagonalTransitions < (currentNode.DistanceAbovePlane / 2 + 1) / 6 + 1 :
                               currentNode.LowerHemisphereDiagonalTransitions < (currentNode.DistanceBelowPlane / 2 + 1) / 6 + 1;
                case AvidPathingOptions.DiagonalTransitionsLimitWithPolar:
                    if (proposedLink.IsDiagonal)
                    {
                        if (currentNode.TotalDiagonalTransitions > 0 && currentNode.TotalDiagonalTransitions >= 2)
                        {
                            return false;
                        }

                        return proposedLink.IsAbovePlane ?
                               currentNode.UpperHemisphereDiagonalTransitions < (currentNode.DistanceAbovePlane / 2 + 1) / 6 + 1 :
                               currentNode.LowerHemisphereDiagonalTransitions < (currentNode.DistanceBelowPlane / 2 + 1) / 6 + 1;
                    }
                    if (proposedLink.IsPolarDiagonal)
                    {
                        int currentPolarDiagonalTransitionLimit = (currentNode.NodeDistance / 2 + 1) / 6 + 1;
                        // First transition is always available;
                        return currentNode.TotalPolarDiagonalTransitions == 0 ||
                               // the second is only available as the sixth transition if the second diagonal transition has not been taken. 
                               currentNode.TotalPolarDiagonalTransitions < currentPolarDiagonalTransitionLimit &&
                               currentNode.TotalDiagonalTransitions < 2;
                    }
                    return true;
                default:
                    throw new ArgumentException(string.Format("Option not supported: {0}", options), "options");
            }
        }