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

DomCR / ACadSharp / 20972584561

13 Jan 2026 09:05PM UTC coverage: 76.954% (+0.06%) from 76.896%
20972584561

Pull #949

github

web-flow
Merge 944cf1dfb into 024480147
Pull Request #949: issue-948 dynamic properties

7968 of 11209 branches covered (71.09%)

Branch coverage included in aggregate %.

137 of 148 new or added lines in 10 files covered. (92.57%)

15 existing lines in 4 files now uncovered.

28972 of 36794 relevant lines covered (78.74%)

148849.84 hits per line

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

86.67
/src/ACadSharp/Entities/DimensionAngular2Line.cs
1
using ACadSharp.Attributes;
2
using CSMath;
3
using CSMath.Geometry;
4

5
namespace ACadSharp.Entities
6
{
7
        /// <summary>
8
        /// Represents a <see cref="DimensionAngular2Line"/> entity.
9
        /// </summary>
10
        /// <remarks>
11
        /// Object name <see cref="DxfFileToken.EntityDimension"/> <br/>
12
        /// Dxf class name <see cref="DxfSubclassMarker.Angular2LineDimension"/>
13
        /// </remarks>
14
        [DxfName(DxfFileToken.EntityDimension)]
15
        [DxfSubClass(DxfSubclassMarker.Angular2LineDimension)]
16
        public class DimensionAngular2Line : Dimension
17
        {
18
                /// <summary>
19
                /// Definition point for diameter, radius, and angular dimensions (in WCS).
20
                /// </summary>
21
                [DxfCodeValue(15, 25, 35)]
22
                public XYZ AngleVertex { get; set; }
1,552✔
23

24
                /// <summary>
25
                /// Gets the center point of the measured arc.
26
                /// </summary>
27
                public XYZ Center
28
                {
29
                        get
30
                        {
55✔
31
                                Line3D l1 = LineExtensions.CreateFromPoints<Line3D, XYZ>(this.DefinitionPoint, this.AngleVertex);
55✔
32
                                Line3D l2 = LineExtensions.CreateFromPoints<Line3D, XYZ>(this.FirstPoint, this.SecondPoint);
55✔
33

34
                                return l1.FindIntersection(l2);
55✔
35
                        }
55✔
36
                }
37

38
                /// <summary>
39
                /// Point defining dimension arc for angular dimensions (in OCS).
40
                /// </summary>
41
                [DxfCodeValue(16, 26, 36)]
42
                public XYZ DimensionArc { get; set; }
1,475✔
43

44
                /// <summary>
45
                /// Definition point for linear and angular dimensions (in WCS).
46
                /// </summary>
47
                [DxfCodeValue(13, 23, 33)]
48
                public XYZ FirstPoint { get; set; }
1,565✔
49

50
                /// <inheritdoc/>
51
                public override double Measurement
52
                {
53
                        get
54
                        {
54✔
55
                                var v1 = this.SecondPoint - this.FirstPoint;
54✔
56
                                var v2 = this.DefinitionPoint - this.AngleVertex;
54✔
57
                                var angle = v1.AngleBetweenVectors(v2);
54✔
58

59
                                var vArc = this.DimensionArc - this.Center;
54✔
60
                                if (vArc.IsZero())
54✔
61
                                        return angle;
14✔
62

63
                                var cross1 = XYZ.Cross(v1, vArc);
40✔
64
                                var cross2 = XYZ.Cross(vArc, v2);
40✔
65

66
                                // Check if both cross products point in the same direction as the normal
67
                                // This means vArc is in the sector between v1 and v2 (going counterclockwise)
68
                                var dot1 = cross1.Dot(this.Normal);
40✔
69
                                var dot2 = cross2.Dot(this.Normal);
40✔
70

71
                                var isInOppositeSector = (dot1 < 0 && dot2 > 0) || (dot1 > 0 && dot2 < 0);
40✔
72
                                if (isInOppositeSector)
40✔
73
                                        angle = MathHelper.PI - angle;
2✔
74

75
                                return angle;
40✔
76
                        }
54✔
77
                }
78

79
                /// <inheritdoc/>
80
                public override string ObjectName => DxfFileToken.EntityDimension;
1,394✔
81

82
                /// <inheritdoc/>
83
                public override ObjectType ObjectType => ObjectType.DIMENSION_ANG_2_Ln;
27✔
84

85
                /// <summary>
86
                /// Definition point offset relative to the <see cref="Center"/>.
87
                /// </summary>
88
                public virtual double Offset
89
                {
UNCOV
90
                        get { return this.SecondPoint.DistanceFrom(this.DefinitionPoint); }
×
91
                        set
92
                        {
12✔
93
                                XYZ dir = this.SecondPoint - this.FirstPoint;
12✔
94
                                XYZ v = XYZ.Cross(this.Normal, dir).Normalize(); //Perpendicular to SecondPoint
12✔
95

96
                                this.DefinitionPoint = this.SecondPoint + v * value;
12✔
97
                        }
12✔
98
                }
99

100
                /// <summary>
101
                /// Definition point for linear and angular dimensions (in WCS).
102
                /// </summary>
103
                [DxfCodeValue(14, 24, 34)]
104
                public XYZ SecondPoint { get; set; }
1,581✔
105

106
                /// <inheritdoc/>
107
                public override string SubclassMarker => DxfSubclassMarker.Angular2LineDimension;
2,450✔
108

109
                /// <summary>
110
                /// Default constructor.
111
                /// </summary>
112
                public DimensionAngular2Line() : base(DimensionType.Angular)
392✔
113
                {
392✔
114
                }
392✔
115

116
                /// <inheritdoc/>
117
                public override void ApplyTransform(Transform transform)
UNCOV
118
                {
×
UNCOV
119
                        base.ApplyTransform(transform);
×
120

UNCOV
121
                        this.FirstPoint = transform.ApplyTransform(this.FirstPoint);
×
UNCOV
122
                        this.SecondPoint = transform.ApplyTransform(this.SecondPoint);
×
UNCOV
123
                        this.AngleVertex = transform.ApplyTransform(this.AngleVertex);
×
UNCOV
124
                        this.DimensionArc = transform.ApplyTransform(this.DimensionArc);
×
UNCOV
125
                }
×
126

127
                /// <inheritdoc/>
128
                public override BoundingBox GetBoundingBox()
129
                {
1✔
130
                        return new BoundingBox(this.FirstPoint, this.SecondPoint);
1✔
131
                }
1✔
132

133
                /// <inheritdoc/>
134
                /// <remarks>
135
                /// For <see cref="DimensionAngular2Line"/> the generation of the block is not yet implemented.
136
                /// </remarks>
137
                public override void UpdateBlock()
138
                {
10✔
139
                        //Needs a lot more investigation
140
                        return;
10✔
141

142
                        base.UpdateBlock();
143

144
                        var v1 = this.SecondPoint - this.FirstPoint;
145
                        var v2 = this.DefinitionPoint - this.AngleVertex;
146

147
                        this._block.Entities.Add(createDefinitionPoint(FirstPoint));
148
                        this._block.Entities.Add(createDefinitionPoint(SecondPoint));
149
                        this._block.Entities.Add(createDefinitionPoint(AngleVertex));
150
                        this._block.Entities.Add(createDefinitionPoint(DefinitionPoint));
151

152
                        if (this.Center.IsNaN())
153
                        {
154
                                return;
155
                        }
156

157
                        var startAngle = XYZ.AxisX.AngleBetweenVectors(this.AngleVertex);
158
                        var endAngle = XYZ.AxisX.AngleBetweenVectors(this.FirstPoint);
159

160
                        this._block.Entities.Add(new Arc(this.Center, this.Offset, startAngle, endAngle));
161
                }
10✔
162
        }
163
}
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