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

DomCR / ACadSharp / 20297070459

17 Dec 2025 08:53AM UTC coverage: 77.112% (-0.6%) from 77.723%
20297070459

push

github

web-flow
Merge pull request #921 from DomCR/read-table-R2007Pre

Read table r2007 pre

7690 of 10817 branches covered (71.09%)

Branch coverage included in aggregate %.

187 of 513 new or added lines in 9 files covered. (36.45%)

22 existing lines in 7 files now uncovered.

28309 of 35867 relevant lines covered (78.93%)

159788.76 hits per line

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

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

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

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

22
                //Avoid to move the reader to the next line
23
                protected bool lockPointer = false;
1,110✔
24
                protected string currentSubclass = null;
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
                {
924,115✔
116
                        isExtendedData = false;
924,115✔
117

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

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

239
                                        this._reader.ReadNext();
×
240

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

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

254
                                        return unknownEntityTemplate;
×
255
                        }
256
                }
176,134✔
257

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

263
                        DxfMap map = DxfMap.Create<T>();
230,520✔
264

265
                        while (this._reader.DxfCode != DxfCode.Start)
3,121,658✔
266
                        {
2,891,138✔
267
                                if (!readEntity(template, map))
2,891,138✔
268
                                {
1,012,844✔
269
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
1,012,844✔
270
                                        if (isExtendedData)
1,012,844✔
271
                                                continue;
16,010✔
272
                                }
996,834✔
273

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

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

284
                        return template;
230,520✔
285
                }
230,520✔
286

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

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

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

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

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

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

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

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

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

413
                        switch (this._reader.Code)
158,040!
414
                        {
415
                                case 1:
416
                                        TableEntity.CellContent content;
417
                                        if (tmp.CurrentCell.Content == null)
3,120!
418
                                        {
3,120✔
419
                                                content = new TableEntity.CellContent();
3,120✔
420
                                                content.Value.ValueType = TableEntity.CellValueType.String;
3,120✔
421
                                                tmp.CurrentCell.Contents.Add(content);
3,120✔
422
                                        }
3,120✔
423
                                        else
NEW
424
                                        {
×
NEW
425
                                                content = tmp.CurrentCell.Content;
×
NEW
426
                                        }
×
427

428
                                        if (content.Value.Value == null)
3,120!
429
                                        {
3,120✔
430
                                                content.Value.Value = this._reader.ValueAsString;
3,120✔
431
                                        }
3,120✔
432
                                        else
NEW
433
                                        {
×
NEW
434
                                                string str = content.Value.Value as string;
×
NEW
435
                                                str += this._reader.ValueAsString;
×
NEW
436
                                                content.Value.Value = str;
×
NEW
437
                                        }
×
438
                                        return true;
3,120✔
439
                                case 2:
440
                                        if (this.currentSubclass.Equals(DxfSubclassMarker.TableEntity, StringComparison.OrdinalIgnoreCase))
480!
NEW
441
                                        {
×
NEW
442
                                                content = tmp.CurrentCell.Content;
×
NEW
443
                                                if (content.Value.Value == null)
×
NEW
444
                                                {
×
NEW
445
                                                        content.Value.Value = this._reader.ValueAsString;
×
NEW
446
                                                }
×
447
                                                else
NEW
448
                                                {
×
NEW
449
                                                        string str = content.Value.Value as string;
×
NEW
450
                                                        str += this._reader.ValueAsString;
×
NEW
451
                                                        content.Value.Value = str;
×
NEW
452
                                                }
×
NEW
453
                                        }
×
454
                                        else
455
                                        {
480✔
456
                                                tmp.BlockName = this._reader.ValueAsString;
480✔
457
                                        }
480✔
458
                                        return true;
480✔
459
                                //Border overrides:
460
                                case 177:
461
                                        //Cell override flag value (before AutoCAD 2007)
462
                                        return true;
3,280✔
463
                                case 279:
464
                                        //Lineweight for the top border of the cell; override applied at the cell level
465
                                        tmp.CurrentCell.StyleOverride.TopBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,680✔
466
                                        return true;
1,680✔
467
                                case 275:
468
                                        //Lineweight for the right border of the cell; override applied at the cell level
469
                                        tmp.CurrentCell.StyleOverride.RightBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
480✔
470
                                        return true;
480✔
471
                                case 276:
472
                                        //Lineweight for the bottom border of the cell; override applied at the cell level
473
                                        tmp.CurrentCell.StyleOverride.BottomBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
×
474
                                        return true;
×
475
                                case 278:
476
                                        //Lineweight for the left border of the cell; override applied at the cell level
477
                                        tmp.CurrentCell.StyleOverride.LeftBorder.LineWeight = (LineWeightType)this._reader.ValueAsShort;
1,440✔
478
                                        return true;
1,440✔
479
                                case 69:
480
                                        //True color value for the top border of the cell; override applied at the cell level
481
                                        tmp.CurrentCell.StyleOverride.TopBorder.Color = new Color(this._reader.ValueAsShort);
1,680✔
482
                                        return true;
1,680✔
483
                                case 65:
484
                                        //True color value for the right border of the cell; override applied at the cell level
485
                                        tmp.CurrentCell.StyleOverride.RightBorder.Color = new Color(this._reader.ValueAsShort);
480✔
486
                                        return true;
480✔
487
                                case 66:
488
                                        //True color value for the bottom border of the cell; override applied at the cell level
489
                                        tmp.CurrentCell.StyleOverride.BottomBorder.Color = new Color(this._reader.ValueAsShort);
×
490
                                        return true;
×
491
                                case 68:
492
                                        //True color value for the left border of the cell; override applied at the cell level
493
                                        tmp.CurrentCell.StyleOverride.LeftBorder.Color = new Color(this._reader.ValueAsShort);
1,440✔
494
                                        return true;
1,440✔
495
                                case 40:
496
                                        tmp.HorizontalMargin = this._reader.ValueAsDouble;
240✔
497
                                        return true;
240✔
498
                                case 63:
499
                                        tmp.CurrentCell.StyleOverride.BackgroundColor = new Color(this._reader.ValueAsShort);
240✔
500
                                        return true;
240✔
501
                                case 64:
502
                                        tmp.CurrentCell.StyleOverride.ContentColor = new Color(this._reader.ValueAsShort);
240✔
503
                                        return true;
240✔
504
                                case 140:
505
                                        if (tmp.CurrentCellTemplate != null)
5,760✔
506
                                        {
5,040✔
507
                                                tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
5,040✔
508
                                        }
5,040✔
509
                                        return true;
5,760✔
510
                                case 283:
511
                                        tmp.CurrentCell.StyleOverride.IsFillColorOn = this._reader.ValueAsBool;
240✔
512
                                        return true;
240✔
513
                                case 342:
514
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
480✔
515
                                        return true;
480✔
516
                                case 343:
517
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
480✔
518
                                        return true;
480✔
519
                                case 141:
520
                                        var row = new TableEntity.Row();
2,640✔
521
                                        row.Height = this._reader.ValueAsDouble;
2,640✔
522
                                        table.Rows.Add(row);
2,640✔
523
                                        return true;
2,640✔
524
                                case 142:
525
                                        var col = new TableEntity.Column();
1,920✔
526
                                        col.Width = this._reader.ValueAsDouble;
1,920✔
527
                                        table.Columns.Add(col);
1,920✔
528
                                        return true;
1,920✔
529
                                case 144:
530
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
480✔
531
                                        return true;
480✔
532
                                case 145:
533
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
9,840✔
534
                                        return true;
9,840✔
535
                                case 170:
536
                                        //Has data flag
537
                                        return true;
720✔
538
                                case 171:
539
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
9,840✔
540
                                        return true;
9,840✔
541
                                case 172:
542
                                        tmp.CurrentCell.EdgeFlags = this._reader.ValueAsShort;
9,840✔
543
                                        return true;
9,840✔
544
                                case 173:
545
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsShort;
9,840✔
546
                                        return true;
9,840✔
547
                                case 174:
548
                                        tmp.CurrentCell.AutoFit = this._reader.ValueAsBool;
9,840✔
549
                                        return true;
9,840✔
550
                                case 175:
551
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
9,840✔
552
                                        return true;
9,840✔
553
                                case 176:
554
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
9,840✔
555
                                        return true;
9,840✔
556
                                case 178:
557
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
9,840✔
558
                                        return true;
9,840✔
559
                                case 179:
560
                                        //Unknown value
561
                                        return true;
480✔
562
                                case 301:
563
                                        content = new TableEntity.CellContent();
6,560✔
564
                                        tmp.CurrentCell.Contents.Add(content);
6,560✔
565
                                        this.readCellValue(content);
6,560✔
566
                                        return true;
6,560✔
567
                                case 340:
568
                                        tmp.CurrentCellTemplate.ValueHandle = this._reader.ValueAsHandle;
480✔
569
                                        return true;
480✔
570
                                default:
571
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
44,280✔
572
                                        {
42,600✔
573
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
42,600✔
574
                                        }
575
                                        return true;
1,680✔
576
                        }
577
                }
158,040✔
578

579
                private void readCellValue(TableEntity.CellContent content)
580
                {
6,560✔
581
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
582
                        {
6,560✔
583
                                this._reader.ReadNext();
6,560✔
584
                        }
6,560✔
585
                        else
586
                        {
×
587
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
588
                        }
589

590
                        while (this._reader.Code != 304
42,880✔
591
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
42,880✔
592
                        {
36,320✔
593
                                switch (this._reader.Code)
36,320!
594
                                {
595
                                        case 1:
596
                                                content.Value.Text = this._reader.ValueAsString;
1,920✔
597
                                                break;
1,920✔
598
                                        case 2:
599
                                                content.Value.Text += this._reader.ValueAsString;
×
600
                                                break;
×
601
                                        case 11:
602
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
160✔
603
                                                break;
160✔
604
                                        case 21:
605
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
160✔
606
                                                break;
160✔
607
                                        case 31:
608
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
160✔
609
                                                break;
160✔
610
                                        case 302:
611
                                                //TODO: Fix this assignation to cell value
612
                                                content.Value.Value = this._reader.ValueAsString;
6,560✔
613
                                                break;
6,560✔
614
                                        case 90:
615
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
6,560✔
616
                                                break;
6,560✔
617
                                        case 91:
618
                                                content.Value.Value = this._reader.ValueAsInt;
160✔
619
                                                break;
160✔
620
                                        case 92:
621
                                                //Extended cell flags (from AutoCAD 2007)
622
                                                break;
160✔
623
                                        case 93:
624
                                                content.Value.Flags = this._reader.ValueAsInt;
6,560✔
625
                                                break;
6,560✔
626
                                        case 94:
627
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
6,560✔
628
                                                break;
6,560✔
629
                                        case 140:
630
                                                content.Value.Value = this._reader.ValueAsDouble;
640✔
631
                                                break;
640✔
632
                                        case 300:
633
                                                content.Value.Format = this._reader.ValueAsString;
6,560✔
634
                                                break;
6,560✔
635
                                        case 310:
636
                                                //Data for proxy entity graphics (multiple lines; 256-character maximum per line)
637
                                                break;
160✔
638
                                        default:
639
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
640
                                                break;
×
641
                                }
642

643
                                this._reader.ReadNext();
36,320✔
644
                        }
36,320✔
645
                }
6,560✔
646

647
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
648
                {
344,818✔
649
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
344,818✔
650
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
344,818✔
651

652
                        switch (this._reader.Code)
344,818✔
653
                        {
654
                                //TODO: Implement multiline text def codes
655
                                case 1 or 3 when tmp.CadObject is MText mtext:
30,662✔
656
                                        mtext.Value += this._reader.ValueAsString;
11,466✔
657
                                        return true;
11,466✔
658
                                case 50 when tmp.CadObject is MText mtext://Read only for MText
570!
659
                                        double angle = MathHelper.DegToRad(this._reader.ValueAsDouble);
×
660
                                        mtext.AlignmentPoint = new XYZ(System.Math.Cos(angle), System.Math.Sin(angle), 0.0);
×
661
                                        return true;
×
662
                                case 70:
663
                                case 74:
664
                                case 101:
665
                                        return true;
480✔
666
                                case 7:
667
                                        tmp.StyleName = this._reader.ValueAsString;
3,360✔
668
                                        return true;
3,360✔
669
                                default:
670
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
329,512✔
671
                        }
672
                }
344,818✔
673

674
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
675
                {
7,200✔
676
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
677

678
                        switch (this._reader.Code)
7,200✔
679
                        {
680
                                case 3:
681
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
682
                                        return true;
720✔
683
                                default:
684
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
685
                        }
686
                }
7,200✔
687

688
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
689
                {
80,560✔
690
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
691

692
                        switch (this._reader.Code)
80,560✔
693
                        {
694
                                case 2:
695
                                        tmp.BlockName = this._reader.ValueAsString;
3,080✔
696
                                        return true;
3,080✔
697
                                case 3:
698
                                        tmp.StyleName = this._reader.ValueAsString;
2,640✔
699
                                        return true;
2,640✔
700
                                case 50:
701
                                        var dim = new DimensionLinear();
280✔
702
                                        tmp.SetDimensionObject(dim);
280✔
703
                                        dim.Rotation = this._reader.ValueAsAngle;
280✔
704
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
280✔
705
                                        return true;
280✔
706
                                case 70:
707
                                        //Flags do not have set
708
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
3,080✔
709
                                        return true;
3,080✔
710
                                //Measurement - read only
711
                                case 42:
712
                                        return true;
2,640✔
713
                                //Undocumented codes
714
                                case 73:
715
                                case 74:
716
                                case 75:
717
                                case 90:
718
                                case 361:
719
                                        return true;
5,280✔
720
                                case 100:
721
                                        switch (this._reader.ValueAsString)
8,640✔
722
                                        {
723
                                                case DxfSubclassMarker.Dimension:
724
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
2,640✔
725
                                                case DxfSubclassMarker.AlignedDimension:
726
                                                        tmp.SetDimensionObject(new DimensionAligned());
1,200✔
727
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
1,200✔
728
                                                        return true;
1,200✔
729
                                                case DxfSubclassMarker.DiametricDimension:
730
                                                        tmp.SetDimensionObject(new DimensionDiameter());
240✔
731
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
240✔
732
                                                        return true;
240✔
733
                                                case DxfSubclassMarker.Angular2LineDimension:
734
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
240✔
735
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
240✔
736
                                                        return true;
240✔
737
                                                case DxfSubclassMarker.Angular3PointDimension:
738
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
240✔
739
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
240✔
740
                                                        return true;
240✔
741
                                                case DxfSubclassMarker.RadialDimension:
742
                                                        tmp.SetDimensionObject(new DimensionRadius());
240✔
743
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
240✔
744
                                                        return true;
240✔
745
                                                case DxfSubclassMarker.OrdinateDimension:
746
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
480✔
747
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
480✔
748
                                                        return true;
480✔
749
                                                case DxfSubclassMarker.LinearDimension:
750
                                                        return true;
720✔
751
                                                default:
752
                                                        return false;
2,640✔
753
                                        }
754
                                default:
755
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
54,920✔
756
                        }
757
                }
80,560✔
758

759
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
760
                {
51,360✔
761
                        CadHatchTemplate tmp = template as CadHatchTemplate;
51,360✔
762
                        Hatch hatch = tmp.CadObject;
51,360✔
763

764
                        XY seedPoint = new XY();
51,360✔
765

766
                        switch (this._reader.Code)
51,360!
767
                        {
768
                                case 2:
769
                                        hatch.Pattern.Name = this._reader.ValueAsString;
1,920✔
770
                                        return true;
1,920✔
771
                                case 10:
772
                                        seedPoint.X = this._reader.ValueAsDouble;
3,840✔
773
                                        hatch.SeedPoints.Add(seedPoint);
3,840✔
774
                                        return true;
3,840✔
775
                                case 20:
776
                                        seedPoint = hatch.SeedPoints.LastOrDefault();
3,840✔
777
                                        seedPoint.Y = this._reader.ValueAsDouble;
3,840✔
778
                                        hatch.SeedPoints[hatch.SeedPoints.Count - 1] = seedPoint;
3,840✔
779
                                        return true;
3,840✔
780
                                case 30:
781
                                        hatch.Elevation = this._reader.ValueAsDouble;
1,920✔
782
                                        return true;
1,920✔
783
                                case 53:
784
                                        hatch.PatternAngle = this._reader.ValueAsAngle;
×
785
                                        return true;
×
786
                                //TODO: Check hatch undocumented codes
787
                                case 90:
788
                                        return true;
×
789
                                //Information about the hatch pattern
790
                                case 75:
791
                                        return true;
1,920✔
792
                                //Number of pattern definition lines
793
                                case 78:
794
                                        this.readPattern(hatch.Pattern, this._reader.ValueAsInt);
1,440✔
795
                                        this.lockPointer = true;
1,440✔
796
                                        return true;
1,440✔
797
                                //Number of boundary paths (loops)
798
                                case 91:
799
                                        this.readLoops(tmp, this._reader.ValueAsInt);
1,920✔
800
                                        this.lockPointer = true;
1,920✔
801
                                        return true;
1,920✔
802
                                //Number of seed points
803
                                case 98:
804
                                        return true;
1,200✔
805
                                case 450:
806
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
400✔
807
                                        return true;
400✔
808
                                case 451:
809
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
400✔
810
                                        return true;
400✔
811
                                case 452:
812
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
400✔
813
                                        return true;
400✔
814
                                case 453:
815
                                        //Number of colors
816
                                        return true;
400✔
817
                                case 460:
818
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
400✔
819
                                        return true;
400✔
820
                                case 461:
821
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
400✔
822
                                        return true;
400✔
823
                                case 462:
824
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
400✔
825
                                        return true;
400✔
826
                                case 463:
827
                                        GradientColor gradient = new GradientColor();
800✔
828
                                        gradient.Value = this._reader.ValueAsDouble;
800✔
829
                                        hatch.GradientColor.Colors.Add(gradient);
800✔
830
                                        return true;
800✔
831
                                case 63:
832
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
800✔
833
                                        if (colorByIndex != null)
800✔
834
                                        {
800✔
835
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
800✔
836
                                        }
800✔
837
                                        return true;
800✔
838
                                case 421:
839
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
800✔
840
                                        if (colorByRgb != null)
800✔
841
                                        {
800✔
842
                                                //TODO: Hatch assign color by true color
843
                                                //TODO: Is always duplicated by 63, is it needed??
844
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
845
                                        }
800✔
846
                                        return true;
800✔
847
                                case 470:
848
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
400✔
849
                                        return true;
400✔
850
                                default:
851
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,760✔
852
                        }
853
                }
51,360✔
854

855
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
856
                {
69,626✔
857
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
858

859
                        switch (this._reader.Code)
69,626✔
860
                        {
861
                                case 2:
862
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
863
                                        return true;
6,508✔
864
                                case 100:
865
                                        //AcDbEntity
866
                                        //AcDbBlockReference
867
                                        //AcDbMInsertBlock
868
                                        return true;
6,528✔
869
                                case 66:
870
                                        return true;
560✔
871
                                default:
872
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
873
                        }
874
                }
69,626✔
875

876
                private CadEntityTemplate readPolyline()
877
                {
12,388✔
878
                        CadPolyLineTemplate template = null;
12,388✔
879

880
                        if (this._builder.Version == ACadVersion.Unknown
12,388!
881
                                || this._builder.Version == ACadVersion.AC1009)
12,388✔
882
                        {
11,908✔
883
                                var polyline = new Polyline2D();
11,908✔
884
                                template = new CadPolyLineTemplate(polyline);
11,908✔
885
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
11,908✔
886

887
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
54,308!
888
                                {
42,400✔
889
                                        Vertex2D v = new Vertex2D();
42,400✔
890
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
42,400✔
891
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
42,400✔
892

893
                                        if (vertexTemplate.Vertex.Handle == 0)
42,400!
894
                                        {
×
895
                                                polyline.Vertices.Add(v);
×
896
                                        }
×
897
                                        else
898
                                        {
42,400✔
899
                                                template.OwnedObjectsHandlers.Add(vertexTemplate.Vertex.Handle);
42,400✔
900
                                                this._builder.AddTemplate(vertexTemplate);
42,400✔
901
                                        }
42,400✔
902
                                }
42,400✔
903

904
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
23,816!
905
                                {
11,908✔
906
                                        var seqend = new Seqend();
11,908✔
907
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
11,908✔
908
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
11,908✔
909

910
                                        polyline.Vertices.Seqend = seqend;
11,908✔
911
                                }
11,908✔
912
                        }
11,908✔
913
                        else
914
                        {
480✔
915
                                template = new CadPolyLineTemplate();
480✔
916
                                this.readEntityCodes<Entity>(template, this.readPolyline);
480✔
917
                        }
480✔
918

919
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,388!
920
                        {
×
921
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
×
922
                                return null;
×
923
                        }
924

925
                        return template;
12,388✔
926
                }
12,388✔
927

928
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
929
                {
88,952✔
930
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,952✔
931

932
                        switch (this._reader.Code)
88,952✔
933
                        {
934
                                //DXF: always 0
935
                                //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)
936
                                case 10:
937
                                case 20:
938
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
939
                                case 66:
940
                                //Polygon mesh M vertex count (optional; default = 0)
941
                                case 71:
942
                                //Polygon mesh N vertex count(optional; default = 0)
943
                                case 72:
944
                                //Smooth surface M density(optional; default = 0)
945
                                case 73:
946
                                //Smooth surface N density (optional; default = 0)
947
                                case 74:
948
                                        return true;
37,724✔
949
                                case 100:
950
                                        switch (this._reader.ValueAsString)
960!
951
                                        {
952
                                                case DxfSubclassMarker.Polyline:
953
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
954
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
955
                                                        return true;
×
956
                                                case DxfSubclassMarker.Polyline3d:
957
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
958
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
959
                                                        return true;
240✔
960
                                                case DxfSubclassMarker.PolyfaceMesh:
961
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
962
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
963
                                                        return true;
240✔
964
                                                default:
965
                                                        return false;
480✔
966
                                        }
967
                                default:
968
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,268✔
969
                        }
970
                }
88,952✔
971

972
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
973
                {
6,000✔
974
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
975

976
                        switch (this._reader.Code)
6,000✔
977
                        {
978
                                case 3:
979
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
240✔
980
                                        return true;
240✔
981
                                case 10:
982
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
960✔
983
                                        return true;
960✔
984
                                case 20:
985
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
986
                                        y.Y = this._reader.ValueAsDouble;
960✔
987
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
960✔
988
                                        return true;
960✔
989
                                case 30:
990
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
991
                                        z.Z = this._reader.ValueAsDouble;
960✔
992
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
960✔
993
                                        return true;
960✔
994
                                case 340:
995
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
240✔
996
                                        return true;
240✔
997
                                //Hook line flag - read only
998
                                case 75:
999
                                //Vertices count
1000
                                case 76:
1001
                                        return true;
480✔
1002
                                default:
1003
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,160✔
1004
                        }
1005
                }
6,000✔
1006

1007
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
1008
                {
102,456✔
1009
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
102,456✔
1010

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

1013
                        switch (this._reader.Code)
102,456!
1014
                        {
1015
                                case 10:
1016
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
24,372✔
1017
                                        return true;
24,372✔
1018
                                case 20:
1019
                                        if (last is not null)
24,372✔
1020
                                        {
24,372✔
1021
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
24,372✔
1022
                                        }
24,372✔
1023
                                        return true;
24,372✔
1024
                                case 40:
1025
                                        if (last is not null)
2,400✔
1026
                                        {
2,400✔
1027
                                                last.StartWidth = this._reader.ValueAsDouble;
2,400✔
1028
                                        }
2,400✔
1029
                                        return true;
2,400✔
1030
                                case 41:
1031
                                        if (last is not null)
2,400✔
1032
                                        {
2,400✔
1033
                                                last.EndWidth = this._reader.ValueAsDouble;
2,400✔
1034
                                        }
2,400✔
1035
                                        return true;
2,400✔
1036
                                case 42:
1037
                                        if (last is not null)
3,288✔
1038
                                        {
3,288✔
1039
                                                last.Bulge = this._reader.ValueAsDouble;
3,288✔
1040
                                        }
3,288✔
1041
                                        return true;
3,288✔
1042
                                case 50:
1043
                                        if (last is not null)
×
1044
                                        {
×
1045
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
1046
                                        }
×
1047
                                        return true;
×
1048
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
1049
                                case 66:
1050
                                //Vertex count
1051
                                case 90:
1052
                                        return true;
5,496✔
1053
                                case 91:
1054
                                        if (last is not null)
×
1055
                                        {
×
1056
                                                last.Id = this._reader.ValueAsInt;
×
1057
                                        }
×
1058
                                        return true;
×
1059
                                default:
1060
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
40,128✔
1061
                        }
1062
                }
102,456✔
1063

1064
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
1065
                {
42,240✔
1066
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
1067

1068
                        switch (this._reader.Code)
42,240✔
1069
                        {
1070
                                case 100:
1071
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
1072
                                        {
480✔
1073
                                                tmp.SubclassMarker = true;
480✔
1074
                                        }
480✔
1075
                                        return true;
960✔
1076
                                //Count of sub-entity which property has been overridden
1077
                                case 90:
1078
                                        //TODO: process further entities
1079
                                        return true;
480✔
1080
                                case 92:
1081
                                        if (!tmp.SubclassMarker)
720✔
1082
                                        {
240✔
1083
                                                return false;
240✔
1084
                                        }
1085

1086
                                        int nvertices = this._reader.ValueAsInt;
480✔
1087
                                        for (int i = 0; i < nvertices; i++)
61,440✔
1088
                                        {
30,240✔
1089
                                                this._reader.ReadNext();
30,240✔
1090
                                                double x = this._reader.ValueAsDouble;
30,240✔
1091
                                                this._reader.ReadNext();
30,240✔
1092
                                                double y = this._reader.ValueAsDouble;
30,240✔
1093
                                                this._reader.ReadNext();
30,240✔
1094
                                                double z = this._reader.ValueAsDouble;
30,240✔
1095
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
1096
                                        }
30,240✔
1097
                                        return true;
480✔
1098
                                case 93:
1099
                                        int size = this._reader.ValueAsInt;
480✔
1100
                                        this._reader.ReadNext();
480✔
1101

1102
                                        int indexes = 0;
480✔
1103
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
1104
                                        {
32,640✔
1105
                                                indexes = this._reader.ValueAsInt;
32,640✔
1106
                                                this._reader.ReadNext();
32,640✔
1107

1108
                                                int[] face = new int[indexes];
32,640✔
1109
                                                for (int j = 0; j < indexes; j++)
314,880✔
1110
                                                {
124,800✔
1111
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
1112

1113
                                                        if ((i + j + 2) < size)
124,800✔
1114
                                                        {
124,320✔
1115
                                                                this._reader.ReadNext();
124,320✔
1116
                                                        }
124,320✔
1117
                                                }
124,800✔
1118

1119
                                                tmp.CadObject.Faces.Add(face);
32,640✔
1120
                                        }
32,640✔
1121

1122
                                        Debug.Assert(this._reader.Code == 90);
480✔
1123

1124
                                        return true;
480✔
1125
                                case 94:
1126
                                        int numEdges = this._reader.ValueAsInt;
480✔
1127
                                        this._reader.ReadNext();
480✔
1128
                                        for (int i = 0; i < numEdges; i++)
125,760✔
1129
                                        {
62,400✔
1130
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
1131

1132
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
1133
                                                this._reader.ReadNext();
62,400✔
1134
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1135

1136
                                                if (i < numEdges - 1)
62,400✔
1137
                                                {
61,920✔
1138
                                                        this._reader.ReadNext();
61,920✔
1139
                                                }
61,920✔
1140

1141
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1142
                                        }
62,400✔
1143

1144
                                        Debug.Assert(this._reader.Code == 90);
480✔
1145

1146
                                        return true;
480✔
1147
                                case 95:
1148
                                        this._reader.ReadNext();
480✔
1149
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1150
                                        {
62,400✔
1151
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1152
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1153

1154
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1155

1156
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1157
                                                {
61,920✔
1158
                                                        this._reader.ReadNext();
61,920✔
1159
                                                }
61,920✔
1160
                                        }
62,400✔
1161

1162
                                        Debug.Assert(this._reader.Code == 140);
480✔
1163

1164
                                        return true;
480✔
1165
                                default:
1166
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1167
                        }
1168
                }
42,240✔
1169

1170
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1171
                {
62,400✔
1172
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1173

1174
                        switch (this._reader.Code)
62,400✔
1175
                        {
1176
                                // 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.
1177
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1178
                                case 2:
1179
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1180
                                        return true;
720✔
1181
                                case 72:
1182
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1183
                                        return true;
720✔
1184
                                case 73:
1185
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1186
                                        return true;
720✔
1187
                                case 340:
1188
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1189
                                        return true;
720✔
1190
                                default:
1191
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1192
                                        {
10,080✔
1193
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1194
                                        }
1195
                                        return true;
49,440✔
1196
                        }
1197
                }
62,400✔
1198

1199
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1200
                {
169,440✔
1201
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1202

1203
                        switch (this._reader.Code)
169,440✔
1204
                        {
1205
                                case 270:
1206
                                        //f270 Version
1207
                                        return true;
1,800✔
1208
                                case 300:
1209
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1210
                                        return true;
3,600✔
1211
                                case 340:
1212
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1213
                                        return true;
3,600✔
1214
                                case 341:
1215
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1216
                                        return true;
3,600✔
1217
                                case 343:
1218
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1219
                                        return true;
3,600✔
1220
                                default:
1221
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1222
                        }
1223
                }
169,440✔
1224

1225
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1226
                {
3,600✔
1227
                        this._reader.ReadNext();
3,600✔
1228

1229
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1230
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1231

1232
                        bool end = false;
3,600✔
1233
                        while (this._reader.DxfCode != DxfCode.Start)
201,600✔
1234
                        {
201,600✔
1235
                                switch (this._reader.Code)
201,600✔
1236
                                {
1237
                                        case 301 when this._reader.ValueAsString.Equals("}"):
3,600✔
1238
                                                end = true;
3,600✔
1239
                                                break;
3,600✔
1240
                                        case 302 when this._reader.ValueAsString.Equals("LEADER{"):
3,600✔
1241
                                                contextData.LeaderRoots.Add(this.readMultiLeaderLeader(template));
3,600✔
1242
                                                break;
3,600✔
1243
                                        case 340:
1244
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1245
                                                break;
3,600✔
1246
                                        default:
1247
                                                if (!this.tryAssignCurrentValue(contextData, map.SubClasses[contextData.SubclassMarker]))
190,800!
1248
                                                {
×
1249
                                                        this._builder.Notify($"[AcDbMLeaderObjectContextData] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1250
                                                }
×
1251
                                                break;
190,800✔
1252
                                }
1253

1254
                                if (end)
201,600✔
1255
                                {
3,600✔
1256
                                        break;
3,600✔
1257
                                }
1258

1259
                                this._reader.ReadNext();
198,000✔
1260
                        }
198,000✔
1261
                }
3,600✔
1262

1263
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1264
                {
3,600✔
1265
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1266
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1267

1268
                        this._reader.ReadNext();
3,600✔
1269

1270
                        bool end = false;
3,600✔
1271
                        while (this._reader.DxfCode != DxfCode.Start)
45,000✔
1272
                        {
45,000✔
1273
                                switch (this._reader.Code)
45,000✔
1274
                                {
1275
                                        case 303 when this._reader.ValueAsString.Equals("}"):
3,600✔
1276
                                                end = true;
3,600✔
1277
                                                break;
3,600✔
1278
                                        case 304 when this._reader.ValueAsString.Equals("LEADER_LINE{"):
3,600✔
1279
                                                var lineTemplate = new LeaderLineTemplate();
3,600✔
1280
                                                template.LeaderLineTemplates.Add(lineTemplate);
3,600✔
1281
                                                root.Lines.Add(this.readMultiLeaderLine(lineTemplate));
3,600✔
1282
                                                break;
3,600✔
1283
                                        default:
1284
                                                if (!this.tryAssignCurrentValue(root, map))
37,800!
1285
                                                {
×
1286
                                                        this._builder.Notify($"[LeaderRoot] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1287
                                                }
×
1288
                                                break;
37,800✔
1289
                                }
1290

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

1296
                                this._reader.ReadNext();
41,400✔
1297
                        }
41,400✔
1298

1299
                        return root;
3,600✔
1300
                }
3,600✔
1301

1302
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1303
                {
3,600✔
1304
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1305
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1306

1307
                        this._reader.ReadNext();
3,600✔
1308

1309
                        bool end = false;
3,600✔
1310
                        while (this._reader.DxfCode != DxfCode.Start)
18,000✔
1311
                        {
18,000✔
1312
                                switch (this._reader.Code)
18,000✔
1313
                                {
1314
                                        case 10:
1315
                                                XYZ pt = new XYZ(this._reader.ValueAsDouble, 0, 0);
3,600✔
1316
                                                line.Points.Add(pt);
3,600✔
1317
                                                break;
3,600✔
1318
                                        case 20:
1319
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1320
                                                pt.Y = this._reader.ValueAsDouble;
3,600✔
1321
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1322
                                                break;
3,600✔
1323
                                        case 30:
1324
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1325
                                                pt.Z = this._reader.ValueAsDouble;
3,600✔
1326
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1327
                                                break;
3,600✔
1328
                                        case 305 when this._reader.ValueAsString.Equals("}"):
3,600✔
1329
                                                end = true;
3,600✔
1330
                                                break;
3,600✔
1331
                                        default:
1332
                                                if (!this.tryAssignCurrentValue(line, map))
3,600!
1333
                                                {
×
1334
                                                        this._builder.Notify($"[LeaderLine] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1335
                                                }
×
1336
                                                break;
3,600✔
1337
                                }
1338

1339
                                if (end)
18,000✔
1340
                                {
3,600✔
1341
                                        break;
3,600✔
1342
                                }
1343

1344
                                this._reader.ReadNext();
14,400✔
1345
                        }
14,400✔
1346

1347
                        return line;
3,600✔
1348
                }
3,600✔
1349

1350
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1351
                {
2,680✔
1352
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1353

1354
                        switch (this._reader.Code)
2,680✔
1355
                        {
1356
                                case 2:
1357
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1358
                                        return true;
280✔
1359
                                default:
1360
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1361
                        }
1362
                }
2,680✔
1363

1364
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1365
                {
14,160✔
1366
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1367
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1368

1369
                        switch (this._reader.Code)
14,160✔
1370
                        {
1371
                                case 91:
1372
                                        var nvertices = this._reader.ValueAsInt;
480✔
1373
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1374
                                        {
1,680✔
1375
                                                this._reader.ReadNext();
1,680✔
1376
                                                var x = this._reader.ValueAsDouble;
1,680✔
1377
                                                this._reader.ReadNext();
1,680✔
1378
                                                var y = this._reader.ValueAsDouble;
1,680✔
1379

1380
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1381
                                        }
1,680✔
1382

1383
                                        this._reader.ReadNext();
480✔
1384

1385
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1386
                                case 340:
1387
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1388
                                        return true;
480✔
1389
                                case 360:
1390
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1391
                                        return true;
480✔
1392
                                default:
1393
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1394
                        }
1395
                }
14,160✔
1396

1397
                private bool readOle2Frame(CadEntityTemplate template, DxfMap map, string subclass = null)
1398
                {
×
1399
                        CadOle2FrameTemplate tmp = template as CadOle2FrameTemplate;
×
1400

1401
                        switch (this._reader.Code)
×
1402
                        {
1403
                                //End of data
1404
                                case 1:
1405
                                //Length of binary data
1406
                                case 90:
1407
                                //Undocumented
1408
                                case 73:
1409
                                        return true;
×
1410
                                case 310:
1411
                                        tmp.Chunks.Add(this._reader.ValueAsBinaryChunk);
×
1412
                                        return true;
×
1413
                                default:
1414
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1415
                        }
1416
                }
×
1417

1418
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1419
                {
342,410✔
1420
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
342,410✔
1421
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1422
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1423

1424
                        switch (this._reader.Code)
342,410✔
1425
                        {
1426
                                case 1:
1427
                                case 3:
1428
                                        geometry.ProprietaryData.AppendLine(this._reader.ValueAsString);
44,360✔
1429
                                        return true;
44,360✔
1430
                                case 2:
1431
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1432
                                        return true;
240✔
1433
                                case 290:
1434
                                        return true;
240✔
1435
                                default:
1436
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
297,570✔
1437
                        }
1438
                }
342,410✔
1439

1440
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1441
                {
41,040✔
1442
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1443

1444
                        switch (this._reader.Code)
41,040✔
1445
                        {
1446
                                case 350:
1447
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1448
                                        return true;
320✔
1449
                                default:
1450
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1451
                        }
1452
                }
41,040✔
1453

1454
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1455
                {
16,800✔
1456
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1457

1458
                        XYZ controlPoint;
1459
                        XYZ fitPoint;
1460

1461
                        switch (this._reader.Code)
16,800!
1462
                        {
1463
                                case 10:
1464
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1465
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1466
                                        return true;
1,920✔
1467
                                case 20:
1468
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1469
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1470
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1471
                                        return true;
1,920✔
1472
                                case 30:
1473
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1474
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1475
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1476
                                        return true;
1,920✔
1477
                                case 11:
1478
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1479
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1480
                                        return true;
×
1481
                                case 21:
1482
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1483
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1484
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1485
                                        return true;
×
1486
                                case 31:
1487
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1488
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1489
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1490
                                        return true;
×
1491
                                case 40:
1492
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1493
                                        return true;
3,840✔
1494
                                case 41:
1495
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1496
                                        return true;
×
1497
                                case 72:
1498
                                case 73:
1499
                                case 74:
1500
                                        return true;
1,440✔
1501
                                default:
1502
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1503
                        }
1504
                }
16,800✔
1505

1506
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1507
                        where T : PdfUnderlayDefinition
1508
                {
3,800✔
1509
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1510

1511
                        switch (this._reader.Code)
3,800✔
1512
                        {
1513
                                case 340:
1514
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1515
                                        return true;
240✔
1516
                                default:
1517
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1518
                        }
1519
                }
3,800✔
1520

1521
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1522
                {
281,566✔
1523
                        CadVertexTemplate tmp = template as CadVertexTemplate;
281,566✔
1524

1525
                        switch (this._reader.Code)
281,566✔
1526
                        {
1527
                                case 100:
1528
                                        switch (this._reader.ValueAsString)
8,160!
1529
                                        {
1530
                                                case DxfSubclassMarker.Vertex:
1531
                                                        return true;
2,400✔
1532
                                                case DxfSubclassMarker.PolylineVertex:
1533
                                                        tmp.SetVertexObject(new Vertex2D());
×
1534
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1535
                                                        return true;
×
1536
                                                case DxfSubclassMarker.Polyline3dVertex:
1537
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1538
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1539
                                                        return true;
1,200✔
1540
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1541
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1542
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1543
                                                        return true;
1,200✔
1544
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1545
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1546
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1547
                                                        return true;
480✔
1548
                                                default:
1549
                                                        return false;
2,880✔
1550
                                        }
1551
                                default:
1552
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
273,406✔
1553
                        }
1554
                }
281,566✔
1555

1556
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1557
                {
80,456✔
1558
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1559

1560
                        switch (this._reader.Code)
80,456!
1561
                        {
1562
                                //Undocumented
1563
                                case 67:
1564
                                case 68:
1565
                                        return true;
2,944✔
1566
                                case 69:
1567
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1568
                                        return true;
1,472✔
1569
                                case 331:
1570
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1571
                                        return true;
×
1572
                                case 348:
1573
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1574
                                        return true;
928✔
1575
                                default:
1576
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1577
                        }
1578
                }
80,456✔
1579

1580
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1581
                {
954,920✔
1582
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
954,920✔
1583

1584
                        switch (this._reader.Code)
954,920✔
1585
                        {
1586
                                default:
1587
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
954,920✔
1588
                        }
1589
                }
954,920✔
1590

1591
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1592
                {
40,167✔
1593
                        List<ExtendedDataRecord> records = new();
40,167✔
1594
                        edata.Add(this._reader.ValueAsString, records);
40,167✔
1595

1596
                        this._reader.ReadNext();
40,167✔
1597

1598
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,956✔
1599
                        {
301,555✔
1600
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
301,555✔
1601
                                {
12,766✔
1602
                                        this.readExtendedData(edata);
12,766✔
1603
                                        break;
12,766✔
1604
                                }
1605

1606
                                ExtendedDataRecord record = null;
288,789✔
1607
                                double x = 0;
288,789✔
1608
                                double y = 0;
288,789✔
1609
                                double z = 0;
288,789✔
1610

1611
                                switch (this._reader.DxfCode)
288,789✔
1612
                                {
1613
                                        case DxfCode.ExtendedDataAsciiString:
1614
                                        case DxfCode.ExtendedDataRegAppName:
1615
                                                record = new ExtendedDataString(this._reader.ValueAsString);
27,714✔
1616
                                                break;
27,714✔
1617
                                        case DxfCode.ExtendedDataControlString:
1618
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1619
                                                break;
15,848✔
1620
                                        case DxfCode.ExtendedDataLayerName:
1621
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1622
                                                {
266✔
1623
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1624
                                                }
266✔
1625
                                                else
1626
                                                {
14✔
1627
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1628
                                                }
14✔
1629
                                                break;
280✔
1630
                                        case DxfCode.ExtendedDataBinaryChunk:
1631
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1632
                                                break;
80✔
1633
                                        case DxfCode.ExtendedDataHandle:
1634
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1635
                                                break;
2,958✔
1636
                                        case DxfCode.ExtendedDataXCoordinate:
1637
                                                x = this._reader.ValueAsDouble;
2,984✔
1638
                                                this._reader.ReadNext();
2,984✔
1639
                                                y = this._reader.ValueAsDouble;
2,984✔
1640
                                                this._reader.ReadNext();
2,984✔
1641
                                                z = this._reader.ValueAsDouble;
2,984✔
1642

1643
                                                record = new ExtendedDataCoordinate(
2,984✔
1644
                                                        new XYZ(
2,984✔
1645
                                                                x,
2,984✔
1646
                                                                y,
2,984✔
1647
                                                                z)
2,984✔
1648
                                                        );
2,984✔
1649
                                                break;
2,984✔
1650
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1651
                                                x = this._reader.ValueAsDouble;
1,440✔
1652
                                                this._reader.ReadNext();
1,440✔
1653
                                                y = this._reader.ValueAsDouble;
1,440✔
1654
                                                this._reader.ReadNext();
1,440✔
1655
                                                z = this._reader.ValueAsDouble;
1,440✔
1656

1657
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1658
                                                        new XYZ(
1,440✔
1659
                                                                x,
1,440✔
1660
                                                                y,
1,440✔
1661
                                                                z)
1,440✔
1662
                                                        );
1,440✔
1663
                                                break;
1,440✔
1664
                                        case DxfCode.ExtendedDataWorldXDisp:
1665
                                                x = this._reader.ValueAsDouble;
280✔
1666
                                                this._reader.ReadNext();
280✔
1667
                                                y = this._reader.ValueAsDouble;
280✔
1668
                                                this._reader.ReadNext();
280✔
1669
                                                z = this._reader.ValueAsDouble;
280✔
1670

1671
                                                record = new ExtendedDataDisplacement(
280✔
1672
                                                        new XYZ(
280✔
1673
                                                                x,
280✔
1674
                                                                y,
280✔
1675
                                                                z)
280✔
1676
                                                        );
280✔
1677
                                                break;
280✔
1678
                                        case DxfCode.ExtendedDataWorldXDir:
1679
                                                x = this._reader.ValueAsDouble;
280✔
1680
                                                this._reader.ReadNext();
280✔
1681
                                                y = this._reader.ValueAsDouble;
280✔
1682
                                                this._reader.ReadNext();
280✔
1683
                                                z = this._reader.ValueAsDouble;
280✔
1684

1685
                                                record = new ExtendedDataDirection(
280✔
1686
                                                        new XYZ(
280✔
1687
                                                                x,
280✔
1688
                                                                y,
280✔
1689
                                                                z)
280✔
1690
                                                        );
280✔
1691
                                                break;
280✔
1692
                                        case DxfCode.ExtendedDataReal:
1693
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1694
                                                break;
140,536✔
1695
                                        case DxfCode.ExtendedDataDist:
1696
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1697
                                                break;
280✔
1698
                                        case DxfCode.ExtendedDataScale:
1699
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1700
                                                break;
280✔
1701
                                        case DxfCode.ExtendedDataInteger16:
1702
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
82,053✔
1703
                                                break;
82,053✔
1704
                                        case DxfCode.ExtendedDataInteger32:
1705
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
11,216✔
1706
                                                break;
11,216✔
1707
                                        default:
1708
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1709
                                                break;
2,560✔
1710
                                }
1711

1712
                                if (record != null)
288,789✔
1713
                                {
286,215✔
1714
                                        records.Add(record);
286,215✔
1715
                                }
286,215✔
1716

1717
                                this._reader.ReadNext();
288,789✔
1718
                        }
288,789✔
1719
                }
40,167✔
1720

1721
                private void readPattern(HatchPattern pattern, int nlines)
1722
                {
1,440✔
1723
                        //Jump 78 code
1724
                        this._reader.ReadNext();
1,440✔
1725

1726
                        for (int i = 0; i < nlines; i++)
218,400✔
1727
                        {
107,760✔
1728
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1729
                                XY basePoint = new XY();
107,760✔
1730
                                XY offset = new XY();
107,760✔
1731

1732
                                bool end = false;
107,760✔
1733
                                HashSet<int> codes = new();
107,760✔
1734

1735
                                while (!end)
755,760✔
1736
                                {
754,320✔
1737
                                        if (codes.Contains(this._reader.Code))
754,320✔
1738
                                        {
106,320✔
1739
                                                break;
106,320✔
1740
                                        }
1741
                                        else
1742
                                        {
648,000✔
1743
                                                codes.Add(this._reader.Code);
648,000✔
1744
                                        }
648,000✔
1745

1746
                                        switch (this._reader.Code)
648,000!
1747
                                        {
1748
                                                case 53:
1749
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1750
                                                        break;
107,760✔
1751
                                                case 43:
1752
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1753
                                                        break;
107,760✔
1754
                                                case 44:
1755
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1756
                                                        line.BasePoint = basePoint;
107,760✔
1757
                                                        break;
107,760✔
1758
                                                case 45:
1759
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1760
                                                        line.Offset = offset;
107,760✔
1761
                                                        break;
107,760✔
1762
                                                case 46:
1763
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1764
                                                        line.Offset = offset;
107,760✔
1765
                                                        break;
107,760✔
1766
                                                //Number of dash length items
1767
                                                case 79:
1768
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1769
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1770
                                                        {
215,040✔
1771
                                                                this._reader.ReadNext();
215,040✔
1772
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1773
                                                        }
215,040✔
1774
                                                        break;
107,760✔
1775
                                                case 49:
1776
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
1777
                                                        break;
×
1778
                                                default:
1779
                                                        end = true;
1,440✔
1780
                                                        break;
1,440✔
1781
                                        }
1782
                                        this._reader.ReadNext();
648,000✔
1783
                                }
648,000✔
1784

1785
                                pattern.Lines.Add(line);
107,760✔
1786
                        }
107,760✔
1787
                }
1,440✔
1788

1789
                private void readLoops(CadHatchTemplate template, int count)
1790
                {
1,920✔
1791
                        if (this._reader.Code == 91)
1,920✔
1792
                                this._reader.ReadNext();
1,920✔
1793

1794
                        for (int i = 0; i < count; i++)
7,680✔
1795
                        {
1,920✔
1796
                                if (this._reader.Code != 92)
1,920!
1797
                                {
×
1798
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1799
                                        break;
×
1800
                                }
1801

1802
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1803
                                if (path != null)
1,920✔
1804
                                        template.PathTemplates.Add(path);
1,920✔
1805
                        }
1,920✔
1806
                }
1,920✔
1807

1808
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1809
                {
1,920✔
1810
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1811
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1812
                        template.Path.Flags = flags;
1,920✔
1813

1814
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1815
                        {
720✔
1816
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1817
                                template.Path.Edges.Add(pl);
720✔
1818
                        }
720✔
1819
                        else
1820
                        {
1,200✔
1821
                                this._reader.ReadNext();
1,200✔
1822

1823
                                if (this._reader.Code != 93)
1,200!
1824
                                {
×
1825
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1826
                                        return null;
×
1827
                                }
1828

1829
                                int edges = this._reader.ValueAsInt;
1,200✔
1830
                                this._reader.ReadNext();
1,200✔
1831

1832
                                for (int i = 0; i < edges; i++)
12,000✔
1833
                                {
4,800✔
1834
                                        var edge = this.readEdge();
4,800✔
1835
                                        if (edge != null)
4,800✔
1836
                                                template.Path.Edges.Add(edge);
4,800✔
1837
                                }
4,800✔
1838
                        }
1,200✔
1839

1840
                        bool end = false;
1,920✔
1841
                        while (!end)
7,440✔
1842
                        {
5,520✔
1843
                                switch (this._reader.Code)
5,520✔
1844
                                {
1845
                                        //Number of source boundary objects
1846
                                        case 97:
1847
                                                break;
1,920✔
1848
                                        case 330:
1849
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1850
                                                break;
1,680✔
1851
                                        default:
1852
                                                end = true;
1,920✔
1853
                                                continue;
1,920✔
1854
                                }
1855

1856
                                this._reader.ReadNext();
3,600✔
1857
                        }
3,600✔
1858

1859
                        return template;
1,920✔
1860
                }
1,920✔
1861

1862
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1863
                {
720✔
1864
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1865

1866
                        this._reader.ReadNext();
720✔
1867

1868
                        if (this._reader.Code != 72)
720!
1869
                        {
×
1870
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1871
                                return null;
×
1872
                        }
1873

1874
                        //72
1875
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1876
                        this._reader.ReadNext();
720✔
1877

1878
                        //73
1879
                        bool isClosed = this._reader.ValueAsBool;
720✔
1880
                        this._reader.ReadNext();
720✔
1881

1882
                        //93
1883
                        int nvertices = this._reader.ValueAsInt;
720✔
1884
                        this._reader.ReadNext();
720✔
1885

1886
                        for (int i = 0; i < nvertices; i++)
7,200✔
1887
                        {
2,880✔
1888
                                double bulge = 0.0;
2,880✔
1889

1890
                                //10
1891
                                double x = this._reader.ValueAsDouble;
2,880✔
1892
                                this._reader.ReadNext();
2,880✔
1893
                                //20
1894
                                double y = this._reader.ValueAsDouble;
2,880✔
1895
                                this._reader.ReadNext();
2,880✔
1896

1897
                                if (hasBulge)
2,880!
1898
                                {
×
1899
                                        //42
1900
                                        bulge = this._reader.ValueAsDouble;
×
1901
                                        this._reader.ReadNext();
×
1902
                                }
×
1903

1904
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1905
                        }
2,880✔
1906

1907
                        return boundary;
720✔
1908
                }
720✔
1909

1910
                private Hatch.BoundaryPath.Edge readEdge()
1911
                {
4,800✔
1912
                        if (this._reader.Code != 72)
4,800!
1913
                        {
×
1914
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1915
                                return null;
×
1916
                        }
1917

1918
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1919
                        this._reader.ReadNext();
4,800✔
1920

1921
                        switch (type)
4,800!
1922
                        {
1923
                                case Hatch.BoundaryPath.EdgeType.Line:
1924
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1925
                                        while (true)
24,000✔
1926
                                        {
24,000✔
1927
                                                switch (this._reader.Code)
24,000✔
1928
                                                {
1929
                                                        case 10:
1930
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1931
                                                                break;
4,800✔
1932
                                                        case 20:
1933
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1934
                                                                break;
4,800✔
1935
                                                        case 11:
1936
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1937
                                                                break;
4,800✔
1938
                                                        case 21:
1939
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1940
                                                                break;
4,800✔
1941
                                                        default:
1942
                                                                return line;
4,800✔
1943
                                                }
1944

1945
                                                this._reader.ReadNext();
19,200✔
1946
                                        }
19,200✔
1947
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1948
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1949
                                        while (true)
×
1950
                                        {
×
1951
                                                switch (this._reader.Code)
×
1952
                                                {
1953
                                                        case 10:
1954
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1955
                                                                break;
×
1956
                                                        case 20:
1957
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1958
                                                                break;
×
1959
                                                        case 40:
1960
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1961
                                                                break;
×
1962
                                                        case 50:
1963
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1964
                                                                break;
×
1965
                                                        case 51:
1966
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1967
                                                                break;
×
1968
                                                        case 73:
1969
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1970
                                                                break;
×
1971
                                                        default:
1972
                                                                return arc;
×
1973
                                                }
1974

1975
                                                this._reader.ReadNext();
×
1976
                                        }
×
1977
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1978
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1979
                                        while (true)
×
1980
                                        {
×
1981
                                                switch (this._reader.Code)
×
1982
                                                {
1983
                                                        case 10:
1984
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1985
                                                                break;
×
1986
                                                        case 20:
1987
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1988
                                                                break;
×
1989
                                                        case 11:
1990
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1991
                                                                break;
×
1992
                                                        case 21:
1993
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1994
                                                                break;
×
1995
                                                        case 40:
1996
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1997
                                                                break;
×
1998
                                                        case 50:
1999
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
2000
                                                                break;
×
2001
                                                        case 51:
2002
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
2003
                                                                break;
×
2004
                                                        case 73:
2005
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
2006
                                                                break;
×
2007
                                                        default:
2008
                                                                return ellipse;
×
2009
                                                }
2010

2011
                                                this._reader.ReadNext();
×
2012
                                        }
×
2013
                                case Hatch.BoundaryPath.EdgeType.Spline:
2014
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
2015
                                        int nKnots = 0;
×
2016
                                        int nCtrlPoints = 0;
×
2017
                                        int nFitPoints = 0;
×
2018

2019
                                        XYZ controlPoint = new XYZ();
×
2020
                                        XY fitPoint = new XY();
×
2021

2022
                                        while (true)
×
2023
                                        {
×
2024
                                                switch (this._reader.Code)
×
2025
                                                {
2026
                                                        case 10:
2027
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
2028
                                                                break;
×
2029
                                                        case 20:
2030
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
2031
                                                                spline.ControlPoints.Add(controlPoint);
×
2032
                                                                break;
×
2033
                                                        case 11:
2034
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
2035
                                                                break;
×
2036
                                                        case 21:
2037
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
2038
                                                                spline.FitPoints.Add(fitPoint);
×
2039
                                                                break;
×
2040
                                                        case 42:
2041
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
2042
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
2043
                                                                break;
×
2044
                                                        case 12:
2045
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
2046
                                                                break;
×
2047
                                                        case 22:
2048
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
2049
                                                                break;
×
2050
                                                        case 13:
2051
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
2052
                                                                break;
×
2053
                                                        case 23:
2054
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
2055
                                                                break;
×
2056
                                                        case 94:
2057
                                                                spline.Degree = this._reader.ValueAsInt;
×
2058
                                                                break;
×
2059
                                                        case 73:
2060
                                                                spline.Rational = this._reader.ValueAsBool;
×
2061
                                                                break;
×
2062
                                                        case 74:
2063
                                                                spline.Periodic = this._reader.ValueAsBool;
×
2064
                                                                break;
×
2065
                                                        case 95:
2066
                                                                nKnots = this._reader.ValueAsInt;
×
2067
                                                                break;
×
2068
                                                        case 96:
2069
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
2070
                                                                break;
×
2071
                                                        case 97:
2072
                                                                nFitPoints = this._reader.ValueAsInt;
×
2073
                                                                break;
×
2074
                                                        case 40:
2075
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
2076
                                                                break;
×
2077
                                                        default:
2078
                                                                return spline;
×
2079
                                                }
2080

2081
                                                this._reader.ReadNext();
×
2082
                                        }
×
2083
                        }
2084

2085
                        return null;
×
2086
                }
4,800✔
2087

2088
                private void readDefinedGroups(CadTemplate template)
2089
                {
79,112✔
2090
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
79,112✔
2091

2092
                        template.XDictHandle = xdict;
79,112✔
2093
                        template.ReactorsHandles.UnionWith(reactorsHandles);
79,112✔
2094
                }
79,112✔
2095

2096
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
2097
                {
79,354✔
2098
                        xdictHandle = null;
79,354✔
2099
                        reactors = new HashSet<ulong>();
79,354✔
2100

2101
                        switch (this._reader.ValueAsString)
79,354✔
2102
                        {
2103
                                case DxfFileToken.DictionaryToken:
2104
                                        this._reader.ReadNext();
11,615✔
2105
                                        xdictHandle = this._reader.ValueAsHandle;
11,615✔
2106
                                        this._reader.ReadNext();
11,615✔
2107
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
11,615✔
2108
                                        return;
11,615✔
2109
                                case DxfFileToken.ReactorsToken:
2110
                                        reactors = this.readReactors();
65,339✔
2111
                                        break;
65,339✔
2112
                                case DxfFileToken.BlkRefToken:
2113
                                default:
2114
                                        do
2115
                                        {
6,240✔
2116
                                                this._reader.ReadNext();
6,240✔
2117
                                        }
6,240✔
2118
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2119
                                        return;
2,400✔
2120
                        }
2121
                }
79,354✔
2122

2123
                private HashSet<ulong> readReactors()
2124
                {
65,339✔
2125
                        HashSet<ulong> reactors = new();
65,339✔
2126

2127
                        this._reader.ReadNext();
65,339✔
2128

2129
                        while (this._reader.DxfCode != DxfCode.ControlString)
137,962✔
2130
                        {
72,623✔
2131
                                reactors.Add(this._reader.ValueAsHandle);
72,623✔
2132

2133
                                this._reader.ReadNext();
72,623✔
2134
                        }
72,623✔
2135

2136
                        return reactors;
65,339✔
2137
                }
65,339✔
2138

2139
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2140
                {
4,946,504✔
2141
                        try
2142
                        {
4,946,504✔
2143
                                //Use this method only if the value is not a link between objects
2144
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
4,946,504✔
2145
                                {
2,665,857✔
2146
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,665,857✔
2147
                                        {
14,790✔
2148
                                                return true;
14,790✔
2149
                                        }
2150

2151
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,651,067✔
2152
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,651,067✔
2153
                                        {
17,410✔
2154
                                                return false;
17,410✔
2155
                                        }
2156

2157
                                        object value = this._reader.Value;
2,633,657✔
2158

2159
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,633,657✔
2160
                                        {
29,312✔
2161
                                                value = MathHelper.DegToRad((double)value);
29,312✔
2162
                                        }
29,312✔
2163

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

2166
                                        return true;
2,633,657✔
2167
                                }
2168
                        }
2,280,647✔
2169
                        catch (Exception ex)
×
2170
                        {
×
2171
                                if (!this._builder.Configuration.Failsafe)
×
2172
                                {
×
2173
                                        throw ex;
×
2174
                                }
2175
                                else
2176
                                {
×
2177
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2178
                                }
×
2179
                        }
×
2180

2181
                        return false;
2,280,647✔
2182
                }
4,946,504✔
2183
        }
2184
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc