예제 #1
0
        public static void Clip(
            IList <Polygon2I> clip,
            IList <Polygon2I> subject,
            VattiClipper2I.PolygonFillMode fillMode)
        {
            List <VattiClipper2I.Class191> localMinimumList = new List <VattiClipper2I.Class191>();

            foreach (Polygon2I polygon in (IEnumerable <Polygon2I>)clip)
            {
                VattiClipper2I.smethod_0(polygon, (byte)1, localMinimumList);
            }
            foreach (Polygon2I polygon in (IEnumerable <Polygon2I>)subject)
            {
                VattiClipper2I.smethod_0(polygon, (byte)2, localMinimumList);
            }
            localMinimumList.Sort();
            VattiClipper2I.Class191 localMinimum = (VattiClipper2I.Class191)null;
            if (localMinimumList.Count > 1)
            {
                VattiClipper2I.Class191 class191_1 = localMinimumList[localMinimumList.Count - 1];
                for (int index = localMinimumList.Count - 2; index >= 0; --index)
                {
                    VattiClipper2I.Class191 class191_2 = localMinimumList[index];
                    class191_2.Next = class191_1;
                    class191_1      = class191_2;
                }
                localMinimum = class191_1;
            }
            VattiClipper2I.Class195 class195 = new VattiClipper2I.Class195();
            if (localMinimum == null)
            {
                return;
            }
            class195.EventQueue.Add(localMinimum);
        }
예제 #2
0
        internal static void smethod_0(
            Polygon2I polygon,
            byte type,
            List <VattiClipper2I.Class191> localMinimumList)
        {
            if (polygon.Count == 0)
            {
                return;
            }
            Point2I point2I1 = polygon[polygon.Count - 1];
            Point2I p        = polygon[0];

            VattiClipper2I.Class199 class199_1 = new VattiClipper2I.Class199(point2I1.X, point2I1.Y, p.X, p.Y)
            {
                Type = type
            };
            VattiClipper2I.Class199 e0 = class199_1;
            int  num1  = System.Math.Sign(p.Y - point2I1.Y);
            bool flag1 = false;

            if (num1 == 0)
            {
                flag1 = true;
                for (int index = polygon.Count - 2; index > 0; --index)
                {
                    num1 = System.Math.Sign(p.Y - polygon[index].Y);
                    if (num1 != 0)
                    {
                        break;
                    }
                }
            }
            class199_1.XBottom = num1 < 0 ? p.X : point2I1.X;
            for (int index = 1; index < polygon.Count; ++index)
            {
                Point2I point2I2 = polygon[index];
                VattiClipper2I.Class199 class199_2 = new VattiClipper2I.Class199(p.X, p.Y, point2I2.X, point2I2.Y)
                {
                    Type = type
                };
                int  num2  = System.Math.Sign(point2I2.Y - p.Y);
                bool flag2 = false;
                if (num2 == 0)
                {
                    flag2 = true;
                    num2  = num1;
                    if (flag1)
                    {
                        e0.method_2(class199_2);
                        class199_2 = e0;
                    }
                    else if (num2 > 0)
                    {
                        e0.Successor       = class199_2;
                        class199_2.XBottom = p.X;
                    }
                    else
                    {
                        class199_2.Successor = e0;
                        class199_2.XBottom   = point2I2.X;
                    }
                }
                else if (num2 == num1)
                {
                    if (num2 > 0)
                    {
                        e0.Successor       = class199_2;
                        class199_2.XBottom = p.X;
                    }
                    else
                    {
                        class199_2.Successor = e0;
                        class199_2.XBottom   = point2I2.X;
                    }
                }
                else if (num2 > 0 && num1 < 0)
                {
                    VattiClipper2I.smethod_1(p, localMinimumList, e0, class199_2);
                }
                else if (num2 < 0 && num1 > 0)
                {
                    class199_2.XBottom = point2I2.X;
                }
                num1  = num2;
                flag1 = flag2;
                p     = point2I2;
                e0    = class199_2;
            }
            Point2I point2I3 = polygon[0];

            VattiClipper2I.Class199 class199_3 = class199_1;
            int num3 = System.Math.Sign(point2I3.Y - p.Y);

            if (num3 == 0)
            {
                int num2 = num1;
                if (flag1)
                {
                    e0.method_2(class199_3);
                }
                else if (num2 > 0)
                {
                    e0.Successor       = class199_3;
                    class199_3.XBottom = p.X;
                }
                else
                {
                    class199_3.Successor = e0;
                    class199_3.XBottom   = point2I3.X;
                }
            }
            else if (num3 == num1)
            {
                if (num3 > 0)
                {
                    e0.Successor       = class199_3;
                    class199_3.XBottom = p.X;
                }
                else
                {
                    class199_3.Successor = e0;
                    class199_3.XBottom   = point2I3.X;
                }
            }
            else if (num3 > 0 && num1 < 0)
            {
                VattiClipper2I.smethod_1(p, localMinimumList, e0, class199_3);
            }
            else if (num3 < 0)
            {
                ;
            }
        }