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

DomCR / ACadSharp / 20135018812

11 Dec 2025 01:38PM UTC coverage: 77.615% (-0.3%) from 77.865%
20135018812

Pull #877

github

web-flow
Merge eff277e86 into 945ffe15e
Pull Request #877: Test refactor

7569 of 10567 branches covered (71.63%)

Branch coverage included in aggregate %.

3 of 9 new or added lines in 2 files covered. (33.33%)

161 existing lines in 34 files now uncovered.

28037 of 35308 relevant lines covered (79.41%)

161872.8 hits per line

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

81.49
/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 System;
8
using System.Collections.Generic;
9
using System.Diagnostics;
10
using System.Linq;
11
using static ACadSharp.IO.Templates.CadMLeaderAnnotContextTemplate;
12

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

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

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

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

31
                public abstract void Read();
32

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

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

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

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

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

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

113
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
114
                {
930,515✔
115
                        isExtendedData = false;
930,515✔
116

117
                        switch (this._reader.Code)
930,515✔
118
                        {
119
                                //Handle
120
                                case 5:
121
                                        template.CadObject.Handle = this._reader.ValueAsHandle;
349,134✔
122
                                        break;
349,134✔
123
                                //Check with mapper
124
                                case 100:
125
                                        if (map != null && !map.SubClasses.ContainsKey(this._reader.ValueAsString))
238,614!
126
                                        {
1,708✔
127
                                                this._builder.Notify($"[{template.CadObject.ObjectName}] Unidentified subclass {this._reader.ValueAsString}", NotificationType.Warning);
1,708✔
128
                                        }
1,708✔
129
                                        break;
238,614✔
130
                                //Start of application - defined group
131
                                case 102:
132
                                        this.readDefinedGroups(template);
78,428✔
133
                                        break;
78,428✔
134
                                //Soft - pointer ID / handle to owner BLOCK_RECORD object
135
                                case 330:
136
                                        template.OwnerHandle = this._reader.ValueAsHandle;
194,920✔
137
                                        break;
194,920✔
138
                                case 1001:
139
                                        isExtendedData = true;
27,181✔
140
                                        this.readExtendedData(template.EDataTemplateByAppName);
27,181✔
141
                                        break;
27,181✔
142
                                default:
143
                                        this._builder.Notify($"[{template.CadObject.SubclassMarker}] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
42,238✔
144
                                        break;
42,238✔
145
                        }
146
                }
930,515✔
147

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

237
                                        this._reader.ReadNext();
×
238

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

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

252
                                        return unknownEntityTemplate;
×
253
                        }
254
                }
176,134✔
255

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

261
                        DxfMap map = DxfMap.Create<T>();
230,520✔
262

263
                        while (this._reader.DxfCode != DxfCode.Start)
3,121,658✔
264
                        {
2,891,138✔
265
                                if (!readEntity(template, map))
2,891,138✔
266
                                {
1,019,244✔
267
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
1,019,244✔
268
                                        if (isExtendedData)
1,019,244✔
269
                                                continue;
16,010✔
270
                                }
1,003,234✔
271

272
                                if (this.lockPointer)
2,875,128✔
273
                                {
3,360✔
274
                                        this.lockPointer = false;
3,360✔
275
                                        continue;
3,360✔
276
                                }
277

278
                                if (this._reader.DxfCode != DxfCode.Start)
2,871,768✔
279
                                        this._reader.ReadNext();
2,871,210✔
280
                        }
2,871,768✔
281

282
                        return template;
230,520✔
283
                }
230,520✔
284

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

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

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

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

348
                        switch (this._reader.Code)
42,222✔
349
                        {
350
                                case 40:
351
                                        double radius = this._reader.ValueAsDouble;
4,382✔
352
                                        if (radius <= 0)
4,382!
353
                                        {
×
354
                                                circle.Radius = MathHelper.Epsilon;
×
355
                                        }
×
356
                                        else
357
                                        {
4,382✔
358
                                                circle.Radius = radius;
4,382✔
359
                                        }
4,382✔
360
                                        return true;
4,382✔
361
                                default:
362
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Circle]);
37,840✔
363
                        }
364
                }
42,222✔
365

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

879
                        return template;
12,388✔
880
                }
12,388✔
881

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

886
                        switch (this._reader.Code)
88,952✔
887
                        {
888
                                //DXF: always 0
889
                                //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)
890
                                case 10:
891
                                case 20:
892
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
893
                                case 66:
894
                                //Polygon mesh M vertex count (optional; default = 0)
895
                                case 71:
896
                                //Polygon mesh N vertex count(optional; default = 0)
897
                                case 72:
898
                                //Smooth surface M density(optional; default = 0)
899
                                case 73:
900
                                //Smooth surface N density (optional; default = 0)
901
                                case 74:
902
                                        return true;
37,724✔
903
                                case 100:
904
                                        switch (this._reader.ValueAsString)
960!
905
                                        {
906
                                                case DxfSubclassMarker.Polyline:
907
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
908
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
909
                                                        return true;
×
910
                                                case DxfSubclassMarker.Polyline3d:
911
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
912
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
913
                                                        return true;
240✔
914
                                                case DxfSubclassMarker.PolyfaceMesh:
915
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
916
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
917
                                                        return true;
240✔
918
                                                default:
919
                                                        return false;
480✔
920
                                        }
921
                                default:
922
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,268✔
923
                        }
924
                }
88,952✔
925

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

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

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

965
                        LwPolyline.Vertex last = tmp.CadObject.Vertices.LastOrDefault();
102,456✔
966

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1128
                        switch (this._reader.Code)
62,400✔
1129
                        {
1130
                                // 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.
1131
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1132
                                case 2:
1133
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1134
                                        return true;
720✔
1135
                                case 72:
1136
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1137
                                        return true;
720✔
1138
                                case 73:
1139
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1140
                                        return true;
720✔
1141
                                case 340:
1142
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1143
                                        return true;
720✔
1144
                                default:
1145
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1146
                                        {
10,080✔
1147
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1148
                                        }
1149
                                        return true;
49,440✔
1150
                        }
1151
                }
62,400✔
1152

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1351
                private bool readOle2Frame(CadEntityTemplate template, DxfMap map, string subclass = null)
1352
                {
×
1353
                        CadOle2FrameTemplate tmp = template as CadOle2FrameTemplate;
×
1354

1355
                        switch (this._reader.Code)
×
1356
                        {
1357
                                //End of data
1358
                                case 1:
1359
                                //Length of binary data
1360
                                case 90:
1361
                                //Undocumented
1362
                                case 73:
1363
                                        return true;
×
1364
                                case 310:
1365
                                        tmp.Chunks.Add(this._reader.ValueAsBinaryChunk);
×
1366
                                        return true;
×
1367
                                default:
1368
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1369
                        }
1370
                }
×
1371

1372
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1373
                {
342,410✔
1374
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
342,410✔
1375
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1376
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1377

1378
                        switch (this._reader.Code)
342,410✔
1379
                        {
1380
                                case 1:
1381
                                case 3:
1382
                                        geometry.ProprietaryData.AppendLine(this._reader.ValueAsString);
44,360✔
1383
                                        return true;
44,360✔
1384
                                case 2:
1385
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1386
                                        return true;
240✔
1387
                                case 290:
1388
                                        return true;
240✔
1389
                                default:
1390
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
297,570✔
1391
                        }
1392
                }
342,410✔
1393

1394
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1395
                {
41,040✔
1396
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1397

1398
                        switch (this._reader.Code)
41,040✔
1399
                        {
1400
                                case 350:
1401
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1402
                                        return true;
320✔
1403
                                default:
1404
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1405
                        }
1406
                }
41,040✔
1407

1408
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1409
                {
16,800✔
1410
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1411

1412
                        XYZ controlPoint;
1413
                        XYZ fitPoint;
1414

1415
                        switch (this._reader.Code)
16,800!
1416
                        {
1417
                                case 10:
1418
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1419
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1420
                                        return true;
1,920✔
1421
                                case 20:
1422
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1423
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1424
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1425
                                        return true;
1,920✔
1426
                                case 30:
1427
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1428
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1429
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1430
                                        return true;
1,920✔
1431
                                case 11:
1432
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1433
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1434
                                        return true;
×
1435
                                case 21:
1436
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1437
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1438
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1439
                                        return true;
×
1440
                                case 31:
1441
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1442
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1443
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1444
                                        return true;
×
1445
                                case 40:
1446
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1447
                                        return true;
3,840✔
1448
                                case 41:
1449
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1450
                                        return true;
×
1451
                                case 72:
1452
                                case 73:
1453
                                case 74:
1454
                                        return true;
1,440✔
1455
                                default:
1456
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1457
                        }
1458
                }
16,800✔
1459

1460
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1461
                        where T : PdfUnderlayDefinition
1462
                {
3,800✔
1463
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1464

1465
                        switch (this._reader.Code)
3,800✔
1466
                        {
1467
                                case 340:
1468
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1469
                                        return true;
240✔
1470
                                default:
1471
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1472
                        }
1473
                }
3,800✔
1474

1475
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1476
                {
281,566✔
1477
                        CadVertexTemplate tmp = template as CadVertexTemplate;
281,566✔
1478

1479
                        switch (this._reader.Code)
281,566✔
1480
                        {
1481
                                case 100:
1482
                                        switch (this._reader.ValueAsString)
8,160!
1483
                                        {
1484
                                                case DxfSubclassMarker.Vertex:
1485
                                                        return true;
2,400✔
1486
                                                case DxfSubclassMarker.PolylineVertex:
UNCOV
1487
                                                        tmp.SetVertexObject(new Vertex2D());
×
UNCOV
1488
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
UNCOV
1489
                                                        return true;
×
1490
                                                case DxfSubclassMarker.Polyline3dVertex:
1491
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1492
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1493
                                                        return true;
1,200✔
1494
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1495
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1496
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1497
                                                        return true;
1,200✔
1498
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1499
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1500
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1501
                                                        return true;
480✔
1502
                                                default:
1503
                                                        return false;
2,880✔
1504
                                        }
1505
                                default:
1506
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
273,406✔
1507
                        }
1508
                }
281,566✔
1509

1510
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1511
                {
80,456✔
1512
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1513

1514
                        switch (this._reader.Code)
80,456!
1515
                        {
1516
                                //Undocumented
1517
                                case 67:
1518
                                case 68:
1519
                                        return true;
2,944✔
1520
                                case 69:
1521
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1522
                                        return true;
1,472✔
1523
                                case 331:
UNCOV
1524
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
UNCOV
1525
                                        return true;
×
1526
                                case 348:
1527
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1528
                                        return true;
928✔
1529
                                default:
1530
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1531
                        }
1532
                }
80,456✔
1533

1534
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1535
                {
961,320✔
1536
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
961,320✔
1537

1538
                        switch (this._reader.Code)
961,320✔
1539
                        {
1540
                                default:
1541
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
961,320✔
1542
                        }
1543
                }
961,320✔
1544

1545
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1546
                {
40,167✔
1547
                        List<ExtendedDataRecord> records = new();
40,167✔
1548
                        edata.Add(this._reader.ValueAsString, records);
40,167✔
1549

1550
                        this._reader.ReadNext();
40,167✔
1551

1552
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,956✔
1553
                        {
301,555✔
1554
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
301,555✔
1555
                                {
12,766✔
1556
                                        this.readExtendedData(edata);
12,766✔
1557
                                        break;
12,766✔
1558
                                }
1559

1560
                                ExtendedDataRecord record = null;
288,789✔
1561
                                double x = 0;
288,789✔
1562
                                double y = 0;
288,789✔
1563
                                double z = 0;
288,789✔
1564

1565
                                switch (this._reader.DxfCode)
288,789✔
1566
                                {
1567
                                        case DxfCode.ExtendedDataAsciiString:
1568
                                        case DxfCode.ExtendedDataRegAppName:
1569
                                                record = new ExtendedDataString(this._reader.ValueAsString);
27,714✔
1570
                                                break;
27,714✔
1571
                                        case DxfCode.ExtendedDataControlString:
1572
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1573
                                                break;
15,848✔
1574
                                        case DxfCode.ExtendedDataLayerName:
1575
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1576
                                                {
266✔
1577
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1578
                                                }
266✔
1579
                                                else
1580
                                                {
14✔
1581
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1582
                                                }
14✔
1583
                                                break;
280✔
1584
                                        case DxfCode.ExtendedDataBinaryChunk:
1585
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1586
                                                break;
80✔
1587
                                        case DxfCode.ExtendedDataHandle:
1588
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1589
                                                break;
2,958✔
1590
                                        case DxfCode.ExtendedDataXCoordinate:
1591
                                                x = this._reader.ValueAsDouble;
2,984✔
1592
                                                this._reader.ReadNext();
2,984✔
1593
                                                y = this._reader.ValueAsDouble;
2,984✔
1594
                                                this._reader.ReadNext();
2,984✔
1595
                                                z = this._reader.ValueAsDouble;
2,984✔
1596

1597
                                                record = new ExtendedDataCoordinate(
2,984✔
1598
                                                        new XYZ(
2,984✔
1599
                                                                x,
2,984✔
1600
                                                                y,
2,984✔
1601
                                                                z)
2,984✔
1602
                                                        );
2,984✔
1603
                                                break;
2,984✔
1604
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1605
                                                x = this._reader.ValueAsDouble;
1,440✔
1606
                                                this._reader.ReadNext();
1,440✔
1607
                                                y = this._reader.ValueAsDouble;
1,440✔
1608
                                                this._reader.ReadNext();
1,440✔
1609
                                                z = this._reader.ValueAsDouble;
1,440✔
1610

1611
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1612
                                                        new XYZ(
1,440✔
1613
                                                                x,
1,440✔
1614
                                                                y,
1,440✔
1615
                                                                z)
1,440✔
1616
                                                        );
1,440✔
1617
                                                break;
1,440✔
1618
                                        case DxfCode.ExtendedDataWorldXDisp:
1619
                                                x = this._reader.ValueAsDouble;
280✔
1620
                                                this._reader.ReadNext();
280✔
1621
                                                y = this._reader.ValueAsDouble;
280✔
1622
                                                this._reader.ReadNext();
280✔
1623
                                                z = this._reader.ValueAsDouble;
280✔
1624

1625
                                                record = new ExtendedDataDisplacement(
280✔
1626
                                                        new XYZ(
280✔
1627
                                                                x,
280✔
1628
                                                                y,
280✔
1629
                                                                z)
280✔
1630
                                                        );
280✔
1631
                                                break;
280✔
1632
                                        case DxfCode.ExtendedDataWorldXDir:
1633
                                                x = this._reader.ValueAsDouble;
280✔
1634
                                                this._reader.ReadNext();
280✔
1635
                                                y = this._reader.ValueAsDouble;
280✔
1636
                                                this._reader.ReadNext();
280✔
1637
                                                z = this._reader.ValueAsDouble;
280✔
1638

1639
                                                record = new ExtendedDataDirection(
280✔
1640
                                                        new XYZ(
280✔
1641
                                                                x,
280✔
1642
                                                                y,
280✔
1643
                                                                z)
280✔
1644
                                                        );
280✔
1645
                                                break;
280✔
1646
                                        case DxfCode.ExtendedDataReal:
1647
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1648
                                                break;
140,536✔
1649
                                        case DxfCode.ExtendedDataDist:
1650
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1651
                                                break;
280✔
1652
                                        case DxfCode.ExtendedDataScale:
1653
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1654
                                                break;
280✔
1655
                                        case DxfCode.ExtendedDataInteger16:
1656
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
82,053✔
1657
                                                break;
82,053✔
1658
                                        case DxfCode.ExtendedDataInteger32:
1659
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
11,216✔
1660
                                                break;
11,216✔
1661
                                        default:
1662
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1663
                                                break;
2,560✔
1664
                                }
1665

1666
                                if (record != null)
288,789✔
1667
                                {
286,215✔
1668
                                        records.Add(record);
286,215✔
1669
                                }
286,215✔
1670

1671
                                this._reader.ReadNext();
288,789✔
1672
                        }
288,789✔
1673
                }
40,167✔
1674

1675
                private void readPattern(HatchPattern pattern, int nlines)
1676
                {
1,440✔
1677
                        //Jump 78 code
1678
                        this._reader.ReadNext();
1,440✔
1679

1680
                        for (int i = 0; i < nlines; i++)
218,400✔
1681
                        {
107,760✔
1682
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1683
                                XY basePoint = new XY();
107,760✔
1684
                                XY offset = new XY();
107,760✔
1685

1686
                                bool end = false;
107,760✔
1687
                                HashSet<int> codes = new();
107,760✔
1688

1689
                                while (!end)
755,760✔
1690
                                {
754,320✔
1691
                                        if (codes.Contains(this._reader.Code))
754,320✔
1692
                                        {
106,320✔
1693
                                                break;
106,320✔
1694
                                        }
1695
                                        else
1696
                                        {
648,000✔
1697
                                                codes.Add(this._reader.Code);
648,000✔
1698
                                        }
648,000✔
1699

1700
                                        switch (this._reader.Code)
648,000!
1701
                                        {
1702
                                                case 53:
1703
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1704
                                                        break;
107,760✔
1705
                                                case 43:
1706
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1707
                                                        break;
107,760✔
1708
                                                case 44:
1709
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1710
                                                        line.BasePoint = basePoint;
107,760✔
1711
                                                        break;
107,760✔
1712
                                                case 45:
1713
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1714
                                                        line.Offset = offset;
107,760✔
1715
                                                        break;
107,760✔
1716
                                                case 46:
1717
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1718
                                                        line.Offset = offset;
107,760✔
1719
                                                        break;
107,760✔
1720
                                                //Number of dash length items
1721
                                                case 79:
1722
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1723
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1724
                                                        {
215,040✔
1725
                                                                this._reader.ReadNext();
215,040✔
1726
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1727
                                                        }
215,040✔
1728
                                                        break;
107,760✔
1729
                                                case 49:
UNCOV
1730
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
UNCOV
1731
                                                        break;
×
1732
                                                default:
1733
                                                        end = true;
1,440✔
1734
                                                        break;
1,440✔
1735
                                        }
1736
                                        this._reader.ReadNext();
648,000✔
1737
                                }
648,000✔
1738

1739
                                pattern.Lines.Add(line);
107,760✔
1740
                        }
107,760✔
1741
                }
1,440✔
1742

1743
                private void readLoops(CadHatchTemplate template, int count)
1744
                {
1,920✔
1745
                        if (this._reader.Code == 91)
1,920✔
1746
                                this._reader.ReadNext();
1,920✔
1747

1748
                        for (int i = 0; i < count; i++)
7,680✔
1749
                        {
1,920✔
1750
                                if (this._reader.Code != 92)
1,920!
UNCOV
1751
                                {
×
UNCOV
1752
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
UNCOV
1753
                                        break;
×
1754
                                }
1755

1756
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1757
                                if (path != null)
1,920✔
1758
                                        template.PathTemplates.Add(path);
1,920✔
1759
                        }
1,920✔
1760
                }
1,920✔
1761

1762
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1763
                {
1,920✔
1764
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1765
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1766
                        template.Path.Flags = flags;
1,920✔
1767

1768
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1769
                        {
720✔
1770
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1771
                                template.Path.Edges.Add(pl);
720✔
1772
                        }
720✔
1773
                        else
1774
                        {
1,200✔
1775
                                this._reader.ReadNext();
1,200✔
1776

1777
                                if (this._reader.Code != 93)
1,200!
UNCOV
1778
                                {
×
UNCOV
1779
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
UNCOV
1780
                                        return null;
×
1781
                                }
1782

1783
                                int edges = this._reader.ValueAsInt;
1,200✔
1784
                                this._reader.ReadNext();
1,200✔
1785

1786
                                for (int i = 0; i < edges; i++)
12,000✔
1787
                                {
4,800✔
1788
                                        var edge = this.readEdge();
4,800✔
1789
                                        if (edge != null)
4,800✔
1790
                                                template.Path.Edges.Add(edge);
4,800✔
1791
                                }
4,800✔
1792
                        }
1,200✔
1793

1794
                        bool end = false;
1,920✔
1795
                        while (!end)
7,440✔
1796
                        {
5,520✔
1797
                                switch (this._reader.Code)
5,520✔
1798
                                {
1799
                                        //Number of source boundary objects
1800
                                        case 97:
1801
                                                break;
1,920✔
1802
                                        case 330:
1803
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1804
                                                break;
1,680✔
1805
                                        default:
1806
                                                end = true;
1,920✔
1807
                                                continue;
1,920✔
1808
                                }
1809

1810
                                this._reader.ReadNext();
3,600✔
1811
                        }
3,600✔
1812

1813
                        return template;
1,920✔
1814
                }
1,920✔
1815

1816
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1817
                {
720✔
1818
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1819

1820
                        this._reader.ReadNext();
720✔
1821

1822
                        if (this._reader.Code != 72)
720!
UNCOV
1823
                        {
×
UNCOV
1824
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
UNCOV
1825
                                return null;
×
1826
                        }
1827

1828
                        //72
1829
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1830
                        this._reader.ReadNext();
720✔
1831

1832
                        //73
1833
                        bool isClosed = this._reader.ValueAsBool;
720✔
1834
                        this._reader.ReadNext();
720✔
1835

1836
                        //93
1837
                        int nvertices = this._reader.ValueAsInt;
720✔
1838
                        this._reader.ReadNext();
720✔
1839

1840
                        for (int i = 0; i < nvertices; i++)
7,200✔
1841
                        {
2,880✔
1842
                                double bulge = 0.0;
2,880✔
1843

1844
                                //10
1845
                                double x = this._reader.ValueAsDouble;
2,880✔
1846
                                this._reader.ReadNext();
2,880✔
1847
                                //20
1848
                                double y = this._reader.ValueAsDouble;
2,880✔
1849
                                this._reader.ReadNext();
2,880✔
1850

1851
                                if (hasBulge)
2,880!
UNCOV
1852
                                {
×
1853
                                        //42
UNCOV
1854
                                        bulge = this._reader.ValueAsDouble;
×
UNCOV
1855
                                        this._reader.ReadNext();
×
UNCOV
1856
                                }
×
1857

1858
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1859
                        }
2,880✔
1860

1861
                        return boundary;
720✔
1862
                }
720✔
1863

1864
                private Hatch.BoundaryPath.Edge readEdge()
1865
                {
4,800✔
1866
                        if (this._reader.Code != 72)
4,800!
UNCOV
1867
                        {
×
UNCOV
1868
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
UNCOV
1869
                                return null;
×
1870
                        }
1871

1872
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1873
                        this._reader.ReadNext();
4,800✔
1874

1875
                        switch (type)
4,800!
1876
                        {
1877
                                case Hatch.BoundaryPath.EdgeType.Line:
1878
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1879
                                        while (true)
24,000✔
1880
                                        {
24,000✔
1881
                                                switch (this._reader.Code)
24,000✔
1882
                                                {
1883
                                                        case 10:
1884
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1885
                                                                break;
4,800✔
1886
                                                        case 20:
1887
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1888
                                                                break;
4,800✔
1889
                                                        case 11:
1890
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1891
                                                                break;
4,800✔
1892
                                                        case 21:
1893
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1894
                                                                break;
4,800✔
1895
                                                        default:
1896
                                                                return line;
4,800✔
1897
                                                }
1898

1899
                                                this._reader.ReadNext();
19,200✔
1900
                                        }
19,200✔
1901
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
UNCOV
1902
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
UNCOV
1903
                                        while (true)
×
UNCOV
1904
                                        {
×
UNCOV
1905
                                                switch (this._reader.Code)
×
1906
                                                {
1907
                                                        case 10:
1908
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1909
                                                                break;
×
1910
                                                        case 20:
1911
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
UNCOV
1912
                                                                break;
×
1913
                                                        case 40:
1914
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1915
                                                                break;
×
1916
                                                        case 50:
1917
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1918
                                                                break;
×
1919
                                                        case 51:
1920
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1921
                                                                break;
×
1922
                                                        case 73:
1923
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1924
                                                                break;
×
1925
                                                        default:
1926
                                                                return arc;
×
1927
                                                }
1928

1929
                                                this._reader.ReadNext();
×
1930
                                        }
×
1931
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1932
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
UNCOV
1933
                                        while (true)
×
UNCOV
1934
                                        {
×
1935
                                                switch (this._reader.Code)
×
1936
                                                {
1937
                                                        case 10:
1938
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1939
                                                                break;
×
1940
                                                        case 20:
1941
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
UNCOV
1942
                                                                break;
×
1943
                                                        case 11:
1944
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1945
                                                                break;
×
1946
                                                        case 21:
1947
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1948
                                                                break;
×
1949
                                                        case 40:
1950
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1951
                                                                break;
×
1952
                                                        case 50:
1953
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1954
                                                                break;
×
1955
                                                        case 51:
1956
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1957
                                                                break;
×
1958
                                                        case 73:
1959
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1960
                                                                break;
×
1961
                                                        default:
1962
                                                                return ellipse;
×
1963
                                                }
1964

1965
                                                this._reader.ReadNext();
×
1966
                                        }
×
1967
                                case Hatch.BoundaryPath.EdgeType.Spline:
1968
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
UNCOV
1969
                                        int nKnots = 0;
×
UNCOV
1970
                                        int nCtrlPoints = 0;
×
1971
                                        int nFitPoints = 0;
×
1972

UNCOV
1973
                                        XYZ controlPoint = new XYZ();
×
1974
                                        XY fitPoint = new XY();
×
1975

1976
                                        while (true)
×
1977
                                        {
×
UNCOV
1978
                                                switch (this._reader.Code)
×
1979
                                                {
1980
                                                        case 10:
UNCOV
1981
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1982
                                                                break;
×
1983
                                                        case 20:
1984
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
UNCOV
1985
                                                                spline.ControlPoints.Add(controlPoint);
×
UNCOV
1986
                                                                break;
×
1987
                                                        case 11:
1988
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
UNCOV
1989
                                                                break;
×
1990
                                                        case 21:
1991
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1992
                                                                spline.FitPoints.Add(fitPoint);
×
UNCOV
1993
                                                                break;
×
1994
                                                        case 42:
1995
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
UNCOV
1996
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1997
                                                                break;
×
1998
                                                        case 12:
1999
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
UNCOV
2000
                                                                break;
×
2001
                                                        case 22:
2002
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
2003
                                                                break;
×
2004
                                                        case 13:
2005
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
2006
                                                                break;
×
2007
                                                        case 23:
2008
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
2009
                                                                break;
×
2010
                                                        case 94:
2011
                                                                spline.Degree = this._reader.ValueAsInt;
×
2012
                                                                break;
×
2013
                                                        case 73:
2014
                                                                spline.Rational = this._reader.ValueAsBool;
×
2015
                                                                break;
×
2016
                                                        case 74:
2017
                                                                spline.Periodic = this._reader.ValueAsBool;
×
2018
                                                                break;
×
2019
                                                        case 95:
2020
                                                                nKnots = this._reader.ValueAsInt;
×
2021
                                                                break;
×
2022
                                                        case 96:
2023
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
2024
                                                                break;
×
2025
                                                        case 97:
2026
                                                                nFitPoints = this._reader.ValueAsInt;
×
2027
                                                                break;
×
2028
                                                        case 40:
2029
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
2030
                                                                break;
×
2031
                                                        default:
2032
                                                                return spline;
×
2033
                                                }
2034

2035
                                                this._reader.ReadNext();
×
2036
                                        }
×
2037
                        }
2038

UNCOV
2039
                        return null;
×
2040
                }
4,800✔
2041

2042
                private void readDefinedGroups(CadTemplate template)
2043
                {
79,112✔
2044
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
79,112✔
2045

2046
                        template.XDictHandle = xdict;
79,112✔
2047
                        template.ReactorsHandles.UnionWith(reactorsHandles);
79,112✔
2048
                }
79,112✔
2049

2050
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
2051
                {
79,354✔
2052
                        xdictHandle = null;
79,354✔
2053
                        reactors = new HashSet<ulong>();
79,354✔
2054

2055
                        switch (this._reader.ValueAsString)
79,354✔
2056
                        {
2057
                                case DxfFileToken.DictionaryToken:
2058
                                        this._reader.ReadNext();
11,615✔
2059
                                        xdictHandle = this._reader.ValueAsHandle;
11,615✔
2060
                                        this._reader.ReadNext();
11,615✔
2061
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
11,615✔
2062
                                        return;
11,615✔
2063
                                case DxfFileToken.ReactorsToken:
2064
                                        reactors = this.readReactors();
65,339✔
2065
                                        break;
65,339✔
2066
                                case DxfFileToken.BlkRefToken:
2067
                                default:
2068
                                        do
2069
                                        {
6,240✔
2070
                                                this._reader.ReadNext();
6,240✔
2071
                                        }
6,240✔
2072
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2073
                                        return;
2,400✔
2074
                        }
2075
                }
79,354✔
2076

2077
                private HashSet<ulong> readReactors()
2078
                {
65,339✔
2079
                        HashSet<ulong> reactors = new();
65,339✔
2080

2081
                        this._reader.ReadNext();
65,339✔
2082

2083
                        while (this._reader.DxfCode != DxfCode.ControlString)
137,962✔
2084
                        {
72,623✔
2085
                                this._reader.ReadNext();
72,623✔
2086
                        }
72,623✔
2087

2088
                        return reactors;
65,339✔
2089
                }
65,339✔
2090

2091
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2092
                {
4,975,356✔
2093
                        try
2094
                        {
4,975,356✔
2095
                                //Use this method only if the value is not a link between objects
2096
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
4,975,356✔
2097
                                {
2,665,857✔
2098
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,665,857✔
2099
                                        {
14,790✔
2100
                                                return true;
14,790✔
2101
                                        }
2102

2103
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,651,067✔
2104
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,651,067✔
2105
                                        {
17,410✔
2106
                                                return false;
17,410✔
2107
                                        }
2108

2109
                                        object value = this._reader.Value;
2,633,657✔
2110

2111
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,633,657✔
2112
                                        {
29,312✔
2113
                                                value = MathHelper.DegToRad((double)value);
29,312✔
2114
                                        }
29,312✔
2115

2116
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,633,657✔
2117

2118
                                        return true;
2,633,657✔
2119
                                }
2120
                        }
2,309,499✔
UNCOV
2121
                        catch (Exception ex)
×
UNCOV
2122
                        {
×
UNCOV
2123
                                if (!this._builder.Configuration.Failsafe)
×
UNCOV
2124
                                {
×
UNCOV
2125
                                        throw ex;
×
2126
                                }
2127
                                else
2128
                                {
×
2129
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2130
                                }
×
2131
                        }
×
2132

2133
                        return false;
2,309,499✔
2134
                }
4,975,356✔
2135
        }
2136
}
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