/// <summary> /// Create a (still unlinked) node halfway through the next section (so halfway between this /// and the next junction. Needed specially for disambiguity. /// </summary> /// <param name="junctionNode">The junction node where we start</param> /// <param name="tvnIndex">The TrackVectorNode index for the path</param> /// <returns>An unlinked vectorNode at the midpoint.</returns> private TrainpathVectorNode CreateHalfWayNode(TrainpathJunctionNode junctionNode, int tvnIndex) { // The idea here is to use all the code in traveller to make life easier. // move the traveller halfway through the next vector section Traveller traveller = junctionNode.PlaceTravellerAfterJunction(tvnIndex); float distanceToTravel = traveller.TrackNodeLength / 2; traveller.Move(distanceToTravel); TrainpathVectorNode halfwayNode = new TrainpathVectorNode(junctionNode, traveller); halfwayNode.DetermineOrientation(junctionNode, tvnIndex); return(halfwayNode); }
/// <summary> /// Add a new vector path node at the location of nodeCandidate. /// </summary> /// <param name="lastNode">node that will be predecessor of the new nodeCandidate</param> /// <param name="nodeCandidate">partial trainpath vector node describing the current mouse location</param> /// <param name="isMainPath">Do we add the node to the main path or not</param> /// <returns>The newly created vector node</returns> public TrainpathVectorNode AddAdditionalVectorNode(TrainpathNode lastNode, TrainpathVectorNode nodeCandidate, bool isMainPath) { // we add a new activeNodeAsJunction TrainpathVectorNode newNode = new TrainpathVectorNode(nodeCandidate); newNode.DetermineOrientation(lastNode, newNode.TvnIndex); // simple linking if (isMainPath) { lastNode.NextMainTvnIndex = newNode.NextMainTvnIndex; lastNode.NextMainNode = newNode; newNode.PrevNode = lastNode; } else { lastNode.NextSidingTvnIndex = newNode.NextMainTvnIndex; newNode.NextSidingTvnIndex = newNode.NextMainTvnIndex; lastNode.NextSidingNode = newNode; } NetNodesAdded++; return(newNode); }