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

DomCR / ACadSharp / 20591400745

30 Dec 2025 07:28AM UTC coverage: 77.183% (+0.2%) from 77.021%
20591400745

Pull #878

github

web-flow
Merge b4f21cb3d into 9e3f92ac2
Pull Request #878: svg spline

7727 of 10857 branches covered (71.17%)

Branch coverage included in aggregate %.

31 of 47 new or added lines in 4 files covered. (65.96%)

6 existing lines in 1 file now uncovered.

28451 of 36016 relevant lines covered (79.0%)

159262.3 hits per line

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

47.06
/src/ACadSharp/Entities/Hatch.BoundaryPath.Spline.cs
1
using ACadSharp.Attributes;
2
using CSMath;
3
using System.Collections.Generic;
4
using System.Drawing;
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>();
26✔
21

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

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

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

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

46
                                /// <summary>
47
                                /// Periodic.
48
                                /// </summary>
49
                                [DxfCodeValue(74)]
50
                                public bool Periodic { get; set; }
4✔
51

52
                                /// <summary>
53
                                /// Rational.
54
                                /// </summary>
55
                                [DxfCodeValue(73)]
56
                                public bool Rational { get; set; }
22✔
57

58
                                /// <summary>
59
                                /// Start tangent.
60
                                /// </summary>
61
                                [DxfCodeValue(12, 22)]
62
                                public XY StartTangent { get; set; }
2✔
63

64
                                /// <inheritdoc/>
65
                                public override EdgeType Type => EdgeType.Spline;
×
66

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

72
                                /// <inheritdoc/>
73
                                public override void ApplyTransform(Transform transform)
74
                                {
×
75
                                        var arr = this.ControlPoints.ToArray();
×
76
                                        this.ControlPoints.Clear();
×
77
                                        for (int i = 0; i < arr.Length; i++)
×
78
                                        {
×
79
                                                var weight = arr[i].Z;
×
80
                                                var v = transform.ApplyTransform(arr[i]);
×
81
                                                v.Z = weight;
×
82

83
                                                this.ControlPoints.Add(v);
×
84
                                        }
×
85

86
                                        for (int i = 0; i < this.FitPoints.Count; i++)
×
87
                                        {
×
88
                                                this.FitPoints[i] = transform.ApplyTransform(this.FitPoints[i].Convert<XYZ>()).Convert<XY>();
×
89
                                        }
×
90
                                }
×
91

92
                                /// <inheritdoc/>
93
                                public override Edge Clone()
94
                                {
×
95
                                        Spline clone = (Spline)base.Clone();
×
96

97
                                        clone.ControlPoints = new List<XYZ>(this.ControlPoints);
×
98
                                        clone.FitPoints = new List<XY>(this.FitPoints);
×
99
                                        clone.Knots = new List<double>(this.Knots);
×
100

101
                                        return clone;
×
102
                                }
×
103

104
                                /// <inheritdoc/>
105
                                public override BoundingBox GetBoundingBox()
106
                                {
×
107
                                        return BoundingBox.FromPoints(this.ControlPoints);
×
108
                                }
×
109

110
                                /// <summary>
111
                                /// Converts the spline in a list of vertexes.
112
                                /// </summary>
113
                                /// <param name="precision">Number of vertexes generated.</param>
114
                                /// <returns>A list vertexes that represents the spline expressed in object coordinate system.</returns>
115
                                public List<XYZ> PolygonalVertexes(int precision)
116
                                {
2✔
117
                                        Entities.Spline spline = (Entities.Spline)this.ToEntity();
2✔
118
                                        return spline.PolygonalVertexes(precision);
2✔
119
                                }
2✔
120

121
                                /// <inheritdoc/>
122
                                public override Entity ToEntity()
123
                                {
2✔
124
                                        Entities.Spline spline = new();
2✔
125

126
                                        spline.Degree = this.Degree;
2✔
127
                                        spline.Flags = this.Periodic ? spline.Flags |= (SplineFlags.Periodic) : spline.Flags;
2!
128
                                        spline.Flags = this.Rational ? spline.Flags |= (SplineFlags.Rational) : spline.Flags;
2!
129

130
                                        spline.StartTangent = this.StartTangent.Convert<XYZ>();
2✔
131
                                        spline.EndTangent = this.EndTangent.Convert<XYZ>();
2✔
132

133
                                        spline.ControlPoints.AddRange(this.ControlPoints);
2✔
134

135
                                        if (this.Weights.Any(w => w == 0))
4!
136
                                        {
2✔
137
                                                spline.Weights.AddRange(Enumerable.Repeat(1.0d, this.ControlPoints.Count));
2✔
138
                                        }
2✔
139
                                        else
NEW
140
                                        {
×
NEW
141
                                                spline.Weights.AddRange(this.Weights);
×
NEW
142
                                        }
×
143

144
                                        spline.FitPoints.AddRange(this.FitPoints.Select(x => x.Convert<XYZ>()));
2✔
145
                                        spline.Knots.AddRange(this.Knots);
2✔
146

147
                                        return spline;
2✔
148
                                }
2✔
149
                        }
150
                }
151
        }
152
}
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