Beispiel #1
0
 public Class819(Class811.Class818 segment, double x)
 {
     this.class818_0 = segment;
     this.double_0   = x;
 }
Beispiel #2
0
        private static List <Segment2D[]> smethod_8(
            Polyline2D[] borders,
            Point2D reference,
            Vector2D offset,
            Vector2D direction,
            double[] dashes,
            bool fillInterior)
        {
            double   angle     = System.Math.Atan2(direction.Y, direction.X);
            Matrix3D matrix3D1 = Transformation3D.Rotate(-angle) * Transformation3D.Translation(-reference.X, -reference.Y);
            Matrix3D matrix3D2 = Transformation3D.Translation(reference.X, reference.Y) * Transformation3D.Rotate(angle);
            Vector2D vector2D  = matrix3D1.Transform(offset);

            if (vector2D.Y == 0.0)
            {
                return(new List <Segment2D[]>());
            }
            if (vector2D.Y < 0.0)
            {
                vector2D = -vector2D;
            }
            List <Class811.Class818> class818List1 = new List <Class811.Class818>();
            double dashPatternLength = 0.0;

            if (dashes != null)
            {
                foreach (double dash in dashes)
                {
                    dashPatternLength += System.Math.Abs(dash);
                }
            }
            int num1 = 0;
            int num2 = -1;

            foreach (Polyline2D border in borders)
            {
                int borderId = border.Closed ? num1++ : num2--;
                for (int index = border.Count - 1; index > 0; --index)
                {
                    class818List1.Add(new Class811.Class818(borderId, matrix3D1.Transform(border[index]), matrix3D1.Transform(border[index - 1])));
                }
                if (border.Closed && border.Count >= 3)
                {
                    class818List1.Add(new Class811.Class818(borderId, matrix3D1.Transform(border[0]), matrix3D1.Transform(border[border.Count - 1])));
                }
            }
            if (class818List1.Count == 0)
            {
                return(new List <Segment2D[]>());
            }
            class818List1.Sort((IComparer <Class811.Class818>)Class811.class816_0);
            List <Class811.Class818> class818List2 = new List <Class811.Class818>();
            double y1   = class818List1[0].point2D_0.Y;
            double num3 = double.NegativeInfinity;

            foreach (Class811.Class818 class818 in class818List1)
            {
                if (class818.point2D_1.Y > num3)
                {
                    num3 = class818.point2D_1.Y;
                }
            }
            double             num4 = System.Math.Ceiling(y1 / vector2D.Y);
            double             x    = vector2D.X * num4;
            double             y2   = vector2D.Y * num4;
            List <Segment2D[]> segment2DArrayList = new List <Segment2D[]>();

            for (; y2 <= num3; y2 += vector2D.Y)
            {
                while (class818List1.Count > 0 && class818List1[0].point2D_0.Y <= y2)
                {
                    Class811.Class818 class818 = class818List1[0];
                    class818List1.RemoveAt(0);
                    if (class818.point2D_1.Y > y2)
                    {
                        class818List2.Add(class818);
                    }
                }
                List <Class811.Class819> intersections = new List <Class811.Class819>();
                for (int index = class818List2.Count - 1; index >= 0; --index)
                {
                    Class811.Class818 class818 = class818List2[index];
                    if (class818.point2D_1.Y <= y2)
                    {
                        class818List2.RemoveAt(index);
                    }
                    else
                    {
                        intersections.Add(class818.method_0(y2));
                    }
                }
                if (intersections.Count >= 2)
                {
                    intersections.Sort();
                    if (intersections.Count % 2 != 0)
                    {
                        Class811.smethod_10(intersections);
                    }
                    for (int index = intersections.Count - 1; index > 0; --index)
                    {
                        if (intersections[index].double_0 == intersections[index - 1].double_0)
                        {
                            intersections.RemoveAt(index);
                            intersections.RemoveAt(--index);
                        }
                    }
                    if (intersections.Count > 0)
                    {
                        if (dashPatternLength > 0.0)
                        {
                            List <Pair <double> > mappedDashes = new List <Pair <double> >();
                            int num5 = intersections.Count / 2;
                            for (int index = 0; index < num5; ++index)
                            {
                                Class811.Class819 class819_1 = intersections[2 * index];
                                Class811.Class819 class819_2 = intersections[2 * index + 1];
                                Class811.smethod_9(mappedDashes, x, class819_1.double_0, class819_2.double_0, dashes, dashPatternLength);
                            }
                            if (mappedDashes.Count > 0)
                            {
                                Segment2D[] segment2DArray = new Segment2D[mappedDashes.Count];
                                for (int index = 0; index < mappedDashes.Count; ++index)
                                {
                                    Point2D point1 = new Point2D(mappedDashes[index].First, y2);
                                    Point2D point2 = new Point2D(mappedDashes[index].Second, y2);
                                    segment2DArray[index] = new Segment2D(matrix3D2.Transform(point1), matrix3D2.Transform(point2));
                                }
                                segment2DArrayList.Add(segment2DArray);
                            }
                        }
                        else
                        {
                            Segment2D[] segment2DArray = new Segment2D[intersections.Count / 2];
                            for (int index = 0; index < intersections.Count; index += 2)
                            {
                                Point2D point1 = new Point2D(intersections[index].double_0, y2);
                                Point2D point2 = new Point2D(intersections[index + 1].double_0, y2);
                                segment2DArray[index / 2] = new Segment2D(matrix3D2.Transform(point1), matrix3D2.Transform(point2));
                            }
                            segment2DArrayList.Add(segment2DArray);
                        }
                    }
                }
                x += vector2D.X;
            }
            return(segment2DArrayList);
        }