public void When_Two_Group_Do_It() { var target = GroupParser.NobiGroupParser(); var grpA = new BitPlane(10); grpA.Add(new Coords(1, 1)); grpA.Add(new Coords(1, 2)); grpA.Add(new Coords(1, 3)); grpA.Add(new Coords(1, 4)); var grpB = new BitPlane(10); grpB.Add(new Coords(4, 1)); grpB.Add(new Coords(4, 2)); grpB.Add(new Coords(4, 3)); grpB.Add(new Coords(4, 4)); var data = new BitPlane(10); data.Or(grpA); data.Or(grpB); var actual = target.Parse(data.Copy()); Assert.AreEqual(2, actual.Count); BitPlaneTestHelper.AssertBitPlane(grpA, actual[0], "Group A"); //Todo Algorithm : Make to Order Tolerance BitPlaneTestHelper.AssertBitPlane(grpB, actual[1], "Group B"); }
public void When_One_Group_Do_It() { var target = GroupParser.NobiGroupParser(); var grpA = new BitPlane(10); grpA.Add(new Coords(1, 1)); grpA.Add(new Coords(1, 2)); grpA.Add(new Coords(1, 3)); grpA.Add(new Coords(1, 4)); var actual = target.Parse(grpA.Copy()); Assert.AreEqual(1, actual.Count); BitPlaneTestHelper.AssertBitPlane(grpA, actual[0], "Group A"); }
public List <BitPlane> Parse(BitPlane stones) { var ret = new List <BitPlane>(); var scope = stones.Copy(); while (scope.Unabled.Any()) { var grp = GroupWalker(scope, scope.Unabled.First()); var bp = new BitPlane(stones.Width, stones.Height); bp.AddRange(grp); ret.Add(bp); } return(ret); }
public static void AssertBitPlane(BitPlane excepted, BitPlane actual, string message) { var compare = excepted.Copy(); compare.Xor(actual); if (!compare.Empty()) { Trace.WriteLine(message); TraceBitPlane(actual, "actual :"); TraceBitPlane(excepted, "excepted :"); TraceBitPlane(compare, "Errors :"); Assert.Fail("See Trace"); } else { TraceBitPlane(actual, "Ok!"); } }