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

DomCR / ACadSharp / 14680051233

26 Apr 2025 09:45AM UTC coverage: 75.224% (+0.02%) from 75.202%
14680051233

push

github

web-flow
Merge pull request #634 from DomCR/issue-631_PolygonalVertexes-fix

Issue 631 polygonal vertexes fix

5661 of 8257 branches covered (68.56%)

Branch coverage included in aggregate %.

77 of 104 new or added lines in 5 files covered. (74.04%)

17 existing lines in 4 files now uncovered.

22548 of 29243 relevant lines covered (77.11%)

83187.1 hits per line

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

41.58
/src/ACadSharp/Entities/UnderlayEntity.cs
1
using ACadSharp.Attributes;
2
using ACadSharp.Objects;
3
using CSMath;
4
using System;
5
using System.Collections.Generic;
6

7
namespace ACadSharp.Entities
8
{
9
        /// <summary>
10
        /// Common base class for all underlay entities, like <see cref="PdfUnderlay" />.
11
        /// </summary>
12
        [DxfSubClass(null, true)]
13
        public abstract class UnderlayEntity : Entity
14
        {
15
                /// <summary>
16
                /// Contrast
17
                /// </summary>
18
                /// <remarks>
19
                /// 0-100; default = 50
20
                /// </remarks>
21
                [DxfCodeValue(281)]
22
                public byte Contrast
23
                {
24
                        get { return this._contrast; }
×
25
                        set
26
                        {
5✔
27
                                if (value < 0 || value > 100)
5!
28
                                {
4✔
29
                                        throw new ArgumentException($"Invalid Brightness value: {value}, must be in range 0-100");
4✔
30
                                }
31

32
                                this._contrast = value;
1✔
33
                        }
1✔
34
                }
35

36
                [DxfCodeValue(DxfReferenceType.Handle, 340)]
37
                public UnderlayDefinition Definition { get; set; }
×
38

39
                /// <summary>
40
                /// Fade
41
                /// </summary>
42
                /// <value>
43
                /// Range: 0 - 100 <br/>
44
                /// Default: 0
45
                /// </value>
46
                [DxfCodeValue(282)]
47
                public byte Fade
48
                {
49
                        get { return this._fade; }
×
50
                        set
51
                        {
5✔
52
                                if (value < 0 || value > 100)
5!
53
                                {
5✔
54
                                        throw new ArgumentException($"Invalid Brightness value: {value}, must be in range 0-100");
5✔
55
                                }
56

UNCOV
57
                                this._fade = value;
×
UNCOV
58
                        }
×
59
                }
60

61
                /// <summary>
62
                /// Underlay display options.
63
                /// </summary>
64
                [DxfCodeValue(280)]
65
                public UnderlayDisplayFlags Flags { get; set; }
×
66

67
                /// <summary>
68
                /// Insertion point(in WCS)
69
                /// </summary>
70
                [DxfCodeValue(10, 20, 30)]
71
                public XYZ InsertPoint { get; set; }
5✔
72

73
                /// <summary>
74
                /// Specifies the three-dimensional normal unit vector for the object.
75
                /// </summary>
76
                [DxfCodeValue(210, 220, 230)]
77
                public XYZ Normal { get; set; } = XYZ.AxisZ;
11✔
78

79
                /// <summary>
80
                /// Specifies the rotation angle for the object.
81
                /// </summary>
82
                /// <value>
83
                /// The rotation angle in radians.
84
                /// </value>
85
                [DxfCodeValue(DxfReferenceType.IsAngle, 50)]
86
                public double Rotation { get; set; } = 0.0;
11✔
87

88
                /// <inheritdoc/>
89
                public override string SubclassMarker => DxfSubclassMarker.Underlay;
2✔
90

91
                /// <summary>
92
                /// X scale factor.
93
                /// </summary>
94
                [DxfCodeValue(41)]
95
                public double XScale
96
                {
97
                        get
98
                        {
×
99
                                return this._xscale;
×
100
                        }
×
101
                        set
102
                        {
5✔
103
                                if (value.Equals(0))
5!
104
                                {
×
105
                                        string name = nameof(this.XScale);
×
106
                                        throw new ArgumentOutOfRangeException(name, value, $"{name} value must be none zero.");
×
107
                                }
108
                                this._xscale = value;
5✔
109
                        }
5✔
110
                }
111

112
                /// <summary>
113
                /// Y scale factor.
114
                /// </summary>
115
                [DxfCodeValue(42)]
116
                public double YScale
117
                {
118
                        get
119
                        {
×
120
                                return this._yscale;
×
121
                        }
×
122
                        set
123
                        {
5✔
124
                                if (value.Equals(0))
5!
125
                                {
×
126
                                        string name = nameof(this.YScale);
×
127
                                        throw new ArgumentOutOfRangeException(name, value, $"{name} value must be none zero.");
×
128
                                }
129
                                this._yscale = value;
5✔
130
                        }
5✔
131
                }
132

133
                /// <summary>
134
                /// Z scale factor.
135
                /// </summary>
136
                [DxfCodeValue(43)]
137
                public double ZScale
138
                {
139
                        get
140
                        {
×
141
                                return this._zscale;
×
142
                        }
×
143
                        set
144
                        {
5✔
145
                                if (value.Equals(0))
5!
146
                                {
×
147
                                        string name = nameof(this.ZScale);
×
148
                                        throw new ArgumentOutOfRangeException(name, value, $"{name} value must be none zero.");
×
149
                                }
150
                                this._zscale = value;
5✔
151
                        }
5✔
152
                }
153

154
                private byte _contrast = 50;
6✔
155

156
                private byte _fade = 0;
6✔
157

158
                private double _xscale = 1;
6✔
159

160
                private double _yscale = 1;
6✔
161

162
                private double _zscale = 1;
6✔
163

164
                /// <inheritdoc/>
165
                public override void ApplyTransform(Transform transform)
166
                {
×
167
                        XYZ newPosition = transform.ApplyTransform(this.InsertPoint);
×
168
                        XYZ newNormal = this.transformNormal(transform, Normal);
×
169

170
                        var transformation = getWorldMatrix(transform, newNormal, this.Normal, out Matrix3 transOW, out Matrix3 transWO);
×
171

172
                        List<XY> uv = applyRotation(
×
173
                                new[]
×
174
                                {
×
175
                                        XY.AxisX, XY.AxisY
×
176
                                },
×
177
                                this.Rotation);
×
178

179
                        XYZ v;
180
                        v = transOW * new XYZ(uv[0].X, uv[0].Y, 0.0);
×
181
                        v = transformation * v;
×
182
                        v = transWO * v;
×
183
                        XY newUvector = new XY(v.X, v.Y);
×
184

185
                        v = transOW * new XYZ(uv[1].X, uv[1].Y, 0.0);
×
186
                        v = transformation * v;
×
187
                        v = transWO * v;
×
188
                        XY newVvector = new XY(v.X, v.Y);
×
189

190
                        int sign = Math.Sign(transformation.m00 * transformation.m11 * transformation.m22) < 0 ? -1 : 1;
×
191

192
                        double newRotation = (sign * newUvector).GetAngle();
×
193

194
                        this.InsertPoint = newPosition;
×
195
                        this.Normal = newNormal;
×
196
                        this.Rotation = newRotation;
×
197
                        this.XScale = transform.Scale.X * this.XScale;
×
198
                        this.YScale = transform.Scale.Y * this.YScale;
×
199
                        this.ZScale = transform.Scale.Z * this.ZScale;
×
200
                }
×
201

202
                /// <inheritdoc/>
203
                public override BoundingBox GetBoundingBox()
204
                {
1✔
205
                        return BoundingBox.Null;
1✔
206
                }
1✔
207
        }
208
}
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