Пример #1
0
        private static void CreateRect(DxfLine line)
        {
            Rect r = new Rect();

            r.X        = Math.Min(line.StartPoint.X, line.EndPoint.X);
            r.Y        = Math.Min(line.StartPoint.Y, line.EndPoint.Y);
            r.Width    = Math.Abs(line.StartPoint.X - line.EndPoint.X);
            r.Height   = Math.Abs(line.StartPoint.Y - line.EndPoint.Y);
            line.Bound = r;
        }
Пример #2
0
        // Создание линии из вершин полилинии
        public static DxfLine Create(DxfVertex vertex1, DxfVertex vertex2, DxfColors color = DxfColors.MainOutline)
        {
            DxfLine line = new DxfLine
            {
                Color      = color,
                StartPoint = vertex1.AsDot,
                EndPoint   = DxfEndPoint.EndPointFromDot(vertex2.AsDot)
            };

            CreateRect(line);
            return(line);
        }
Пример #3
0
        // Создание линии из пар кодов
        public static DxfLine Create(List <DxfCodePair> pairs, bool ignoreLineType)
        {
            DxfLine line = new DxfLine();

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

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

                case 11:
                    if ((i + 2) < pairs.Count && pairs[i + 2].Code == 31)
                    {
                        line.EndPoint = DxfEndPoint.Create(pairs.GetRange(i, 3));
                        i            += 2;
                    }
                    else
                    {
                        line.EndPoint = DxfEndPoint.Create(pairs.GetRange(i, 2));
                        i++;
                    }
                    break;
                }
            }

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

            CreateRect(line);

            return(line);
        }
Пример #4
0
        public DxfLine ReadLine(StreamReader Reader)
        {
            string buffer;

            buffer = Reader.ReadLine();

            DxfLine Line = new DxfLine();

            while (buffer != "  0")
            {
                switch (buffer.Trim())
                {
                case "10":
                    buffer = Reader.ReadLine();
                    Line.startPoint.xval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "20":
                    buffer = Reader.ReadLine();
                    Line.startPoint.yval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "30":
                    buffer = Reader.ReadLine();
                    Line.startPoint.zval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "39":
                    buffer         = Reader.ReadLine();
                    Line.thickness = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "11":
                    buffer             = Reader.ReadLine();
                    Line.endPoint.xval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "21":
                    buffer             = Reader.ReadLine();
                    Line.endPoint.yval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "31":
                    buffer             = Reader.ReadLine();
                    Line.endPoint.zval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "210":
                    buffer = Reader.ReadLine();
                    Line.extrusionDirection.xval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "220":
                    buffer = Reader.ReadLine();
                    Line.extrusionDirection.yval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                case "230":
                    buffer = Reader.ReadLine();
                    Line.extrusionDirection.zval = Convert.ToDouble(buffer.Replace(".", ","));
                    break;

                default:
                    break;
                }

                buffer = Reader.ReadLine();
            }
            return(Line);
        }