示例#1
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;
            }
        }