예제 #1
0
        public static Point[,] PolygonParallelEdges(IPolygonReader poly, bool closed, Point pt1, Point pt2)
        {
            List <int> r = PolygonParallelEdges(poly, closed, pt2.Minus(pt1));

            Point[,] ret = new Point[r.Count, 2];
            int i = 0, k;

            foreach (int j in r)
            {
                poly.GetRow(j, out double x, out double y);
                ret[i, 0].X = x; ret[i, 0].Y = y;
                if (j == poly.Length - 1)
                {
                    k = 0;
                }
                else
                {
                    k = j + 1;
                }
                poly.GetRow(k, out x, out y);
                ret[i, 1].X = x; ret[i, 1].Y = y;
                i++;
            }
            return(ret);
        }
예제 #2
0
        public PolygonOffset(IPolygonReader poly, bool isClosed = true, bool isOutline = true)
        {
            // testovani a vyhozeni vyjimek
            if (poly == null)
            {
                throw (new ArgumentNullException("PolygonOffset(poly,..)"));
            }
            if (poly.Length < (isClosed ? 3 : 2))
            {
                throw (new FormatException("PolygonOffset, small number of points"));
            }

            mySrc = new MyPoint[poly.Length];
            myRet = null;

            IsClosed  = isClosed;
            IsOutline = isOutline;

            // zjistim smer otaceni
            myIsReversed = Funcs2D.PolygonIsClockwise(poly) == IsOutline;
            for (int i = 0; i < poly.Length; i++)
            {
                poly.GetRow(i, out double x, out double y);
                mySrc[i].Pt.X   = x;
                mySrc[i].Pt.Y   = y;
                mySrc[i].Id     = i;
                mySrc[i].Offset = 0;
            }

            if (!IsClosed)
            {
                mySrc[poly.Length - 1].Id = 0;
            }
        }
예제 #3
0
        public static Rect2D PolygonBoundary(IPolygonReader poly, ITransEngine2D mat)
        {
            if (poly == null)
            {
                throw (new ArgumentNullException("PolygonBoundary(poly)"));
            }
            Rect2D ret = Rect2D.Empty;
            Point  pt  = new Point();

            for (int i = 0; i < poly.Length; i++)
            {
                poly.GetRow(i, out double x, out double y);
                pt.X = x;
                pt.Y = y;
                if (mat != null)
                {
                    mat.TransTo(pt, ref pt);
                }
                if (ret.IsEmpty)
                {
                    ret = new Rect2D(pt, new Size(0, 0));
                }
                else
                {
                    ret.Union(pt);
                }
            }
            return(ret);
        }
예제 #4
0
 public BoxListPoint(IPolygonReader pr)
 {
     if (pr == null)
     {
         throw (new ArgumentNullException("pr"));
     }
     myValue = new List <Point>();
     for (int i = 0; i < pr.Length; i++)
     {
         pr.GetRow(i, out double x, out double y);
         myValue.Add(new Point(x, y));
     }
 }
예제 #5
0
        public override void GetRow(int row, out double x, out double y)
        {
            if (row >= myPoly.Length)
            {
                throw (new IndexOutOfRangeException());
            }
            myPoly.GetRow(row, out x, out y);
            Point pt = new Point();

            d_Trans(new Point(x, y), ref pt);
            x = pt.X;
            y = pt.Y;
        }
예제 #6
0
 public BoxArrayPoint(IPolygonReader pr)
 {
     if (pr == null)
     {
         throw (new ArgumentNullException("pr"));
     }
     myValue = new Point[pr.Length];
     for (int i = 0; i < pr.Length; i++)
     {
         pr.GetRow(i, out double x, out double y);
         myValue[i].X = x;
         myValue[i].Y = y;
     }
 }