Exemple #1
0
        void Four_po_netnumber(PO[] p)
        {
            /*
             * 输入:长方形区域的四个角点的坐标
             * 输出:长方形所包括的网格的坐标
             */
            util u1 = new util();
            int  x1, x1g, x2, x2g, xm, X0, Y0, X1, Y1, i;
            PO   p1d, p2d, pm;

            pm = new PO();
            if (u1.Direct_2d(new LINE(p[1], p[2]), p[3]) * u1.Direct_2d(new LINE(p[1], p[2]), p[0]) >= 0)
            {
                pm.x   = p[2].x;
                pm.y   = p[2].y;
                p[2].x = p[3].x;
                p[2].y = p[3].y;
                p[3].x = pm.x;
                p[3].y = pm.y;
            }
            X0  = (int)(p[0].x / Xi);
            Y0  = (int)(p[0].y / Yi);
            X1  = (int)(p[3].x / Xi);
            Y1  = (int)(p[3].y / Yi);
            p1d = p[0];
            p2d = p[0];
            x1g = x2g = 0;
            net_choosed.Clear();
            for (i = Y0 + 1; i <= Y1 + 1; i++)
            {
                if (p1d.x == p[1].x)
                {
                    x1 = (int)(p[1].x / Xi);
                }
                else if (p1d.y == p[1].y)
                {
                    x1 = (int)(p[1].x / Xi);
                }
                else
                {
                    x1 = (int)(u1.Cal_po_on_Line(p1d, p[1], (i + x1g) * Yi) / Xi);
                }
                if (p2d.x == p[2].x)
                {
                    x2 = (int)(p[2].x / Xi);
                }
                else if (p2d.y == p[2].y)
                {
                    x2 = (int)(p[2].x / Xi);
                }
                else
                {
                    x2 = (int)(u1.Cal_po_on_Line(p2d, p[2], (i + x2g) * Yi) / Xi);
                }
                if (i - 1 == (int)(p[1].y / Yi))
                {
                    x1  = (int)(p[1].x / Xi);
                    p1d = p[3];
                    x1g = -1;
                }
                if (i - 1 == (int)(p[2].y / Yi))
                {
                    x2  = (int)(p[2].x / Xi);
                    x2g = -1;
                    p2d = p[3];
                }
                if (x1 > x2)
                {
                    xm = x1; x1 = x2; x2 = xm;
                }
                while (x1 <= x2)
                {
                    net_choosed.Insert(new PO(x1, i - 1));
                    x1++;
                }
            }
        }