/// <summary> /// Check if after this node a disambiguity node needs to be added /// </summary> /// <param name="currentNode"></param> public void AddDisambiguityNodeIfNeeded(TrainpathNode currentNode) { //Check if we need to add an disambiguity node TrainpathJunctionNode currentNodeAsJunction = currentNode as TrainpathJunctionNode; if ((currentNodeAsJunction != null) && (currentNode.NextMainNode != null) && (currentNode.NextMainNode is TrainpathJunctionNode) && (currentNodeAsJunction.IsSimpleSidingStart()) ) { TrainpathVectorNode halfwayNode = CreateHalfWayNode(currentNodeAsJunction, currentNodeAsJunction.NextMainTvnIndex); halfwayNode.PrevNode = currentNode; AddIntermediateMainNode(halfwayNode); } }
/// <summary> /// Add an additional node starting at the given node, following the TvnIndex, /// but take care of a possible need for disambiguity. /// </summary> /// <param name="lastNode">Node after which a new node needs to be added</param> /// <param name="tvnIndex">TrackVectorNode index of the track the path needs to be on</param> /// <param name="isMainPath">Do we add the node to the main path or not</param> /// <returns>The newly created path node</returns> public TrainpathNode AddAdditionalNode(TrainpathNode lastNode, int tvnIndex, bool isMainPath) { TrainpathVectorNode lastNodeAsVector = lastNode as TrainpathVectorNode; if (lastNodeAsVector != null) { return(AddAdditionalJunctionNode(lastNode, lastNodeAsVector.TvnIndex, isMainPath)); } TrainpathJunctionNode junctionNode = lastNode as TrainpathJunctionNode; if (junctionNode.IsSimpleSidingStart()) { // start of a simple siding. So the next node should be a node to remove disambiguity. TrainpathVectorNode halfwayNode = CreateHalfWayNode(junctionNode, tvnIndex); return(AddAdditionalVectorNode(junctionNode, halfwayNode, isMainPath)); } else { return(AddAdditionalJunctionNode(junctionNode, tvnIndex, isMainPath)); } }