/// <summary>
/// IsFit checks if given a specified side, it can be fit with a shreds's edge
/// This Also returns a match object
/// </summary>
/// <param name="root"> </param>
/// <param name="shred"> </param>
/// <param name="side"> </param>
/// <returns> </returns>
private static Tuple <Match, Direction> IsFit(INode root, Shred shred, Side side)
{
Side query;
Match match;
if (side.Orientation != shred.Orientation)
{
query = new Side(shred, Enumeration.Opposite(side.Direction), shred.Orientation);
match = Match.Inverted;
}
else
{
query = side;
match = Match.NonInverted;
}
// If Directions match AND The Availablility then return match, otherwise impossible
if (query.Direction == Direction.FromLeft && root.LeftEdge() == shred.LeftEdge())
{
return(new Tuple <Match, Direction>(match, Direction.FromLeft));
}
if (query.Direction == Direction.FromRight && root.RightEdge() == shred.RightEdge())
{
return(new Tuple <Match, Direction>(match, Direction.FromRight));
}
return(new Tuple <Match, Direction>(Match.Impossible, Direction.FromLeft));
}