Example #1
0
        //--------------------------------------------------------------------------------------------------

        void _ImportLwPolyline(DxfDomLwPolyline dxfPolyline)
        {
            if (dxfPolyline.Points.Length == 0)
            {
                return;
            }

            var startIndex = _AddPoint(dxfPolyline.Points[0]);

            for (int i = 1; i < dxfPolyline.Points.Length; i++)
            {
                var endIndex = _AddPoint(dxfPolyline.Points[i]);
                _Segments.Add(new SketchSegmentLine(startIndex, endIndex));
                startIndex = endIndex;
            }
        }
        //--------------------------------------------------------------------------------------------------

        void _AddPolygonCurve(Geom2d_Curve curve)
        {
            var converter = new Geom2dConvert_ApproxCurve(curve, _Precision, GeomAbs_Shape.GeomAbs_C0, 500, 1);

            if (!(converter.IsDone() && converter.HasResult()))
            {
                Messages.Error($"Cannot tesselate curve to polyline.");
                return;
            }

            var approx = converter.Curve();
            var points = new Pnt2d[approx.NbPoles()];

            for (int i = 0; i < points.Length; i++)
            {
                points[i] = approx.Pole(i + 1);
            }

            var entity = new DxfDomLwPolyline("0", points);

            _Document.Entities.Add(entity);
        }
Example #3
0
        //--------------------------------------------------------------------------------------------------

        void _ReadEntities(DxfReader reader)
        {
            while (reader.GroupCode >= 0)
            {
                if (reader.GroupCode != 0)
                {
                    reader.Skip();
                    continue;
                }

                var type = reader.ReadString()?.ToUpper();
                if (type == null)
                {
                    continue;
                }

                DxfDomEntity entity = null;
                switch (type)
                {
                case "ENDSEC":
                    return;

                case "LINE":
                    entity = new DxfDomLine();
                    break;

                case "CIRCLE":
                case "ARC":
                    entity = new DxfDomCircle();
                    break;

                case "ELLIPSE":
                    entity = new DxfDomEllipse();
                    break;

                case "LWPOLYLINE":
                    entity = new DxfDomLwPolyline();
                    break;

                case "POLYLINE":
                    entity = new DxfDomPolyline();
                    break;

                case "SPLINE":
                    entity = new DxfDomSpline();
                    break;
                }

                if (entity == null)
                {
                    continue;
                }

                if (entity.Read(reader))
                {
                    Entities.Add(entity);
                }
                else
                {
                    Messages.Error($"DxfReader: Incomplete entity description at line {reader.Line}.");
                }
            }
        }