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

DomCR / ACadSharp / 18814871545

26 Oct 2025 07:36AM UTC coverage: 78.074% (+0.2%) from 77.923%
18814871545

Pull #831

github

web-flow
Merge a09dc8e36 into f84cb1d2a
Pull Request #831: Table entity refactor

7323 of 10163 branches covered (72.06%)

Branch coverage included in aggregate %.

717 of 843 new or added lines in 16 files covered. (85.05%)

13 existing lines in 4 files now uncovered.

27305 of 34190 relevant lines covered (79.86%)

107186.93 hits per line

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

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

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

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

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

29
                public abstract void Read();
30

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

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

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

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

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

107
                                this._reader.ReadNext();
2,052✔
108
                        }
2,052✔
109
                }
684✔
110

111
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
112
                {
1,198,197✔
113
                        isExtendedData = false;
1,198,197✔
114

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

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

233
                                        this._reader.ReadNext();
×
234

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

244
                                                this._reader.ReadNext();
×
245
                                        }
×
246
                                        while (this._reader.DxfCode != DxfCode.Start);
×
247

248
                                        return unknownEntityTemplate;
×
249
                        }
250
                }
228,486✔
251

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

257
                        DxfMap map = DxfMap.Create<T>();
228,564✔
258

259
                        while (this._reader.DxfCode != DxfCode.Start)
3,097,294✔
260
                        {
2,868,730✔
261
                                if (!readEntity(template, map))
2,868,730✔
262
                                {
1,239,036✔
263
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
1,239,036✔
264
                                        if (isExtendedData)
1,239,036✔
265
                                                continue;
16,010✔
266
                                }
1,223,026✔
267

268
                                if (this._reader.DxfCode != DxfCode.Start)
2,852,720✔
269
                                        this._reader.ReadNext();
2,852,162✔
270
                        }
2,852,720✔
271

272
                        return template;
228,564✔
273
                }
228,564✔
274

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

310
                protected bool checkObjectEnd(CadTemplate template, DxfMap map, Func<CadTemplate, DxfMap, bool> func)
311
                {
760✔
312
                        if (this._reader.DxfCode == DxfCode.Start)
760✔
313
                        {
532✔
314
                                return true;
532✔
315
                        }
316
                        else
317
                        {
228✔
318
                                return func.Invoke(template, map);
228✔
319
                        }
320
                }
760✔
321

322
                protected bool checkEntityEnd(CadEntityTemplate template, DxfMap map, string subclass, Func<CadEntityTemplate, DxfMap, string, bool> func)
323
                {
480✔
324
                        if (this._reader.DxfCode == DxfCode.Start)
480!
325
                        {
480✔
326
                                return true;
480✔
327
                        }
328
                        else
329
                        {
×
330
                                return func.Invoke(template, map, subclass);
×
331
                        }
332
                }
480✔
333

334
                private bool readArc(CadEntityTemplate template, DxfMap map, string subclass = null)
335
                {
10,648✔
336
                        switch (this._reader.Code)
10,648✔
337
                        {
338
                                default:
339
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Arc]))
10,648✔
340
                                        {
9,024✔
341
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.Circle);
9,024✔
342
                                        }
343
                                        return true;
1,624✔
344
                        }
345
                }
10,648✔
346

347
                private bool readAttributeDefinition(CadEntityTemplate template, DxfMap map, string subclass = null)
348
                {
39,546✔
349
                        DxfClassMap emap = map.SubClasses[template.CadObject.SubclassMarker];
39,546✔
350
                        CadAttributeTemplate tmp = template as CadAttributeTemplate;
39,546✔
351

352
                        switch (this._reader.Code)
39,546!
353
                        {
354
                                case 44:
355
                                case 46:
356
                                        return true;
×
357
                                case 101:
358
                                        var att = tmp.CadObject as AttributeBase;
78✔
359
                                        att.MText = new MText();
78✔
360
                                        CadTextEntityTemplate mtextTemplate = new CadTextEntityTemplate(att.MText);
78✔
361
                                        tmp.MTextTemplate = mtextTemplate;
78✔
362
                                        this.readEntityCodes<MText>(mtextTemplate, this.readTextEntity);
78✔
363
                                        return true;
78✔
364
                                default:
365
                                        if (!this.tryAssignCurrentValue(template.CadObject, emap))
39,468✔
366
                                        {
29,858✔
367
                                                return this.readTextEntity(template, map, DxfSubclassMarker.Text);
29,858✔
368
                                        }
369
                                        return true;
9,610✔
370
                        }
371
                }
39,546✔
372

373
                private bool readTableEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
374
                {
158,040✔
375
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
158,040!
376
                        CadTableEntityTemplate tmp = template as CadTableEntityTemplate;
158,040✔
377
                        TableEntity table = tmp.CadObject as TableEntity;
158,040✔
378

379
                        switch (this._reader.Code)
158,040!
380
                        {
381
                                //Border overrides:
382
                                case 279:
383
                                        //Lineweight for the top border of the cell; override applied at the cell level
384
                                        tmp.CurrentCell.StyleOverride.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,680✔
385
                                        return true;
1,680✔
386
                                case 275:
387
                                        //Lineweight for the right border of the cell; override applied at the cell level
388
                                        tmp.CurrentCell.StyleOverride.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
480✔
389
                                        return true;
480✔
390
                                case 276:
391
                                        //Lineweight for the bottom border of the cell; override applied at the cell level
NEW
392
                                        tmp.CurrentCell.StyleOverride.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
×
NEW
393
                                        return true;
×
394
                                case 278:
395
                                        //Lineweight for the left border of the cell; override applied at the cell level
396
                                        tmp.CurrentCell.StyleOverride.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,440✔
397
                                        return true;
1,440✔
398
                                case 69:
399
                                        //True color value for the top border of the cell; override applied at the cell level
400
                                        tmp.CurrentCell.StyleOverride.TopBorder.Color = new Color(this._reader.ValueAsShort);
1,680✔
401
                                        return true;
1,680✔
402
                                case 65:
403
                                        //True color value for the right border of the cell; override applied at the cell level
404
                                        tmp.CurrentCell.StyleOverride.RightBorder.Color = new Color(this._reader.ValueAsShort);
480✔
405
                                        return true;
480✔
406
                                case 66:
407
                                        //True color value for the bottom border of the cell; override applied at the cell level
NEW
408
                                        tmp.CurrentCell.StyleOverride.BottomBorder.Color = new Color(this._reader.ValueAsShort);
×
NEW
409
                                        return true;
×
410
                                case 68:
411
                                        //True color value for the left border of the cell; override applied at the cell level
412
                                        tmp.CurrentCell.StyleOverride.LeftBorder.Color = new Color(this._reader.ValueAsShort);
1,440✔
413
                                        return true;
1,440✔
414
                                case 2:
415
                                        tmp.BlockName = this._reader.ValueAsString;
480✔
416
                                        return true;
480✔
417
                                case 40:
418
                                        tmp.HorizontalMargin = this._reader.ValueAsDouble;
240✔
419
                                        return true;
240✔
420
                                case 63:
421
                                        tmp.CurrentCell.StyleOverride.BackgroundColor = new Color(this._reader.ValueAsShort);
240✔
422
                                        return true;
240✔
423
                                case 64:
424
                                        tmp.CurrentCell.StyleOverride.ContentColor = new Color(this._reader.ValueAsShort);
240✔
425
                                        return true;
240✔
426
                                case 140:
427
                                        if (tmp.CurrentCellTemplate != null)
5,760✔
428
                                        {
5,040✔
429
                                                tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
5,040✔
430
                                        }
5,040✔
431
                                        return true;
5,760✔
432
                                case 283:
433
                                        tmp.CurrentCell.StyleOverride.IsFillColorOn = this._reader.ValueAsBool;
240✔
434
                                        return true;
240✔
435
                                case 342:
436
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
480✔
437
                                        return true;
480✔
438
                                case 343:
439
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
480✔
440
                                        return true;
480✔
441
                                case 141:
442
                                        var row = new TableEntity.Row();
2,640✔
443
                                        row.Height = this._reader.ValueAsDouble;
2,640✔
444
                                        table.Rows.Add(row);
2,640✔
445
                                        return true;
2,640✔
446
                                case 142:
447
                                        var col = new TableEntity.Column();
1,920✔
448
                                        col.Width = this._reader.ValueAsDouble;
1,920✔
449
                                        table.Columns.Add(col);
1,920✔
450
                                        return true;
1,920✔
451
                                case 144:
452
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
480✔
453
                                        return true;
480✔
454
                                case 145:
455
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
9,840✔
456
                                        return true;
9,840✔
457
                                case 170:
458
                                        //Has data flag
459
                                        return true;
720✔
460
                                case 171:
461
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
9,840✔
462
                                        return true;
9,840✔
463
                                case 172:
464
                                        tmp.CurrentCell.FlagValue = this._reader.ValueAsInt;
9,840✔
465
                                        return true;
9,840✔
466
                                case 173:
467
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsInt;
9,840✔
468
                                        return true;
9,840✔
469
                                case 174:
470
                                        tmp.CurrentCell.AutoFit = this._reader.ValueAsBool;
9,840✔
471
                                        return true;
9,840✔
472
                                case 175:
473
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
9,840✔
474
                                        return true;
9,840✔
475
                                case 176:
476
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
9,840✔
477
                                        return true;
9,840✔
478
                                case 178:
479
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
9,840✔
480
                                        return true;
9,840✔
481
                                case 179:
482
                                        //Unknown value
483
                                        return true;
480✔
484
                                case 301:
485
                                        var content = new TableEntity.CellContent();
6,560✔
486
                                        tmp.CurrentCell.Contents.Add(content);
6,560✔
487
                                        this.readCellValue(content);
6,560✔
488
                                        return true;
6,560✔
489
                                case 340:
490
                                        tmp.CurrentCellTemplate.BlockRecordHandle = this._reader.ValueAsHandle;
480✔
491
                                        return true;
480✔
492
                                default:
493
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
50,680✔
494
                                        {
49,000✔
495
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
49,000✔
496
                                        }
497
                                        return true;
1,680✔
498
                        }
499
                }
158,040✔
500

501
                private void readCellValue(TableEntity.CellContent content)
502
                {
6,560✔
503
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
504
                        {
6,560✔
505
                                this._reader.ReadNext();
6,560✔
506
                        }
6,560✔
507
                        else
508
                        {
×
509
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
510
                        }
511

512
                        while (this._reader.Code != 304
42,880✔
513
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
42,880✔
514
                        {
36,320✔
515
                                switch (this._reader.Code)
36,320!
516
                                {
517
                                        case 1:
518
                                                content.Value.Text = this._reader.ValueAsString;
1,920✔
519
                                                break;
1,920✔
520
                                        case 2:
521
                                                content.Value.Text += this._reader.ValueAsString;
×
522
                                                break;
×
523
                                        case 11:
524
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
160✔
525
                                                break;
160✔
526
                                        case 21:
527
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
160✔
528
                                                break;
160✔
529
                                        case 31:
530
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
160✔
531
                                                break;
160✔
532
                                        case 302:
533
                                                //TODO: Fix this assignation to cell value
534
                                                content.Value.Value = this._reader.ValueAsString;
6,560✔
535
                                                break;
6,560✔
536
                                        case 90:
537
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
6,560✔
538
                                                break;
6,560✔
539
                                        case 91:
540
                                                content.Value.Value = this._reader.ValueAsInt;
160✔
541
                                                break;
160✔
542
                                        case 92:
543
                                                //Extended cell flags (from AutoCAD 2007)
544
                                                break;
160✔
545
                                        case 93:
546
                                                content.Value.Flags = this._reader.ValueAsInt;
6,560✔
547
                                                break;
6,560✔
548
                                        case 94:
549
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
6,560✔
550
                                                break;
6,560✔
551
                                        case 140:
552
                                                content.Value.Value = this._reader.ValueAsDouble;
640✔
553
                                                break;
640✔
554
                                        case 300:
555
                                                content.Value.Format = this._reader.ValueAsString;
6,560✔
556
                                                break;
6,560✔
557
                                        case 310:
558
                                                //Data for proxy entity graphics (multiple lines; 256-character maximum per line)
559
                                                break;
160✔
560
                                        default:
UNCOV
561
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
UNCOV
562
                                                break;
×
563
                                }
564

565
                                this._reader.ReadNext();
36,320✔
566
                        }
36,320✔
567
                }
6,560✔
568

569
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
570
                {
341,010✔
571
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
341,010✔
572
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
341,010✔
573

574
                        switch (this._reader.Code)
341,010✔
575
                        {
576
                                //TODO: Implement multiline text def codes
577
                                case 1 or 3 when tmp.CadObject is MText mtext:
30,306✔
578
                                        mtext.Value += this._reader.ValueAsString;
11,466✔
579
                                        return true;
11,466✔
580
                                case 50 when tmp.CadObject is MText mtext://Read only for MText
570!
581
                                        double angle = MathHelper.DegToRad(this._reader.ValueAsDouble);
×
582
                                        mtext.AlignmentPoint = new XYZ(System.Math.Cos(angle), System.Math.Sin(angle), 0.0);
×
583
                                        return true;
×
584
                                case 70:
585
                                case 74:
586
                                case 101:
587
                                        return true;
480✔
588
                                case 7:
589
                                        tmp.StyleName = this._reader.ValueAsString;
3,080✔
590
                                        return true;
3,080✔
591
                                default:
592
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
325,984✔
593
                        }
594
                }
341,010✔
595

596
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
597
                {
7,200✔
598
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
599

600
                        switch (this._reader.Code)
7,200✔
601
                        {
602
                                case 3:
603
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
604
                                        return true;
720✔
605
                                default:
606
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
607
                        }
608
                }
7,200✔
609

610
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
611
                {
80,560✔
612
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
613

614
                        switch (this._reader.Code)
80,560✔
615
                        {
616
                                case 2:
617
                                        tmp.BlockName = this._reader.ValueAsString;
3,080✔
618
                                        return true;
3,080✔
619
                                case 3:
620
                                        tmp.StyleName = this._reader.ValueAsString;
2,640✔
621
                                        return true;
2,640✔
622
                                case 50:
623
                                        var dim = new DimensionLinear();
280✔
624
                                        tmp.SetDimensionObject(dim);
280✔
625
                                        dim.Rotation = this._reader.ValueAsAngle;
280✔
626
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
280✔
627
                                        return true;
280✔
628
                                case 70:
629
                                        //Flags do not have set
630
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
3,080✔
631
                                        return true;
3,080✔
632
                                //Measurement - read only
633
                                case 42:
634
                                        return true;
2,640✔
635
                                //Undocumented codes
636
                                case 73:
637
                                case 74:
638
                                case 75:
639
                                case 90:
640
                                case 361:
641
                                        return true;
5,280✔
642
                                case 100:
643
                                        switch (this._reader.ValueAsString)
8,640✔
644
                                        {
645
                                                case DxfSubclassMarker.Dimension:
646
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
2,640✔
647
                                                case DxfSubclassMarker.AlignedDimension:
648
                                                        tmp.SetDimensionObject(new DimensionAligned());
1,200✔
649
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
1,200✔
650
                                                        return true;
1,200✔
651
                                                case DxfSubclassMarker.DiametricDimension:
652
                                                        tmp.SetDimensionObject(new DimensionDiameter());
240✔
653
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
240✔
654
                                                        return true;
240✔
655
                                                case DxfSubclassMarker.Angular2LineDimension:
656
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
240✔
657
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
240✔
658
                                                        return true;
240✔
659
                                                case DxfSubclassMarker.Angular3PointDimension:
660
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
240✔
661
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
240✔
662
                                                        return true;
240✔
663
                                                case DxfSubclassMarker.RadialDimension:
664
                                                        tmp.SetDimensionObject(new DimensionRadius());
240✔
665
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
240✔
666
                                                        return true;
240✔
667
                                                case DxfSubclassMarker.OrdinateDimension:
668
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
480✔
669
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
480✔
670
                                                        return true;
480✔
671
                                                case DxfSubclassMarker.LinearDimension:
672
                                                        return true;
720✔
673
                                                default:
674
                                                        return false;
2,640✔
675
                                        }
676
                                default:
677
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
54,920✔
678
                        }
679
                }
80,560✔
680

681
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
682
                {
48,000✔
683
                        CadHatchTemplate tmp = template as CadHatchTemplate;
48,000✔
684
                        Hatch hatch = tmp.CadObject;
48,000✔
685

686
                        bool isFirstSeed = true;
48,000✔
687
                        XY seedPoint = new XY();
48,000✔
688

689
                        switch (this._reader.Code)
48,000!
690
                        {
691
                                case 2:
692
                                        hatch.Pattern.Name = this._reader.ValueAsString;
1,920✔
693
                                        return true;
1,920✔
694
                                case 10:
695
                                        seedPoint.X = this._reader.ValueAsDouble;
3,120✔
696
                                        return true;
3,120✔
697
                                case 20:
698
                                        if (!isFirstSeed)
3,840!
699
                                        {
×
700
                                                seedPoint.Y = this._reader.ValueAsDouble;
×
701
                                                hatch.SeedPoints.Add(seedPoint);
×
702
                                        }
×
703
                                        return true;
3,840✔
704
                                case 30:
705
                                        hatch.Elevation = this._reader.ValueAsDouble;
1,920✔
706
                                        isFirstSeed = false;
1,920✔
707
                                        return true;
1,920✔
708
                                case 53:
709
                                        hatch.PatternAngle = this._reader.ValueAsAngle;
×
710
                                        return true;
×
711
                                //TODO: Check hatch undocumented codes
712
                                case 90:
713
                                        return true;
×
714
                                //Information about the hatch pattern
715
                                case 75:
716
                                        return true;
×
717
                                //Number of pattern definition lines
718
                                case 78:
719
                                        this.readPattern(hatch.Pattern, this._reader.ValueAsInt);
1,440✔
720
                                        return true;
1,440✔
721
                                //Number of boundary paths (loops)
722
                                case 91:
723
                                        this.readLoops(tmp, this._reader.ValueAsInt);
1,920✔
724
                                        return true;
1,920✔
725
                                //Number of seed points
726
                                case 98:
727
                                        return true;
480✔
728
                                case 450:
729
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
400✔
730
                                        return true;
400✔
731
                                case 451:
732
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
400✔
733
                                        return true;
400✔
734
                                case 452:
735
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
400✔
736
                                        return true;
400✔
737
                                case 453:
738
                                        //Number of colors
739
                                        return true;
400✔
740
                                case 460:
741
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
400✔
742
                                        return true;
400✔
743
                                case 461:
744
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
400✔
745
                                        return true;
400✔
746
                                case 462:
747
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
400✔
748
                                        return true;
400✔
749
                                case 463:
750
                                        GradientColor gradient = new GradientColor();
800✔
751
                                        gradient.Value = this._reader.ValueAsDouble;
800✔
752
                                        hatch.GradientColor.Colors.Add(gradient);
800✔
753
                                        return true;
800✔
754
                                case 63:
755
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
800✔
756
                                        if (colorByIndex != null)
800✔
757
                                        {
800✔
758
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
800✔
759
                                        }
800✔
760
                                        return true;
800✔
761
                                case 421:
762
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
800✔
763
                                        if (colorByRgb != null)
800✔
764
                                        {
800✔
765
                                                //TODO: Hatch assign color by true color
766
                                                //TODO: Is always duplicated by 63, is it needed??
767
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
768
                                        }
800✔
769
                                        return true;
800✔
770
                                case 470:
771
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
400✔
772
                                        return true;
400✔
773
                                default:
774
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,760✔
775
                        }
776
                }
48,000✔
777

778
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
779
                {
69,626✔
780
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
781

782
                        switch (this._reader.Code)
69,626✔
783
                        {
784
                                case 2:
785
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
786
                                        return true;
6,508✔
787
                                case 100:
788
                                        //AcDbEntity
789
                                        //AcDbBlockReference
790
                                        //AcDbMInsertBlock
791
                                        return true;
6,528✔
792
                                case 66:
793
                                        return true;
560✔
794
                                default:
795
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
796
                        }
797
                }
69,626✔
798

799
                private CadEntityTemplate readPolyline()
800
                {
12,348✔
801
                        CadPolyLineTemplate template = null;
12,348✔
802

803
                        if (this._builder.Version == ACadVersion.Unknown)
12,348!
804
                        {
×
805
                                var polyline = new Polyline2D();
×
806
                                template = new CadPolyLineTemplate(polyline);
×
807
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
×
808

809
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
×
810
                                {
×
811
                                        Vertex2D v = new Vertex2D();
×
812
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
×
813
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
×
814

815
                                        if (vertexTemplate.Vertex.Handle == 0)
×
816
                                        {
×
817
                                                polyline.Vertices.Add(v);
×
818
                                        }
×
819
                                        else
820
                                        {
×
821
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
×
822
                                                this._builder.AddTemplate(vertexTemplate);
×
823
                                        }
×
824
                                }
×
825

826
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
×
827
                                {
×
828
                                        var seqend = new Seqend();
×
829
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
×
830
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
×
831

832
                                        polyline.Vertices.Seqend = seqend;
×
833
                                }
×
834
                        }
×
835
                        else
836
                        {
12,348✔
837
                                template = new CadPolyLineTemplate();
12,348✔
838
                                this.readEntityCodes<Entity>(template, this.readPolyline);
12,348✔
839
                        }
12,348✔
840

841
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,348✔
842
                        {
11,868✔
843
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
11,868✔
844
                                return null;
11,868✔
845
                        }
846

847
                        return template;
480✔
848
                }
12,348✔
849

850
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
851
                {
88,672✔
852
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,672✔
853

854
                        switch (this._reader.Code)
88,672✔
855
                        {
856
                                //DXF: always 0
857
                                //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)
858
                                case 10:
859
                                case 20:
860
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
861
                                case 66:
862
                                //Polygon mesh M vertex count (optional; default = 0)
863
                                case 71:
864
                                //Polygon mesh N vertex count(optional; default = 0)
865
                                case 72:
866
                                //Smooth surface M density(optional; default = 0)
867
                                case 73:
868
                                //Smooth surface N density (optional; default = 0)
869
                                case 74:
870
                                        return true;
37,604✔
871
                                case 100:
872
                                        switch (this._reader.ValueAsString)
960!
873
                                        {
874
                                                case DxfSubclassMarker.Polyline:
875
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
876
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
877
                                                        return true;
×
878
                                                case DxfSubclassMarker.Polyline3d:
879
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
880
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
881
                                                        return true;
240✔
882
                                                case DxfSubclassMarker.PolyfaceMesh:
883
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
884
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
885
                                                        return true;
240✔
886
                                                default:
887
                                                        return false;
480✔
888
                                        }
889
                                default:
890
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,108✔
891
                        }
892
                }
88,672✔
893

894
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
895
                {
6,000✔
896
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
897

898
                        switch (this._reader.Code)
6,000✔
899
                        {
900
                                case 3:
901
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
240✔
902
                                        return true;
240✔
903
                                case 10:
904
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
960✔
905
                                        return true;
960✔
906
                                case 20:
907
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
908
                                        y.Y = this._reader.ValueAsDouble;
960✔
909
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
960✔
910
                                        return true;
960✔
911
                                case 30:
912
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
913
                                        z.Z = this._reader.ValueAsDouble;
960✔
914
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
960✔
915
                                        return true;
960✔
916
                                case 340:
917
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
240✔
918
                                        return true;
240✔
919
                                //Hook line flag - read only
920
                                case 75:
921
                                //Vertices count
922
                                case 76:
923
                                        return true;
480✔
924
                                default:
925
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,160✔
926
                        }
927
                }
6,000✔
928

929
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
930
                {
98,616✔
931
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
98,616✔
932

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

935
                        switch (this._reader.Code)
98,616!
936
                        {
937
                                case 10:
938
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
23,412✔
939
                                        return true;
23,412✔
940
                                case 20:
941
                                        if (last is not null)
23,412✔
942
                                        {
23,412✔
943
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
23,412✔
944
                                        }
23,412✔
945
                                        return true;
23,412✔
946
                                case 40:
947
                                        if (last is not null)
2,400✔
948
                                        {
2,400✔
949
                                                last.StartWidth = this._reader.ValueAsDouble;
2,400✔
950
                                        }
2,400✔
951
                                        return true;
2,400✔
952
                                case 41:
953
                                        if (last is not null)
2,400✔
954
                                        {
2,400✔
955
                                                last.EndWidth = this._reader.ValueAsDouble;
2,400✔
956
                                        }
2,400✔
957
                                        return true;
2,400✔
958
                                case 42:
959
                                        if (last is not null)
3,288✔
960
                                        {
3,288✔
961
                                                last.Bulge = this._reader.ValueAsDouble;
3,288✔
962
                                        }
3,288✔
963
                                        return true;
3,288✔
964
                                case 50:
965
                                        if (last is not null)
×
966
                                        {
×
967
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
968
                                        }
×
969
                                        return true;
×
970
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
971
                                case 66:
972
                                //Vertex count
973
                                case 90:
974
                                        return true;
5,256✔
975
                                case 91:
976
                                        if (last is not null)
×
977
                                        {
×
978
                                                last.Id = this._reader.ValueAsInt;
×
979
                                        }
×
980
                                        return true;
×
981
                                default:
982
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,448✔
983
                        }
984
                }
98,616✔
985

986
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
987
                {
42,240✔
988
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
989

990
                        switch (this._reader.Code)
42,240✔
991
                        {
992
                                case 100:
993
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
994
                                        {
480✔
995
                                                tmp.SubclassMarker = true;
480✔
996
                                        }
480✔
997
                                        return true;
960✔
998
                                //Count of sub-entity which property has been overridden
999
                                case 90:
1000
                                        //TODO: process further entities
1001
                                        return true;
480✔
1002
                                case 92:
1003
                                        if (!tmp.SubclassMarker)
720✔
1004
                                        {
240✔
1005
                                                return false;
240✔
1006
                                        }
1007

1008
                                        int nvertices = this._reader.ValueAsInt;
480✔
1009
                                        for (int i = 0; i < nvertices; i++)
61,440✔
1010
                                        {
30,240✔
1011
                                                this._reader.ReadNext();
30,240✔
1012
                                                double x = this._reader.ValueAsDouble;
30,240✔
1013
                                                this._reader.ReadNext();
30,240✔
1014
                                                double y = this._reader.ValueAsDouble;
30,240✔
1015
                                                this._reader.ReadNext();
30,240✔
1016
                                                double z = this._reader.ValueAsDouble;
30,240✔
1017
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
1018
                                        }
30,240✔
1019
                                        return true;
480✔
1020
                                case 93:
1021
                                        int size = this._reader.ValueAsInt;
480✔
1022
                                        this._reader.ReadNext();
480✔
1023

1024
                                        int indexes = 0;
480✔
1025
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
1026
                                        {
32,640✔
1027
                                                indexes = this._reader.ValueAsInt;
32,640✔
1028
                                                this._reader.ReadNext();
32,640✔
1029

1030
                                                int[] face = new int[indexes];
32,640✔
1031
                                                for (int j = 0; j < indexes; j++)
314,880✔
1032
                                                {
124,800✔
1033
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
1034

1035
                                                        if ((i + j + 2) < size)
124,800✔
1036
                                                        {
124,320✔
1037
                                                                this._reader.ReadNext();
124,320✔
1038
                                                        }
124,320✔
1039
                                                }
124,800✔
1040

1041
                                                tmp.CadObject.Faces.Add(face);
32,640✔
1042
                                        }
32,640✔
1043

1044
                                        Debug.Assert(this._reader.Code == 90);
480✔
1045

1046
                                        return true;
480✔
1047
                                case 94:
1048
                                        int numEdges = this._reader.ValueAsInt;
480✔
1049
                                        this._reader.ReadNext();
480✔
1050
                                        for (int i = 0; i < numEdges; i++)
125,760✔
1051
                                        {
62,400✔
1052
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
1053

1054
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
1055
                                                this._reader.ReadNext();
62,400✔
1056
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1057

1058
                                                if (i < numEdges - 1)
62,400✔
1059
                                                {
61,920✔
1060
                                                        this._reader.ReadNext();
61,920✔
1061
                                                }
61,920✔
1062

1063
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1064
                                        }
62,400✔
1065

1066
                                        Debug.Assert(this._reader.Code == 90);
480✔
1067

1068
                                        return true;
480✔
1069
                                case 95:
1070
                                        this._reader.ReadNext();
480✔
1071
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1072
                                        {
62,400✔
1073
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1074
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1075

1076
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1077

1078
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1079
                                                {
61,920✔
1080
                                                        this._reader.ReadNext();
61,920✔
1081
                                                }
61,920✔
1082
                                        }
62,400✔
1083

1084
                                        Debug.Assert(this._reader.Code == 140);
480✔
1085

1086
                                        return true;
480✔
1087
                                default:
1088
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1089
                        }
1090
                }
42,240✔
1091

1092
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1093
                {
62,400✔
1094
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1095

1096
                        switch (this._reader.Code)
62,400✔
1097
                        {
1098
                                // 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.
1099
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1100
                                case 2:
1101
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1102
                                        return true;
720✔
1103
                                case 72:
1104
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1105
                                        return true;
720✔
1106
                                case 73:
1107
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1108
                                        return true;
720✔
1109
                                case 340:
1110
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1111
                                        return true;
720✔
1112
                                default:
1113
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1114
                                        {
10,080✔
1115
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1116
                                        }
1117
                                        return true;
49,440✔
1118
                        }
1119
                }
62,400✔
1120

1121
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1122
                {
169,440✔
1123
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1124

1125
                        switch (this._reader.Code)
169,440✔
1126
                        {
1127
                                case 270:
1128
                                        //f270 Version
1129
                                        return true;
1,800✔
1130
                                case 300:
1131
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1132
                                        return true;
3,600✔
1133
                                case 340:
1134
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1135
                                        return true;
3,600✔
1136
                                case 341:
1137
                                        tmp.LineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1138
                                        return true;
3,600✔
1139
                                case 343:
1140
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1141
                                        return true;
3,600✔
1142
                                default:
1143
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1144
                        }
1145
                }
169,440✔
1146

1147
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1148
                {
3,600✔
1149
                        this._reader.ReadNext();
3,600✔
1150

1151
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1152
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1153

1154
                        bool end = false;
3,600✔
1155
                        while (this._reader.DxfCode != DxfCode.Start)
201,600✔
1156
                        {
201,600✔
1157
                                switch (this._reader.Code)
201,600✔
1158
                                {
1159
                                        case 301 when this._reader.ValueAsString.Equals("}"):
3,600✔
1160
                                                end = true;
3,600✔
1161
                                                break;
3,600✔
1162
                                        case 302 when this._reader.ValueAsString.Equals("LEADER{"):
3,600✔
1163
                                                contextData.LeaderRoots.Add(this.readMultiLeaderLeader(template));
3,600✔
1164
                                                break;
3,600✔
1165
                                        case 340:
1166
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1167
                                                break;
3,600✔
1168
                                        default:
1169
                                                if (!this.tryAssignCurrentValue(contextData, map.SubClasses[contextData.SubclassMarker]))
190,800!
1170
                                                {
×
1171
                                                        this._builder.Notify($"[AcDbMLeaderObjectContextData] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1172
                                                }
×
1173
                                                break;
190,800✔
1174
                                }
1175

1176
                                if (end)
201,600✔
1177
                                {
3,600✔
1178
                                        break;
3,600✔
1179
                                }
1180

1181
                                this._reader.ReadNext();
198,000✔
1182
                        }
198,000✔
1183
                }
3,600✔
1184

1185
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1186
                {
3,600✔
1187
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1188
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1189

1190
                        this._reader.ReadNext();
3,600✔
1191

1192
                        bool end = false;
3,600✔
1193
                        while (this._reader.DxfCode != DxfCode.Start)
45,000✔
1194
                        {
45,000✔
1195
                                switch (this._reader.Code)
45,000✔
1196
                                {
1197
                                        case 303 when this._reader.ValueAsString.Equals("}"):
3,600✔
1198
                                                end = true;
3,600✔
1199
                                                break;
3,600✔
1200
                                        case 304 when this._reader.ValueAsString.Equals("LEADER_LINE{"):
3,600✔
1201
                                                var lineTemplate = new LeaderLineTemplate();
3,600✔
1202
                                                template.LeaderLineTemplates.Add(lineTemplate);
3,600✔
1203
                                                root.Lines.Add(this.readMultiLeaderLine(lineTemplate));
3,600✔
1204
                                                break;
3,600✔
1205
                                        default:
1206
                                                if (!this.tryAssignCurrentValue(root, map))
37,800!
1207
                                                {
×
1208
                                                        this._builder.Notify($"[LeaderRoot] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1209
                                                }
×
1210
                                                break;
37,800✔
1211
                                }
1212

1213
                                if (end)
45,000✔
1214
                                {
3,600✔
1215
                                        break;
3,600✔
1216
                                }
1217

1218
                                this._reader.ReadNext();
41,400✔
1219
                        }
41,400✔
1220

1221
                        return root;
3,600✔
1222
                }
3,600✔
1223

1224
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1225
                {
3,600✔
1226
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1227
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1228

1229
                        this._reader.ReadNext();
3,600✔
1230

1231
                        bool end = false;
3,600✔
1232
                        while (this._reader.DxfCode != DxfCode.Start)
18,000✔
1233
                        {
18,000✔
1234
                                switch (this._reader.Code)
18,000✔
1235
                                {
1236
                                        case 10:
1237
                                                XYZ pt = new XYZ(this._reader.ValueAsDouble, 0, 0);
3,600✔
1238
                                                line.Points.Add(pt);
3,600✔
1239
                                                break;
3,600✔
1240
                                        case 20:
1241
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1242
                                                pt.Y = this._reader.ValueAsDouble;
3,600✔
1243
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1244
                                                break;
3,600✔
1245
                                        case 30:
1246
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1247
                                                pt.Z = this._reader.ValueAsDouble;
3,600✔
1248
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1249
                                                break;
3,600✔
1250
                                        case 305 when this._reader.ValueAsString.Equals("}"):
3,600✔
1251
                                                end = true;
3,600✔
1252
                                                break;
3,600✔
1253
                                        default:
1254
                                                if (!this.tryAssignCurrentValue(line, map))
3,600!
1255
                                                {
×
1256
                                                        this._builder.Notify($"[LeaderLine] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1257
                                                }
×
1258
                                                break;
3,600✔
1259
                                }
1260

1261
                                if (end)
18,000✔
1262
                                {
3,600✔
1263
                                        break;
3,600✔
1264
                                }
1265

1266
                                this._reader.ReadNext();
14,400✔
1267
                        }
14,400✔
1268

1269
                        return line;
3,600✔
1270
                }
3,600✔
1271

1272
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1273
                {
2,680✔
1274
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1275

1276
                        switch (this._reader.Code)
2,680✔
1277
                        {
1278
                                case 2:
1279
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1280
                                        return true;
280✔
1281
                                default:
1282
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1283
                        }
1284
                }
2,680✔
1285

1286
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1287
                {
14,160✔
1288
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1289
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1290

1291
                        switch (this._reader.Code)
14,160✔
1292
                        {
1293
                                case 91:
1294
                                        var nvertices = this._reader.ValueAsInt;
480✔
1295
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1296
                                        {
1,680✔
1297
                                                this._reader.ReadNext();
1,680✔
1298
                                                var x = this._reader.ValueAsDouble;
1,680✔
1299
                                                this._reader.ReadNext();
1,680✔
1300
                                                var y = this._reader.ValueAsDouble;
1,680✔
1301

1302
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1303
                                        }
1,680✔
1304

1305
                                        this._reader.ReadNext();
480✔
1306

1307
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1308
                                case 340:
1309
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1310
                                        return true;
480✔
1311
                                case 360:
1312
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1313
                                        return true;
480✔
1314
                                default:
1315
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1316
                        }
1317
                }
14,160✔
1318

1319
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1320
                {
342,410✔
1321
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1322
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1323

1324
                        switch (this._reader.Code)
342,410✔
1325
                        {
1326
                                case 2:
1327
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1328
                                        return true;
240✔
1329
                                case 290:
1330
                                        return true;
240✔
1331
                                default:
1332
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
341,930✔
1333
                        }
1334
                }
342,410✔
1335

1336
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1337
                {
41,040✔
1338
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1339

1340
                        switch (this._reader.Code)
41,040✔
1341
                        {
1342
                                case 350:
1343
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1344
                                        return true;
320✔
1345
                                default:
1346
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1347
                        }
1348
                }
41,040✔
1349

1350
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1351
                {
16,800✔
1352
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1353

1354
                        XYZ controlPoint;
1355
                        XYZ fitPoint;
1356

1357
                        switch (this._reader.Code)
16,800!
1358
                        {
1359
                                case 10:
1360
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1361
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1362
                                        return true;
1,920✔
1363
                                case 20:
1364
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1365
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1366
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1367
                                        return true;
1,920✔
1368
                                case 30:
1369
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1370
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1371
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1372
                                        return true;
1,920✔
1373
                                case 11:
1374
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1375
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1376
                                        return true;
×
1377
                                case 21:
1378
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1379
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1380
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1381
                                        return true;
×
1382
                                case 31:
1383
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1384
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1385
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1386
                                        return true;
×
1387
                                case 40:
1388
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1389
                                        return true;
3,840✔
1390
                                case 41:
1391
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1392
                                        return true;
×
1393
                                case 72:
1394
                                case 73:
1395
                                case 74:
1396
                                        return true;
1,440✔
1397
                                default:
1398
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1399
                        }
1400
                }
16,800✔
1401

1402
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1403
                        where T : PdfUnderlayDefinition
1404
                {
3,800✔
1405
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1406

1407
                        switch (this._reader.Code)
3,800✔
1408
                        {
1409
                                case 340:
1410
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1411
                                        return true;
240✔
1412
                                default:
1413
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1414
                        }
1415
                }
3,800✔
1416

1417
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1418
                {
280,766✔
1419
                        CadVertexTemplate tmp = template as CadVertexTemplate;
280,766✔
1420

1421
                        switch (this._reader.Code)
280,766✔
1422
                        {
1423
                                //Polyface mesh vertex index
1424
                                case 71:
1425
                                case 72:
1426
                                case 73:
1427
                                case 74:
1428
                                        return true;
1,960✔
1429
                                case 100:
1430
                                        switch (this._reader.ValueAsString)
8,160!
1431
                                        {
1432
                                                case DxfSubclassMarker.Vertex:
1433
                                                        return true;
2,400✔
1434
                                                case DxfSubclassMarker.PolylineVertex:
1435
                                                        tmp.SetVertexObject(new Vertex2D());
×
1436
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1437
                                                        return true;
×
1438
                                                case DxfSubclassMarker.Polyline3dVertex:
1439
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1440
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1441
                                                        return true;
1,200✔
1442
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1443
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1444
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1445
                                                        return true;
1,200✔
1446
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1447
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1448
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1449
                                                        return true;
480✔
1450
                                                default:
1451
                                                        return false;
2,880✔
1452
                                        }
1453
                                default:
1454
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
270,646✔
1455
                        }
1456
                }
280,766✔
1457

1458
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1459
                {
80,456✔
1460
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1461

1462
                        switch (this._reader.Code)
80,456!
1463
                        {
1464
                                //Undocumented
1465
                                case 67:
1466
                                case 68:
1467
                                        return true;
2,944✔
1468
                                case 69:
1469
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1470
                                        return true;
1,472✔
1471
                                case 331:
1472
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1473
                                        return true;
×
1474
                                case 348:
1475
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1476
                                        return true;
928✔
1477
                                default:
1478
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1479
                        }
1480
                }
80,456✔
1481

1482
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1483
                {
993,222✔
1484
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
993,222✔
1485

1486
                        switch (this._reader.Code)
993,222✔
1487
                        {
1488
                                default:
1489
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
993,222✔
1490
                        }
1491
                }
993,222✔
1492

1493
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1494
                {
42,721✔
1495
                        List<ExtendedDataRecord> records = new();
42,721✔
1496
                        edata.Add(this._reader.ValueAsString, records);
42,721✔
1497

1498
                        this._reader.ReadNext();
42,721✔
1499

1500
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,498✔
1501
                        {
298,543✔
1502
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
298,543✔
1503
                                {
12,766✔
1504
                                        this.readExtendedData(edata);
12,766✔
1505
                                        break;
12,766✔
1506
                                }
1507

1508
                                ExtendedDataRecord record = null;
285,777✔
1509
                                double x = 0;
285,777✔
1510
                                double y = 0;
285,777✔
1511
                                double z = 0;
285,777✔
1512

1513
                                switch (this._reader.DxfCode)
285,777✔
1514
                                {
1515
                                        case DxfCode.ExtendedDataAsciiString:
1516
                                        case DxfCode.ExtendedDataRegAppName:
1517
                                                record = new ExtendedDataString(this._reader.ValueAsString);
30,268✔
1518
                                                break;
30,268✔
1519
                                        case DxfCode.ExtendedDataControlString:
1520
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1521
                                                break;
15,848✔
1522
                                        case DxfCode.ExtendedDataLayerName:
1523
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1524
                                                {
266✔
1525
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1526
                                                }
266✔
1527
                                                else
1528
                                                {
14✔
1529
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1530
                                                }
14✔
1531
                                                break;
280✔
1532
                                        case DxfCode.ExtendedDataBinaryChunk:
1533
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1534
                                                break;
80✔
1535
                                        case DxfCode.ExtendedDataHandle:
1536
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1537
                                                break;
2,958✔
1538
                                        case DxfCode.ExtendedDataXCoordinate:
1539
                                                x = this._reader.ValueAsDouble;
2,984✔
1540
                                                this._reader.ReadNext();
2,984✔
1541
                                                y = this._reader.ValueAsDouble;
2,984✔
1542
                                                this._reader.ReadNext();
2,984✔
1543
                                                z = this._reader.ValueAsDouble;
2,984✔
1544

1545
                                                record = new ExtendedDataCoordinate(
2,984✔
1546
                                                        new XYZ(
2,984✔
1547
                                                                x,
2,984✔
1548
                                                                y,
2,984✔
1549
                                                                z)
2,984✔
1550
                                                        );
2,984✔
1551
                                                break;
2,984✔
1552
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1553
                                                x = this._reader.ValueAsDouble;
1,440✔
1554
                                                this._reader.ReadNext();
1,440✔
1555
                                                y = this._reader.ValueAsDouble;
1,440✔
1556
                                                this._reader.ReadNext();
1,440✔
1557
                                                z = this._reader.ValueAsDouble;
1,440✔
1558

1559
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1560
                                                        new XYZ(
1,440✔
1561
                                                                x,
1,440✔
1562
                                                                y,
1,440✔
1563
                                                                z)
1,440✔
1564
                                                        );
1,440✔
1565
                                                break;
1,440✔
1566
                                        case DxfCode.ExtendedDataWorldXDisp:
1567
                                                x = this._reader.ValueAsDouble;
280✔
1568
                                                this._reader.ReadNext();
280✔
1569
                                                y = this._reader.ValueAsDouble;
280✔
1570
                                                this._reader.ReadNext();
280✔
1571
                                                z = this._reader.ValueAsDouble;
280✔
1572

1573
                                                record = new ExtendedDataDisplacement(
280✔
1574
                                                        new XYZ(
280✔
1575
                                                                x,
280✔
1576
                                                                y,
280✔
1577
                                                                z)
280✔
1578
                                                        );
280✔
1579
                                                break;
280✔
1580
                                        case DxfCode.ExtendedDataWorldXDir:
1581
                                                x = this._reader.ValueAsDouble;
280✔
1582
                                                this._reader.ReadNext();
280✔
1583
                                                y = this._reader.ValueAsDouble;
280✔
1584
                                                this._reader.ReadNext();
280✔
1585
                                                z = this._reader.ValueAsDouble;
280✔
1586

1587
                                                record = new ExtendedDataDirection(
280✔
1588
                                                        new XYZ(
280✔
1589
                                                                x,
280✔
1590
                                                                y,
280✔
1591
                                                                z)
280✔
1592
                                                        );
280✔
1593
                                                break;
280✔
1594
                                        case DxfCode.ExtendedDataReal:
1595
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1596
                                                break;
140,536✔
1597
                                        case DxfCode.ExtendedDataDist:
1598
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1599
                                                break;
280✔
1600
                                        case DxfCode.ExtendedDataScale:
1601
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1602
                                                break;
280✔
1603
                                        case DxfCode.ExtendedDataInteger16:
1604
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
78,517✔
1605
                                                break;
78,517✔
1606
                                        case DxfCode.ExtendedDataInteger32:
1607
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
9,186✔
1608
                                                break;
9,186✔
1609
                                        default:
1610
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1611
                                                break;
2,560✔
1612
                                }
1613

1614
                                if (record != null)
285,777✔
1615
                                {
283,203✔
1616
                                        records.Add(record);
283,203✔
1617
                                }
283,203✔
1618

1619
                                this._reader.ReadNext();
285,777✔
1620
                        }
285,777✔
1621
                }
42,721✔
1622

1623
                private void readPattern(HatchPattern pattern, int nlines)
1624
                {
1,440✔
1625
                        //Jump 78 code
1626
                        this._reader.ReadNext();
1,440✔
1627

1628
                        for (int i = 0; i < nlines; i++)
218,400✔
1629
                        {
107,760✔
1630
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1631
                                XY basePoint = new XY();
107,760✔
1632
                                XY offset = new XY();
107,760✔
1633

1634
                                bool end = false;
107,760✔
1635
                                HashSet<int> codes = new();
107,760✔
1636

1637
                                while (!end)
755,760✔
1638
                                {
754,320✔
1639
                                        if (codes.Contains(this._reader.Code))
754,320✔
1640
                                        {
106,320✔
1641
                                                break;
106,320✔
1642
                                        }
1643
                                        else
1644
                                        {
648,000✔
1645
                                                codes.Add(this._reader.Code);
648,000✔
1646
                                        }
648,000✔
1647

1648
                                        switch (this._reader.Code)
648,000!
1649
                                        {
1650
                                                case 53:
1651
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1652
                                                        break;
107,760✔
1653
                                                case 43:
1654
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1655
                                                        break;
107,760✔
1656
                                                case 44:
1657
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1658
                                                        line.BasePoint = basePoint;
107,760✔
1659
                                                        break;
107,760✔
1660
                                                case 45:
1661
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1662
                                                        line.Offset = offset;
107,760✔
1663
                                                        break;
107,760✔
1664
                                                case 46:
1665
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1666
                                                        line.Offset = offset;
107,760✔
1667
                                                        break;
107,760✔
1668
                                                //Number of dash length items
1669
                                                case 79:
1670
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1671
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1672
                                                        {
215,040✔
1673
                                                                this._reader.ReadNext();
215,040✔
1674
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1675
                                                        }
215,040✔
1676
                                                        break;
107,760✔
1677
                                                case 49:
1678
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
1679
                                                        break;
×
1680
                                                default:
1681
                                                        end = true;
1,440✔
1682
                                                        break;
1,440✔
1683
                                        }
1684
                                        this._reader.ReadNext();
648,000✔
1685
                                }
648,000✔
1686

1687
                                pattern.Lines.Add(line);
107,760✔
1688
                        }
107,760✔
1689
                }
1,440✔
1690

1691
                private void readLoops(CadHatchTemplate template, int count)
1692
                {
1,920✔
1693
                        if (this._reader.Code == 91)
1,920✔
1694
                                this._reader.ReadNext();
1,920✔
1695

1696
                        for (int i = 0; i < count; i++)
7,680✔
1697
                        {
1,920✔
1698
                                if (this._reader.Code != 92)
1,920!
1699
                                {
×
1700
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1701
                                        break;
×
1702
                                }
1703

1704
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1705
                                if (path != null)
1,920✔
1706
                                        template.PathTempaltes.Add(path);
1,920✔
1707
                        }
1,920✔
1708
                }
1,920✔
1709

1710
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1711
                {
1,920✔
1712
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1713
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1714
                        template.Path.Flags = flags;
1,920✔
1715

1716
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1717
                        {
720✔
1718
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1719
                                template.Path.Edges.Add(pl);
720✔
1720
                        }
720✔
1721
                        else
1722
                        {
1,200✔
1723
                                this._reader.ReadNext();
1,200✔
1724

1725
                                if (this._reader.Code != 93)
1,200!
1726
                                {
×
1727
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1728
                                        return null;
×
1729
                                }
1730

1731
                                int edges = this._reader.ValueAsInt;
1,200✔
1732
                                this._reader.ReadNext();
1,200✔
1733

1734
                                for (int i = 0; i < edges; i++)
12,000✔
1735
                                {
4,800✔
1736
                                        var edge = this.readEdge();
4,800✔
1737
                                        if (edge != null)
4,800✔
1738
                                                template.Path.Edges.Add(edge);
4,800✔
1739
                                }
4,800✔
1740
                        }
1,200✔
1741

1742
                        bool end = false;
1,920✔
1743
                        while (!end)
7,440✔
1744
                        {
5,520✔
1745
                                switch (this._reader.Code)
5,520✔
1746
                                {
1747
                                        //Number of source boundary objects
1748
                                        case 97:
1749
                                                break;
1,920✔
1750
                                        case 330:
1751
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1752
                                                break;
1,680✔
1753
                                        default:
1754
                                                end = true;
1,920✔
1755
                                                continue;
1,920✔
1756
                                }
1757

1758
                                this._reader.ReadNext();
3,600✔
1759
                        }
3,600✔
1760

1761
                        return template;
1,920✔
1762
                }
1,920✔
1763

1764
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1765
                {
720✔
1766
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1767

1768
                        this._reader.ReadNext();
720✔
1769

1770
                        if (this._reader.Code != 72)
720!
1771
                        {
×
1772
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1773
                                return null;
×
1774
                        }
1775

1776
                        //72
1777
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1778
                        this._reader.ReadNext();
720✔
1779

1780
                        //73
1781
                        bool isClosed = this._reader.ValueAsBool;
720✔
1782
                        this._reader.ReadNext();
720✔
1783

1784
                        //93
1785
                        int nvertices = this._reader.ValueAsInt;
720✔
1786
                        this._reader.ReadNext();
720✔
1787

1788
                        for (int i = 0; i < nvertices; i++)
7,200✔
1789
                        {
2,880✔
1790
                                double bulge = 0.0;
2,880✔
1791

1792
                                //10
1793
                                double x = this._reader.ValueAsDouble;
2,880✔
1794
                                this._reader.ReadNext();
2,880✔
1795
                                //20
1796
                                double y = this._reader.ValueAsDouble;
2,880✔
1797
                                this._reader.ReadNext();
2,880✔
1798

1799
                                if (hasBulge)
2,880!
1800
                                {
×
1801
                                        //42
1802
                                        bulge = this._reader.ValueAsDouble;
×
1803
                                        this._reader.ReadNext();
×
1804
                                }
×
1805

1806
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1807
                        }
2,880✔
1808

1809
                        return boundary;
720✔
1810
                }
720✔
1811

1812
                private Hatch.BoundaryPath.Edge readEdge()
1813
                {
4,800✔
1814
                        if (this._reader.Code != 72)
4,800!
1815
                        {
×
1816
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1817
                                return null;
×
1818
                        }
1819

1820
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1821
                        this._reader.ReadNext();
4,800✔
1822

1823
                        switch (type)
4,800!
1824
                        {
1825
                                case Hatch.BoundaryPath.EdgeType.Line:
1826
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1827
                                        while (true)
24,000✔
1828
                                        {
24,000✔
1829
                                                switch (this._reader.Code)
24,000✔
1830
                                                {
1831
                                                        case 10:
1832
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1833
                                                                break;
4,800✔
1834
                                                        case 20:
1835
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1836
                                                                break;
4,800✔
1837
                                                        case 11:
1838
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1839
                                                                break;
4,800✔
1840
                                                        case 21:
1841
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1842
                                                                break;
4,800✔
1843
                                                        default:
1844
                                                                return line;
4,800✔
1845
                                                }
1846

1847
                                                this._reader.ReadNext();
19,200✔
1848
                                        }
19,200✔
1849
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1850
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1851
                                        while (true)
×
1852
                                        {
×
1853
                                                switch (this._reader.Code)
×
1854
                                                {
1855
                                                        case 10:
1856
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1857
                                                                break;
×
1858
                                                        case 20:
1859
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1860
                                                                break;
×
1861
                                                        case 40:
1862
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1863
                                                                break;
×
1864
                                                        case 50:
1865
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1866
                                                                break;
×
1867
                                                        case 51:
1868
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1869
                                                                break;
×
1870
                                                        case 73:
1871
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1872
                                                                break;
×
1873
                                                        default:
1874
                                                                return arc;
×
1875
                                                }
1876

1877
                                                this._reader.ReadNext();
×
1878
                                        }
×
1879
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1880
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1881
                                        while (true)
×
1882
                                        {
×
1883
                                                switch (this._reader.Code)
×
1884
                                                {
1885
                                                        case 10:
1886
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1887
                                                                break;
×
1888
                                                        case 20:
1889
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1890
                                                                break;
×
1891
                                                        case 11:
1892
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1893
                                                                break;
×
1894
                                                        case 21:
1895
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1896
                                                                break;
×
1897
                                                        case 40:
1898
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1899
                                                                break;
×
1900
                                                        case 50:
1901
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1902
                                                                break;
×
1903
                                                        case 51:
1904
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1905
                                                                break;
×
1906
                                                        case 73:
1907
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1908
                                                                break;
×
1909
                                                        default:
1910
                                                                return ellipse;
×
1911
                                                }
1912

1913
                                                this._reader.ReadNext();
×
1914
                                        }
×
1915
                                case Hatch.BoundaryPath.EdgeType.Spline:
1916
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1917
                                        int nKnots = 0;
×
1918
                                        int nCtrlPoints = 0;
×
1919
                                        int nFitPoints = 0;
×
1920

1921
                                        XYZ controlPoint = new XYZ();
×
1922
                                        XY fitPoint = new XY();
×
1923

1924
                                        while (true)
×
1925
                                        {
×
1926
                                                switch (this._reader.Code)
×
1927
                                                {
1928
                                                        case 10:
1929
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1930
                                                                break;
×
1931
                                                        case 20:
1932
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1933
                                                                spline.ControlPoints.Add(controlPoint);
×
1934
                                                                break;
×
1935
                                                        case 11:
1936
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1937
                                                                break;
×
1938
                                                        case 21:
1939
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1940
                                                                spline.FitPoints.Add(fitPoint);
×
1941
                                                                break;
×
1942
                                                        case 42:
1943
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1944
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1945
                                                                break;
×
1946
                                                        case 12:
1947
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
1948
                                                                break;
×
1949
                                                        case 22:
1950
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
1951
                                                                break;
×
1952
                                                        case 13:
1953
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
1954
                                                                break;
×
1955
                                                        case 23:
1956
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
1957
                                                                break;
×
1958
                                                        case 94:
1959
                                                                spline.Degree = this._reader.ValueAsInt;
×
1960
                                                                break;
×
1961
                                                        case 73:
1962
                                                                spline.Rational = this._reader.ValueAsBool;
×
1963
                                                                break;
×
1964
                                                        case 74:
1965
                                                                spline.Periodic = this._reader.ValueAsBool;
×
1966
                                                                break;
×
1967
                                                        case 95:
1968
                                                                nKnots = this._reader.ValueAsInt;
×
1969
                                                                break;
×
1970
                                                        case 96:
1971
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
1972
                                                                break;
×
1973
                                                        case 97:
1974
                                                                nFitPoints = this._reader.ValueAsInt;
×
1975
                                                                break;
×
1976
                                                        case 40:
1977
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
1978
                                                                break;
×
1979
                                                        default:
1980
                                                                return spline;
×
1981
                                                }
1982

1983
                                                this._reader.ReadNext();
×
1984
                                        }
×
1985
                        }
1986

1987
                        return null;
×
1988
                }
4,800✔
1989

1990
                private void readDefinedGroups(CadTemplate template)
1991
                {
67,534✔
1992
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
67,534✔
1993

1994
                        template.XDictHandle = xdict;
67,534✔
1995
                        template.ReactorsHandles.UnionWith(reactorsHandles);
67,534✔
1996
                }
67,534✔
1997

1998
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
1999
                {
67,776✔
2000
                        xdictHandle = null;
67,776✔
2001
                        reactors = new HashSet<ulong>();
67,776✔
2002

2003
                        switch (this._reader.ValueAsString)
67,776✔
2004
                        {
2005
                                case DxfFileToken.DictionaryToken:
2006
                                        this._reader.ReadNext();
12,845✔
2007
                                        xdictHandle = this._reader.ValueAsHandle;
12,845✔
2008
                                        this._reader.ReadNext();
12,845✔
2009
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
12,845✔
2010
                                        return;
12,845✔
2011
                                case DxfFileToken.ReactorsToken:
2012
                                        reactors = this.readReactors();
52,531✔
2013
                                        break;
52,531✔
2014
                                case DxfFileToken.BlkRefToken:
2015
                                default:
2016
                                        do
2017
                                        {
6,240✔
2018
                                                this._reader.ReadNext();
6,240✔
2019
                                        }
6,240✔
2020
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2021
                                        return;
2,400✔
2022
                        }
2023
                }
67,776✔
2024

2025
                private HashSet<ulong> readReactors()
2026
                {
52,531✔
2027
                        HashSet<ulong> reactors = new();
52,531✔
2028

2029
                        this._reader.ReadNext();
52,531✔
2030

2031
                        while (this._reader.DxfCode != DxfCode.ControlString)
112,346✔
2032
                        {
59,815✔
2033
                                this._reader.ReadNext();
59,815✔
2034
                        }
59,815✔
2035

2036
                        return reactors;
52,531✔
2037
                }
52,531✔
2038

2039
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2040
                {
5,395,516✔
2041
                        try
2042
                        {
5,395,516✔
2043
                                //Use this method only if the value is not a link between objects
2044
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
5,395,516✔
2045
                                {
2,656,779✔
2046
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,656,779✔
2047
                                        {
14,548✔
2048
                                                return true;
14,548✔
2049
                                        }
2050

2051
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,642,231✔
2052
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,642,231✔
2053
                                        {
73,416✔
2054
                                                return false;
73,416✔
2055
                                        }
2056

2057
                                        object value = this._reader.Value;
2,568,815✔
2058

2059
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,568,815✔
2060
                                        {
28,828✔
2061
                                                value = MathHelper.DegToRad((double)value);
28,828✔
2062
                                        }
28,828✔
2063

2064
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,568,815✔
2065

2066
                                        return true;
2,568,815✔
2067
                                }
2068
                        }
2,738,737✔
2069
                        catch (Exception ex)
×
2070
                        {
×
2071
                                if (!this._builder.Configuration.Failsafe)
×
2072
                                {
×
2073
                                        throw ex;
×
2074
                                }
2075
                                else
2076
                                {
×
2077
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2078
                                }
×
2079
                        }
×
2080

2081
                        return false;
2,738,737✔
2082
                }
5,395,516✔
2083
        }
2084
}
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