using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Microsoft.Research.DynamicDataDisplay.Charts.Isolines
{
///
/// Edge identifier - indicates which side of cell isoline crosses.
///
internal enum Edge
{
// todo check if everything is ok with None.
None = 0,
///
/// Isoline crosses left boundary of cell (bit 0)
///
Left = 1,
///
/// Isoline crosses top boundary of cell (bit 1)
///
Top = 2,
///
/// Isoline crosses right boundary of cell (bit 2)
///
Right = 4,
///
/// Isoline crosses bottom boundary of cell (bit 3)
///
Bottom = 8
}
[Flags]
internal enum CellBitmask
{
None = 0,
LeftTop = 1,
LeftBottom = 8,
RightBottom = 4,
RightTop = 2
}
internal static class IsolineExtensions
{
internal static bool IsDiagonal(this CellBitmask bitmask)
{
return bitmask == (CellBitmask.RightBottom | CellBitmask.LeftTop) ||
bitmask == (CellBitmask.LeftBottom | CellBitmask.RightTop);
}
internal static bool IsAppropriate(this SubCell sub, Edge edge)
{
switch (sub)
{
case SubCell.LeftBottom:
return edge == Edge.Left || edge == Edge.Bottom;
case SubCell.LeftTop:
return edge == Edge.Left || edge == Edge.Top;
case SubCell.RightBottom:
return edge == Edge.Right || edge == Edge.Bottom;
case SubCell.RightTop:
default:
return edge == Edge.Right || edge == Edge.Top;
}
}
}
}