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

DomCR / ACadSharp / 18551198169

16 Oct 2025 05:23AM UTC coverage: 78.107% (-0.2%) from 78.347%
18551198169

push

github

web-flow
Merge pull request #824 from DomCR/issue-821_spline-polygonalvertexes-fix

issue 821

6872 of 9557 branches covered (71.91%)

Branch coverage included in aggregate %.

111 of 217 new or added lines in 4 files covered. (51.15%)

26 existing lines in 2 files now uncovered.

26467 of 33127 relevant lines covered (79.9%)

108185.57 hits per line

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

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

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

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

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

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

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

67
                /// <inheritdoc/>
68
                public override string ObjectName => DxfFileToken.EntityLwPolyline;
22,603✔
69

70
                /// <inheritdoc/>
71
                public override ObjectType ObjectType => ObjectType.LWPOLYLINE;
9✔
72

73
                /// <inheritdoc/>
74
                public override string SubclassMarker => DxfSubclassMarker.LwPolyline;
36,518✔
75

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

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

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

91
                private LwPolylineFlags _flags;
92

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

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

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

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

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

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

133
                        this.Normal = newNormal;
×
134
                }
×
135

136
                /// <inheritdoc/>
137
                public override BoundingBox GetBoundingBox()
138
                {
9✔
139
                        if (this.Vertices.Count < 2)
9✔
140
                        {
1✔
141
                                return BoundingBox.Null;
1✔
142
                        }
143

144
                        XYZ first = (XYZ)this.Vertices[0].Location;
8✔
145
                        XYZ second = (XYZ)this.Vertices[1].Location;
8✔
146

147
                        XYZ min = new XYZ(System.Math.Min(first.X, second.X), System.Math.Min(first.Y, second.Y), System.Math.Min(first.Z, second.Z));
8✔
148
                        XYZ max = new XYZ(System.Math.Max(first.X, second.X), System.Math.Max(first.Y, second.Y), System.Math.Max(first.Z, second.Z));
8✔
149

150
                        for (int i = 2; i < this.Vertices.Count; i++)
48✔
151
                        {
16✔
152
                                XYZ curr = (XYZ)this.Vertices[i].Location;
16✔
153

154
                                min = new XYZ(System.Math.Min(min.X, curr.X), System.Math.Min(min.Y, curr.Y), System.Math.Min(min.Z, curr.Z));
16✔
155
                                max = new XYZ(System.Math.Max(max.X, curr.X), System.Math.Max(max.Y, curr.Y), System.Math.Max(max.Z, curr.Z));
16✔
156
                        }
16✔
157

158
                        return new BoundingBox(min, max);
8✔
159
                }
9✔
160
        }
161
}
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