Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace Microsoft.Research.DynamicDataDisplay.Charts.Isolines
|
---|
| 7 | {
|
---|
| 8 | /// <summary>
|
---|
| 9 | /// Edge identifier - indicates which side of cell isoline crosses.
|
---|
| 10 | /// </summary>
|
---|
| 11 | internal enum Edge
|
---|
| 12 | {
|
---|
| 13 | // todo check if everything is ok with None.
|
---|
| 14 | None = 0,
|
---|
| 15 | /// <summary>
|
---|
| 16 | /// Isoline crosses left boundary of cell (bit 0)
|
---|
| 17 | /// </summary>
|
---|
| 18 | Left = 1,
|
---|
| 19 | /// <summary>
|
---|
| 20 | /// Isoline crosses top boundary of cell (bit 1)
|
---|
| 21 | /// </summary>
|
---|
| 22 | Top = 2,
|
---|
| 23 | /// <summary>
|
---|
| 24 | /// Isoline crosses right boundary of cell (bit 2)
|
---|
| 25 | /// </summary>
|
---|
| 26 | Right = 4,
|
---|
| 27 | /// <summary>
|
---|
| 28 | /// Isoline crosses bottom boundary of cell (bit 3)
|
---|
| 29 | /// </summary>
|
---|
| 30 | Bottom = 8
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | [Flags]
|
---|
| 34 | internal enum CellBitmask
|
---|
| 35 | {
|
---|
| 36 | None = 0,
|
---|
| 37 | LeftTop = 1,
|
---|
| 38 | LeftBottom = 8,
|
---|
| 39 | RightBottom = 4,
|
---|
| 40 | RightTop = 2
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | internal static class IsolineExtensions
|
---|
| 44 | {
|
---|
| 45 | internal static bool IsDiagonal(this CellBitmask bitmask)
|
---|
| 46 | {
|
---|
| 47 | return bitmask == (CellBitmask.RightBottom | CellBitmask.LeftTop) ||
|
---|
| 48 | bitmask == (CellBitmask.LeftBottom | CellBitmask.RightTop);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | internal static bool IsAppropriate(this SubCell sub, Edge edge)
|
---|
| 52 | {
|
---|
| 53 | switch (sub)
|
---|
| 54 | {
|
---|
| 55 | case SubCell.LeftBottom:
|
---|
| 56 | return edge == Edge.Left || edge == Edge.Bottom;
|
---|
| 57 | case SubCell.LeftTop:
|
---|
| 58 | return edge == Edge.Left || edge == Edge.Top;
|
---|
| 59 | case SubCell.RightBottom:
|
---|
| 60 | return edge == Edge.Right || edge == Edge.Bottom;
|
---|
| 61 | case SubCell.RightTop:
|
---|
| 62 | default:
|
---|
| 63 | return edge == Edge.Right || edge == Edge.Top;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.