Exemplo n.º 1
0
 public void method_0()
 {
     for (double?nullable = this.class28_0.method_4(); nullable.HasValue; nullable = this.class28_0.method_4())
     {
         this.double_1 = nullable.Value;
         bool flag = false;
         while (this.class103_0 != null && this.class103_0.point2D_0.Y == this.double_1)
         {
             VattiClipper2DV3.Class100 edge1 = new VattiClipper2DV3.Class100((VattiClipper2DV3.Class102) this.class103_0, this.class103_0.class102_0);
             edge1.double_2 = edge1.point2D_0.X;
             VattiClipper2DV3.Class100 edge2 = new VattiClipper2DV3.Class100((VattiClipper2DV3.Class102) this.class103_0, this.class103_0.class102_1);
             int index = this.list_1.BinarySearch(edge1, (IComparer <VattiClipper2DV3.Class100>)VattiClipper2DV3.Class100.Class101.class101_0);
             if (index < 0)
             {
                 index = ~index;
             }
             this.list_1.Insert(index, edge1);
             this.list_1.Insert(index + 1, edge2);
             this.method_1(edge1);
             this.method_1(edge2);
             this.class103_0 = this.class103_0.class103_0;
             flag            = true;
         }
         if (flag && this.class103_0 != null)
         {
             this.class28_0.TryAdd(this.class103_0.point2D_0.Y);
         }
         this.list_3.Clear();
         this.double_0 = double.NegativeInfinity;
         for (this.int_0 = 0; this.int_0 < this.list_1.Count; ++this.int_0)
         {
             VattiClipper2DV3.Class100 edge = this.list_1[this.int_0];
             if (edge.double_2 != this.double_0 && !double.IsNegativeInfinity(this.double_0))
             {
                 this.method_3();
             }
             this.double_0 = edge.double_2;
             if (edge.point2D_0.Y == this.double_1)
             {
                 this.method_2(edge);
             }
             else if (edge.point2D_1.Y == this.double_1)
             {
                 if (edge.class102_1.class102_0 != null)
                 {
                     this.method_2(new VattiClipper2DV3.Class100(edge.class102_1, edge.class102_1.class102_0));
                 }
             }
             else
             {
                 this.method_5(edge);
             }
         }
         this.method_3();
         List <VattiClipper2DV3.Class100> list1 = this.list_1;
         this.list_1 = this.list_3;
         this.list_3 = list1;
     }
 }
Exemplo n.º 2
0
        public static IList <Polygon2D> Clip(
            IList <Polygon2D> clip,
            IList <Polygon2D> subject,
            VattiClipper2DV3.PolygonFillMode fillMode)
        {
            List <VattiClipper2DV3.Class102.Class103> localMinimumList = new List <VattiClipper2DV3.Class102.Class103>();

            foreach (Polygon2D polygon in (IEnumerable <Polygon2D>)clip)
            {
                VattiClipper2DV3.smethod_0(polygon, (byte)1, localMinimumList);
            }
            foreach (Polygon2D polygon in (IEnumerable <Polygon2D>)subject)
            {
                VattiClipper2DV3.smethod_0(polygon, (byte)2, localMinimumList);
            }
            localMinimumList.Sort((IComparer <VattiClipper2DV3.Class102.Class103>)VattiClipper2DV3.Class102.Class105.class105_0);
            VattiClipper2DV3.Class102.Class103 class103_1 = (VattiClipper2DV3.Class102.Class103)null;
            if (localMinimumList.Count > 1)
            {
                VattiClipper2DV3.Class102.Class103 class103_2 = localMinimumList[localMinimumList.Count - 1];
                for (int index = localMinimumList.Count - 2; index >= 0; --index)
                {
                    VattiClipper2DV3.Class102.Class103 class103_3 = localMinimumList[index];
                    class103_3.class103_0 = class103_2;
                    class103_2            = class103_3;
                }
                class103_1 = class103_2;
            }
            VattiClipper2DV3.Class99 class99 = new VattiClipper2DV3.Class99();
            class99.class103_0 = class103_1;
            if (class103_1 != null)
            {
                class99.class28_0.Add(class103_1.point2D_0.Y);
            }
            class99.method_0();
            if (class99.list_0.Count == 0)
            {
                return((IList <Polygon2D>)VattiClipper2DV3.polygon2D_0);
            }
            List <Polygon2D> polygon2DList = new List <Polygon2D>(class99.list_0.Count);

            foreach (VattiClipper2DV3.Class106 class106 in class99.list_0)
            {
                if (class106.Count > 2)
                {
                    polygon2DList.Add(class106.method_0());
                }
            }
            if (polygon2DList.Count == 0)
            {
                return((IList <Polygon2D>)VattiClipper2DV3.polygon2D_0);
            }
            return((IList <Polygon2D>)polygon2DList);
        }
Exemplo n.º 3
0
        internal static void smethod_0(Polygon2D polygon, byte type, List <VattiClipper2DV3.Class102.Class103> localMinimumList)
        {
            if (polygon.Count == 0)
            {
                return;
            }
            Point2D item    = polygon[0];
            Point2D point2D = item;
            int     num     = 1;
            int     num1    = 0;
            int     count   = polygon.Count;

            while (true)
            {
                if (num < count)
                {
                    point2D = polygon[num];
                    num1    = System.Math.Sign(point2D.Y - item.Y);
                    if (num1 == 0)
                    {
                        num1 = System.Math.Sign(point2D.X - item.X);
                    }
                    if (num1 != 0)
                    {
                        num++;
                        break;
                    }
                    else
                    {
                        num++;
                    }
                }
                else
                {
                    break;
                }
            }
            VattiClipper2DV3.Class102          class102  = null;
            Action <VattiClipper2DV3.Class102> class1020 = null;

            while (true)
            {
                if (num <= count)
                {
                    Point2D item1 = polygon[num % count];
                    int     num2  = System.Math.Sign(item1.Y - point2D.Y);
                    if (num2 == 0)
                    {
                        num2 = System.Math.Sign(item1.X - point2D.X);
                    }
                    if (num2 != 0)
                    {
                        if (num2 == num1)
                        {
                            if (num2 <= 0)
                            {
                                VattiClipper2DV3.Class102 class1021 = new VattiClipper2DV3.Class102(point2D);
                                class1020 = (VattiClipper2DV3.Class102 prev) => class1021.class102_0 = prev;
                                class102  = class1021;
                            }
                            else
                            {
                                VattiClipper2DV3.Class102 class1022 = new VattiClipper2DV3.Class102(point2D);
                                class1020 = (VattiClipper2DV3.Class102 prev) => prev.class102_0 = class1022;
                                class102  = class1022;
                            }
                        }
                        else if (num2 <= 0 || num1 >= 0)
                        {
                            VattiClipper2DV3.Class102 class1023 = new VattiClipper2DV3.Class102(point2D);
                            class1020 = (VattiClipper2DV3.Class102 prev) => prev.class102_0 = class1023;
                            class102  = class1023;
                        }
                        else
                        {
                            VattiClipper2DV3.Class102.Class103 class103 = new VattiClipper2DV3.Class102.Class103(point2D);
                            class1020 = (VattiClipper2DV3.Class102 prev) => class103.class102_1 = prev;
                            class102  = class103;
                            localMinimumList.Add(class103);
                        }
                        num1    = num2;
                        point2D = item1;
                        num++;
                        break;
                    }
                    else
                    {
                        num++;
                    }
                }
                else
                {
                    break;
                }
            }
            int num3 = count + 2;

            while (num < num3)
            {
                Point2D point2D1 = polygon[num % count];
                int     num4     = System.Math.Sign(point2D1.Y - point2D.Y);
                if (num4 == 0)
                {
                    num4 = System.Math.Sign(point2D1.X - point2D.X);
                }
                if (num4 != 0)
                {
                    if (num4 == num1)
                    {
                        if (num4 <= 0)
                        {
                            class102 = new VattiClipper2DV3.Class102(point2D)
                            {
                                class102_0 = class102
                            };
                        }
                        else
                        {
                            VattiClipper2DV3.Class102 class1024 = new VattiClipper2DV3.Class102(point2D);
                            class102.class102_0 = class1024;
                            class102            = class1024;
                        }
                    }
                    else if (num4 <= 0 || num1 >= 0)
                    {
                        VattiClipper2DV3.Class102 class1025 = new VattiClipper2DV3.Class102(point2D);
                        class102.class102_0 = class1025;
                        class102            = class1025;
                    }
                    else
                    {
                        VattiClipper2DV3.Class102.Class103 class1031 = new VattiClipper2DV3.Class102.Class103(point2D)
                        {
                            class102_1 = class102
                        };
                        class102 = class1031;
                        localMinimumList.Add(class1031);
                    }
                    num1    = num4;
                    point2D = point2D1;
                }
                num++;
            }
            if (class1020 != null)
            {
                class1020(class102);
            }
        }