Ejemplo n.º 1
0
        // Создание класса из пар кодов
        public static DxfCircle Create(List <DxfCodePair> pairs, bool ignoreLineType)
        {
            DxfCircle circle = new DxfCircle();

            for (int i = 0; i < pairs.Count; i++)
            {
                switch (pairs[i].Code)
                {
                case 62:
                    circle.Color = DxfColor.Create(pairs[i], ignoreLineType);
                    break;

                case 10:
                    if (pairs[i + 2].Code == 30)
                    {
                        circle.Center = DxfDot.Create(pairs.GetRange(i, 3));
                        i            += 2;
                    }
                    else
                    {
                        circle.Center = DxfDot.Create(pairs.GetRange(i, 2));
                        i++;
                    }
                    break;

                case 40:
                    circle.Radius = pairs[i].AsDouble;
                    break;
                }
            }

            if (circle.Color == 0 && ignoreLineType)
            {
                circle.Color = DxfColors.MainOutline;
            }
            else if (circle.Color == 0 || circle.Color == DxfColors.NoColor)
            {
                return(null);
            }

            Rect rt = new Rect(circle.Center.X - circle.Radius, circle.Center.Y - circle.Radius,
                               circle.Radius * 2, circle.Radius * 2);

            circle.Bound = rt;

            return(circle);
        }
Ejemplo n.º 2
0
        public void ReadArcAndCirle(StreamReader Reader, List <IDxfComponent> DxfList)
        {
            string temp;
            double x1 = 0; double y1 = 0; double z1 = 0;
            double x2 = 0; double y2 = 0; double z2 = 0;
            double startAngle = 0;
            double stopAngle  = 0;
            double radius     = 0;

            for (int i = 0; i < 7; i++)
            {
                temp = (string)Reader.ReadLine();
                temp = temp.Trim();
                switch (temp)
                {
                case "10":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    x1   = Convert.ToDouble(temp.Replace(".", ","));
                    break;

                case "20":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    y1   = Convert.ToDouble(temp.Replace(".", ","));
                    break;

                case "30":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    z1   = Convert.ToDouble(temp.Replace(".", ","));
                    break;


                case "40":
                    temp   = (string)Reader.ReadLine();
                    temp   = temp.Trim();
                    radius = Convert.ToDouble(temp.Replace(".", ","));
                    break;

                case "210":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    x2   = Convert.ToDouble(temp.Replace(".", ","));
                    break;

                case "220":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    y2   = Convert.ToDouble(temp.Replace(".", ","));
                    break;

                case "230":
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    z2   = Convert.ToDouble(temp.Replace(".", ","));
                    break;
                }
            }

            string line1;
            string line2;

            line1 = (string)Reader.ReadLine();
            line2 = (string)Reader.ReadLine();

            if (line1 == "100" && line2 == "AcDbArc")
            {
                for (int i = 0; i < 2; i++)
                {
                    temp = (string)Reader.ReadLine();
                    temp = temp.Trim();
                    switch (temp)
                    {
                    case "50":
                        temp       = (string)Reader.ReadLine();
                        temp       = temp.Trim();
                        startAngle = Convert.ToDouble(temp.Replace(".", ","));
                        break;

                    case "51":
                        temp      = (string)Reader.ReadLine();
                        temp      = temp.Trim();
                        stopAngle = Convert.ToDouble(temp.Replace(".", ","));
                        break;
                    }
                }

                DxfArc Arc = new DxfArc();
                Arc.startPoint.xval = x1;
                Arc.startPoint.yval = y1;
                Arc.startPoint.zval = z1;
                Arc.startAngle      = startAngle;
                Arc.radius          = radius;
                Arc.endPoint.xval   = x2;
                Arc.endPoint.yval   = y2;
                Arc.endPoint.zval   = z2;
                Arc.stopAngle       = stopAngle;
                DxfList.Add(Arc);
            }


            else
            {
                DxfCircle Circle = new DxfCircle();
                Circle.startPoint.xval = x1;
                Circle.startPoint.yval = y1;
                Circle.startPoint.zval = z1;

                Circle.endPoint.xval = x2;
                Circle.endPoint.yval = y2;
                Circle.endPoint.zval = z2;
                Circle.radius        = radius;
                DxfList.Add(Circle);
            }
        }