示例#1
0
        /// <summary>
        /// Try to find a connection between two given nodes. Depth-first search via main track at junctions.
        /// Also reversing the start or reconnectNode is tried, in case one of these nodes has a non-defined orientation
        /// because both before and after the node the path is broken.
        /// </summary>
        /// <param name="fromNode">Node at which the reconnection should start</param>
        /// <param name="toNode">Node at which the reconnection should end</param>
        /// <param name="firstTvnIndex">In case defined, the index of the first TVN the path has to follow</param>
        /// <returns>True if a connection has been found</returns>
        public bool FindConnection(TrainpathNode fromNode, TrainpathNode toNode, int?firstTvnIndex)

        {
            // We try to find a connection between two non-broken nodes.
            // We store the connection as a stack of linking tvns (track-node-vector-indexes)
            // The connection will only contain junctions (apart from maybe start and end=reconnect nodes)

            autoConnectFromNode      = new ConnectableNode(fromNode, true, true);
            autoConnectToNodeOptions = new ReconnectNodeOptions(true);
            autoConnectToNodeOptions.AddNode(toNode, false); // only one option here

            return(FindConnectionFromTo(firstTvnIndex, false));
        }
示例#2
0
        //static Dictionary<bool, Drawing.DebugWindow> debugWindows = new Dictionary<bool, Drawing.DebugWindow>();
        //static ContinuousAutoConnecting()
        //{
        //    debugWindows[true] = new Drawing.DebugWindow(10, 40);
        //    debugWindows[false] = new Drawing.DebugWindow(10, 60);
        //}
        //private string debugString = String.Empty;

        /// <summary>
        /// Constructor. This will also find store the candidates for reconnecting
        /// </summary>
        /// <param name="startNode">The node to start from for reconnection. Only used for initial determination of possible reconnection nodes</param>
        /// <param name="isConnectingForward">Is this node connecting forwards (along the path) or not</param>
        public ContinuousAutoConnecting(TrainpathNode startNode, bool isConnectingForward)
        {
            isForward = isConnectingForward;
            List <TrainpathNode> reconnectNodes = this.FindReconnectNodeCandidates(startNode, isConnectingForward, true);

            autoConnectToNodeOptions = new ReconnectNodeOptions(isConnectingForward);
            int count = 0;

            foreach (TrainpathNode node in reconnectNodes)
            {
                autoConnectToNodeOptions.AddNode(node, false);
                //debugString += node.ToStringShort();
                if (count++ > maxNumberNodesToCheckForAutoFix)
                {
                    break;
                }
            }
        }