Esempio n. 1
0
    //-----------------------

    //public bool PointExists(int rx, int ry)
    //{
    //    for (int i = 0; i < PointsLst.Count; i++)
    //    {
    //        if ((PointsLst[i].X == rx) && (PointsLst[i].Y == ry))
    //        {
    //            return true;
    //        }
    //    }
    //    return false;
    //}

    //-----------------------

    public void Draw(ref byte[] img)
    {
        for (int i = 0; i < Items.Count; i++)
        {
            Poly poly1 = Items[i];
            if (poly1.active == true)
            {
                poly1.Dopoly(this, PointsLst, true, img);
            }
            poly1.active = false;
        }
    }
Esempio n. 2
0
    //-----------------------

    public int ErrorOfpolys(System.Collections.ArrayList lst, ref byte[] img, double prevmin)
    {
        int error = 0;

        foreach (int idx in lst)
        {
            Poly t = Items[idx];
            if ((error <= prevmin) || (prevmin == -1))
            {
                error = error + t.Dopoly(this, PointsLst, false);
            }
        }
        return(error);
    }
Esempio n. 3
0
    //-----------------------

    public void recalc()
    {
        int n  = 16;
        int s  = Width / n + 1;
        int xx = 0;
        int yy = 0;


        System.Text.StringBuilder bld = new StringBuilder();
        for (int y = 0; y <= 768 / n; y++)
        {
            for (int x = 0; x <= Width / n; x++)
            {
                if (!PointsLst.Contains(new Point(x * n, y * n)))
                {
                    yy = y * n;
                    xx = x * n;
                    if (yy == Height)
                    {
                        yy = Height - 1;
                    }
                    if (xx == Width)
                    {
                        xx = Width - 1;
                    }
                    PointsLst.Add(new Point(xx, yy));
                    PointsLst_cpy.Add(new Point(xx, yy));
                }
            }
        }


        for (int y = 0; y < Height / n; y++)
        {
            for (int x = 0; x < Width / n; x++)
            {
                int i1 = PointsLst.IndexOf(new Point(x * n, y * n));
                xx = (x + 1) * n;
                if (xx == Width)
                {
                    xx = Width - 1;
                }
                int i2 = PointsLst.IndexOf(new Point(xx, y * n));
                yy = (y + 1) * n;
                if (yy == Height)
                {
                    yy = Height - 1;
                }
                int i3 = PointsLst.IndexOf(new Point(x * n, yy));
                yy = (y + 1) * n;
                xx = (x + 1) * n;
                if (yy == Height)
                {
                    yy = Height - 1;
                }
                if (xx == Width)
                {
                    xx = Width - 1;
                }
                int  i4 = PointsLst.IndexOf(new Point(xx, yy));
                Poly d1 = new Poly(i2, i3, i1, PointsLst);
                Poly d2 = new Poly(i2, i3, i4, PointsLst);
                Poly d3 = new Poly(i1, i4, i2, PointsLst);
                Poly d4 = new Poly(i1, i4, i3, PointsLst);

                // Todo Parallel
                int err1 = d1.Dopoly(this, PointsLst, false);
                int err2 = d2.Dopoly(this, PointsLst, false);
                int err3 = d3.Dopoly(this, PointsLst, false);
                int err4 = d4.Dopoly(this, PointsLst, false);

                if (err1 + err2 > err3 + err4)
                {
                    Items.Add(d3);
                    Items.Add(d4);
                }
                else
                {
                    Items.Add(d1);
                    Items.Add(d2);
                }
            }
        }
    }