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

DomCR / ACadSharp / 19269943512

11 Nov 2025 03:11PM UTC coverage: 78.156% (+0.2%) from 78.002%
19269943512

push

github

web-flow
Merge pull request #831 from DomCR/table-entity-refactor

Table entity refactor

7383 of 10235 branches covered (72.13%)

Branch coverage included in aggregate %.

731 of 859 new or added lines in 16 files covered. (85.1%)

14 existing lines in 4 files now uncovered.

27606 of 34533 relevant lines covered (79.94%)

98649.31 hits per line

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

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

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

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

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

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

32
                public abstract void Read();
33

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

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

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

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

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

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

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

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

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

236
                                        this._reader.ReadNext();
×
237

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

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

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

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

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

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

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

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

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

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

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

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

343
                private bool readArc(CadEntityTemplate template, DxfMap map, string subclass = null)
344
                {
10,648✔
345
                        switch (this._reader.Code)
10,648✔
346
                        {
347
                                default:
348
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Arc]))
10,648✔
349
                                        {
9,024✔
350
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.Circle);
9,024✔
351
                                        }
352
                                        return true;
1,624✔
353
                        }
354
                }
10,648✔
355

356
                private bool readAttributeDefinition(CadEntityTemplate template, DxfMap map, string subclass = null)
357
                {
39,546✔
358
                        DxfClassMap emap = map.SubClasses[template.CadObject.SubclassMarker];
39,546✔
359
                        CadAttributeTemplate tmp = template as CadAttributeTemplate;
39,546✔
360

361
                        switch (this._reader.Code)
39,546!
362
                        {
363
                                case 44:
364
                                case 46:
365
                                        return true;
×
366
                                case 101:
367
                                        var att = tmp.CadObject as AttributeBase;
78✔
368
                                        att.MText = new MText();
78✔
369
                                        CadTextEntityTemplate mtextTemplate = new CadTextEntityTemplate(att.MText);
78✔
370
                                        tmp.MTextTemplate = mtextTemplate;
78✔
371
                                        this.readEntityCodes<MText>(mtextTemplate, this.readTextEntity);
78✔
372
                                        return true;
78✔
373
                                default:
374
                                        if (!this.tryAssignCurrentValue(template.CadObject, emap))
39,468✔
375
                                        {
29,858✔
376
                                                return this.readTextEntity(template, map, DxfSubclassMarker.Text);
29,858✔
377
                                        }
378
                                        return true;
9,610✔
379
                        }
380
                }
39,546✔
381

382
                private bool readTableEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
383
                {
158,040✔
384
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
158,040!
385
                        CadTableEntityTemplate tmp = template as CadTableEntityTemplate;
158,040✔
386
                        TableEntity table = tmp.CadObject as TableEntity;
158,040✔
387

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

510
                private void readCellValue(TableEntity.CellContent content)
511
                {
6,560✔
512
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
513
                        {
6,560✔
514
                                this._reader.ReadNext();
6,560✔
515
                        }
6,560✔
516
                        else
517
                        {
×
518
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
519
                        }
520

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

574
                                this._reader.ReadNext();
36,320✔
575
                        }
36,320✔
576
                }
6,560✔
577

578
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
579
                {
341,010✔
580
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
341,010✔
581
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
341,010✔
582

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

605
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
606
                {
7,200✔
607
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
608

609
                        switch (this._reader.Code)
7,200✔
610
                        {
611
                                case 3:
612
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
613
                                        return true;
720✔
614
                                default:
615
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
616
                        }
617
                }
7,200✔
618

619
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
620
                {
80,560✔
621
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
622

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

690
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
691
                {
51,360✔
692
                        CadHatchTemplate tmp = template as CadHatchTemplate;
51,360✔
693
                        Hatch hatch = tmp.CadObject;
51,360✔
694

695
                        XY seedPoint = new XY();
51,360✔
696

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

786
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
787
                {
69,626✔
788
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
789

790
                        switch (this._reader.Code)
69,626✔
791
                        {
792
                                case 2:
793
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
794
                                        return true;
6,508✔
795
                                case 100:
796
                                        //AcDbEntity
797
                                        //AcDbBlockReference
798
                                        //AcDbMInsertBlock
799
                                        return true;
6,528✔
800
                                case 66:
801
                                        return true;
560✔
802
                                default:
803
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
804
                        }
805
                }
69,626✔
806

807
                private CadEntityTemplate readPolyline()
808
                {
12,348✔
809
                        CadPolyLineTemplate template = null;
12,348✔
810

811
                        if (this._builder.Version == ACadVersion.Unknown
12,348!
812
                                || this._builder.Version == ACadVersion.AC1009)
12,348✔
813
                        {
11,868✔
814
                                var polyline = new Polyline2D();
11,868✔
815
                                template = new CadPolyLineTemplate(polyline);
11,868✔
816
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
11,868✔
817

818
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
54,108!
819
                                {
42,240✔
820
                                        Vertex2D v = new Vertex2D();
42,240✔
821
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
42,240✔
822
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
42,240✔
823

824
                                        if (vertexTemplate.Vertex.Handle == 0)
42,240!
825
                                        {
×
826
                                                polyline.Vertices.Add(v);
×
827
                                        }
×
828
                                        else
829
                                        {
42,240✔
830
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
42,240✔
831
                                                this._builder.AddTemplate(vertexTemplate);
42,240✔
832
                                        }
42,240✔
833
                                }
42,240✔
834

835
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
23,736!
836
                                {
11,868✔
837
                                        var seqend = new Seqend();
11,868✔
838
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
11,868✔
839
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
11,868✔
840

841
                                        polyline.Vertices.Seqend = seqend;
11,868✔
842
                                }
11,868✔
843
                        }
11,868✔
844
                        else
845
                        {
480✔
846
                                template = new CadPolyLineTemplate();
480✔
847
                                this.readEntityCodes<Entity>(template, this.readPolyline);
480✔
848
                        }
480✔
849

850
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,348!
851
                        {
×
852
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
×
853
                                return null;
×
854
                        }
855

856
                        return template;
12,348✔
857
                }
12,348✔
858

859
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
860
                {
88,672✔
861
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,672✔
862

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

903
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
904
                {
6,000✔
905
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
906

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

938
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
939
                {
98,616✔
940
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
98,616✔
941

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

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

995
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
996
                {
42,240✔
997
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
998

999
                        switch (this._reader.Code)
42,240✔
1000
                        {
1001
                                case 100:
1002
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
1003
                                        {
480✔
1004
                                                tmp.SubclassMarker = true;
480✔
1005
                                        }
480✔
1006
                                        return true;
960✔
1007
                                //Count of sub-entity which property has been overridden
1008
                                case 90:
1009
                                        //TODO: process further entities
1010
                                        return true;
480✔
1011
                                case 92:
1012
                                        if (!tmp.SubclassMarker)
720✔
1013
                                        {
240✔
1014
                                                return false;
240✔
1015
                                        }
1016

1017
                                        int nvertices = this._reader.ValueAsInt;
480✔
1018
                                        for (int i = 0; i < nvertices; i++)
61,440✔
1019
                                        {
30,240✔
1020
                                                this._reader.ReadNext();
30,240✔
1021
                                                double x = this._reader.ValueAsDouble;
30,240✔
1022
                                                this._reader.ReadNext();
30,240✔
1023
                                                double y = this._reader.ValueAsDouble;
30,240✔
1024
                                                this._reader.ReadNext();
30,240✔
1025
                                                double z = this._reader.ValueAsDouble;
30,240✔
1026
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
1027
                                        }
30,240✔
1028
                                        return true;
480✔
1029
                                case 93:
1030
                                        int size = this._reader.ValueAsInt;
480✔
1031
                                        this._reader.ReadNext();
480✔
1032

1033
                                        int indexes = 0;
480✔
1034
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
1035
                                        {
32,640✔
1036
                                                indexes = this._reader.ValueAsInt;
32,640✔
1037
                                                this._reader.ReadNext();
32,640✔
1038

1039
                                                int[] face = new int[indexes];
32,640✔
1040
                                                for (int j = 0; j < indexes; j++)
314,880✔
1041
                                                {
124,800✔
1042
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
1043

1044
                                                        if ((i + j + 2) < size)
124,800✔
1045
                                                        {
124,320✔
1046
                                                                this._reader.ReadNext();
124,320✔
1047
                                                        }
124,320✔
1048
                                                }
124,800✔
1049

1050
                                                tmp.CadObject.Faces.Add(face);
32,640✔
1051
                                        }
32,640✔
1052

1053
                                        Debug.Assert(this._reader.Code == 90);
480✔
1054

1055
                                        return true;
480✔
1056
                                case 94:
1057
                                        int numEdges = this._reader.ValueAsInt;
480✔
1058
                                        this._reader.ReadNext();
480✔
1059
                                        for (int i = 0; i < numEdges; i++)
125,760✔
1060
                                        {
62,400✔
1061
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
1062

1063
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
1064
                                                this._reader.ReadNext();
62,400✔
1065
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1066

1067
                                                if (i < numEdges - 1)
62,400✔
1068
                                                {
61,920✔
1069
                                                        this._reader.ReadNext();
61,920✔
1070
                                                }
61,920✔
1071

1072
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1073
                                        }
62,400✔
1074

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

1077
                                        return true;
480✔
1078
                                case 95:
1079
                                        this._reader.ReadNext();
480✔
1080
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1081
                                        {
62,400✔
1082
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1083
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1084

1085
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1086

1087
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1088
                                                {
61,920✔
1089
                                                        this._reader.ReadNext();
61,920✔
1090
                                                }
61,920✔
1091
                                        }
62,400✔
1092

1093
                                        Debug.Assert(this._reader.Code == 140);
480✔
1094

1095
                                        return true;
480✔
1096
                                default:
1097
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1098
                        }
1099
                }
42,240✔
1100

1101
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1102
                {
62,400✔
1103
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1104

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

1130
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1131
                {
169,440✔
1132
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1133

1134
                        switch (this._reader.Code)
169,440✔
1135
                        {
1136
                                case 270:
1137
                                        //f270 Version
1138
                                        return true;
1,800✔
1139
                                case 300:
1140
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1141
                                        return true;
3,600✔
1142
                                case 340:
1143
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1144
                                        return true;
3,600✔
1145
                                case 341:
1146
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1147
                                        return true;
3,600✔
1148
                                case 343:
1149
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1150
                                        return true;
3,600✔
1151
                                default:
1152
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1153
                        }
1154
                }
169,440✔
1155

1156
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1157
                {
3,600✔
1158
                        this._reader.ReadNext();
3,600✔
1159

1160
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1161
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1162

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

1185
                                if (end)
201,600✔
1186
                                {
3,600✔
1187
                                        break;
3,600✔
1188
                                }
1189

1190
                                this._reader.ReadNext();
198,000✔
1191
                        }
198,000✔
1192
                }
3,600✔
1193

1194
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1195
                {
3,600✔
1196
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1197
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1198

1199
                        this._reader.ReadNext();
3,600✔
1200

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

1222
                                if (end)
45,000✔
1223
                                {
3,600✔
1224
                                        break;
3,600✔
1225
                                }
1226

1227
                                this._reader.ReadNext();
41,400✔
1228
                        }
41,400✔
1229

1230
                        return root;
3,600✔
1231
                }
3,600✔
1232

1233
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1234
                {
3,600✔
1235
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1236
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1237

1238
                        this._reader.ReadNext();
3,600✔
1239

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

1270
                                if (end)
18,000✔
1271
                                {
3,600✔
1272
                                        break;
3,600✔
1273
                                }
1274

1275
                                this._reader.ReadNext();
14,400✔
1276
                        }
14,400✔
1277

1278
                        return line;
3,600✔
1279
                }
3,600✔
1280

1281
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1282
                {
2,680✔
1283
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1284

1285
                        switch (this._reader.Code)
2,680✔
1286
                        {
1287
                                case 2:
1288
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1289
                                        return true;
280✔
1290
                                default:
1291
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1292
                        }
1293
                }
2,680✔
1294

1295
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1296
                {
14,160✔
1297
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1298
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1299

1300
                        switch (this._reader.Code)
14,160✔
1301
                        {
1302
                                case 91:
1303
                                        var nvertices = this._reader.ValueAsInt;
480✔
1304
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1305
                                        {
1,680✔
1306
                                                this._reader.ReadNext();
1,680✔
1307
                                                var x = this._reader.ValueAsDouble;
1,680✔
1308
                                                this._reader.ReadNext();
1,680✔
1309
                                                var y = this._reader.ValueAsDouble;
1,680✔
1310

1311
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1312
                                        }
1,680✔
1313

1314
                                        this._reader.ReadNext();
480✔
1315

1316
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1317
                                case 340:
1318
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1319
                                        return true;
480✔
1320
                                case 360:
1321
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1322
                                        return true;
480✔
1323
                                default:
1324
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1325
                        }
1326
                }
14,160✔
1327

1328
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1329
                {
342,410✔
1330
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1331
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1332

1333
                        switch (this._reader.Code)
342,410✔
1334
                        {
1335
                                case 2:
1336
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1337
                                        return true;
240✔
1338
                                case 290:
1339
                                        return true;
240✔
1340
                                default:
1341
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
341,930✔
1342
                        }
1343
                }
342,410✔
1344

1345
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1346
                {
41,040✔
1347
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1348

1349
                        switch (this._reader.Code)
41,040✔
1350
                        {
1351
                                case 350:
1352
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1353
                                        return true;
320✔
1354
                                default:
1355
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1356
                        }
1357
                }
41,040✔
1358

1359
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1360
                {
16,800✔
1361
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1362

1363
                        XYZ controlPoint;
1364
                        XYZ fitPoint;
1365

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

1411
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1412
                        where T : PdfUnderlayDefinition
1413
                {
3,800✔
1414
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1415

1416
                        switch (this._reader.Code)
3,800✔
1417
                        {
1418
                                case 340:
1419
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1420
                                        return true;
240✔
1421
                                default:
1422
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1423
                        }
1424
                }
3,800✔
1425

1426
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1427
                {
280,766✔
1428
                        CadVertexTemplate tmp = template as CadVertexTemplate;
280,766✔
1429

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

1467
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1468
                {
80,456✔
1469
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1470

1471
                        switch (this._reader.Code)
80,456!
1472
                        {
1473
                                //Undocumented
1474
                                case 67:
1475
                                case 68:
1476
                                        return true;
2,944✔
1477
                                case 69:
1478
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1479
                                        return true;
1,472✔
1480
                                case 331:
1481
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1482
                                        return true;
×
1483
                                case 348:
1484
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1485
                                        return true;
928✔
1486
                                default:
1487
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1488
                        }
1489
                }
80,456✔
1490

1491
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1492
                {
993,222✔
1493
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
993,222✔
1494

1495
                        switch (this._reader.Code)
993,222✔
1496
                        {
1497
                                default:
1498
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
993,222✔
1499
                        }
1500
                }
993,222✔
1501

1502
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1503
                {
42,721✔
1504
                        List<ExtendedDataRecord> records = new();
42,721✔
1505
                        edata.Add(this._reader.ValueAsString, records);
42,721✔
1506

1507
                        this._reader.ReadNext();
42,721✔
1508

1509
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,498✔
1510
                        {
298,543✔
1511
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
298,543✔
1512
                                {
12,766✔
1513
                                        this.readExtendedData(edata);
12,766✔
1514
                                        break;
12,766✔
1515
                                }
1516

1517
                                ExtendedDataRecord record = null;
285,777✔
1518
                                double x = 0;
285,777✔
1519
                                double y = 0;
285,777✔
1520
                                double z = 0;
285,777✔
1521

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

1554
                                                record = new ExtendedDataCoordinate(
2,984✔
1555
                                                        new XYZ(
2,984✔
1556
                                                                x,
2,984✔
1557
                                                                y,
2,984✔
1558
                                                                z)
2,984✔
1559
                                                        );
2,984✔
1560
                                                break;
2,984✔
1561
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1562
                                                x = this._reader.ValueAsDouble;
1,440✔
1563
                                                this._reader.ReadNext();
1,440✔
1564
                                                y = this._reader.ValueAsDouble;
1,440✔
1565
                                                this._reader.ReadNext();
1,440✔
1566
                                                z = this._reader.ValueAsDouble;
1,440✔
1567

1568
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1569
                                                        new XYZ(
1,440✔
1570
                                                                x,
1,440✔
1571
                                                                y,
1,440✔
1572
                                                                z)
1,440✔
1573
                                                        );
1,440✔
1574
                                                break;
1,440✔
1575
                                        case DxfCode.ExtendedDataWorldXDisp:
1576
                                                x = this._reader.ValueAsDouble;
280✔
1577
                                                this._reader.ReadNext();
280✔
1578
                                                y = this._reader.ValueAsDouble;
280✔
1579
                                                this._reader.ReadNext();
280✔
1580
                                                z = this._reader.ValueAsDouble;
280✔
1581

1582
                                                record = new ExtendedDataDisplacement(
280✔
1583
                                                        new XYZ(
280✔
1584
                                                                x,
280✔
1585
                                                                y,
280✔
1586
                                                                z)
280✔
1587
                                                        );
280✔
1588
                                                break;
280✔
1589
                                        case DxfCode.ExtendedDataWorldXDir:
1590
                                                x = this._reader.ValueAsDouble;
280✔
1591
                                                this._reader.ReadNext();
280✔
1592
                                                y = this._reader.ValueAsDouble;
280✔
1593
                                                this._reader.ReadNext();
280✔
1594
                                                z = this._reader.ValueAsDouble;
280✔
1595

1596
                                                record = new ExtendedDataDirection(
280✔
1597
                                                        new XYZ(
280✔
1598
                                                                x,
280✔
1599
                                                                y,
280✔
1600
                                                                z)
280✔
1601
                                                        );
280✔
1602
                                                break;
280✔
1603
                                        case DxfCode.ExtendedDataReal:
1604
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1605
                                                break;
140,536✔
1606
                                        case DxfCode.ExtendedDataDist:
1607
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1608
                                                break;
280✔
1609
                                        case DxfCode.ExtendedDataScale:
1610
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1611
                                                break;
280✔
1612
                                        case DxfCode.ExtendedDataInteger16:
1613
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
78,517✔
1614
                                                break;
78,517✔
1615
                                        case DxfCode.ExtendedDataInteger32:
1616
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
9,186✔
1617
                                                break;
9,186✔
1618
                                        default:
1619
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1620
                                                break;
2,560✔
1621
                                }
1622

1623
                                if (record != null)
285,777✔
1624
                                {
283,203✔
1625
                                        records.Add(record);
283,203✔
1626
                                }
283,203✔
1627

1628
                                this._reader.ReadNext();
285,777✔
1629
                        }
285,777✔
1630
                }
42,721✔
1631

1632
                private void readPattern(HatchPattern pattern, int nlines)
1633
                {
1,440✔
1634
                        //Jump 78 code
1635
                        this._reader.ReadNext();
1,440✔
1636

1637
                        for (int i = 0; i < nlines; i++)
218,400✔
1638
                        {
107,760✔
1639
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1640
                                XY basePoint = new XY();
107,760✔
1641
                                XY offset = new XY();
107,760✔
1642

1643
                                bool end = false;
107,760✔
1644
                                HashSet<int> codes = new();
107,760✔
1645

1646
                                while (!end)
755,760✔
1647
                                {
754,320✔
1648
                                        if (codes.Contains(this._reader.Code))
754,320✔
1649
                                        {
106,320✔
1650
                                                break;
106,320✔
1651
                                        }
1652
                                        else
1653
                                        {
648,000✔
1654
                                                codes.Add(this._reader.Code);
648,000✔
1655
                                        }
648,000✔
1656

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

1696
                                pattern.Lines.Add(line);
107,760✔
1697
                        }
107,760✔
1698
                }
1,440✔
1699

1700
                private void readLoops(CadHatchTemplate template, int count)
1701
                {
1,920✔
1702
                        if (this._reader.Code == 91)
1,920✔
1703
                                this._reader.ReadNext();
1,920✔
1704

1705
                        for (int i = 0; i < count; i++)
7,680✔
1706
                        {
1,920✔
1707
                                if (this._reader.Code != 92)
1,920!
1708
                                {
×
1709
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1710
                                        break;
×
1711
                                }
1712

1713
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1714
                                if (path != null)
1,920✔
1715
                                        template.PathTemplates.Add(path);
1,920✔
1716
                        }
1,920✔
1717
                }
1,920✔
1718

1719
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1720
                {
1,920✔
1721
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1722
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1723
                        template.Path.Flags = flags;
1,920✔
1724

1725
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1726
                        {
720✔
1727
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1728
                                template.Path.Edges.Add(pl);
720✔
1729
                        }
720✔
1730
                        else
1731
                        {
1,200✔
1732
                                this._reader.ReadNext();
1,200✔
1733

1734
                                if (this._reader.Code != 93)
1,200!
1735
                                {
×
1736
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1737
                                        return null;
×
1738
                                }
1739

1740
                                int edges = this._reader.ValueAsInt;
1,200✔
1741
                                this._reader.ReadNext();
1,200✔
1742

1743
                                for (int i = 0; i < edges; i++)
12,000✔
1744
                                {
4,800✔
1745
                                        var edge = this.readEdge();
4,800✔
1746
                                        if (edge != null)
4,800✔
1747
                                                template.Path.Edges.Add(edge);
4,800✔
1748
                                }
4,800✔
1749
                        }
1,200✔
1750

1751
                        bool end = false;
1,920✔
1752
                        while (!end)
7,440✔
1753
                        {
5,520✔
1754
                                switch (this._reader.Code)
5,520✔
1755
                                {
1756
                                        //Number of source boundary objects
1757
                                        case 97:
1758
                                                break;
1,920✔
1759
                                        case 330:
1760
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1761
                                                break;
1,680✔
1762
                                        default:
1763
                                                end = true;
1,920✔
1764
                                                continue;
1,920✔
1765
                                }
1766

1767
                                this._reader.ReadNext();
3,600✔
1768
                        }
3,600✔
1769

1770
                        return template;
1,920✔
1771
                }
1,920✔
1772

1773
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1774
                {
720✔
1775
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1776

1777
                        this._reader.ReadNext();
720✔
1778

1779
                        if (this._reader.Code != 72)
720!
1780
                        {
×
1781
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1782
                                return null;
×
1783
                        }
1784

1785
                        //72
1786
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1787
                        this._reader.ReadNext();
720✔
1788

1789
                        //73
1790
                        bool isClosed = this._reader.ValueAsBool;
720✔
1791
                        this._reader.ReadNext();
720✔
1792

1793
                        //93
1794
                        int nvertices = this._reader.ValueAsInt;
720✔
1795
                        this._reader.ReadNext();
720✔
1796

1797
                        for (int i = 0; i < nvertices; i++)
7,200✔
1798
                        {
2,880✔
1799
                                double bulge = 0.0;
2,880✔
1800

1801
                                //10
1802
                                double x = this._reader.ValueAsDouble;
2,880✔
1803
                                this._reader.ReadNext();
2,880✔
1804
                                //20
1805
                                double y = this._reader.ValueAsDouble;
2,880✔
1806
                                this._reader.ReadNext();
2,880✔
1807

1808
                                if (hasBulge)
2,880!
1809
                                {
×
1810
                                        //42
1811
                                        bulge = this._reader.ValueAsDouble;
×
1812
                                        this._reader.ReadNext();
×
1813
                                }
×
1814

1815
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1816
                        }
2,880✔
1817

1818
                        return boundary;
720✔
1819
                }
720✔
1820

1821
                private Hatch.BoundaryPath.Edge readEdge()
1822
                {
4,800✔
1823
                        if (this._reader.Code != 72)
4,800!
1824
                        {
×
1825
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1826
                                return null;
×
1827
                        }
1828

1829
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1830
                        this._reader.ReadNext();
4,800✔
1831

1832
                        switch (type)
4,800!
1833
                        {
1834
                                case Hatch.BoundaryPath.EdgeType.Line:
1835
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1836
                                        while (true)
24,000✔
1837
                                        {
24,000✔
1838
                                                switch (this._reader.Code)
24,000✔
1839
                                                {
1840
                                                        case 10:
1841
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1842
                                                                break;
4,800✔
1843
                                                        case 20:
1844
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1845
                                                                break;
4,800✔
1846
                                                        case 11:
1847
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1848
                                                                break;
4,800✔
1849
                                                        case 21:
1850
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1851
                                                                break;
4,800✔
1852
                                                        default:
1853
                                                                return line;
4,800✔
1854
                                                }
1855

1856
                                                this._reader.ReadNext();
19,200✔
1857
                                        }
19,200✔
1858
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1859
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1860
                                        while (true)
×
1861
                                        {
×
1862
                                                switch (this._reader.Code)
×
1863
                                                {
1864
                                                        case 10:
1865
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1866
                                                                break;
×
1867
                                                        case 20:
1868
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1869
                                                                break;
×
1870
                                                        case 40:
1871
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1872
                                                                break;
×
1873
                                                        case 50:
1874
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1875
                                                                break;
×
1876
                                                        case 51:
1877
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1878
                                                                break;
×
1879
                                                        case 73:
1880
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1881
                                                                break;
×
1882
                                                        default:
1883
                                                                return arc;
×
1884
                                                }
1885

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

1922
                                                this._reader.ReadNext();
×
1923
                                        }
×
1924
                                case Hatch.BoundaryPath.EdgeType.Spline:
1925
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1926
                                        int nKnots = 0;
×
1927
                                        int nCtrlPoints = 0;
×
1928
                                        int nFitPoints = 0;
×
1929

1930
                                        XYZ controlPoint = new XYZ();
×
1931
                                        XY fitPoint = new XY();
×
1932

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

1992
                                                this._reader.ReadNext();
×
1993
                                        }
×
1994
                        }
1995

1996
                        return null;
×
1997
                }
4,800✔
1998

1999
                private void readDefinedGroups(CadTemplate template)
2000
                {
67,534✔
2001
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
67,534✔
2002

2003
                        template.XDictHandle = xdict;
67,534✔
2004
                        template.ReactorsHandles.UnionWith(reactorsHandles);
67,534✔
2005
                }
67,534✔
2006

2007
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
2008
                {
67,776✔
2009
                        xdictHandle = null;
67,776✔
2010
                        reactors = new HashSet<ulong>();
67,776✔
2011

2012
                        switch (this._reader.ValueAsString)
67,776✔
2013
                        {
2014
                                case DxfFileToken.DictionaryToken:
2015
                                        this._reader.ReadNext();
12,845✔
2016
                                        xdictHandle = this._reader.ValueAsHandle;
12,845✔
2017
                                        this._reader.ReadNext();
12,845✔
2018
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
12,845✔
2019
                                        return;
12,845✔
2020
                                case DxfFileToken.ReactorsToken:
2021
                                        reactors = this.readReactors();
52,531✔
2022
                                        break;
52,531✔
2023
                                case DxfFileToken.BlkRefToken:
2024
                                default:
2025
                                        do
2026
                                        {
6,240✔
2027
                                                this._reader.ReadNext();
6,240✔
2028
                                        }
6,240✔
2029
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2030
                                        return;
2,400✔
2031
                        }
2032
                }
67,776✔
2033

2034
                private HashSet<ulong> readReactors()
2035
                {
52,531✔
2036
                        HashSet<ulong> reactors = new();
52,531✔
2037

2038
                        this._reader.ReadNext();
52,531✔
2039

2040
                        while (this._reader.DxfCode != DxfCode.ControlString)
112,346✔
2041
                        {
59,815✔
2042
                                this._reader.ReadNext();
59,815✔
2043
                        }
59,815✔
2044

2045
                        return reactors;
52,531✔
2046
                }
52,531✔
2047

2048
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2049
                {
5,211,096✔
2050
                        try
2051
                        {
5,211,096✔
2052
                                //Use this method only if the value is not a link between objects
2053
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
5,211,096✔
2054
                                {
2,786,863✔
2055
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,786,863✔
2056
                                        {
14,548✔
2057
                                                return true;
14,548✔
2058
                                        }
2059

2060
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,772,315✔
2061
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,772,315✔
2062
                                        {
17,370✔
2063
                                                return false;
17,370✔
2064
                                        }
2065

2066
                                        object value = this._reader.Value;
2,754,945✔
2067

2068
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,754,945✔
2069
                                        {
28,828✔
2070
                                                value = MathHelper.DegToRad((double)value);
28,828✔
2071
                                        }
28,828✔
2072

2073
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,754,945✔
2074

2075
                                        return true;
2,754,945✔
2076
                                }
2077
                        }
2,424,233✔
2078
                        catch (Exception ex)
×
2079
                        {
×
2080
                                if (!this._builder.Configuration.Failsafe)
×
2081
                                {
×
2082
                                        throw ex;
×
2083
                                }
2084
                                else
2085
                                {
×
2086
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2087
                                }
×
2088
                        }
×
2089

2090
                        return false;
2,424,233✔
2091
                }
5,211,096✔
2092
        }
2093
}
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

© 2025 Coveralls, Inc