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

DomCR / ACadSharp / 25844597337

14 May 2026 06:00AM UTC coverage: 76.79% (-0.04%) from 76.83%
25844597337

push

github

web-flow
Merge pull request #1069 from simonedd/master

Update Hatch.BoundaryPath.Spline.cs

8596 of 12131 branches covered (70.86%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

17 existing lines in 2 files now uncovered.

30817 of 39195 relevant lines covered (78.62%)

157446.78 hits per line

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

35.37
/src/ACadSharp/Entities/Hatch.BoundaryPath.Spline.cs
1
using ACadSharp.Attributes;
2
using CSMath;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6

7
namespace ACadSharp.Entities
8
{
9
        public partial class Hatch
10
        {
11
                public partial class BoundaryPath
12
                {
13
                        public class Spline : Edge
14
                        {
15
                                /// <remarks>
16
                                /// Position values are only X and Y, Z represents the weight.
17
                                /// </remarks>
18
                                [DxfCodeValue(96)]
19
                                //42        Weights(optional, default = 1)        ??
20
                                public List<XYZ> ControlPoints { get; private set; } = new List<XYZ>();
12✔
21

22
                                /// <summary>
23
                                /// Degree.
24
                                /// </summary>
25
                                [DxfCodeValue(94)]
26
                                public int Degree { get; set; }
2✔
27

28
                                /// <summary>
29
                                /// End tangent.
30
                                /// </summary>
31
                                [DxfCodeValue(13, 23)]
32
                                public XY EndTangent { get; set; }
1✔
33

34
                                /// <remarks>
35
                                /// Number of fit data.
36
                                /// </remarks>
37
                                [DxfCodeValue(97)]
38
                                public List<XY> FitPoints { get; private set; } = new List<XY>();
2✔
39

40
                                /// <summary>
41
                                /// Number of knots.
42
                                /// </summary>
43
                                [DxfCodeValue(95)]
44
                                public List<double> Knots { get; private set; } = new List<double>();
15✔
45

46
                                /// <summary>
47
                                /// Gets or sets a value indicating whether the spline is periodic.
48
                                /// </summary>
49
                                /// <remarks>A periodic spline forms a closed, continuous curve where the start and end points are joined
50
                                /// seamlessly. Setting this property to true creates a smooth, looping spline; setting it to false creates an open
51
                                /// spline.</remarks>
52
                                [DxfCodeValue(74)]
53
                                public bool IsPeriodic { get; set; }
2✔
54

55
                                /// <summary>
56
                                /// Gets or sets a value indicating whether the spline is rational.
57
                                /// </summary>
58
                                [DxfCodeValue(73)]
59
                                public bool IsRational { get; set; }
11✔
60

61
                                /// <summary>
62
                                /// Start tangent.
63
                                /// </summary>
64
                                [DxfCodeValue(12, 22)]
65
                                public XY StartTangent { get; set; }
1✔
66

67
                                /// <inheritdoc/>
68
                                public override EdgeType Type => EdgeType.Spline;
×
69

70
                                /// <summary>
71
                                /// Gets a collection of weights derived from the Z-coordinates of the control points.
72
                                /// </summary>
73
                                public IEnumerable<double> Weights { get { return this.ControlPoints.Select(c => c.Z); } }
×
74

75
                                /// <summary>
76
                                /// Initializes a new instance of the Spline class.
77
                                /// </summary>
78
                                public Spline()
1✔
79
                                { }
2✔
80

81
                                /// <summary>
82
                                /// Initializes a new instance of the Spline class using the specified spline entity.
83
                                /// </summary>
84
                                /// <param name="spline">The spline entity that provides the data for initializing this Spline instance. Cannot be null.</param>
85
                                public Spline(Entities.Spline spline)
×
86
                                {
×
87
                                        this.Degree = spline.Degree;
×
88
                                        this.IsRational = true;
×
89
                                        this.IsPeriodic = spline.IsClosed;
×
90
                                        if (!spline.ControlPoints.Any())
×
91
                                        {
×
92
                                                throw new ArgumentException("The HatchBoundaryPath spline edge requires a spline entity with control points.", nameof(spline));
×
93
                                        }
94

95
                                        Matrix3 trans = Matrix3.ArbitraryAxis(spline.Normal).Transpose();
×
96
                                        for (int i = 0; i < spline.ControlPoints.Count; i++)
×
97
                                        {
×
98
                                                XYZ point = trans * spline.ControlPoints[i];
×
NEW
99
                                                this.ControlPoints.Add(new XYZ(point.X, point.Y, spline.Weights[i]));
×
100
                                        }
×
101

102
                                        this.Knots.AddRange(spline.Knots);
×
103
                                }
×
104

105
                                /// <inheritdoc/>
106
                                public override void ApplyTransform(Transform transform)
107
                                {
×
108
                                        var arr = this.ControlPoints.ToArray();
×
109
                                        this.ControlPoints.Clear();
×
110
                                        for (int i = 0; i < arr.Length; i++)
×
111
                                        {
×
112
                                                var weight = arr[i].Z;
×
113
                                                var v = transform.ApplyTransform(arr[i]);
×
114
                                                v.Z = weight;
×
115

116
                                                this.ControlPoints.Add(v);
×
117
                                        }
×
118

119
                                        for (int i = 0; i < this.FitPoints.Count; i++)
×
120
                                        {
×
121
                                                this.FitPoints[i] = transform.ApplyTransform(this.FitPoints[i].Convert<XYZ>()).Convert<XY>();
×
122
                                        }
×
123
                                }
×
124

125
                                /// <inheritdoc/>
126
                                public override Edge Clone()
127
                                {
×
128
                                        Spline clone = (Spline)base.Clone();
×
129

130
                                        clone.ControlPoints = new List<XYZ>(this.ControlPoints);
×
131
                                        clone.FitPoints = new List<XY>(this.FitPoints);
×
132
                                        clone.Knots = new List<double>(this.Knots);
×
133

134
                                        return clone;
×
135
                                }
×
136

137
                                /// <inheritdoc/>
138
                                public override BoundingBox GetBoundingBox()
139
                                {
×
140
                                        return BoundingBox.FromPoints(this.ControlPoints);
×
141
                                }
×
142

143
                                /// <summary>
144
                                /// Converts the spline in a list of vertexes.
145
                                /// </summary>
146
                                /// <param name="precision">Number of vertexes generated.</param>
147
                                /// <returns>A list vertexes that represents the spline expressed in object coordinate system.</returns>
148
                                public List<XYZ> PolygonalVertexes(int precision)
149
                                {
1✔
150
                                        Entities.Spline spline = (Entities.Spline)this.ToEntity();
1✔
151
                                        return spline.PolygonalVertexes(precision);
1✔
152
                                }
1✔
153

154
                                /// <inheritdoc/>
155
                                public override Entity ToEntity()
156
                                {
1✔
157
                                        Entities.Spline spline = new();
1✔
158

159
                                        spline.Degree = this.Degree;
1✔
160
                                        spline.Flags = this.IsPeriodic ? spline.Flags |= (SplineFlags.Periodic) : spline.Flags;
1!
161
                                        spline.Flags = this.IsRational ? spline.Flags |= (SplineFlags.Rational) : spline.Flags;
1!
162

163
                                        spline.StartTangent = this.StartTangent.Convert<XYZ>();
1✔
164
                                        spline.EndTangent = this.EndTangent.Convert<XYZ>();
1✔
165

166
                                        spline.ControlPoints.AddRange(this.ControlPoints);
1✔
167
                                        spline.Weights.AddRange(this.ControlPoints.Select(x => x.Z));
10✔
168
                                        spline.FitPoints.AddRange(this.FitPoints.Select(x => x.Convert<XYZ>()));
1✔
169
                                        spline.Knots.AddRange(this.Knots);
1✔
170

171
                                        return spline;
1✔
172
                                }
1✔
173
                        }
174
                }
175
        }
176
}
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