Пример #1
0
        public PolyCurve ToPolyCurve(double radius)
        {
            Circle2      circle2    = new Circle2(this.M, radius);
            PolyCurve    polyCurve1 = new PolyCurve();
            Circle       circle     = new Circle(new Point3d(this.M.x, this.M.y, 0.0), radius);
            double       num1       = double.NaN;
            double       num2       = double.NaN;
            List <Line2> line2List  = this.Edges();
            PolyCurve    polyCurve2;

            if (line2List.Count == 0)
            {
                polyCurve2 = (PolyCurve)null;
            }
            else
            {
                int num3 = line2List.Count - 1;
                for (int index = 0; index <= num3; ++index)
                {
                    double l0 = 0.0;
                    double l1 = 0.0;
                    double a0 = 0.0;
                    double a1 = 0.0;
                    switch (circle2.Intersect(line2List[index], ref l0, ref l1, ref a0, ref a1))
                    {
                    case LineCircleX.Secant:
                        Node2 node2_1 = line2List[index].PointAt(l0);
                        Node2 node2_2 = line2List[index].PointAt(l1);
                        if (l0 <= 1.0 && l1 >= 0.0)
                        {
                            if (l0 >= 0.0)
                            {
                                if (l0 < 1.0)
                                {
                                    if (double.IsNaN(num1))
                                    {
                                        num1 = a0;
                                    }
                                    if (!double.IsNaN(num2))
                                    {
                                        Node2 node2_3 = circle2.PointAt(num2);
                                        Node2 node2_4 = circle2.PointAt(a0);
                                        Vec2  vec2    = circle2.TangentAt(num2);
                                        Arc   arc     = new Arc(new Point3d(node2_3.x, node2_3.y, 0.0), new Vector3d(vec2.x, vec2.y, 0.0), new Point3d(node2_4.x, node2_4.y, 0.0));
                                        polyCurve1.Append(arc);
                                    }
                                    if (l1 > l0 && l1 <= 1.0)
                                    {
                                        polyCurve1.Append(new Line(new Point3d(node2_1.x, node2_1.y, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0)));
                                        num2 = a1;
                                        break;
                                    }
                                    polyCurve1.Append(new Line(new Point3d(node2_1.x, node2_1.y, 0.0), new Point3d(line2List[index].Bx, line2List[index].By, 0.0)));
                                    num2 = double.NaN;
                                    break;
                                }
                                break;
                            }
                            if (l1 >= 0.0 && l1 <= 1.0)
                            {
                                polyCurve1.Append(new Line(new Point3d(line2List[index].Ax, line2List[index].Ay, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0)));
                                num2 = a1;
                                break;
                            }
                            polyCurve1.Append(new Line(new Point3d(line2List[index].Ax, line2List[index].Ay, 0.0), new Point3d(line2List[index].Bx, line2List[index].By, 0.0)));
                            num2 = double.NaN;
                            break;
                        }
                        break;
                    }
                }
                if (!double.IsNaN(num2) && !double.IsNaN(num1))
                {
                    Node2 node2_1 = circle2.PointAt(num2);
                    Node2 node2_2 = circle2.PointAt(num1);
                    Vec2  vec2    = circle2.TangentAt(num2);
                    Arc   arc     = new Arc(new Point3d(node2_1.x, node2_1.y, 0.0), new Vector3d(vec2.x, vec2.y, 0.0), new Point3d(node2_2.x, node2_2.y, 0.0));
                    polyCurve1.Append(arc);
                }
                if (polyCurve1.SegmentCount == 0)
                {
                    polyCurve1.Append((Curve) new ArcCurve(new Circle(new Point3d(this.M.x, this.M.y, 0.0), radius)));
                }
                polyCurve2 = polyCurve1;
            }
            return(polyCurve2);
        }