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

DomCR / ACadSharp / 19388797072

15 Nov 2025 10:54AM UTC coverage: 78.193% (-0.02%) from 78.209%
19388797072

push

github

web-flow
Merge pull request #875 from DomCR/issue-873_arcs-and-circles-with-radius-0-dxf

Issue 873 arcs and circles with radius 0 dxf

7405 of 10257 branches covered (72.19%)

Branch coverage included in aggregate %.

13 of 16 new or added lines in 1 file covered. (81.25%)

6 existing lines in 1 file now uncovered.

27642 of 34564 relevant lines covered (79.97%)

98573.92 hits per line

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

82.3
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs
1
using ACadSharp.Entities;
2
using ACadSharp.IO.Templates;
3
using ACadSharp.Objects;
4
using ACadSharp.Tables;
5
using ACadSharp.XData;
6
using CSMath;
7
using CSUtilities.Converters;
8
using System;
9
using System.Collections.Generic;
10
using System.Diagnostics;
11
using System.Linq;
12
using static ACadSharp.IO.Templates.CadMLeaderAnnotContextTemplate;
13

14
namespace ACadSharp.IO.DXF
15
{
16
        internal abstract class DxfSectionReaderBase
17
        {
18
                public delegate bool ReadEntityDelegate<T>(CadEntityTemplate template, DxfMap map, string subclass = null) where T : Entity;
19

20
                protected readonly IDxfStreamReader _reader;
21
                protected readonly DxfDocumentBuilder _builder;
22

23
                //Avoid to move the reader to the next line
24
                protected bool lockPointer = false;
1,110✔
25

26
                public DxfSectionReaderBase(IDxfStreamReader reader, DxfDocumentBuilder builder)
1,110✔
27
                {
1,110✔
28
                        this._reader = reader;
1,110✔
29
                        this._builder = builder;
1,110✔
30
                }
1,110✔
31

32
                public abstract void Read();
33

34
                protected void readCommonObjectData(out string name, out ulong handle, out ulong? ownerHandle, out ulong? xdictHandle, out HashSet<ulong> reactors)
35
                {
2,606✔
36
                        name = null;
2,606✔
37
                        handle = 0;
2,606✔
38
                        ownerHandle = null;
2,606✔
39
                        xdictHandle = null;
2,606✔
40
                        reactors = new HashSet<ulong>();
2,606✔
41

42
                        if (this._reader.DxfCode == DxfCode.Start
2,606!
43
                                        || this._reader.DxfCode == DxfCode.Subclass)
2,606✔
44
                                this._reader.ReadNext();
×
45

46
                        //Loop until the common data end
47
                        while (this._reader.DxfCode != DxfCode.Start
10,346✔
48
                                        && this._reader.DxfCode != DxfCode.Subclass)
10,346✔
49
                        {
7,740✔
50
                                switch (this._reader.Code)
7,740!
51
                                {
52
                                        //Table name
53
                                        case 2:
54
                                                name = this._reader.ValueAsString;
2,606✔
55
                                                break;
2,606✔
56
                                        //Handle
57
                                        case 5:
58
                                        case 105:
59
                                                handle = this._reader.ValueAsHandle;
2,286✔
60
                                                break;
2,286✔
61
                                        //Start of application - defined group
62
                                        case 102:
63
                                                this.readDefinedGroups(out xdictHandle, out reactors);
242✔
64
                                                break;
242✔
65
                                        //Soft - pointer ID / handle to owner BLOCK_RECORD object
66
                                        case 330:
67
                                                ownerHandle = this._reader.ValueAsHandle;
2,286✔
68
                                                break;
2,286✔
69
                                        case 71:
70
                                        //Number of entries for dimension style table
71
                                        case 340:
72
                                        //Dimension table has the handles of the styles at the begining
73
                                        default:
74
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} at line {this._reader.Position}.");
320✔
75
                                                break;
320✔
76
                                }
77

78
                                this._reader.ReadNext();
7,740✔
79
                        }
7,740✔
80
                }
2,606✔
81

82
                [Obsolete("Only needed for SortEntitiesTable but it should be removed")]
83
                protected void readCommonObjectData(CadTemplate template)
84
                {
684✔
85
                        while (this._reader.DxfCode != DxfCode.Subclass)
2,736✔
86
                        {
2,052✔
87
                                switch (this._reader.Code)
2,052!
88
                                {
89
                                        //object name
90
                                        case 0:
91
                                                Debug.Assert(template.CadObject.ObjectName == this._reader.ValueAsString);
×
92
                                                break;
×
93
                                        //Handle
94
                                        case 5:
95
                                                template.CadObject.Handle = this._reader.ValueAsHandle;
684✔
96
                                                break;
684✔
97
                                        //Start of application - defined group
98
                                        case 102:
99
                                                this.readDefinedGroups(template);
684✔
100
                                                break;
684✔
101
                                        //Soft - pointer ID / handle to owner BLOCK_RECORD object
102
                                        case 330:
103
                                                template.OwnerHandle = this._reader.ValueAsHandle;
684✔
104
                                                break;
684✔
105
                                        default:
106
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} at line {this._reader.Position}.", NotificationType.None);
×
107
                                                break;
×
108
                                }
109

110
                                this._reader.ReadNext();
2,052✔
111
                        }
2,052✔
112
                }
684✔
113

114
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
115
                {
1,013,023✔
116
                        isExtendedData = false;
1,013,023✔
117

118
                        switch (this._reader.Code)
1,013,023✔
119
                        {
120
                                //Handle
121
                                case 5:
122
                                        template.CadObject.Handle = this._reader.ValueAsHandle;
332,738✔
123
                                        break;
332,738✔
124
                                //Check with mapper
125
                                case 100:
126
                                        if (map != null && !map.SubClasses.ContainsKey(this._reader.ValueAsString))
236,748!
127
                                        {
1,780✔
128
                                                this._builder.Notify($"[{template.CadObject.ObjectName}] Unidentified subclass {this._reader.ValueAsString}", NotificationType.Warning);
1,780✔
129
                                        }
1,780✔
130
                                        break;
236,748✔
131
                                //Start of application - defined group
132
                                case 102:
133
                                        this.readDefinedGroups(template);
67,080✔
134
                                        break;
67,080✔
135
                                //Soft - pointer ID / handle to owner BLOCK_RECORD object
136
                                case 330:
137
                                        template.OwnerHandle = this._reader.ValueAsHandle;
179,078✔
138
                                        break;
179,078✔
139
                                case 1001:
140
                                        isExtendedData = true;
29,735✔
141
                                        this.readExtendedData(template.EDataTemplateByAppName);
29,735✔
142
                                        break;
29,735✔
143
                                default:
144
                                        this._builder.Notify($"[{template.CadObject.SubclassMarker}] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
167,644✔
145
                                        break;
167,644✔
146
                        }
147
                }
1,013,023✔
148

149
                protected CadEntityTemplate readEntity()
150
                {
174,378✔
151
                        switch (this._reader.ValueAsString)
174,378!
152
                        {
153
                                case DxfFileToken.EntityAttribute:
154
                                        return this.readEntityCodes<AttributeEntity>(new CadAttributeTemplate(new AttributeEntity()), this.readAttributeDefinition);
1,120✔
155
                                case DxfFileToken.EntityAttributeDefinition:
156
                                        return this.readEntityCodes<AttributeDefinition>(new CadAttributeTemplate(new AttributeDefinition()), this.readAttributeDefinition);
1,330✔
157
                                case DxfFileToken.EntityArc:
158
                                        return this.readEntityCodes<Arc>(new CadEntityTemplate<Arc>(), this.readArc);
812✔
159
                                case DxfFileToken.EntityBody:
160
                                        return this.readEntityCodes<CadBody>(new CadEntityTemplate<CadBody>(), this.readEntitySubclassMap);
×
161
                                case DxfFileToken.EntityCircle:
162
                                        return this.readEntityCodes<Circle>(new CadEntityTemplate<Circle>(), this.readCircle);
2,450✔
163
                                case DxfFileToken.EntityDimension:
164
                                        return this.readEntityCodes<Dimension>(new CadDimensionTemplate(), this.readDimension);
3,080✔
165
                                case DxfFileToken.Entity3DFace:
166
                                        return this.readEntityCodes<Face3D>(new CadEntityTemplate<Face3D>(), this.readEntitySubclassMap);
280✔
167
                                case DxfFileToken.EntityEllipse:
168
                                        return this.readEntityCodes<Ellipse>(new CadEntityTemplate<Ellipse>(), this.readEntitySubclassMap);
240✔
169
                                case DxfFileToken.EntityLeader:
170
                                        return this.readEntityCodes<Leader>(new CadLeaderTemplate(), this.readLeader);
240✔
171
                                case DxfFileToken.EntityLine:
172
                                        return this.readEntityCodes<Line>(new CadEntityTemplate<Line>(), this.readEntitySubclassMap);
73,024✔
173
                                case DxfFileToken.EntityLwPolyline:
174
                                        return this.readEntityCodes<LwPolyline>(new CadEntityTemplate<LwPolyline>(), this.readLwPolyline);
5,256✔
175
                                case DxfFileToken.EntityMesh:
176
                                        return this.readEntityCodes<Mesh>(new CadMeshTemplate(), this.readMesh);
480✔
177
                                case DxfFileToken.EntityHatch:
178
                                        return this.readEntityCodes<Hatch>(new CadHatchTemplate(), this.readHatch);
1,920✔
179
                                case DxfFileToken.EntityInsert:
180
                                        return this.readEntityCodes<Insert>(new CadInsertTemplate(), this.readInsert);
6,508✔
181
                                case DxfFileToken.EntityMText:
182
                                        return this.readEntityCodes<MText>(new CadTextEntityTemplate(new MText()), this.readTextEntity);
8,268✔
183
                                case DxfFileToken.EntityMLine:
184
                                        return this.readEntityCodes<MLine>(new CadMLineTemplate(), this.readMLine);
720✔
185
                                case DxfFileToken.EntityMultiLeader:
186
                                        return this.readEntityCodes<MultiLeader>(new CadMLeaderTemplate(), this.readMLeader);
3,600✔
187
                                case DxfFileToken.EntityPdfUnderlay:
188
                                        return this.readEntityCodes<PdfUnderlay>(new CadUnderlayTemplate<PdfUnderlayDefinition>(new PdfUnderlay()), this.readUnderlayEntity<PdfUnderlayDefinition>);
240✔
189
                                case DxfFileToken.EntityPoint:
190
                                        return this.readEntityCodes<Point>(new CadEntityTemplate<Point>(), this.readEntitySubclassMap);
10,724✔
191
                                case DxfFileToken.EntityPolyline:
192
                                        return this.readPolyline();
12,348✔
193
                                case DxfFileToken.EntityRay:
194
                                        return this.readEntityCodes<Ray>(new CadEntityTemplate<Ray>(), this.readEntitySubclassMap);
240✔
195
                                case DxfFileToken.EndSequence:
196
                                        return this.readEntityCodes<Seqend>(new CadEntityTemplate<Seqend>(), this.readEntitySubclassMap);
1,040✔
197
                                case DxfFileToken.EntitySolid:
198
                                        return this.readEntityCodes<Solid>(new CadEntityTemplate<Solid>(), this.readModelerGeometry);
16,316✔
199
                                case DxfFileToken.EntityTable:
200
                                        return this.readEntityCodes<TableEntity>(new CadTableEntityTemplate(), this.readTableEntity);
480✔
201
                                case DxfFileToken.EntityText:
202
                                        return this.readEntityCodes<TextEntity>(new CadTextEntityTemplate(new TextEntity()), this.readTextEntity);
16,390✔
203
                                case DxfFileToken.EntityTolerance:
204
                                        return this.readEntityCodes<Tolerance>(new CadToleranceTemplate(new Tolerance()), this.readTolerance);
720✔
205
                                case DxfFileToken.EntityVertex:
206
                                        return this.readEntityCodes<Entity>(new CadVertexTemplate(), this.readVertex);
2,880✔
207
                                case DxfFileToken.EntityViewport:
208
                                        return this.readEntityCodes<Viewport>(new CadViewportTemplate(), this.readViewport);
1,472✔
209
                                case DxfFileToken.EntityShape:
210
                                        return this.readEntityCodes<Shape>(new CadShapeTemplate(new Shape()), this.readShape);
280✔
211
                                case DxfFileToken.EntitySpline:
212
                                        return this.readEntityCodes<Spline>(new CadSplineTemplate(), this.readSpline);
480✔
213
                                case DxfFileToken.Entity3DSolid:
214
                                        return this.readEntityCodes<Solid3D>(new CadSolid3DTemplate(), this.readSolid3d);
480✔
215
                                case DxfFileToken.EntityRegion:
216
                                        return this.readEntityCodes<Region>(new CadEntityTemplate<Region>(), this.readModelerGeometry);
240✔
217
                                case DxfFileToken.EntityImage:
218
                                        return this.readEntityCodes<RasterImage>(new CadWipeoutBaseTemplate(new RasterImage()), this.readWipeoutBase);
240✔
219
                                case DxfFileToken.EntityWipeout:
220
                                        return this.readEntityCodes<Wipeout>(new CadWipeoutBaseTemplate(new Wipeout()), this.readWipeoutBase);
240✔
221
                                case DxfFileToken.EntityXline:
222
                                        return this.readEntityCodes<XLine>(new CadEntityTemplate<XLine>(), this.readEntitySubclassMap);
240✔
223
                                default:
224
                                        DxfMap map = DxfMap.Create<Entity>();
×
225
                                        CadUnknownEntityTemplate unknownEntityTemplate = null;
×
226
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
×
227
                                        {
×
228
                                                this._builder.Notify($"Entity not supported read as an UnknownEntity: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
229
                                                unknownEntityTemplate = new CadUnknownEntityTemplate(new UnknownEntity(dxfClass));
×
230
                                        }
×
231
                                        else
232
                                        {
×
233
                                                this._builder.Notify($"Entity not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
234
                                        }
×
235

236
                                        this._reader.ReadNext();
×
237

238
                                        do
239
                                        {
×
240
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
×
241
                                                {
×
242
                                                        this.readCommonEntityCodes(unknownEntityTemplate, out bool isExtendedData, map);
×
243
                                                        if (isExtendedData)
×
244
                                                                continue;
×
245
                                                }
×
246

247
                                                this._reader.ReadNext();
×
248
                                        }
×
249
                                        while (this._reader.DxfCode != DxfCode.Start);
×
250

251
                                        return unknownEntityTemplate;
×
252
                        }
253
                }
174,378✔
254

255
                protected CadEntityTemplate readEntityCodes<T>(CadEntityTemplate template, ReadEntityDelegate<T> readEntity)
256
                        where T : Entity
257
                {
228,564✔
258
                        this._reader.ReadNext();
228,564✔
259

260
                        DxfMap map = DxfMap.Create<T>();
228,564✔
261

262
                        while (this._reader.DxfCode != DxfCode.Start)
3,100,654✔
263
                        {
2,872,090✔
264
                                if (!readEntity(template, map))
2,872,090✔
265
                                {
1,054,616✔
266
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
1,054,616✔
267
                                        if (isExtendedData)
1,054,616✔
268
                                                continue;
16,010✔
269
                                }
1,038,606✔
270

271
                                if (this.lockPointer)
2,856,080✔
272
                                {
3,360✔
273
                                        this.lockPointer = false;
3,360✔
274
                                        continue;
3,360✔
275
                                }
276

277
                                if (this._reader.DxfCode != DxfCode.Start)
2,852,720✔
278
                                        this._reader.ReadNext();
2,852,162✔
279
                        }
2,852,720✔
280

281
                        return template;
228,564✔
282
                }
228,564✔
283

284
                protected void readCommonEntityCodes(CadEntityTemplate template, out bool isExtendedData, DxfMap map = null)
285
                {
1,134,206✔
286
                        isExtendedData = false;
1,134,206✔
287
                        switch (this._reader.Code)
1,134,206✔
288
                        {
289
                                case 6:
290
                                        template.LineTypeName = this._reader.ValueAsString;
30,446✔
291
                                        break;
30,446✔
292
                                case 8:
293
                                        template.LayerName = this._reader.ValueAsString;
248,002✔
294
                                        break;
248,002✔
295
                                //Absent or zero indicates entity is in model space. 1 indicates entity is in paper space (optional).
296
                                case 67:
297
                                        break;
1,452✔
298
                                //Number of bytes Proxy entity graphics data
299
                                case 92:
300
                                case 160:
301
                                //Proxy entity graphics data
302
                                case 310:
303
                                        break;
90,080✔
304
                                case 347:
305
                                        template.MaterialHandle = this._reader.ValueAsHandle;
160✔
306
                                        break;
160✔
307
                                case 430:
308
                                        template.BookColorName = this._reader.ValueAsString;
200✔
309
                                        break;
200✔
310
                                default:
311
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Entity]))
763,866✔
312
                                        {
604,838✔
313
                                                this.readCommonCodes(template, out isExtendedData, map);
604,838✔
314
                                        }
604,838✔
315
                                        break;
763,866✔
316
                        }
317
                }
1,134,206✔
318

319
                protected bool checkObjectEnd(CadTemplate template, DxfMap map, Func<CadTemplate, DxfMap, bool> func)
320
                {
760✔
321
                        if (this._reader.DxfCode == DxfCode.Start)
760✔
322
                        {
532✔
323
                                return true;
532✔
324
                        }
325
                        else
326
                        {
228✔
327
                                return func.Invoke(template, map);
228✔
328
                        }
329
                }
760✔
330

331
                protected bool checkEntityEnd(CadEntityTemplate template, DxfMap map, string subclass, Func<CadEntityTemplate, DxfMap, string, bool> func)
332
                {
480✔
333
                        if (this._reader.DxfCode == DxfCode.Start)
480!
334
                        {
480✔
335
                                return true;
480✔
336
                        }
337
                        else
338
                        {
×
339
                                return func.Invoke(template, map, subclass);
×
340
                        }
341
                }
480✔
342

343
                private bool readCircle(CadEntityTemplate template, DxfMap map, string subclass = null)
344
                {
31,982✔
345
                        Circle circle = template.CadObject as Circle;
31,982✔
346

347
                        switch (this._reader.Code)
31,982✔
348
                        {
349
                                case 40:
350
                                        double radius = this._reader.ValueAsDouble;
3,262✔
351
                                        if (radius <= 0)
3,262!
NEW
352
                                        {
×
NEW
353
                                                circle.Radius = MathHelper.Epsilon;
×
NEW
354
                                        }
×
355
                                        else
356
                                        {
3,262✔
357
                                                circle.Radius = radius;
3,262✔
358
                                        }
3,262✔
359
                                        return true;
3,262✔
360
                                default:
361
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Circle]);
28,720✔
362
                        }
363
                }
31,982✔
364

365
                private bool readArc(CadEntityTemplate template, DxfMap map, string subclass = null)
366
                {
10,648✔
367
                        switch (this._reader.Code)
10,648✔
368
                        {
369
                                default:
370
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Arc]))
10,648✔
371
                                        {
9,024✔
372
                                                return this.readCircle(template, map, DxfSubclassMarker.Circle);
9,024✔
373
                                        }
374
                                        return true;
1,624✔
375
                        }
376
                }
10,648✔
377

378
                private bool readAttributeDefinition(CadEntityTemplate template, DxfMap map, string subclass = null)
379
                {
39,546✔
380
                        DxfClassMap emap = map.SubClasses[template.CadObject.SubclassMarker];
39,546✔
381
                        CadAttributeTemplate tmp = template as CadAttributeTemplate;
39,546✔
382

383
                        switch (this._reader.Code)
39,546!
384
                        {
385
                                case 44:
386
                                case 46:
387
                                        return true;
×
388
                                case 101:
389
                                        var att = tmp.CadObject as AttributeBase;
78✔
390
                                        att.MText = new MText();
78✔
391
                                        CadTextEntityTemplate mtextTemplate = new CadTextEntityTemplate(att.MText);
78✔
392
                                        tmp.MTextTemplate = mtextTemplate;
78✔
393
                                        this.readEntityCodes<MText>(mtextTemplate, this.readTextEntity);
78✔
394
                                        return true;
78✔
395
                                default:
396
                                        if (!this.tryAssignCurrentValue(template.CadObject, emap))
39,468✔
397
                                        {
29,858✔
398
                                                return this.readTextEntity(template, map, DxfSubclassMarker.Text);
29,858✔
399
                                        }
400
                                        return true;
9,610✔
401
                        }
402
                }
39,546✔
403

404
                private bool readTableEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
405
                {
158,040✔
406
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
158,040!
407
                        CadTableEntityTemplate tmp = template as CadTableEntityTemplate;
158,040✔
408
                        TableEntity table = tmp.CadObject as TableEntity;
158,040✔
409

410
                        switch (this._reader.Code)
158,040!
411
                        {
412
                                //Border overrides:
413
                                case 279:
414
                                        //Lineweight for the top border of the cell; override applied at the cell level
415
                                        tmp.CurrentCell.StyleOverride.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,680✔
416
                                        return true;
1,680✔
417
                                case 275:
418
                                        //Lineweight for the right border of the cell; override applied at the cell level
419
                                        tmp.CurrentCell.StyleOverride.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
480✔
420
                                        return true;
480✔
421
                                case 276:
422
                                        //Lineweight for the bottom border of the cell; override applied at the cell level
423
                                        tmp.CurrentCell.StyleOverride.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
×
424
                                        return true;
×
425
                                case 278:
426
                                        //Lineweight for the left border of the cell; override applied at the cell level
427
                                        tmp.CurrentCell.StyleOverride.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,440✔
428
                                        return true;
1,440✔
429
                                case 69:
430
                                        //True color value for the top border of the cell; override applied at the cell level
431
                                        tmp.CurrentCell.StyleOverride.TopBorder.Color = new Color(this._reader.ValueAsShort);
1,680✔
432
                                        return true;
1,680✔
433
                                case 65:
434
                                        //True color value for the right border of the cell; override applied at the cell level
435
                                        tmp.CurrentCell.StyleOverride.RightBorder.Color = new Color(this._reader.ValueAsShort);
480✔
436
                                        return true;
480✔
437
                                case 66:
438
                                        //True color value for the bottom border of the cell; override applied at the cell level
439
                                        tmp.CurrentCell.StyleOverride.BottomBorder.Color = new Color(this._reader.ValueAsShort);
×
440
                                        return true;
×
441
                                case 68:
442
                                        //True color value for the left border of the cell; override applied at the cell level
443
                                        tmp.CurrentCell.StyleOverride.LeftBorder.Color = new Color(this._reader.ValueAsShort);
1,440✔
444
                                        return true;
1,440✔
445
                                case 2:
446
                                        tmp.BlockName = this._reader.ValueAsString;
480✔
447
                                        return true;
480✔
448
                                case 40:
449
                                        tmp.HorizontalMargin = this._reader.ValueAsDouble;
240✔
450
                                        return true;
240✔
451
                                case 63:
452
                                        tmp.CurrentCell.StyleOverride.BackgroundColor = new Color(this._reader.ValueAsShort);
240✔
453
                                        return true;
240✔
454
                                case 64:
455
                                        tmp.CurrentCell.StyleOverride.ContentColor = new Color(this._reader.ValueAsShort);
240✔
456
                                        return true;
240✔
457
                                case 140:
458
                                        if (tmp.CurrentCellTemplate != null)
5,760✔
459
                                        {
5,040✔
460
                                                tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
5,040✔
461
                                        }
5,040✔
462
                                        return true;
5,760✔
463
                                case 283:
464
                                        tmp.CurrentCell.StyleOverride.IsFillColorOn = this._reader.ValueAsBool;
240✔
465
                                        return true;
240✔
466
                                case 342:
467
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
480✔
468
                                        return true;
480✔
469
                                case 343:
470
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
480✔
471
                                        return true;
480✔
472
                                case 141:
473
                                        var row = new TableEntity.Row();
2,640✔
474
                                        row.Height = this._reader.ValueAsDouble;
2,640✔
475
                                        table.Rows.Add(row);
2,640✔
476
                                        return true;
2,640✔
477
                                case 142:
478
                                        var col = new TableEntity.Column();
1,920✔
479
                                        col.Width = this._reader.ValueAsDouble;
1,920✔
480
                                        table.Columns.Add(col);
1,920✔
481
                                        return true;
1,920✔
482
                                case 144:
483
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
480✔
484
                                        return true;
480✔
485
                                case 145:
486
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
9,840✔
487
                                        return true;
9,840✔
488
                                case 170:
489
                                        //Has data flag
490
                                        return true;
720✔
491
                                case 171:
492
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
9,840✔
493
                                        return true;
9,840✔
494
                                case 172:
495
                                        tmp.CurrentCell.FlagValue = this._reader.ValueAsInt;
9,840✔
496
                                        return true;
9,840✔
497
                                case 173:
498
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsInt;
9,840✔
499
                                        return true;
9,840✔
500
                                case 174:
501
                                        tmp.CurrentCell.AutoFit = this._reader.ValueAsBool;
9,840✔
502
                                        return true;
9,840✔
503
                                case 175:
504
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
9,840✔
505
                                        return true;
9,840✔
506
                                case 176:
507
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
9,840✔
508
                                        return true;
9,840✔
509
                                case 178:
510
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
9,840✔
511
                                        return true;
9,840✔
512
                                case 179:
513
                                        //Unknown value
514
                                        return true;
480✔
515
                                case 301:
516
                                        var content = new TableEntity.CellContent();
6,560✔
517
                                        tmp.CurrentCell.Contents.Add(content);
6,560✔
518
                                        this.readCellValue(content);
6,560✔
519
                                        return true;
6,560✔
520
                                case 340:
521
                                        tmp.CurrentCellTemplate.BlockRecordHandle = this._reader.ValueAsHandle;
480✔
522
                                        return true;
480✔
523
                                default:
524
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
50,680✔
525
                                        {
49,000✔
526
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
49,000✔
527
                                        }
528
                                        return true;
1,680✔
529
                        }
530
                }
158,040✔
531

532
                private void readCellValue(TableEntity.CellContent content)
533
                {
6,560✔
534
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
535
                        {
6,560✔
536
                                this._reader.ReadNext();
6,560✔
537
                        }
6,560✔
538
                        else
539
                        {
×
540
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
541
                        }
542

543
                        while (this._reader.Code != 304
42,880✔
544
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
42,880✔
545
                        {
36,320✔
546
                                switch (this._reader.Code)
36,320!
547
                                {
548
                                        case 1:
549
                                                content.Value.Text = this._reader.ValueAsString;
1,920✔
550
                                                break;
1,920✔
551
                                        case 2:
552
                                                content.Value.Text += this._reader.ValueAsString;
×
553
                                                break;
×
554
                                        case 11:
555
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
160✔
556
                                                break;
160✔
557
                                        case 21:
558
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
160✔
559
                                                break;
160✔
560
                                        case 31:
561
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
160✔
562
                                                break;
160✔
563
                                        case 302:
564
                                                //TODO: Fix this assignation to cell value
565
                                                content.Value.Value = this._reader.ValueAsString;
6,560✔
566
                                                break;
6,560✔
567
                                        case 90:
568
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
6,560✔
569
                                                break;
6,560✔
570
                                        case 91:
571
                                                content.Value.Value = this._reader.ValueAsInt;
160✔
572
                                                break;
160✔
573
                                        case 92:
574
                                                //Extended cell flags (from AutoCAD 2007)
575
                                                break;
160✔
576
                                        case 93:
577
                                                content.Value.Flags = this._reader.ValueAsInt;
6,560✔
578
                                                break;
6,560✔
579
                                        case 94:
580
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
6,560✔
581
                                                break;
6,560✔
582
                                        case 140:
583
                                                content.Value.Value = this._reader.ValueAsDouble;
640✔
584
                                                break;
640✔
585
                                        case 300:
586
                                                content.Value.Format = this._reader.ValueAsString;
6,560✔
587
                                                break;
6,560✔
588
                                        case 310:
589
                                                //Data for proxy entity graphics (multiple lines; 256-character maximum per line)
590
                                                break;
160✔
591
                                        default:
592
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
593
                                                break;
×
594
                                }
595

596
                                this._reader.ReadNext();
36,320✔
597
                        }
36,320✔
598
                }
6,560✔
599

600
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
601
                {
341,010✔
602
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
341,010✔
603
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
341,010✔
604

605
                        switch (this._reader.Code)
341,010✔
606
                        {
607
                                //TODO: Implement multiline text def codes
608
                                case 1 or 3 when tmp.CadObject is MText mtext:
30,306✔
609
                                        mtext.Value += this._reader.ValueAsString;
11,466✔
610
                                        return true;
11,466✔
611
                                case 50 when tmp.CadObject is MText mtext://Read only for MText
570!
612
                                        double angle = MathHelper.DegToRad(this._reader.ValueAsDouble);
×
613
                                        mtext.AlignmentPoint = new XYZ(System.Math.Cos(angle), System.Math.Sin(angle), 0.0);
×
614
                                        return true;
×
615
                                case 70:
616
                                case 74:
617
                                case 101:
618
                                        return true;
480✔
619
                                case 7:
620
                                        tmp.StyleName = this._reader.ValueAsString;
3,080✔
621
                                        return true;
3,080✔
622
                                default:
623
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
325,984✔
624
                        }
625
                }
341,010✔
626

627
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
628
                {
7,200✔
629
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
630

631
                        switch (this._reader.Code)
7,200✔
632
                        {
633
                                case 3:
634
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
635
                                        return true;
720✔
636
                                default:
637
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
638
                        }
639
                }
7,200✔
640

641
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
642
                {
80,560✔
643
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
644

645
                        switch (this._reader.Code)
80,560✔
646
                        {
647
                                case 2:
648
                                        tmp.BlockName = this._reader.ValueAsString;
3,080✔
649
                                        return true;
3,080✔
650
                                case 3:
651
                                        tmp.StyleName = this._reader.ValueAsString;
2,640✔
652
                                        return true;
2,640✔
653
                                case 50:
654
                                        var dim = new DimensionLinear();
280✔
655
                                        tmp.SetDimensionObject(dim);
280✔
656
                                        dim.Rotation = this._reader.ValueAsAngle;
280✔
657
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
280✔
658
                                        return true;
280✔
659
                                case 70:
660
                                        //Flags do not have set
661
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
3,080✔
662
                                        return true;
3,080✔
663
                                //Measurement - read only
664
                                case 42:
665
                                        return true;
2,640✔
666
                                //Undocumented codes
667
                                case 73:
668
                                case 74:
669
                                case 75:
670
                                case 90:
671
                                case 361:
672
                                        return true;
5,280✔
673
                                case 100:
674
                                        switch (this._reader.ValueAsString)
8,640✔
675
                                        {
676
                                                case DxfSubclassMarker.Dimension:
677
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
2,640✔
678
                                                case DxfSubclassMarker.AlignedDimension:
679
                                                        tmp.SetDimensionObject(new DimensionAligned());
1,200✔
680
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
1,200✔
681
                                                        return true;
1,200✔
682
                                                case DxfSubclassMarker.DiametricDimension:
683
                                                        tmp.SetDimensionObject(new DimensionDiameter());
240✔
684
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
240✔
685
                                                        return true;
240✔
686
                                                case DxfSubclassMarker.Angular2LineDimension:
687
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
240✔
688
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
240✔
689
                                                        return true;
240✔
690
                                                case DxfSubclassMarker.Angular3PointDimension:
691
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
240✔
692
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
240✔
693
                                                        return true;
240✔
694
                                                case DxfSubclassMarker.RadialDimension:
695
                                                        tmp.SetDimensionObject(new DimensionRadius());
240✔
696
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
240✔
697
                                                        return true;
240✔
698
                                                case DxfSubclassMarker.OrdinateDimension:
699
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
480✔
700
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
480✔
701
                                                        return true;
480✔
702
                                                case DxfSubclassMarker.LinearDimension:
703
                                                        return true;
720✔
704
                                                default:
705
                                                        return false;
2,640✔
706
                                        }
707
                                default:
708
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
54,920✔
709
                        }
710
                }
80,560✔
711

712
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
713
                {
51,360✔
714
                        CadHatchTemplate tmp = template as CadHatchTemplate;
51,360✔
715
                        Hatch hatch = tmp.CadObject;
51,360✔
716

717
                        XY seedPoint = new XY();
51,360✔
718

719
                        switch (this._reader.Code)
51,360!
720
                        {
721
                                case 2:
722
                                        hatch.Pattern.Name = this._reader.ValueAsString;
1,920✔
723
                                        return true;
1,920✔
724
                                case 10:
725
                                        seedPoint.X = this._reader.ValueAsDouble;
3,840✔
726
                                        hatch.SeedPoints.Add(seedPoint);
3,840✔
727
                                        return true;
3,840✔
728
                                case 20:
729
                                        seedPoint = hatch.SeedPoints.LastOrDefault();
3,840✔
730
                                        seedPoint.Y = this._reader.ValueAsDouble;
3,840✔
731
                                        hatch.SeedPoints[hatch.SeedPoints.Count - 1] = seedPoint;
3,840✔
732
                                        return true;
3,840✔
733
                                case 30:
734
                                        hatch.Elevation = this._reader.ValueAsDouble;
1,920✔
735
                                        return true;
1,920✔
736
                                case 53:
737
                                        hatch.PatternAngle = this._reader.ValueAsAngle;
×
738
                                        return true;
×
739
                                //TODO: Check hatch undocumented codes
740
                                case 90:
741
                                        return true;
×
742
                                //Information about the hatch pattern
743
                                case 75:
744
                                        return true;
1,920✔
745
                                //Number of pattern definition lines
746
                                case 78:
747
                                        this.readPattern(hatch.Pattern, this._reader.ValueAsInt);
1,440✔
748
                                        this.lockPointer = true;
1,440✔
749
                                        return true;
1,440✔
750
                                //Number of boundary paths (loops)
751
                                case 91:
752
                                        this.readLoops(tmp, this._reader.ValueAsInt);
1,920✔
753
                                        this.lockPointer = true;
1,920✔
754
                                        return true;
1,920✔
755
                                //Number of seed points
756
                                case 98:
757
                                        return true;
1,200✔
758
                                case 450:
759
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
400✔
760
                                        return true;
400✔
761
                                case 451:
762
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
400✔
763
                                        return true;
400✔
764
                                case 452:
765
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
400✔
766
                                        return true;
400✔
767
                                case 453:
768
                                        //Number of colors
769
                                        return true;
400✔
770
                                case 460:
771
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
400✔
772
                                        return true;
400✔
773
                                case 461:
774
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
400✔
775
                                        return true;
400✔
776
                                case 462:
777
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
400✔
778
                                        return true;
400✔
779
                                case 463:
780
                                        GradientColor gradient = new GradientColor();
800✔
781
                                        gradient.Value = this._reader.ValueAsDouble;
800✔
782
                                        hatch.GradientColor.Colors.Add(gradient);
800✔
783
                                        return true;
800✔
784
                                case 63:
785
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
800✔
786
                                        if (colorByIndex != null)
800✔
787
                                        {
800✔
788
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
800✔
789
                                        }
800✔
790
                                        return true;
800✔
791
                                case 421:
792
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
800✔
793
                                        if (colorByRgb != null)
800✔
794
                                        {
800✔
795
                                                //TODO: Hatch assign color by true color
796
                                                //TODO: Is always duplicated by 63, is it needed??
797
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
798
                                        }
800✔
799
                                        return true;
800✔
800
                                case 470:
801
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
400✔
802
                                        return true;
400✔
803
                                default:
804
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,760✔
805
                        }
806
                }
51,360✔
807

808
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
809
                {
69,626✔
810
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
811

812
                        switch (this._reader.Code)
69,626✔
813
                        {
814
                                case 2:
815
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
816
                                        return true;
6,508✔
817
                                case 100:
818
                                        //AcDbEntity
819
                                        //AcDbBlockReference
820
                                        //AcDbMInsertBlock
821
                                        return true;
6,528✔
822
                                case 66:
823
                                        return true;
560✔
824
                                default:
825
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
826
                        }
827
                }
69,626✔
828

829
                private CadEntityTemplate readPolyline()
830
                {
12,348✔
831
                        CadPolyLineTemplate template = null;
12,348✔
832

833
                        if (this._builder.Version == ACadVersion.Unknown
12,348!
834
                                || this._builder.Version == ACadVersion.AC1009)
12,348✔
835
                        {
11,868✔
836
                                var polyline = new Polyline2D();
11,868✔
837
                                template = new CadPolyLineTemplate(polyline);
11,868✔
838
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
11,868✔
839

840
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
54,108!
841
                                {
42,240✔
842
                                        Vertex2D v = new Vertex2D();
42,240✔
843
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
42,240✔
844
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
42,240✔
845

846
                                        if (vertexTemplate.Vertex.Handle == 0)
42,240!
847
                                        {
×
848
                                                polyline.Vertices.Add(v);
×
849
                                        }
×
850
                                        else
851
                                        {
42,240✔
852
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
42,240✔
853
                                                this._builder.AddTemplate(vertexTemplate);
42,240✔
854
                                        }
42,240✔
855
                                }
42,240✔
856

857
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
23,736!
858
                                {
11,868✔
859
                                        var seqend = new Seqend();
11,868✔
860
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
11,868✔
861
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
11,868✔
862

863
                                        polyline.Vertices.Seqend = seqend;
11,868✔
864
                                }
11,868✔
865
                        }
11,868✔
866
                        else
867
                        {
480✔
868
                                template = new CadPolyLineTemplate();
480✔
869
                                this.readEntityCodes<Entity>(template, this.readPolyline);
480✔
870
                        }
480✔
871

872
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,348!
873
                        {
×
874
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
×
875
                                return null;
×
876
                        }
877

878
                        return template;
12,348✔
879
                }
12,348✔
880

881
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
882
                {
88,672✔
883
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,672✔
884

885
                        switch (this._reader.Code)
88,672✔
886
                        {
887
                                //DXF: always 0
888
                                //APP: a “dummy” point; the X and Y values are always 0, and the Z value is the polyline's elevation (in OCS when 2D, WCS when 3D)
889
                                case 10:
890
                                case 20:
891
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
892
                                case 66:
893
                                //Polygon mesh M vertex count (optional; default = 0)
894
                                case 71:
895
                                //Polygon mesh N vertex count(optional; default = 0)
896
                                case 72:
897
                                //Smooth surface M density(optional; default = 0)
898
                                case 73:
899
                                //Smooth surface N density (optional; default = 0)
900
                                case 74:
901
                                        return true;
37,604✔
902
                                case 100:
903
                                        switch (this._reader.ValueAsString)
960!
904
                                        {
905
                                                case DxfSubclassMarker.Polyline:
906
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
907
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
908
                                                        return true;
×
909
                                                case DxfSubclassMarker.Polyline3d:
910
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
911
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
912
                                                        return true;
240✔
913
                                                case DxfSubclassMarker.PolyfaceMesh:
914
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
915
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
916
                                                        return true;
240✔
917
                                                default:
918
                                                        return false;
480✔
919
                                        }
920
                                default:
921
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,108✔
922
                        }
923
                }
88,672✔
924

925
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
926
                {
6,000✔
927
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
928

929
                        switch (this._reader.Code)
6,000✔
930
                        {
931
                                case 3:
932
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
240✔
933
                                        return true;
240✔
934
                                case 10:
935
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
960✔
936
                                        return true;
960✔
937
                                case 20:
938
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
939
                                        y.Y = this._reader.ValueAsDouble;
960✔
940
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
960✔
941
                                        return true;
960✔
942
                                case 30:
943
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
944
                                        z.Z = this._reader.ValueAsDouble;
960✔
945
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
960✔
946
                                        return true;
960✔
947
                                case 340:
948
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
240✔
949
                                        return true;
240✔
950
                                //Hook line flag - read only
951
                                case 75:
952
                                //Vertices count
953
                                case 76:
954
                                        return true;
480✔
955
                                default:
956
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,160✔
957
                        }
958
                }
6,000✔
959

960
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
961
                {
98,616✔
962
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
98,616✔
963

964
                        LwPolyline.Vertex last = tmp.CadObject.Vertices.LastOrDefault();
98,616✔
965

966
                        switch (this._reader.Code)
98,616!
967
                        {
968
                                case 10:
969
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
23,412✔
970
                                        return true;
23,412✔
971
                                case 20:
972
                                        if (last is not null)
23,412✔
973
                                        {
23,412✔
974
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
23,412✔
975
                                        }
23,412✔
976
                                        return true;
23,412✔
977
                                case 40:
978
                                        if (last is not null)
2,400✔
979
                                        {
2,400✔
980
                                                last.StartWidth = this._reader.ValueAsDouble;
2,400✔
981
                                        }
2,400✔
982
                                        return true;
2,400✔
983
                                case 41:
984
                                        if (last is not null)
2,400✔
985
                                        {
2,400✔
986
                                                last.EndWidth = this._reader.ValueAsDouble;
2,400✔
987
                                        }
2,400✔
988
                                        return true;
2,400✔
989
                                case 42:
990
                                        if (last is not null)
3,288✔
991
                                        {
3,288✔
992
                                                last.Bulge = this._reader.ValueAsDouble;
3,288✔
993
                                        }
3,288✔
994
                                        return true;
3,288✔
995
                                case 50:
996
                                        if (last is not null)
×
997
                                        {
×
998
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
999
                                        }
×
1000
                                        return true;
×
1001
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
1002
                                case 66:
1003
                                //Vertex count
1004
                                case 90:
1005
                                        return true;
5,256✔
1006
                                case 91:
1007
                                        if (last is not null)
×
1008
                                        {
×
1009
                                                last.Id = this._reader.ValueAsInt;
×
1010
                                        }
×
1011
                                        return true;
×
1012
                                default:
1013
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,448✔
1014
                        }
1015
                }
98,616✔
1016

1017
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
1018
                {
42,240✔
1019
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
1020

1021
                        switch (this._reader.Code)
42,240✔
1022
                        {
1023
                                case 100:
1024
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
1025
                                        {
480✔
1026
                                                tmp.SubclassMarker = true;
480✔
1027
                                        }
480✔
1028
                                        return true;
960✔
1029
                                //Count of sub-entity which property has been overridden
1030
                                case 90:
1031
                                        //TODO: process further entities
1032
                                        return true;
480✔
1033
                                case 92:
1034
                                        if (!tmp.SubclassMarker)
720✔
1035
                                        {
240✔
1036
                                                return false;
240✔
1037
                                        }
1038

1039
                                        int nvertices = this._reader.ValueAsInt;
480✔
1040
                                        for (int i = 0; i < nvertices; i++)
61,440✔
1041
                                        {
30,240✔
1042
                                                this._reader.ReadNext();
30,240✔
1043
                                                double x = this._reader.ValueAsDouble;
30,240✔
1044
                                                this._reader.ReadNext();
30,240✔
1045
                                                double y = this._reader.ValueAsDouble;
30,240✔
1046
                                                this._reader.ReadNext();
30,240✔
1047
                                                double z = this._reader.ValueAsDouble;
30,240✔
1048
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
1049
                                        }
30,240✔
1050
                                        return true;
480✔
1051
                                case 93:
1052
                                        int size = this._reader.ValueAsInt;
480✔
1053
                                        this._reader.ReadNext();
480✔
1054

1055
                                        int indexes = 0;
480✔
1056
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
1057
                                        {
32,640✔
1058
                                                indexes = this._reader.ValueAsInt;
32,640✔
1059
                                                this._reader.ReadNext();
32,640✔
1060

1061
                                                int[] face = new int[indexes];
32,640✔
1062
                                                for (int j = 0; j < indexes; j++)
314,880✔
1063
                                                {
124,800✔
1064
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
1065

1066
                                                        if ((i + j + 2) < size)
124,800✔
1067
                                                        {
124,320✔
1068
                                                                this._reader.ReadNext();
124,320✔
1069
                                                        }
124,320✔
1070
                                                }
124,800✔
1071

1072
                                                tmp.CadObject.Faces.Add(face);
32,640✔
1073
                                        }
32,640✔
1074

1075
                                        Debug.Assert(this._reader.Code == 90);
480✔
1076

1077
                                        return true;
480✔
1078
                                case 94:
1079
                                        int numEdges = this._reader.ValueAsInt;
480✔
1080
                                        this._reader.ReadNext();
480✔
1081
                                        for (int i = 0; i < numEdges; i++)
125,760✔
1082
                                        {
62,400✔
1083
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
1084

1085
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
1086
                                                this._reader.ReadNext();
62,400✔
1087
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1088

1089
                                                if (i < numEdges - 1)
62,400✔
1090
                                                {
61,920✔
1091
                                                        this._reader.ReadNext();
61,920✔
1092
                                                }
61,920✔
1093

1094
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1095
                                        }
62,400✔
1096

1097
                                        Debug.Assert(this._reader.Code == 90);
480✔
1098

1099
                                        return true;
480✔
1100
                                case 95:
1101
                                        this._reader.ReadNext();
480✔
1102
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1103
                                        {
62,400✔
1104
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1105
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1106

1107
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1108

1109
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1110
                                                {
61,920✔
1111
                                                        this._reader.ReadNext();
61,920✔
1112
                                                }
61,920✔
1113
                                        }
62,400✔
1114

1115
                                        Debug.Assert(this._reader.Code == 140);
480✔
1116

1117
                                        return true;
480✔
1118
                                default:
1119
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1120
                        }
1121
                }
42,240✔
1122

1123
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1124
                {
62,400✔
1125
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1126

1127
                        switch (this._reader.Code)
62,400✔
1128
                        {
1129
                                // String of up to 32 characters. The name of the style used for this mline. An entry for this style must exist in the MLINESTYLE dictionary.
1130
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1131
                                case 2:
1132
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1133
                                        return true;
720✔
1134
                                case 72:
1135
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1136
                                        return true;
720✔
1137
                                case 73:
1138
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1139
                                        return true;
720✔
1140
                                case 340:
1141
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1142
                                        return true;
720✔
1143
                                default:
1144
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1145
                                        {
10,080✔
1146
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1147
                                        }
1148
                                        return true;
49,440✔
1149
                        }
1150
                }
62,400✔
1151

1152
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1153
                {
169,440✔
1154
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1155

1156
                        switch (this._reader.Code)
169,440✔
1157
                        {
1158
                                case 270:
1159
                                        //f270 Version
1160
                                        return true;
1,800✔
1161
                                case 300:
1162
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1163
                                        return true;
3,600✔
1164
                                case 340:
1165
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1166
                                        return true;
3,600✔
1167
                                case 341:
1168
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1169
                                        return true;
3,600✔
1170
                                case 343:
1171
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1172
                                        return true;
3,600✔
1173
                                default:
1174
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1175
                        }
1176
                }
169,440✔
1177

1178
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1179
                {
3,600✔
1180
                        this._reader.ReadNext();
3,600✔
1181

1182
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1183
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1184

1185
                        bool end = false;
3,600✔
1186
                        while (this._reader.DxfCode != DxfCode.Start)
201,600✔
1187
                        {
201,600✔
1188
                                switch (this._reader.Code)
201,600✔
1189
                                {
1190
                                        case 301 when this._reader.ValueAsString.Equals("}"):
3,600✔
1191
                                                end = true;
3,600✔
1192
                                                break;
3,600✔
1193
                                        case 302 when this._reader.ValueAsString.Equals("LEADER{"):
3,600✔
1194
                                                contextData.LeaderRoots.Add(this.readMultiLeaderLeader(template));
3,600✔
1195
                                                break;
3,600✔
1196
                                        case 340:
1197
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1198
                                                break;
3,600✔
1199
                                        default:
1200
                                                if (!this.tryAssignCurrentValue(contextData, map.SubClasses[contextData.SubclassMarker]))
190,800!
1201
                                                {
×
1202
                                                        this._builder.Notify($"[AcDbMLeaderObjectContextData] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1203
                                                }
×
1204
                                                break;
190,800✔
1205
                                }
1206

1207
                                if (end)
201,600✔
1208
                                {
3,600✔
1209
                                        break;
3,600✔
1210
                                }
1211

1212
                                this._reader.ReadNext();
198,000✔
1213
                        }
198,000✔
1214
                }
3,600✔
1215

1216
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1217
                {
3,600✔
1218
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1219
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1220

1221
                        this._reader.ReadNext();
3,600✔
1222

1223
                        bool end = false;
3,600✔
1224
                        while (this._reader.DxfCode != DxfCode.Start)
45,000✔
1225
                        {
45,000✔
1226
                                switch (this._reader.Code)
45,000✔
1227
                                {
1228
                                        case 303 when this._reader.ValueAsString.Equals("}"):
3,600✔
1229
                                                end = true;
3,600✔
1230
                                                break;
3,600✔
1231
                                        case 304 when this._reader.ValueAsString.Equals("LEADER_LINE{"):
3,600✔
1232
                                                var lineTemplate = new LeaderLineTemplate();
3,600✔
1233
                                                template.LeaderLineTemplates.Add(lineTemplate);
3,600✔
1234
                                                root.Lines.Add(this.readMultiLeaderLine(lineTemplate));
3,600✔
1235
                                                break;
3,600✔
1236
                                        default:
1237
                                                if (!this.tryAssignCurrentValue(root, map))
37,800!
1238
                                                {
×
1239
                                                        this._builder.Notify($"[LeaderRoot] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1240
                                                }
×
1241
                                                break;
37,800✔
1242
                                }
1243

1244
                                if (end)
45,000✔
1245
                                {
3,600✔
1246
                                        break;
3,600✔
1247
                                }
1248

1249
                                this._reader.ReadNext();
41,400✔
1250
                        }
41,400✔
1251

1252
                        return root;
3,600✔
1253
                }
3,600✔
1254

1255
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1256
                {
3,600✔
1257
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1258
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1259

1260
                        this._reader.ReadNext();
3,600✔
1261

1262
                        bool end = false;
3,600✔
1263
                        while (this._reader.DxfCode != DxfCode.Start)
18,000✔
1264
                        {
18,000✔
1265
                                switch (this._reader.Code)
18,000✔
1266
                                {
1267
                                        case 10:
1268
                                                XYZ pt = new XYZ(this._reader.ValueAsDouble, 0, 0);
3,600✔
1269
                                                line.Points.Add(pt);
3,600✔
1270
                                                break;
3,600✔
1271
                                        case 20:
1272
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1273
                                                pt.Y = this._reader.ValueAsDouble;
3,600✔
1274
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1275
                                                break;
3,600✔
1276
                                        case 30:
1277
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1278
                                                pt.Z = this._reader.ValueAsDouble;
3,600✔
1279
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1280
                                                break;
3,600✔
1281
                                        case 305 when this._reader.ValueAsString.Equals("}"):
3,600✔
1282
                                                end = true;
3,600✔
1283
                                                break;
3,600✔
1284
                                        default:
1285
                                                if (!this.tryAssignCurrentValue(line, map))
3,600!
1286
                                                {
×
1287
                                                        this._builder.Notify($"[LeaderLine] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1288
                                                }
×
1289
                                                break;
3,600✔
1290
                                }
1291

1292
                                if (end)
18,000✔
1293
                                {
3,600✔
1294
                                        break;
3,600✔
1295
                                }
1296

1297
                                this._reader.ReadNext();
14,400✔
1298
                        }
14,400✔
1299

1300
                        return line;
3,600✔
1301
                }
3,600✔
1302

1303
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1304
                {
2,680✔
1305
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1306

1307
                        switch (this._reader.Code)
2,680✔
1308
                        {
1309
                                case 2:
1310
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1311
                                        return true;
280✔
1312
                                default:
1313
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1314
                        }
1315
                }
2,680✔
1316

1317
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1318
                {
14,160✔
1319
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1320
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1321

1322
                        switch (this._reader.Code)
14,160✔
1323
                        {
1324
                                case 91:
1325
                                        var nvertices = this._reader.ValueAsInt;
480✔
1326
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1327
                                        {
1,680✔
1328
                                                this._reader.ReadNext();
1,680✔
1329
                                                var x = this._reader.ValueAsDouble;
1,680✔
1330
                                                this._reader.ReadNext();
1,680✔
1331
                                                var y = this._reader.ValueAsDouble;
1,680✔
1332

1333
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1334
                                        }
1,680✔
1335

1336
                                        this._reader.ReadNext();
480✔
1337

1338
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1339
                                case 340:
1340
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1341
                                        return true;
480✔
1342
                                case 360:
1343
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1344
                                        return true;
480✔
1345
                                default:
1346
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1347
                        }
1348
                }
14,160✔
1349

1350
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1351
                {
342,410✔
1352
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1353
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1354

1355
                        switch (this._reader.Code)
342,410✔
1356
                        {
1357
                                case 2:
1358
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1359
                                        return true;
240✔
1360
                                case 290:
1361
                                        return true;
240✔
1362
                                default:
1363
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
341,930✔
1364
                        }
1365
                }
342,410✔
1366

1367
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1368
                {
41,040✔
1369
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1370

1371
                        switch (this._reader.Code)
41,040✔
1372
                        {
1373
                                case 350:
1374
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1375
                                        return true;
320✔
1376
                                default:
1377
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1378
                        }
1379
                }
41,040✔
1380

1381
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1382
                {
16,800✔
1383
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1384

1385
                        XYZ controlPoint;
1386
                        XYZ fitPoint;
1387

1388
                        switch (this._reader.Code)
16,800!
1389
                        {
1390
                                case 10:
1391
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1392
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1393
                                        return true;
1,920✔
1394
                                case 20:
1395
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1396
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1397
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1398
                                        return true;
1,920✔
1399
                                case 30:
1400
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1401
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1402
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1403
                                        return true;
1,920✔
1404
                                case 11:
1405
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1406
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1407
                                        return true;
×
1408
                                case 21:
1409
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1410
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1411
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1412
                                        return true;
×
1413
                                case 31:
1414
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1415
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1416
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1417
                                        return true;
×
1418
                                case 40:
1419
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1420
                                        return true;
3,840✔
1421
                                case 41:
1422
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1423
                                        return true;
×
1424
                                case 72:
1425
                                case 73:
1426
                                case 74:
1427
                                        return true;
1,440✔
1428
                                default:
1429
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1430
                        }
1431
                }
16,800✔
1432

1433
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1434
                        where T : PdfUnderlayDefinition
1435
                {
3,800✔
1436
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1437

1438
                        switch (this._reader.Code)
3,800✔
1439
                        {
1440
                                case 340:
1441
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1442
                                        return true;
240✔
1443
                                default:
1444
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1445
                        }
1446
                }
3,800✔
1447

1448
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1449
                {
280,766✔
1450
                        CadVertexTemplate tmp = template as CadVertexTemplate;
280,766✔
1451

1452
                        switch (this._reader.Code)
280,766✔
1453
                        {
1454
                                //Polyface mesh vertex index
1455
                                case 71:
1456
                                case 72:
1457
                                case 73:
1458
                                case 74:
1459
                                        return true;
1,960✔
1460
                                case 100:
1461
                                        switch (this._reader.ValueAsString)
8,160!
1462
                                        {
1463
                                                case DxfSubclassMarker.Vertex:
1464
                                                        return true;
2,400✔
1465
                                                case DxfSubclassMarker.PolylineVertex:
1466
                                                        tmp.SetVertexObject(new Vertex2D());
×
1467
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1468
                                                        return true;
×
1469
                                                case DxfSubclassMarker.Polyline3dVertex:
1470
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1471
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1472
                                                        return true;
1,200✔
1473
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1474
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1475
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1476
                                                        return true;
1,200✔
1477
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1478
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1479
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1480
                                                        return true;
480✔
1481
                                                default:
1482
                                                        return false;
2,880✔
1483
                                        }
1484
                                default:
1485
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
270,646✔
1486
                        }
1487
                }
280,766✔
1488

1489
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1490
                {
80,456✔
1491
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1492

1493
                        switch (this._reader.Code)
80,456!
1494
                        {
1495
                                //Undocumented
1496
                                case 67:
1497
                                case 68:
1498
                                        return true;
2,944✔
1499
                                case 69:
1500
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1501
                                        return true;
1,472✔
1502
                                case 331:
1503
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1504
                                        return true;
×
1505
                                case 348:
1506
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1507
                                        return true;
928✔
1508
                                default:
1509
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1510
                        }
1511
                }
80,456✔
1512

1513
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1514
                {
961,240✔
1515
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
961,240✔
1516

1517
                        switch (this._reader.Code)
961,240✔
1518
                        {
1519
                                default:
1520
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
961,240✔
1521
                        }
1522
                }
961,240✔
1523

1524
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1525
                {
42,721✔
1526
                        List<ExtendedDataRecord> records = new();
42,721✔
1527
                        edata.Add(this._reader.ValueAsString, records);
42,721✔
1528

1529
                        this._reader.ReadNext();
42,721✔
1530

1531
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,498✔
1532
                        {
298,543✔
1533
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
298,543✔
1534
                                {
12,766✔
1535
                                        this.readExtendedData(edata);
12,766✔
1536
                                        break;
12,766✔
1537
                                }
1538

1539
                                ExtendedDataRecord record = null;
285,777✔
1540
                                double x = 0;
285,777✔
1541
                                double y = 0;
285,777✔
1542
                                double z = 0;
285,777✔
1543

1544
                                switch (this._reader.DxfCode)
285,777✔
1545
                                {
1546
                                        case DxfCode.ExtendedDataAsciiString:
1547
                                        case DxfCode.ExtendedDataRegAppName:
1548
                                                record = new ExtendedDataString(this._reader.ValueAsString);
30,268✔
1549
                                                break;
30,268✔
1550
                                        case DxfCode.ExtendedDataControlString:
1551
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1552
                                                break;
15,848✔
1553
                                        case DxfCode.ExtendedDataLayerName:
1554
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1555
                                                {
266✔
1556
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1557
                                                }
266✔
1558
                                                else
1559
                                                {
14✔
1560
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1561
                                                }
14✔
1562
                                                break;
280✔
1563
                                        case DxfCode.ExtendedDataBinaryChunk:
1564
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1565
                                                break;
80✔
1566
                                        case DxfCode.ExtendedDataHandle:
1567
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1568
                                                break;
2,958✔
1569
                                        case DxfCode.ExtendedDataXCoordinate:
1570
                                                x = this._reader.ValueAsDouble;
2,984✔
1571
                                                this._reader.ReadNext();
2,984✔
1572
                                                y = this._reader.ValueAsDouble;
2,984✔
1573
                                                this._reader.ReadNext();
2,984✔
1574
                                                z = this._reader.ValueAsDouble;
2,984✔
1575

1576
                                                record = new ExtendedDataCoordinate(
2,984✔
1577
                                                        new XYZ(
2,984✔
1578
                                                                x,
2,984✔
1579
                                                                y,
2,984✔
1580
                                                                z)
2,984✔
1581
                                                        );
2,984✔
1582
                                                break;
2,984✔
1583
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1584
                                                x = this._reader.ValueAsDouble;
1,440✔
1585
                                                this._reader.ReadNext();
1,440✔
1586
                                                y = this._reader.ValueAsDouble;
1,440✔
1587
                                                this._reader.ReadNext();
1,440✔
1588
                                                z = this._reader.ValueAsDouble;
1,440✔
1589

1590
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1591
                                                        new XYZ(
1,440✔
1592
                                                                x,
1,440✔
1593
                                                                y,
1,440✔
1594
                                                                z)
1,440✔
1595
                                                        );
1,440✔
1596
                                                break;
1,440✔
1597
                                        case DxfCode.ExtendedDataWorldXDisp:
1598
                                                x = this._reader.ValueAsDouble;
280✔
1599
                                                this._reader.ReadNext();
280✔
1600
                                                y = this._reader.ValueAsDouble;
280✔
1601
                                                this._reader.ReadNext();
280✔
1602
                                                z = this._reader.ValueAsDouble;
280✔
1603

1604
                                                record = new ExtendedDataDisplacement(
280✔
1605
                                                        new XYZ(
280✔
1606
                                                                x,
280✔
1607
                                                                y,
280✔
1608
                                                                z)
280✔
1609
                                                        );
280✔
1610
                                                break;
280✔
1611
                                        case DxfCode.ExtendedDataWorldXDir:
1612
                                                x = this._reader.ValueAsDouble;
280✔
1613
                                                this._reader.ReadNext();
280✔
1614
                                                y = this._reader.ValueAsDouble;
280✔
1615
                                                this._reader.ReadNext();
280✔
1616
                                                z = this._reader.ValueAsDouble;
280✔
1617

1618
                                                record = new ExtendedDataDirection(
280✔
1619
                                                        new XYZ(
280✔
1620
                                                                x,
280✔
1621
                                                                y,
280✔
1622
                                                                z)
280✔
1623
                                                        );
280✔
1624
                                                break;
280✔
1625
                                        case DxfCode.ExtendedDataReal:
1626
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1627
                                                break;
140,536✔
1628
                                        case DxfCode.ExtendedDataDist:
1629
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1630
                                                break;
280✔
1631
                                        case DxfCode.ExtendedDataScale:
1632
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1633
                                                break;
280✔
1634
                                        case DxfCode.ExtendedDataInteger16:
1635
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
78,517✔
1636
                                                break;
78,517✔
1637
                                        case DxfCode.ExtendedDataInteger32:
1638
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
9,186✔
1639
                                                break;
9,186✔
1640
                                        default:
1641
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1642
                                                break;
2,560✔
1643
                                }
1644

1645
                                if (record != null)
285,777✔
1646
                                {
283,203✔
1647
                                        records.Add(record);
283,203✔
1648
                                }
283,203✔
1649

1650
                                this._reader.ReadNext();
285,777✔
1651
                        }
285,777✔
1652
                }
42,721✔
1653

1654
                private void readPattern(HatchPattern pattern, int nlines)
1655
                {
1,440✔
1656
                        //Jump 78 code
1657
                        this._reader.ReadNext();
1,440✔
1658

1659
                        for (int i = 0; i < nlines; i++)
218,400✔
1660
                        {
107,760✔
1661
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1662
                                XY basePoint = new XY();
107,760✔
1663
                                XY offset = new XY();
107,760✔
1664

1665
                                bool end = false;
107,760✔
1666
                                HashSet<int> codes = new();
107,760✔
1667

1668
                                while (!end)
755,760✔
1669
                                {
754,320✔
1670
                                        if (codes.Contains(this._reader.Code))
754,320✔
1671
                                        {
106,320✔
1672
                                                break;
106,320✔
1673
                                        }
1674
                                        else
1675
                                        {
648,000✔
1676
                                                codes.Add(this._reader.Code);
648,000✔
1677
                                        }
648,000✔
1678

1679
                                        switch (this._reader.Code)
648,000!
1680
                                        {
1681
                                                case 53:
1682
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1683
                                                        break;
107,760✔
1684
                                                case 43:
1685
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1686
                                                        break;
107,760✔
1687
                                                case 44:
1688
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1689
                                                        line.BasePoint = basePoint;
107,760✔
1690
                                                        break;
107,760✔
1691
                                                case 45:
1692
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1693
                                                        line.Offset = offset;
107,760✔
1694
                                                        break;
107,760✔
1695
                                                case 46:
1696
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1697
                                                        line.Offset = offset;
107,760✔
1698
                                                        break;
107,760✔
1699
                                                //Number of dash length items
1700
                                                case 79:
1701
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1702
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1703
                                                        {
215,040✔
1704
                                                                this._reader.ReadNext();
215,040✔
1705
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1706
                                                        }
215,040✔
1707
                                                        break;
107,760✔
1708
                                                case 49:
1709
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
1710
                                                        break;
×
1711
                                                default:
1712
                                                        end = true;
1,440✔
1713
                                                        break;
1,440✔
1714
                                        }
1715
                                        this._reader.ReadNext();
648,000✔
1716
                                }
648,000✔
1717

1718
                                pattern.Lines.Add(line);
107,760✔
1719
                        }
107,760✔
1720
                }
1,440✔
1721

1722
                private void readLoops(CadHatchTemplate template, int count)
1723
                {
1,920✔
1724
                        if (this._reader.Code == 91)
1,920✔
1725
                                this._reader.ReadNext();
1,920✔
1726

1727
                        for (int i = 0; i < count; i++)
7,680✔
1728
                        {
1,920✔
1729
                                if (this._reader.Code != 92)
1,920!
1730
                                {
×
1731
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1732
                                        break;
×
1733
                                }
1734

1735
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1736
                                if (path != null)
1,920✔
1737
                                        template.PathTemplates.Add(path);
1,920✔
1738
                        }
1,920✔
1739
                }
1,920✔
1740

1741
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1742
                {
1,920✔
1743
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1744
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1745
                        template.Path.Flags = flags;
1,920✔
1746

1747
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1748
                        {
720✔
1749
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1750
                                template.Path.Edges.Add(pl);
720✔
1751
                        }
720✔
1752
                        else
1753
                        {
1,200✔
1754
                                this._reader.ReadNext();
1,200✔
1755

1756
                                if (this._reader.Code != 93)
1,200!
1757
                                {
×
1758
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1759
                                        return null;
×
1760
                                }
1761

1762
                                int edges = this._reader.ValueAsInt;
1,200✔
1763
                                this._reader.ReadNext();
1,200✔
1764

1765
                                for (int i = 0; i < edges; i++)
12,000✔
1766
                                {
4,800✔
1767
                                        var edge = this.readEdge();
4,800✔
1768
                                        if (edge != null)
4,800✔
1769
                                                template.Path.Edges.Add(edge);
4,800✔
1770
                                }
4,800✔
1771
                        }
1,200✔
1772

1773
                        bool end = false;
1,920✔
1774
                        while (!end)
7,440✔
1775
                        {
5,520✔
1776
                                switch (this._reader.Code)
5,520✔
1777
                                {
1778
                                        //Number of source boundary objects
1779
                                        case 97:
1780
                                                break;
1,920✔
1781
                                        case 330:
1782
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1783
                                                break;
1,680✔
1784
                                        default:
1785
                                                end = true;
1,920✔
1786
                                                continue;
1,920✔
1787
                                }
1788

1789
                                this._reader.ReadNext();
3,600✔
1790
                        }
3,600✔
1791

1792
                        return template;
1,920✔
1793
                }
1,920✔
1794

1795
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1796
                {
720✔
1797
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1798

1799
                        this._reader.ReadNext();
720✔
1800

1801
                        if (this._reader.Code != 72)
720!
1802
                        {
×
1803
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1804
                                return null;
×
1805
                        }
1806

1807
                        //72
1808
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1809
                        this._reader.ReadNext();
720✔
1810

1811
                        //73
1812
                        bool isClosed = this._reader.ValueAsBool;
720✔
1813
                        this._reader.ReadNext();
720✔
1814

1815
                        //93
1816
                        int nvertices = this._reader.ValueAsInt;
720✔
1817
                        this._reader.ReadNext();
720✔
1818

1819
                        for (int i = 0; i < nvertices; i++)
7,200✔
1820
                        {
2,880✔
1821
                                double bulge = 0.0;
2,880✔
1822

1823
                                //10
1824
                                double x = this._reader.ValueAsDouble;
2,880✔
1825
                                this._reader.ReadNext();
2,880✔
1826
                                //20
1827
                                double y = this._reader.ValueAsDouble;
2,880✔
1828
                                this._reader.ReadNext();
2,880✔
1829

1830
                                if (hasBulge)
2,880!
1831
                                {
×
1832
                                        //42
1833
                                        bulge = this._reader.ValueAsDouble;
×
1834
                                        this._reader.ReadNext();
×
1835
                                }
×
1836

1837
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1838
                        }
2,880✔
1839

1840
                        return boundary;
720✔
1841
                }
720✔
1842

1843
                private Hatch.BoundaryPath.Edge readEdge()
1844
                {
4,800✔
1845
                        if (this._reader.Code != 72)
4,800!
1846
                        {
×
1847
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1848
                                return null;
×
1849
                        }
1850

1851
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1852
                        this._reader.ReadNext();
4,800✔
1853

1854
                        switch (type)
4,800!
1855
                        {
1856
                                case Hatch.BoundaryPath.EdgeType.Line:
1857
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1858
                                        while (true)
24,000✔
1859
                                        {
24,000✔
1860
                                                switch (this._reader.Code)
24,000✔
1861
                                                {
1862
                                                        case 10:
1863
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1864
                                                                break;
4,800✔
1865
                                                        case 20:
1866
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1867
                                                                break;
4,800✔
1868
                                                        case 11:
1869
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1870
                                                                break;
4,800✔
1871
                                                        case 21:
1872
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1873
                                                                break;
4,800✔
1874
                                                        default:
1875
                                                                return line;
4,800✔
1876
                                                }
1877

1878
                                                this._reader.ReadNext();
19,200✔
1879
                                        }
19,200✔
1880
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1881
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1882
                                        while (true)
×
1883
                                        {
×
1884
                                                switch (this._reader.Code)
×
1885
                                                {
1886
                                                        case 10:
1887
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1888
                                                                break;
×
1889
                                                        case 20:
1890
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1891
                                                                break;
×
1892
                                                        case 40:
1893
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1894
                                                                break;
×
1895
                                                        case 50:
1896
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1897
                                                                break;
×
1898
                                                        case 51:
1899
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1900
                                                                break;
×
1901
                                                        case 73:
1902
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1903
                                                                break;
×
1904
                                                        default:
1905
                                                                return arc;
×
1906
                                                }
1907

1908
                                                this._reader.ReadNext();
×
1909
                                        }
×
1910
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1911
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1912
                                        while (true)
×
1913
                                        {
×
1914
                                                switch (this._reader.Code)
×
1915
                                                {
1916
                                                        case 10:
1917
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1918
                                                                break;
×
1919
                                                        case 20:
1920
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1921
                                                                break;
×
1922
                                                        case 11:
1923
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1924
                                                                break;
×
1925
                                                        case 21:
1926
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1927
                                                                break;
×
1928
                                                        case 40:
1929
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1930
                                                                break;
×
1931
                                                        case 50:
1932
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1933
                                                                break;
×
1934
                                                        case 51:
1935
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1936
                                                                break;
×
1937
                                                        case 73:
1938
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1939
                                                                break;
×
1940
                                                        default:
1941
                                                                return ellipse;
×
1942
                                                }
1943

1944
                                                this._reader.ReadNext();
×
1945
                                        }
×
1946
                                case Hatch.BoundaryPath.EdgeType.Spline:
1947
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1948
                                        int nKnots = 0;
×
1949
                                        int nCtrlPoints = 0;
×
1950
                                        int nFitPoints = 0;
×
1951

1952
                                        XYZ controlPoint = new XYZ();
×
1953
                                        XY fitPoint = new XY();
×
1954

1955
                                        while (true)
×
1956
                                        {
×
1957
                                                switch (this._reader.Code)
×
1958
                                                {
1959
                                                        case 10:
1960
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1961
                                                                break;
×
1962
                                                        case 20:
1963
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1964
                                                                spline.ControlPoints.Add(controlPoint);
×
1965
                                                                break;
×
1966
                                                        case 11:
1967
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1968
                                                                break;
×
1969
                                                        case 21:
1970
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1971
                                                                spline.FitPoints.Add(fitPoint);
×
1972
                                                                break;
×
1973
                                                        case 42:
1974
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1975
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1976
                                                                break;
×
1977
                                                        case 12:
1978
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
1979
                                                                break;
×
1980
                                                        case 22:
1981
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
1982
                                                                break;
×
1983
                                                        case 13:
1984
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
1985
                                                                break;
×
1986
                                                        case 23:
1987
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
1988
                                                                break;
×
1989
                                                        case 94:
1990
                                                                spline.Degree = this._reader.ValueAsInt;
×
1991
                                                                break;
×
1992
                                                        case 73:
1993
                                                                spline.Rational = this._reader.ValueAsBool;
×
1994
                                                                break;
×
1995
                                                        case 74:
1996
                                                                spline.Periodic = this._reader.ValueAsBool;
×
1997
                                                                break;
×
1998
                                                        case 95:
1999
                                                                nKnots = this._reader.ValueAsInt;
×
2000
                                                                break;
×
2001
                                                        case 96:
2002
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
2003
                                                                break;
×
2004
                                                        case 97:
2005
                                                                nFitPoints = this._reader.ValueAsInt;
×
2006
                                                                break;
×
2007
                                                        case 40:
2008
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
2009
                                                                break;
×
2010
                                                        default:
2011
                                                                return spline;
×
2012
                                                }
2013

2014
                                                this._reader.ReadNext();
×
2015
                                        }
×
2016
                        }
2017

2018
                        return null;
×
2019
                }
4,800✔
2020

2021
                private void readDefinedGroups(CadTemplate template)
2022
                {
67,764✔
2023
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
67,764✔
2024

2025
                        template.XDictHandle = xdict;
67,764✔
2026
                        template.ReactorsHandles.UnionWith(reactorsHandles);
67,764✔
2027
                }
67,764✔
2028

2029
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
2030
                {
68,006✔
2031
                        xdictHandle = null;
68,006✔
2032
                        reactors = new HashSet<ulong>();
68,006✔
2033

2034
                        switch (this._reader.ValueAsString)
68,006✔
2035
                        {
2036
                                case DxfFileToken.DictionaryToken:
2037
                                        this._reader.ReadNext();
12,845✔
2038
                                        xdictHandle = this._reader.ValueAsHandle;
12,845✔
2039
                                        this._reader.ReadNext();
12,845✔
2040
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
12,845✔
2041
                                        return;
12,845✔
2042
                                case DxfFileToken.ReactorsToken:
2043
                                        reactors = this.readReactors();
52,761✔
2044
                                        break;
52,761✔
2045
                                case DxfFileToken.BlkRefToken:
2046
                                default:
2047
                                        do
2048
                                        {
6,240✔
2049
                                                this._reader.ReadNext();
6,240✔
2050
                                        }
6,240✔
2051
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2052
                                        return;
2,400✔
2053
                        }
2054
                }
68,006✔
2055

2056
                private HashSet<ulong> readReactors()
2057
                {
52,761✔
2058
                        HashSet<ulong> reactors = new();
52,761✔
2059

2060
                        this._reader.ReadNext();
52,761✔
2061

2062
                        while (this._reader.DxfCode != DxfCode.ControlString)
112,806✔
2063
                        {
60,045✔
2064
                                this._reader.ReadNext();
60,045✔
2065
                        }
60,045✔
2066

2067
                        return reactors;
52,761✔
2068
                }
52,761✔
2069

2070
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2071
                {
5,210,956✔
2072
                        try
2073
                        {
5,210,956✔
2074
                                //Use this method only if the value is not a link between objects
2075
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
5,210,956✔
2076
                                {
2,785,767✔
2077
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,785,767✔
2078
                                        {
14,790✔
2079
                                                return true;
14,790✔
2080
                                        }
2081

2082
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,770,977✔
2083
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,770,977✔
2084
                                        {
17,370✔
2085
                                                return false;
17,370✔
2086
                                        }
2087

2088
                                        object value = this._reader.Value;
2,753,607✔
2089

2090
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,753,607✔
2091
                                        {
29,312✔
2092
                                                value = MathHelper.DegToRad((double)value);
29,312✔
2093
                                        }
29,312✔
2094

2095
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,753,607✔
2096

2097
                                        return true;
2,753,607✔
2098
                                }
2099
                        }
2,425,189✔
2100
                        catch (Exception ex)
×
2101
                        {
×
2102
                                if (!this._builder.Configuration.Failsafe)
×
2103
                                {
×
2104
                                        throw ex;
×
2105
                                }
2106
                                else
2107
                                {
×
2108
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2109
                                }
×
2110
                        }
×
2111

2112
                        return false;
2,425,189✔
2113
                }
5,210,956✔
2114
        }
2115
}
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