Exemplo n.º 1
0
        private static void smethod_4(
            List <Class455.Class459> edgeRefs,
            List <Class455.Class456> intersections)
        {
            edgeRefs.Sort();
            List <Class455.Class458> class458List = new List <Class455.Class458>();

            foreach (Class455.Class459 edgeRef in edgeRefs)
            {
                if (!edgeRef.Insert)
                {
                    class458List.Remove(edgeRef.class458_0);
                }
                else
                {
                    Class455.Class458 class4580 = edgeRef.class458_0;
                    bool bool0 = class4580.bool_0;
                    foreach (Class455.Class458 edge2 in class458List)
                    {
                        if (bool0 ^ edge2.bool_0)
                        {
                            Class455.smethod_5(class4580, edge2, intersections);
                        }
                    }
                    class458List.Add(class4580);
                }
            }
        }
Exemplo n.º 2
0
        private static IList <Class455.Class459> smethod_3(
            Polyline3D poly,
            out Point2D min,
            out Point2D max)
        {
            min = new Point2D(double.MaxValue, double.MaxValue);
            max = new Point2D(double.MinValue, double.MinValue);
            int count = poly.Count;

            if (count <= 0)
            {
                return((IList <Class455.Class459>) new List <Class455.Class459>());
            }
            List <Class455.Class459> class459List = new List <Class455.Class459>(2 * count);
            Point3D end;
            int     num;

            if (poly.Closed)
            {
                end = poly[0];
                num = poly.Count - 1;
            }
            else
            {
                end = poly[poly.Count - 1];
                num = poly.Count - 2;
                min = max = (Point2D)end;
            }
            for (int startParameter = num; startParameter >= 0; --startParameter)
            {
                Point3D start = poly[startParameter];
                if (start.X > max.X)
                {
                    max.X = start.X;
                }
                if (start.Y > max.Y)
                {
                    max.Y = start.Y;
                }
                if (start.X < min.X)
                {
                    min.X = start.X;
                }
                if (start.Y < min.Y)
                {
                    min.Y = start.Y;
                }
                Class455.Class458 edge = new Class455.Class458(startParameter, start, end, true);
                if (edge.vector3D_0 != Vector3D.Zero)
                {
                    class459List.Add(new Class455.Class459(true, edge));
                    class459List.Add(new Class455.Class459(false, edge));
                }
                end = start;
            }
            return((IList <Class455.Class459>)class459List);
        }
Exemplo n.º 3
0
 public Class459(bool fromStart, Class455.Class458 edge)
 {
     this.bool_0     = fromStart;
     this.class458_0 = edge;
     this.int_0      = edge.point3D_0.Y.CompareTo(edge.point3D_1.Y);
     if (this.int_0 == 0)
     {
         this.int_0 = edge.point3D_0.X.CompareTo(edge.point3D_1.X);
     }
     if (fromStart)
     {
         return;
     }
     this.int_0 = -this.int_0;
 }
Exemplo n.º 4
0
        private static IList <Class455.Class459> smethod_2(
            Polygon2D poly,
            out Point2D min,
            out Point2D max)
        {
            min = new Point2D(double.MaxValue, double.MaxValue);
            max = new Point2D(double.MinValue, double.MinValue);
            int count = poly.Count;

            if (count <= 0)
            {
                return((IList <Class455.Class459>) new List <Class455.Class459>());
            }
            List <Class455.Class459> class459List = new List <Class455.Class459>(2 * count);
            Point2D point2D1 = poly[0];

            for (int startParameter = count - 1; startParameter >= 0; --startParameter)
            {
                Point2D point2D2 = poly[startParameter];
                if (point2D2.X > max.X)
                {
                    max.X = point2D2.X;
                }
                if (point2D2.Y > max.Y)
                {
                    max.Y = point2D2.Y;
                }
                if (point2D2.X < min.X)
                {
                    min.X = point2D2.X;
                }
                if (point2D2.Y < min.Y)
                {
                    min.Y = point2D2.Y;
                }
                Class455.Class458 edge = new Class455.Class458(startParameter, (Point3D)point2D2, (Point3D)point2D1, false);
                if (edge.vector3D_0 != Vector3D.Zero)
                {
                    class459List.Add(new Class455.Class459(true, edge));
                    class459List.Add(new Class455.Class459(false, edge));
                }
                point2D1 = point2D2;
            }
            return((IList <Class455.Class459>)class459List);
        }
Exemplo n.º 5
0
            public List <Class455.Class456> method_1(Point3D start, Point3D end)
            {
                double x1;
                double x2;

                if (start.X < end.X)
                {
                    x1 = start.X;
                    x2 = end.X;
                }
                else
                {
                    x1 = end.X;
                    x2 = start.X;
                }
                double y1;
                double y2;

                if (start.Y < end.Y)
                {
                    y1 = start.Y;
                    y2 = end.Y;
                }
                else
                {
                    y1 = end.Y;
                    y2 = start.Y;
                }
                List <Class455.Class456> intersections = new List <Class455.Class456>();

                if (x1 < this.point2D_1.X && x2 > this.point2D_0.X && (y1 < this.point2D_1.Y && y2 > this.point2D_0.Y))
                {
                    List <Class455.Class459> edgeRefs = new List <Class455.Class459>(this.ilist_0.Count + 2);
                    edgeRefs.AddRange((IEnumerable <Class455.Class459>) this.ilist_0);
                    Class455.Class458 edge = new Class455.Class458(0, start, end, true);
                    edgeRefs.Add(new Class455.Class459(true, edge));
                    edgeRefs.Add(new Class455.Class459(false, edge));
                    Class455.smethod_4(edgeRefs, intersections);
                }
                return(intersections);
            }
Exemplo n.º 6
0
        private static void smethod_5(
            Class455.Class458 edge1,
            Class455.Class458 edge2,
            List <Class455.Class456> intersections)
        {
            Class455.Class458 class458_1;
            Class455.Class458 class458_2;
            if (edge1.bool_0)
            {
                class458_1 = edge2;
                class458_2 = edge1;
            }
            else
            {
                class458_1 = edge1;
                class458_2 = edge2;
            }
            Vector3D vector3D0_1 = class458_1.vector3D_0;
            Vector3D vector3D0_2 = class458_2.vector3D_0;
            double   num1        = 1E-08 * class458_1.double_0 * class458_2.double_0;
            double   num2        = vector3D0_1.X * vector3D0_2.Y - vector3D0_1.Y * vector3D0_2.X;

            if (System.Math.Abs(num2) < num1)
            {
                Vector3D vector3D = class458_1.point3D_0 - class458_2.point3D_0;
                if (System.Math.Abs(vector3D.X * vector3D0_2.Y - vector3D.Y * vector3D0_2.X) >= num1)
                {
                    return;
                }
                double val1 = class458_2.method_0(class458_1.point3D_0.X, class458_1.point3D_0.Y);
                double val2 = class458_2.method_0(class458_1.point3D_1.X, class458_1.point3D_1.Y);
                double num3 = System.Math.Min(val1, val2);
                if (num3 > 1.0)
                {
                    return;
                }
                double num4 = System.Math.Max(val1, val2);
                if (num4 < 0.0)
                {
                    return;
                }
                if (num3 < 0.0)
                {
                    num3 = 0.0;
                }
                if (num4 > 1.0)
                {
                    num4 = 1.0;
                }
                if (num4 - num3 < 1E-08)
                {
                    double  num5      = 0.5 * (num3 + num4);
                    Point2D point2D   = class458_2.method_1(num5);
                    double  clipParam = class458_1.method_0(point2D.X, point2D.Y);
                    if (clipParam < 0.0 || clipParam > 1.0)
                    {
                        return;
                    }
                    Class455.Class456 class456 = new Class455.Class456(class458_1.int_0, clipParam, class458_2.int_0, num5);
                    intersections?.Add(class456);
                }
                else
                {
                    if (intersections == null)
                    {
                        return;
                    }
                    Point2D point2D    = class458_2.method_1(num3);
                    double  clipParam1 = class458_1.method_0(point2D.X, point2D.Y);
                    if (clipParam1 < 0.0 || clipParam1 > 1.0)
                    {
                        return;
                    }
                    intersections.Add(new Class455.Class456(class458_1.int_0, clipParam1, class458_2.int_0, num3));
                    point2D = class458_2.method_1(num4);
                    double clipParam2 = class458_1.method_0(point2D.X, point2D.Y);
                    intersections.Add(new Class455.Class456(class458_1.int_0, clipParam2, class458_2.int_0, num4));
                }
            }
            else
            {
                Vector3D vector3D  = class458_2.point3D_0 - class458_1.point3D_0;
                double   clipParam = (vector3D.X * vector3D0_2.Y - vector3D.Y * vector3D0_2.X) / num2;
                if (clipParam < 0.0 || clipParam > 1.0)
                {
                    return;
                }
                double polygonParam = (vector3D.X * vector3D0_1.Y - vector3D.Y * vector3D0_1.X) / num2;
                if (polygonParam < 0.0 || polygonParam > 1.0)
                {
                    return;
                }
                Class455.Class456 class456 = new Class455.Class456(class458_1.int_0, clipParam, class458_2.int_0, polygonParam);
                intersections?.Add(class456);
            }
        }