public void MapNetlists_WorksWell() { IBitmapAccessor accessor = new MockupBitmapAccessor( new string[] { // 012345678 "X X", "X X X X", "X X X X", "XXXX XXXX", "", }); BitmapScanner dut = new BitmapScanner(accessor); dut.Scan(); dut.ComputeNetlists(); dut.CompactNets(); dut.MapNetlists(); for (int netId = 1; netId <= dut.GetNetCount(); netId++) { Console.WriteLine($"NetId : {netId}"); foreach (var segment in dut.GetSegmentsOfNet(netId)) { Console.WriteLine($" {segment}"); } } }
public void TryGetNetAt_WorksWell_WithProperInnput() { IBitmapAccessor accessor = new MockupBitmapAccessor( new string[] { // 012345678 " XXXXXXX", " XX X", " XX XXX X", "", " XX XXX X", " XX X", " XXXX", "", }); BitmapScanner dut = new BitmapScanner(accessor); dut.Scan(); dut.ComputeNetlists(); dut.CompactNets(); dut.MapNetlists(); Assert.IsTrue(dut.TryGetNetAt(1, 2, out int netId)); Assert.AreEqual(1, netId); Assert.IsTrue(dut.TryGetNetAt(5, 2, out netId)); Assert.AreEqual(2, netId); Assert.IsTrue(dut.TryGetNetAt(5, 4, out netId)); Assert.AreEqual(4, netId); Assert.IsFalse(dut.TryGetNetAt(3, 4, out netId)); }
public void Scan_GeneratesGood_Scanlines() { IBitmapAccessor accessor = new MockupBitmapAccessor( new string[] { // 012345678 "XXXXXXXXX", " XXXXXXX", " XXXXX", " XXX", " X", "", }); var expectedStart = new int[] { 0, 1, 2, 3, 4 }; var expectedEnd = new int[] { 8, 7, 6, 5, 4 }; BitmapScanner dut = new BitmapScanner(accessor); dut.Scan(); int y = 0; foreach (var i in dut.Segments) { Console.WriteLine(i.ToString()); Assert.AreEqual(expectedStart[y], i.XMin); Assert.AreEqual(expectedEnd[y], i.XMax); y++; } Assert.AreEqual(y, expectedEnd.Length); }
private bool IsSingleNetlist(BitmapScanner dut) { var result = true; dut.Scan(); dut.ComputeNetlists(); foreach (var segment in dut.Segments) { result &= segment.NetList == 1; } return(result); }
public void Scan_GeneratesGood_CompositeScanlnes_WorksWell() { IBitmapAccessor accessor = new MockupBitmapAccessor( new string[] { // 012345678 " XXXXX", " XX X", " XX XXX X", "", " XX XXX X", " XX X", " XXXX", "", }); Console.WriteLine("Check Segments"); var expectedy = new int[] { 0, 1, 1, 2, 2, 2, 4, 4, 4, 5, 5, 6 }; var expectedStart = new int[] { 2, 1, 7, 1, 4, 8, 1, 4, 8, 2, 8, 3 }; var expectedEnd = new int[] { 6, 2, 7, 2, 6, 8, 2, 6, 8, 3, 8, 6 }; BitmapScanner dut = new BitmapScanner(accessor); dut.Scan(); int i = 0; foreach (var s in dut.Segments) { Assert.AreEqual(expectedy[i], s.Y); Assert.AreEqual(expectedStart[i], s.XMin); Assert.AreEqual(expectedEnd[i], s.XMax); i++; } // Check Scanline Index var expectedY = new int[] { 0, 1, 2, 4, 5, 6 }; var expectedInitial = new int[] { 0, 1, 3, 6, 9, 11 }; var expectedLen = new int[] { 1, 2, 3, 3, 2, 1 }; i = 0; Console.WriteLine("Check ScanLineIndex"); foreach (var index in dut.ScanlineIndex) { Console.WriteLine(index); Assert.AreEqual(expectedY[i], index.Y); Assert.AreEqual(expectedInitial[i], index.InitialIndex); Assert.AreEqual(expectedLen[i], index.Length); i++; } Assert.AreEqual(i, expectedY.Length); }