Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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}");
                }
            }
        }
Ejemplo n.º 4
0
        public void GetHoles_WorksWell_WithProperBitmap()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                //   012345678
                "XXXXXXXXXXX",
                "X         X",
                "X XX  XX  X",
                "X XX  XX  X",
                "X         X",
                "X    XX   X",
                "X    XX   X",
                "X         X",
                "XXXXXXXXXXX",
            });

            BitmapScanner dut = new BitmapScanner(accessor);

            dut.PrepareAll();

            DrillScanner scanner = new DrillScanner(dut);

            var holes = scanner.GetHoles();

            Assert.AreEqual(3, holes.Count);
            Assert.AreEqual(2.5, holes[0].X);
            Assert.AreEqual(2.5, holes[0].Y);
            Assert.AreEqual(6.5, holes[1].X);
            Assert.AreEqual(2.5, holes[1].Y);
            Assert.AreEqual(5.5, holes[2].X);
            Assert.AreEqual(5.5, holes[2].Y);
        }
        public void MockupBitmapAccessor_WorksWell_AlternatingFullAndVoidLines()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[]
                {
                    "XXXXXX",
                    "",
                    "XXXXXX",
                    "",
                });

            Assert.AreEqual(6, accessor.Width);
            Assert.AreEqual(4, accessor.Height);
            for (int x = 0; x < accessor.Width; x++) 
            {
                for (int y=0; y<accessor.Height; y++)
                {
                    if (y%2 ==1)
                    {
                        Assert.IsFalse(accessor.PixelAt(x,y));
                    }
                    else
                    {
                        Assert.IsTrue(accessor.PixelAt(x,y));
                    }
                }
            }
        }
 public void MockupBitmapAccessor_WorksWell_WithOneBitSet1x1bitmap()
 {
     IBitmapAccessor accessor = new MockupBitmapAccessor(
         new string[]
         {
             "X",
         });
     AssertAllSet(1,1, accessor);
 }
 public void MockupBitmapAccessor_WorksWell_WithAllSet2x2bitmap()
 {
     IBitmapAccessor accessor = new MockupBitmapAccessor(
         new string[]
         {
             "XX",
             "XX"
         });
     AssertAllSet(2,2, accessor);
 }
Ejemplo n.º 8
0
        public void ComputeNetlists_WorksWell_Case2()
        {
            IBitmapAccessor accessor = new MockupBitmapAccessor(
                new string[] {
                "  XXXX       XXXXXXXX            X",
                " XXXXXX     XXXX   XXXXX       XXX",
                "XXXXXXXXXXXXXX       XXXXX  XXXX",
                "                        XXXXX"
            });
            BitmapScanner dut = new BitmapScanner(accessor);

            Assert.IsTrue(IsSingleNetlist(dut));
        }
Ejemplo n.º 9
0
        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);
        }