コード例 #1
0
        //--------------------------------------------------------------------------------------------------

        void _ImportArc(DxfDomCircle dxfCircle)
        {
            Pnt2d  center = dxfCircle.CenterPoint;
            double radius = dxfCircle.Radius;

            if (radius <= 0)
            {
                return;
            }

            var startParam = dxfCircle.StartAngle.ToRad();
            var endParam   = dxfCircle.EndAngle.ToRad();

            if (endParam < startParam)
            {
                endParam += 2 * Math.PI;
            }

            var geomCircle = new Geom2d_Circle(new Ax2d(center, Dir2d.DX), radius);

            var startIndex = _AddPoint(geomCircle.Value(startParam));
            var endIndex   = _AddPoint(geomCircle.Value(endParam));
            var rimIndex   = _AddPoint(geomCircle.Value(startParam.Lerp(endParam, 0.5)), false);

            if (startIndex != endIndex)
            {
                _Segments.Add(new SketchSegmentArc(startIndex, endIndex, rimIndex));
            }
        }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------

        void _AddCircleSegment(SketchSegmentCircle circleSegment)
        {
            var p1     = _Sketch.Points[circleSegment.CenterPoint];
            var radius = circleSegment.Radius(_Sketch.Points);

            var entity = new DxfDomCircle("0", p1, radius);

            _Document.Entities.Add(entity);
        }
コード例 #3
0
        //--------------------------------------------------------------------------------------------------

        void _ImportCircle(DxfDomCircle dxfCircle)
        {
            var centerIndex = _AddPoint(dxfCircle.CenterPoint, false);

            double radius = dxfCircle.Radius;

            if (radius <= 0)
            {
                return;
            }
            var rimIndex = _AddPoint(dxfCircle.CenterPoint.Translated(new Vec2d(radius, 0)), false);

            if (centerIndex != rimIndex)
            {
                _Segments.Add(new SketchSegmentCircle(centerIndex, rimIndex));
            }
        }
コード例 #4
0
        //--------------------------------------------------------------------------------------------------

        void _AddArcSegment(SketchSegmentArc arcSegment)
        {
            var circle = arcSegment.GetCircle(_Sketch.Points);

            Pnt2d startPoint;
            Pnt2d endPoint;

            if (circle.Position().Sense() < 0)
            {
                startPoint = _Sketch.Points[arcSegment.StartPoint];
                endPoint   = _Sketch.Points[arcSegment.EndPoint];
            }
            else
            {
                startPoint = _Sketch.Points[arcSegment.EndPoint];
                endPoint   = _Sketch.Points[arcSegment.StartPoint];
            }

            var entity = new DxfDomCircle("0", circle.Location(), circle.Radius(), startPoint, endPoint);

            _Document.Entities.Add(entity);
        }
コード例 #5
0
        //--------------------------------------------------------------------------------------------------

        void _AddCircle(Geom2d_Circle circle, double first, double last)
        {
            if (Math.Abs(last - first) < circle.Period())
            {
                // Circle arc
                if (circle.Position().Sense() > 0)
                {
                    var temp = first;
                    first = last;
                    last  = temp;
                }

                var entity = new DxfDomCircle(_CurrentLayer, circle.Location(), circle.Radius(), circle.Value(first), circle.Value(last));
                _Document.Entities.Add(entity);
            }
            else
            {
                // Full circle
                var entity = new DxfDomCircle(_CurrentLayer, circle.Location(), circle.Radius());
                _Document.Entities.Add(entity);
            }
        }
コード例 #6
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}.");
                }
            }
        }