• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 25551510006

08 May 2026 10:49AM UTC coverage: 76.846% (+0.03%) from 76.814%
25551510006

push

github

web-flow
Merge pull request #1063 from DomCR/issue/1052_lwpolyline-clone-fix

issue-1052 LwPolyline Clone()

8581 of 12105 branches covered (70.89%)

Branch coverage included in aggregate %.

43 of 64 new or added lines in 2 files covered. (67.19%)

3 existing lines in 2 files now uncovered.

30792 of 39131 relevant lines covered (78.69%)

152773.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.08
/src/ACadSharp/Entities/LwPolyLine.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Extensions;
3
using CSMath;
4
using CSUtilities.Extensions;
5
using System.Collections.Generic;
6
using System.Linq;
7

8
namespace ACadSharp.Entities;
9

10
/// <summary>
11
/// Represents a <see cref="LwPolyline"/> entity
12
/// </summary>
13
/// <remarks>
14
/// Object name <see cref="DxfFileToken.EntityLwPolyline"/> <br/>
15
/// Dxf class name <see cref="DxfSubclassMarker.LwPolyline"/>
16
/// </remarks>
17
[DxfName(DxfFileToken.EntityLwPolyline)]
18
[DxfSubClass(DxfSubclassMarker.LwPolyline)]
19
public partial class LwPolyline : Entity, IPolyline
20
{
21
        /// <summary>
22
        /// Constant width
23
        /// </summary>
24
        /// <remarks>
25
        /// Not used if variable width (codes 40 and/or 41) is set
26
        /// </remarks>
27
        [DxfCodeValue(43)]
28
        public double ConstantWidth { get; set; } = 0.0;
12,433✔
29

30
        /// <summary>
31
        /// The current elevation of the object.
32
        /// </summary>
33
        [DxfCodeValue(38)]
34
        public double Elevation { get; set; } = 0.0;
8,481✔
35

36
        /// <summary>
37
        /// Polyline flags.
38
        /// </summary>
39
        [DxfCodeValue(70)]
40
        public LwPolylineFlags Flags { get => this._flags; set => this._flags = value; }
10,621✔
41

42
        /// <inheritdoc/>
43
        public bool IsClosed
44
        {
45
                get
46
                {
47✔
47
                        return this.Flags.HasFlag(LwPolylineFlags.Closed);
47✔
48
                }
47✔
49
                set
50
                {
21✔
51
                        if (value)
21✔
52
                        {
11✔
53
                                _flags.AddFlag(LwPolylineFlags.Closed);
11✔
54
                        }
11✔
55
                        else
56
                        {
10✔
57
                                _flags.RemoveFlag(LwPolylineFlags.Closed);
10✔
58
                        }
10✔
59
                }
21✔
60
        }
61

62
        /// <summary>
63
        /// Specifies the three-dimensional normal unit vector for the object.
64
        /// </summary>
65
        [DxfCodeValue(210, 220, 230)]
66
        public XYZ Normal { get; set; } = XYZ.AxisZ;
8,490✔
67

68
        /// <inheritdoc/>
69
        public override string ObjectName => DxfFileToken.EntityLwPolyline;
21,141✔
70

71
        /// <inheritdoc/>
72
        public override ObjectType ObjectType => ObjectType.LWPOLYLINE;
11✔
73

74
        /// <inheritdoc/>
75
        public override string SubclassMarker => DxfSubclassMarker.LwPolyline;
34,271✔
76

77
        /// <summary>
78
        /// Specifies the distance a 2D object is extruded above or below its elevation.
79
        /// </summary>
80
        [DxfCodeValue(39)]
81
        public double Thickness { get; set; } = 0.0;
8,490✔
82

83
        /// <summary>
84
        /// Vertices that form this LwPolyline
85
        /// </summary>
86
        [DxfCodeValue(DxfReferenceType.Count, 90)]
87
        public List<Vertex> Vertices { get; private set; } = new List<Vertex>();
137,525✔
88

89
        /// <inheritdoc/>
90
        IEnumerable<IVertex> IPolyline.Vertices { get { return this.Vertices; } }
3,231✔
91

92
        private LwPolylineFlags _flags;
93

94
        /// <inheritdoc/>
95
        public LwPolyline() : base() { }
23,964✔
96

97
        /// <summary>
98
        /// Initializes a new instance of the <see cref="LwPolyline"/> class with the specified vertices.
99
        /// </summary>
100
        /// <remarks>The provided <paramref name="vertices"/> are added to the polyline in the order they appear in
101
        /// the collection.</remarks>
102
        /// <param name="vertices">A collection of <see cref="Vertex"/> objects that define the vertices of the polyline.</param>
NEW
103
        public LwPolyline(params IEnumerable<Vertex> vertices)
×
NEW
104
        {
×
NEW
105
                this.Vertices.AddRange(vertices);
×
NEW
106
        }
×
107

108
        /// <summary>
109
        /// Initializes a new instance of the <see cref="LwPolyline"/> class with the specified vertices.
110
        /// </summary>
111
        /// <remarks>This constructor allows you to create a lightweight polyline by specifying its vertices as a
112
        /// collection of <see cref="XY"/> points. The vertices are internally converted to <see cref="Vertex"/>
113
        /// objects.</remarks>
114
        /// <param name="vertices">A collection of <see cref="XY"/> points representing the vertices of the polyline. Each point defines a vertex in
115
        /// the order it appears in the collection.</param>
116
        public LwPolyline(params IEnumerable<XY> vertices)
NEW
117
                : this(vertices.Select(v => new Vertex(v))) { }
×
118

119
        /// <inheritdoc/>
120
        public override void ApplyTransform(Transform transform)
NEW
121
        {
×
NEW
122
                var newNormal = this.transformNormal(transform, this.Normal);
×
123

NEW
124
                this.getWorldMatrix(transform, this.Normal, newNormal, out Matrix3 transOW, out Matrix3 transWO);
×
125

NEW
126
                foreach (var vertex in this.Vertices)
×
UNCOV
127
                {
×
NEW
128
                        XYZ v = transOW * vertex.Location.Convert<XYZ>();
×
NEW
129
                        v = transform.ApplyTransform(v);
×
NEW
130
                        v = transWO * v;
×
NEW
131
                        vertex.Location = v.Convert<XY>();
×
NEW
132
                }
×
133

NEW
134
                this.Normal = newNormal;
×
NEW
135
        }
×
136

137
        /// <inheritdoc/>
138
        public override CadObject Clone()
139
        {
83✔
140
                LwPolyline clone = (LwPolyline)base.Clone();
83✔
141

142
                clone.Vertices = new List<Vertex>();
83✔
143
                foreach (var v in this.Vertices)
969✔
144
                {
360✔
145
                        clone.Vertices.Add(v.Clone());
360✔
146
                }
360✔
147
                return clone;
83✔
148
        }
83✔
149

150
        /// <inheritdoc/>
151
        public override BoundingBox GetBoundingBox()
152
        {
8✔
153
                if (this.Vertices.Any(v => v.Bulge != 0))
40!
UNCOV
154
                {
×
NEW
155
                        return BoundingBox.FromPoints(this.GetPoints<XYZ>(byte.MaxValue));
×
156
                }
157

158
                return BoundingBox.FromPoints(this.Vertices.Select(v => v.Location.Convert<XYZ>()));
40✔
159
        }
8✔
160
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc