/// <summary> /// Checks if a previous node exists and gets its output or else returns the same image /// </summary> /// <param name="image">The input image for the previous node</param> /// <param name="logging">The true or false value of the -verbose option</param> /// <param name="directory">The location where each node's output should be saved for the -saveall option</param> /// <param name="imageNumber">The current image number if multiple images are being processed</param> /// <returns>Output image of the previous node or the same image</returns> public virtual Image GetOutput(Image image, bool logging, string directory, int imageNumber = 0) { if (PreviousNode != null) { NewImage = PreviousNode.GetOutput(image, logging, directory, imageNumber); if (directory != null) { SaveNodeImage(NewImage, directory, imageNumber); } if (logging == true) { LogNodeImage(); } } else { NewImage = image; if (logging == true) { LogNodeImage(); } } return(NewImage); }
/// <summary> /// Gets the number of the node in the pipeline sequence /// </summary> public int NumPreviousNodes() { if (PreviousNode == null) { return(1); } return(1 + PreviousNode.NumPreviousNodes()); }
/// <summary> /// Adds the color. /// </summary> /// <param name="pixel">The pixel.</param> public void AddColor(Bgra pixel) { if (PreviousColor == pixel) { if (PreviousNode == null) { PreviousColor = pixel; Root.AddColor(pixel, MaxColorBits, 0, this); } else { PreviousNode.Increment(pixel); } } else { PreviousColor = pixel; Root.AddColor(pixel, MaxColorBits, 0, this); } }
public override IEnumerable <Waypoint> GetWaypoints(NodeDistCalculator nodeDist) { if (PreviousNode.NodeType == NodeType.Tile && PreviousNode.GetMovementTypeToNeighbour(this) == MovementType.Linear) { var borderNode = new TempNode(GetEdgePosition((ITileNode)PreviousNode), Map); float totalTime = Time - PreviousNode.Time; if (!nodeDist.GetTime(PreviousNode, borderNode, MovementType.Linear, out float firstTime)) { throw new ArgumentException($"Wrong {nameof(nodeDist)} implementation, does not give the same result on path building."); } return(new[] { new Waypoint(borderNode, firstTime, MovementType.Linear), new Waypoint(this, totalTime - firstTime, MovementType.Linear) }); } else { return(new[] { new Waypoint(this, Time - PreviousNode.Time, PreviousNode.GetMovementTypeToNeighbour(this)) }); } }
private static void SetPrevNodeAtLevel(int levelNumber, LeafNode thisNode) { uint i = 0; for ( var tmp = _levelZeroPointer; tmp != null; tmp = tmp.NextLevel ) { if( i++ == levelNumber ) { tmp.PrevNode = thisNode; return; } if( tmp.NextLevel == null ) { tmp.NextLevel = new PreviousNode { PrevNode = null, NextLevel = null }; } } _levelZeroPointer = new PreviousNode { PrevNode = thisNode, NextLevel = null }; }
public override IEnumerable <Waypoint> GetWaypoints(NodeDistCalculator distCalc) { return(new[] { new Waypoint(this, Time - PreviousNode.Time, PreviousNode.GetMovementTypeToNeighbour(this)) }); }