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

DomCR / ACadSharp / 12612533277

04 Jan 2025 05:51PM UTC coverage: 75.623% (+0.6%) from 75.001%
12612533277

push

github

web-flow
Merge pull request #486 from DomCR/dynamic-blocks

Dynamic blocks

5196 of 7588 branches covered (68.48%)

Branch coverage included in aggregate %.

276 of 360 new or added lines in 21 files covered. (76.67%)

3 existing lines in 1 file now uncovered.

20797 of 26784 relevant lines covered (77.65%)

36308.12 hits per line

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

79.51
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs
1
using ACadSharp.Entities;
2
using ACadSharp.IO.Templates;
3
using ACadSharp.XData;
4
using CSMath;
5
using CSUtilities.Converters;
6
using System;
7
using System.Collections.Generic;
8
using System.Diagnostics;
9
using System.Linq;
10

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

17
                protected readonly IDxfStreamReader _reader;
18
                protected readonly DxfDocumentBuilder _builder;
19

20
                public DxfSectionReaderBase(IDxfStreamReader reader, DxfDocumentBuilder builder)
610✔
21
                {
610✔
22
                        this._reader = reader;
610✔
23
                        this._builder = builder;
610✔
24
                }
610✔
25

26
                public abstract void Read();
27

28
                protected void readCommonObjectData(out string name, out ulong handle, out ulong? ownerHandle, out ulong? xdictHandle, out List<ulong> reactors)
29
                {
1,456✔
30
                        name = null;
1,456✔
31
                        handle = 0;
1,456✔
32
                        ownerHandle = null;
1,456✔
33
                        xdictHandle = null;
1,456✔
34
                        reactors = new List<ulong>();
1,456✔
35

36
                        if (this._reader.DxfCode == DxfCode.Start
1,456!
37
                                        || this._reader.DxfCode == DxfCode.Subclass)
1,456✔
38
                                this._reader.ReadNext();
×
39

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

72
                                this._reader.ReadNext();
4,340✔
73
                        }
4,340✔
74
                }
1,456✔
75

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

104
                                this._reader.ReadNext();
651✔
105
                        }
651✔
106
                }
217✔
107

108
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
109
                {
699,036✔
110
                        isExtendedData = false;
699,036✔
111

112
                        switch (this._reader.Code)
699,036✔
113
                        {
114
                                //Handle
115
                                case 5:
116
                                        template.CadObject.Handle = this._reader.ValueAsHandle;
108,636✔
117
                                        break;
108,636✔
118
                                //Check with mapper
119
                                case 100:
120
                                        if (map != null && !map.SubClasses.ContainsKey(this._reader.ValueAsString))
77,068!
121
                                                this._builder.Notify($"[{template.CadObject.ObjectName}] Unidentified subclass {this._reader.ValueAsString}", NotificationType.Warning);
708✔
122
                                        break;
77,068✔
123
                                //Start of application - defined group
124
                                case 102:
125
                                        this.readDefinedGroups(template);
26,788✔
126
                                        break;
26,788✔
127
                                //Soft - pointer ID / handle to owner BLOCK_RECORD object
128
                                case 330:
129
                                        template.OwnerHandle = this._reader.ValueAsHandle;
61,184✔
130
                                        break;
61,184✔
131
                                case 1001:
132
                                        isExtendedData = true;
8,727✔
133
                                        this.readExtendedData(template.EDataTemplateByAppName);
8,727✔
134
                                        break;
8,727✔
135
                                default:
136
                                        this._builder.Notify($"[{template.CadObject.SubclassMarker}] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
416,633✔
137
                                        break;
416,633✔
138
                        }
139
                }
699,036✔
140

141
                protected CadEntityTemplate readEntity()
142
                {
70,493✔
143
                        switch (this._reader.ValueAsString)
70,493!
144
                        {
145
                                case DxfFileToken.EntityAttribute:
146
                                        return this.readEntityCodes<AttributeEntity>(new CadAttributeTemplate(new AttributeEntity()), this.readAttributeDefinition);
560✔
147
                                case DxfFileToken.EntityAttributeDefinition:
148
                                        return this.readEntityCodes<AttributeDefinition>(new CadAttributeTemplate(new AttributeDefinition()), this.readAttributeDefinition);
630✔
149
                                case DxfFileToken.EntityArc:
150
                                        return this.readEntityCodes<Arc>(new CadEntityTemplate<Arc>(), this.readArc);
392✔
151
                                case DxfFileToken.EntityCircle:
152
                                        return this.readEntityCodes<Circle>(new CadEntityTemplate<Circle>(), this.readEntitySubclassMap);
570✔
153
                                case DxfFileToken.EntityDimension:
154
                                        return this.readEntityCodes<Dimension>(new CadDimensionTemplate(), this.readDimension);
1,120✔
155
                                case DxfFileToken.Entity3DFace:
156
                                        return this.readEntityCodes<Face3D>(new CadEntityTemplate<Face3D>(), this.readEntitySubclassMap);
140✔
157
                                case DxfFileToken.EntityEllipse:
158
                                        return this.readEntityCodes<Ellipse>(new CadEntityTemplate<Ellipse>(), this.readEntitySubclassMap);
120✔
159
                                case DxfFileToken.EntityLeader:
160
                                        return this.readEntityCodes<Leader>(new CadLeaderTemplate(), this.readLeader);
120✔
161
                                case DxfFileToken.EntityLine:
162
                                        return this.readEntityCodes<Line>(new CadEntityTemplate<Line>(), this.readEntitySubclassMap);
13,052✔
163
                                case DxfFileToken.EntityLwPolyline:
164
                                        return this.readEntityCodes<LwPolyline>(new CadEntityTemplate<LwPolyline>(), this.readLwPolyline);
1,296✔
165
                                case DxfFileToken.EntityMesh:
166
                                        return this.readEntityCodes<Mesh>(new CadMeshTemplate(), this.readMesh);
240✔
167
                                case DxfFileToken.EntityHatch:
168
                                        return this.readEntityCodes<Hatch>(new CadHatchTemplate(), this.readHatch);
480✔
169
                                case DxfFileToken.EntityInsert:
170
                                        return this.readEntityCodes<Insert>(new CadInsertTemplate(), this.readInsert);
1,252✔
171
                                case DxfFileToken.EntityMText:
172
                                        return this.readEntityCodes<MText>(new CadTextEntityTemplate(new MText()), this.readTextEntity);
2,340✔
173
                                case DxfFileToken.EntityMLine:
174
                                        return this.readEntityCodes<MLine>(new CadMLineTemplate(), this.readMLine);
360✔
175
                                case DxfFileToken.EntityPdfUnderlay:
176
                                        return this.readEntityCodes<PdfUnderlay>(new CadPdfUnderlayTemplate(), this.readUnderlayEntity);
×
177
                                case DxfFileToken.EntityPoint:
178
                                        return this.readEntityCodes<Point>(new CadEntityTemplate<Point>(), this.readEntitySubclassMap);
3,990✔
179
                                case DxfFileToken.EntityPolyline:
180
                                        return this.readPolyline();
5,272✔
181
                                case DxfFileToken.EntityRay:
182
                                        return this.readEntityCodes<Ray>(new CadEntityTemplate<Ray>(), this.readEntitySubclassMap);
120✔
183
                                case DxfFileToken.EndSequence:
184
                                        return this.readEntityCodes<Seqend>(new CadEntityTemplate<Seqend>(), this.readEntitySubclassMap);
5,552✔
185
                                case DxfFileToken.EntitySolid:
186
                                        return this.readEntityCodes<Solid>(new CadEntityTemplate<Solid>(), this.readEntitySubclassMap);
6,980✔
187
                                case DxfFileToken.EntityTable:
188
                                        return this.readEntityCodes<TableEntity>(new CadTableEntityTemplate(), this.readTableEntity);
121✔
189
                                case DxfFileToken.EntityText:
190
                                        return this.readEntityCodes<TextEntity>(new CadTextEntityTemplate(new TextEntity()), this.readTextEntity);
3,964✔
191
                                case DxfFileToken.EntityTolerance:
192
                                        return this.readEntityCodes<Tolerance>(new CadToleranceTemplate(new Tolerance()), this.readTolerance);
360✔
193
                                case DxfFileToken.EntityVertex:
194
                                        return this.readEntityCodes<Entity>(new CadVertexTemplate(), this.readVertex);
19,910✔
195
                                case DxfFileToken.EntityViewport:
196
                                        return this.readEntityCodes<Viewport>(new CadViewportTemplate(), this.readViewport);
712✔
197
                                case DxfFileToken.EntityShape:
198
                                        return this.readEntityCodes<Shape>(new CadShapeTemplate(new Shape()), this.readShape);
120✔
199
                                case DxfFileToken.EntitySpline:
200
                                        return this.readEntityCodes<Spline>(new CadSplineTemplate(), this.readSpline);
240✔
201
                                case DxfFileToken.EntityXline:
202
                                        return this.readEntityCodes<XLine>(new CadEntityTemplate<XLine>(), this.readEntitySubclassMap);
120✔
203
                                default:
204
                                        DxfMap map = DxfMap.Create<Entity>();
360✔
205
                                        CadUnknownEntityTemplate unknownEntityTemplate = null;
360✔
206
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
360✔
207
                                        {
324✔
208
                                                this._builder.Notify($"Entity not supported read as an UnknownEntity: {this._reader.ValueAsString}", NotificationType.NotImplemented);
324✔
209
                                                unknownEntityTemplate = new CadUnknownEntityTemplate(new UnknownEntity(dxfClass));
324✔
210
                                        }
324✔
211
                                        else
212
                                        {
36✔
213
                                                this._builder.Notify($"Entity not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
36✔
214
                                        }
36✔
215

216
                                        this._reader.ReadNext();
360✔
217

218
                                        do
219
                                        {
23,134✔
220
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
23,134✔
221
                                                {
2,308✔
222
                                                        this.readCommonEntityCodes(unknownEntityTemplate, out bool isExtendedData, map);
2,308✔
223
                                                        if (isExtendedData)
2,308✔
224
                                                                continue;
6✔
225
                                                }
2,302✔
226

227
                                                this._reader.ReadNext();
23,128✔
228
                                        }
23,128✔
229
                                        while (this._reader.DxfCode != DxfCode.Start);
23,134✔
230

231
                                        return unknownEntityTemplate;
360✔
232
                        }
233
                }
70,493✔
234

235
                protected CadEntityTemplate readEntityCodes<T>(CadEntityTemplate template, ReadEntityDelegate<T> readEntity)
236
                        where T : Entity
237
                {
70,171✔
238
                        this._reader.ReadNext();
70,171✔
239

240
                        DxfMap map = DxfMap.Create<T>();
70,171✔
241

242
                        while (this._reader.DxfCode != DxfCode.Start)
921,546✔
243
                        {
851,375✔
244
                                if (!readEntity(template, map))
851,375✔
245
                                {
380,080✔
246
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
380,080✔
247
                                        if (isExtendedData)
380,080✔
248
                                                continue;
2,915✔
249
                                }
377,165✔
250

251
                                if (this._reader.DxfCode != DxfCode.Start)
848,460✔
252
                                        this._reader.ReadNext();
848,422✔
253
                        }
848,460✔
254

255
                        return template;
70,171✔
256
                }
70,171✔
257

258
                protected void readCommonEntityCodes(CadEntityTemplate template, out bool isExtendedData, DxfMap map = null)
259
                {
401,852✔
260
                        isExtendedData = false;
401,852✔
261
                        switch (this._reader.Code)
401,852✔
262
                        {
263
                                case 6:
264
                                        template.LineTypeName = this._reader.ValueAsString;
10,265✔
265
                                        break;
10,265✔
266
                                case 8:
267
                                        template.LayerName = this._reader.ValueAsString;
75,361✔
268
                                        break;
75,361✔
269
                                //Absent or zero indicates entity is in model space. 1 indicates entity is in paper space (optional).
270
                                case 67:
271
                                        break;
732✔
272
                                //Number of bytes Proxy entity graphics data
273
                                case 92:
274
                                case 160:
275
                                //Proxy entity graphics data
276
                                case 310:
277
                                        break;
22,704✔
278
                                case 347:
279
                                        template.MaterialHandle = this._reader.ValueAsHandle;
80✔
280
                                        break;
80✔
281
                                case 430:
282
                                        template.BookColorName = this._reader.ValueAsString;
8✔
283
                                        break;
8✔
284
                                default:
285
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Entity]))
292,702✔
286
                                        {
260,867✔
287
                                                this.readCommonCodes(template, out isExtendedData, map);
260,867✔
288
                                        }
260,867✔
289
                                        break;
292,702✔
290
                        }
291
                }
401,852✔
292

293
                private bool readArc(CadEntityTemplate template, DxfMap map, string subclass = null)
294
                {
5,128✔
295
                        switch (this._reader.Code)
5,128✔
296
                        {
297
                                default:
298
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Arc]))
5,128✔
299
                                        {
4,344✔
300
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.Circle);
4,344✔
301
                                        }
302
                                        return true;
784✔
303
                        }
304
                }
5,128✔
305

306
                private bool readAttributeDefinition(CadEntityTemplate template, DxfMap map, string subclass = null)
307
                {
19,186✔
308
                        DxfClassMap emap = map.SubClasses[template.CadObject.SubclassMarker];
19,186✔
309
                        CadAttributeTemplate tmp = template as CadAttributeTemplate;
19,186✔
310

311
                        switch (this._reader.Code)
19,186!
312
                        {
313
                                case 44:
314
                                case 46:
315
                                        return true;
×
316
                                case 101:
317
                                        var att = tmp.CadObject as AttributeBase;
38✔
318
                                        att.MText = new MText();
38✔
319
                                        CadTextEntityTemplate mtextTemplate = new CadTextEntityTemplate(att.MText);
38✔
320
                                        tmp.MTextTemplate = mtextTemplate;
38✔
321
                                        this.readEntityCodes<MText>(mtextTemplate, this.readTextEntity);
38✔
322
                                        return true;
38✔
323
                                default:
324
                                        if (!this.tryAssignCurrentValue(template.CadObject, emap))
19,148✔
325
                                        {
14,498✔
326
                                                return this.readTextEntity(template, map, DxfSubclassMarker.Text);
14,498✔
327
                                        }
328
                                        return true;
4,650✔
329
                        }
330
                }
19,186✔
331

332
                private bool readTableEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
333
                {
42,933✔
334
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
42,933!
335
                        CadTableEntityTemplate tmp = template as CadTableEntityTemplate;
42,933✔
336
                        TableEntity table = tmp.CadObject as TableEntity;
42,933✔
337

338
                        switch (this._reader.Code)
42,933✔
339
                        {
340
                                case 2:
341
                                        tmp.BlockName = this._reader.ValueAsString;
121✔
342
                                        return true;
121✔
343
                                case 342:
344
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
121✔
345
                                        return true;
121✔
346
                                case 343:
347
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
121✔
348
                                        return true;
121✔
349
                                case 141:
350
                                        var row = new TableEntity.Row();
844✔
351
                                        row.Height = this._reader.ValueAsDouble;
844✔
352
                                        table.Rows.Add(row);
844✔
353
                                        return true;
844✔
354
                                case 142:
355
                                        var col = new TableEntity.Column();
365✔
356
                                        col.Width = this._reader.ValueAsDouble;
365✔
357
                                        table.Columns.Add(col);
365✔
358
                                        return true;
365✔
359
                                case 144:
360
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
2✔
361
                                        return true;
2✔
362
                                case 145:
363
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
2,540✔
364
                                        return true;
2,540✔
365
                                case 170:
366
                                        //Has data flag
367
                                        return true;
122✔
368
                                case 171:
369
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
2,540✔
370
                                        return true;
2,540✔
371
                                case 172:
372
                                        tmp.CurrentCell.FlagValue = this._reader.ValueAsInt;
2,540✔
373
                                        return true;
2,540✔
374
                                case 173:
375
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsInt;
2,540✔
376
                                        return true;
2,540✔
377
                                case 174:
378
                                        tmp.CurrentCell.Autofit = this._reader.ValueAsBool;
2,540✔
379
                                        return true;
2,540✔
380
                                case 175:
381
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
2,540✔
382
                                        return true;
2,540✔
383
                                case 176:
384
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
2,540✔
385
                                        return true;
2,540✔
386
                                case 178:
387
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
2,540✔
388
                                        return true;
2,540✔
389
                                case 179:
390
                                        //Unknown value
391
                                        return true;
2✔
392
                                case 301:
393
                                        var content = new TableEntity.CellContent();
1,700✔
394
                                        tmp.CurrentCell.Contents.Add(content);
1,700✔
395
                                        this.readCellValue(content);
1,700✔
396
                                        return true;
1,700✔
397
                                case 340:
398
                                        tmp.CurrentCellTemplate.BlockRecordHandle = this._reader.ValueAsHandle;
2✔
399
                                        return true;
2✔
400
                                default:
401
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
19,213✔
402
                                        {
18,730✔
403
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
18,730✔
404
                                        }
405
                                        return true;
483✔
406
                        }
407
                }
42,933✔
408

409
                private void readCellValue(TableEntity.CellContent content)
410
                {
1,700✔
411
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
1,700!
412
                        {
1,700✔
413
                                this._reader.ReadNext();
1,700✔
414
                        }
1,700✔
415
                        else
416
                        {
×
417
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
418
                        }
419

420
                        while (this._reader.Code != 304
10,854✔
421
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
10,854✔
422
                        {
9,154✔
423
                                switch (this._reader.Code)
9,154!
424
                                {
425
                                        case 1:
426
                                                content.Value.Text = this._reader.ValueAsString;
644✔
427
                                                break;
644✔
428
                                        case 2:
429
                                                content.Value.Text += this._reader.ValueAsString;
×
430
                                                break;
×
431
                                        case 11:
432
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
1✔
433
                                                break;
1✔
434
                                        case 21:
435
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
1✔
436
                                                break;
1✔
437
                                        case 31:
438
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
1✔
439
                                                break;
1✔
440
                                        case 302:
441
                                                //TODO: Fix this assignation to cell value
442
                                                content.Value.Value = this._reader.ValueAsString;
1,700✔
443
                                                break;
1,700✔
444
                                        case 90:
445
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
1,700✔
446
                                                break;
1,700✔
447
                                        case 91:
448
                                                content.Value.Value = this._reader.ValueAsInt;
1✔
449
                                                break;
1✔
450
                                        case 93:
451
                                                content.Value.Flags = this._reader.ValueAsInt;
1,700✔
452
                                                break;
1,700✔
453
                                        case 94:
454
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
1,700✔
455
                                                break;
1,700✔
456
                                        case 140:
457
                                                content.Value.Value = this._reader.ValueAsDouble;
4✔
458
                                                break;
4✔
459
                                        case 300:
460
                                                content.Value.Format = this._reader.ValueAsString;
1,700✔
461
                                                break;
1,700✔
462
                                        default:
463
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
2✔
464
                                                break;
2✔
465
                                }
466

467
                                this._reader.ReadNext();
9,154✔
468
                        }
9,154✔
469
                }
1,700✔
470

471
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
472
                {
94,450✔
473
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
94,450✔
474
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
94,450✔
475

476
                        switch (this._reader.Code)
94,450✔
477
                        {
478
                                //TODO: Implement multiline text def codes
479
                                case 1 or 3 when tmp.CadObject is MText mtext:
9,092✔
480
                                        mtext.Value += this._reader.ValueAsString;
3,938✔
481
                                        return true;
3,938✔
482
                                case 70:
483
                                case 74:
484
                                case 101:
485
                                        return true;
240✔
486
                                case 7:
487
                                        tmp.StyleName = this._reader.ValueAsString;
560✔
488
                                        return true;
560✔
489
                                default:
490
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
89,712✔
491
                        }
492
                }
94,450✔
493

494
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
495
                {
3,600✔
496
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
3,600✔
497

498
                        switch (this._reader.Code)
3,600✔
499
                        {
500
                                case 3:
501
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
360✔
502
                                        return true;
360✔
503
                                default:
504
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
3,240✔
505
                        }
506
                }
3,600✔
507

508
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
509
                {
28,940✔
510
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
28,940✔
511

512
                        switch (this._reader.Code)
28,940✔
513
                        {
514
                                case 2:
515
                                        tmp.BlockName = this._reader.ValueAsString;
1,120✔
516
                                        return true;
1,120✔
517
                                case 3:
518
                                        tmp.StyleName = this._reader.ValueAsString;
960✔
519
                                        return true;
960✔
520
                                case 50:
521
                                        var dim = new DimensionLinear();
140✔
522
                                        tmp.SetDimensionObject(dim);
140✔
523
                                        dim.Rotation = CSMath.MathHelper.DegToRad(this._reader.ValueAsDouble);
140✔
524
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
140✔
525
                                        return true;
140✔
526
                                case 70:
527
                                        //Flags do not have set
528
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
1,120✔
529
                                        return true;
1,120✔
530
                                //Measurement - read only
531
                                case 42:
532
                                        return true;
960✔
533
                                //Undocumented codes
534
                                case 73:
535
                                case 74:
536
                                case 75:
537
                                case 90:
538
                                case 361:
539
                                        return true;
1,920✔
540
                                case 100:
541
                                        switch (this._reader.ValueAsString)
3,000✔
542
                                        {
543
                                                case DxfSubclassMarker.Dimension:
544
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
960✔
545
                                                case DxfSubclassMarker.AlignedDimension:
546
                                                        tmp.SetDimensionObject(new DimensionAligned());
240✔
547
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
240✔
548
                                                        return true;
240✔
549
                                                case DxfSubclassMarker.DiametricDimension:
550
                                                        tmp.SetDimensionObject(new DimensionDiameter());
120✔
551
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
120✔
552
                                                        return true;
120✔
553
                                                case DxfSubclassMarker.Angular2LineDimension:
554
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
120✔
555
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
120✔
556
                                                        return true;
120✔
557
                                                case DxfSubclassMarker.Angular3PointDimension:
558
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
120✔
559
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
120✔
560
                                                        return true;
120✔
561
                                                case DxfSubclassMarker.RadialDimension:
562
                                                        tmp.SetDimensionObject(new DimensionRadius());
120✔
563
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
120✔
564
                                                        return true;
120✔
565
                                                case DxfSubclassMarker.OrdinateDimension:
566
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
240✔
567
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
240✔
568
                                                        return true;
240✔
569
                                                case DxfSubclassMarker.LinearDimension:
570
                                                        return true;
120✔
571
                                                default:
572
                                                        return false;
960✔
573
                                        }
574
                                default:
575
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
19,720✔
576
                        }
577
                }
28,940✔
578

579
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
580
                {
27,600✔
581
                        CadHatchTemplate tmp = template as CadHatchTemplate;
27,600✔
582
                        Hatch hatch = tmp.CadObject;
27,600✔
583

584
                        bool isFirstSeed = true;
27,600✔
585
                        XY seedPoint = new XY();
27,600✔
586

587
                        switch (this._reader.Code)
27,600!
588
                        {
589
                                case 2:
590
                                        tmp.HatchPatternName = this._reader.ValueAsString;
480✔
591
                                        return true;
480✔
592
                                case 10:
593
                                        seedPoint.X = this._reader.ValueAsDouble;
960✔
594
                                        return true;
960✔
595
                                case 20:
596
                                        if (!isFirstSeed)
960!
597
                                        {
×
598
                                                seedPoint.Y = this._reader.ValueAsDouble;
×
599
                                                hatch.SeedPoints.Add(seedPoint);
×
600
                                        }
×
601
                                        return true;
960✔
602
                                case 30:
603
                                        hatch.Elevation = this._reader.ValueAsDouble;
480✔
604
                                        isFirstSeed = false;
480✔
605
                                        return true;
480✔
606
                                //TODO: Check hatch undocumented codes
607
                                case 43:
608
                                case 44:
609
                                case 45:
610
                                case 46:
611
                                case 49:
612
                                case 53:
613
                                case 79:
614
                                case 90:
615
                                        return true;
14,160✔
616
                                //Information about the hatch pattern
617
                                case 75:
618
                                        return true;
×
619
                                //Number of pattern definition lines
620
                                case 78:
621
                                        return true;
240✔
622
                                //Number of boundary paths (loops)
623
                                case 91:
624
                                        this.readLoops(tmp, this._reader.ValueAsInt);
480✔
625
                                        return true;
480✔
626
                                //Number of seed points
627
                                case 98:
628
                                        return true;
480✔
629
                                case 450:
630
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
200✔
631
                                        return true;
200✔
632
                                case 451:
633
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
200✔
634
                                        return true;
200✔
635
                                case 452:
636
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
200✔
637
                                        return true;
200✔
638
                                case 453:
639
                                        //Number of colors
640
                                        return true;
200✔
641
                                case 460:
642
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
200✔
643
                                        return true;
200✔
644
                                case 461:
645
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
200✔
646
                                        return true;
200✔
647
                                case 462:
648
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
200✔
649
                                        return true;
200✔
650
                                case 463:
651
                                        GradientColor gradient = new GradientColor();
400✔
652
                                        gradient.Value = this._reader.ValueAsDouble;
400✔
653
                                        hatch.GradientColor.Colors.Add(gradient);
400✔
654
                                        return true;
400✔
655
                                case 63:
656
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
400✔
657
                                        if (colorByIndex != null)
400✔
658
                                        {
400✔
659
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
400✔
660
                                        }
400✔
661
                                        return true;
400✔
662
                                case 421:
663
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
400✔
664
                                        if (colorByRgb != null)
400✔
665
                                        {
400✔
666
                                                //TODO: Hatch assign color by true color
667
                                                //TODO: Is always duplicated by 63, is it needed??
668
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
669
                                        }
400✔
670
                                        return true;
400✔
671
                                case 470:
672
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
200✔
673
                                        return true;
200✔
674
                                default:
675
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,560✔
676
                        }
677
                }
27,600✔
678

679
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
680
                {
12,657✔
681
                        CadInsertTemplate tmp = template as CadInsertTemplate;
12,657✔
682

683
                        switch (this._reader.Code)
12,657✔
684
                        {
685
                                case 2:
686
                                        tmp.BlockName = this._reader.ValueAsString;
1,252✔
687
                                        return true;
1,252✔
688
                                case 66:
689
                                        return true;
280✔
690
                                default:
691
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
11,125✔
692
                        }
693
                }
12,657✔
694

695
                private CadEntityTemplate readPolyline()
696
                {
5,272✔
697
                        CadPolyLineTemplate template = null;
5,272✔
698

699
                        if (this._builder.Version == ACadVersion.Unknown)
5,272!
700
                        {
×
701
                                var polyline = new Polyline2D();
×
702
                                template = new CadPolyLineTemplate(polyline);
×
703
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
×
704

705
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
×
706
                                {
×
707
                                        Vertex2D v = new Vertex2D();
×
708
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
×
709
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
×
710

711
                                        if (vertexTemplate.Vertex.Handle == 0)
×
712
                                        {
×
713
                                                template.PolyLine.Vertices.Add(vertexTemplate.Vertex);
×
714
                                        }
×
715
                                        else
716
                                        {
×
717
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
×
718
                                                this._builder.AddTemplate(vertexTemplate);
×
719
                                        }
×
720
                                }
×
721

722
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
×
723
                                {
×
724
                                        var seqend = new Seqend();
×
725
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
×
726
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
×
727

728
                                        this._builder.AddTemplate(seqendTemplate);
×
729

730
                                        template.SeqendHandle = seqend.Handle;
×
731
                                }
×
732
                        }
×
733
                        else
734
                        {
5,272✔
735
                                template = new CadPolyLineTemplate();
5,272✔
736
                                this.readEntityCodes<Entity>(template, this.readPolyline);
5,272✔
737
                        }
5,272✔
738

739
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
5,272✔
740
                        {
5,032✔
741
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
5,032✔
742
                                return null;
5,032✔
743
                        }
744

745
                        return template;
240✔
746
                }
5,272✔
747

748
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
749
                {
37,960✔
750
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
37,960✔
751

752
                        switch (this._reader.Code)
37,960✔
753
                        {
754
                                //DXF: always 0
755
                                //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)
756
                                case 10:
757
                                case 20:
758
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
759
                                case 66:
760
                                //Polygon mesh M vertex count (optional; default = 0)
761
                                case 71:
762
                                //Polygon mesh N vertex count(optional; default = 0)
763
                                case 72:
764
                                //Smooth surface M density(optional; default = 0)
765
                                case 73:
766
                                //Smooth surface N density (optional; default = 0)
767
                                case 74:
768
                                        return true;
16,096✔
769
                                case 100:
770
                                        switch (this._reader.ValueAsString)
480!
771
                                        {
772
                                                case DxfSubclassMarker.Polyline:
773
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
774
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
775
                                                        return true;
×
776
                                                case DxfSubclassMarker.Polyline3d:
777
                                                        tmp.SetPolyLineObject(new Polyline3D());
120✔
778
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
120✔
779
                                                        return true;
120✔
780
                                                case DxfSubclassMarker.PolyfaceMesh:
781
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
120✔
782
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
120✔
783
                                                        return true;
120✔
784
                                                default:
785
                                                        return false;
240✔
786
                                        }
787
                                default:
788
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
21,384✔
789
                        }
790
                }
37,960✔
791

792
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
793
                {
3,000✔
794
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
3,000✔
795

796
                        switch (this._reader.Code)
3,000✔
797
                        {
798
                                case 3:
799
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
120✔
800
                                        return true;
120✔
801
                                case 10:
802
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
480✔
803
                                        return true;
480✔
804
                                case 20:
805
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
480✔
806
                                        y.Y = this._reader.ValueAsDouble;
480✔
807
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
480✔
808
                                        return true;
480✔
809
                                case 30:
810
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
480✔
811
                                        z.Z = this._reader.ValueAsDouble;
480✔
812
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
480✔
813
                                        return true;
480✔
814
                                case 340:
815
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
120✔
816
                                        return true;
120✔
817
                                //Vertices count
818
                                case 76:
819
                                        return true;
120✔
820
                                default:
821
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,200✔
822
                        }
823
                }
3,000✔
824

825
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
826
                {
27,576✔
827
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
27,576✔
828

829
                        LwPolyline.Vertex last = tmp.CadObject.Vertices.LastOrDefault();
27,576✔
830

831
                        switch (this._reader.Code)
27,576!
832
                        {
833
                                case 10:
834
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
6,372✔
835
                                        return true;
6,372✔
836
                                case 20:
837
                                        if (last is not null)
6,372✔
838
                                        {
6,372✔
839
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
6,372✔
840
                                        }
6,372✔
841
                                        return true;
6,372✔
842
                                case 40:
843
                                        if (last is not null)
1,200✔
844
                                        {
1,200✔
845
                                                last.StartWidth = this._reader.ValueAsDouble;
1,200✔
846
                                        }
1,200✔
847
                                        return true;
1,200✔
848
                                case 41:
849
                                        if (last is not null)
1,200✔
850
                                        {
1,200✔
851
                                                last.EndWidth = this._reader.ValueAsDouble;
1,200✔
852
                                        }
1,200✔
853
                                        return true;
1,200✔
854
                                case 42:
855
                                        if (last is not null)
1,608✔
856
                                        {
1,608✔
857
                                                last.Bulge = this._reader.ValueAsDouble;
1,608✔
858
                                        }
1,608✔
859
                                        return true;
1,608✔
860
                                case 50:
861
                                        if (last is not null)
×
862
                                        {
×
863
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
864
                                        }
×
865
                                        return true;
×
866
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
867
                                case 66:
868
                                //Vertex count
869
                                case 90:
870
                                        return true;
1,296✔
871
                                case 91:
872
                                        if (last is not null)
×
873
                                        {
×
874
                                                last.Id = this._reader.ValueAsInt;
×
875
                                        }
×
876
                                        return true;
×
877
                                default:
878
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
9,528✔
879
                        }
880
                }
27,576✔
881

882
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
883
                {
21,120✔
884
                        CadMeshTemplate tmp = template as CadMeshTemplate;
21,120✔
885

886
                        switch (this._reader.Code)
21,120✔
887
                        {
888
                                case 100:
889
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
480✔
890
                                        {
240✔
891
                                                tmp.SubclassMarker = true;
240✔
892
                                        }
240✔
893
                                        return true;
480✔
894
                                //Count of sub-entity which property has been overridden
895
                                case 90:
896
                                        //TODO: process further entities
897
                                        return true;
240✔
898
                                case 92:
899
                                        if (!tmp.SubclassMarker)
360✔
900
                                        {
120✔
901
                                                return false;
120✔
902
                                        }
903

904
                                        int nvertices = this._reader.ValueAsInt;
240✔
905
                                        for (int i = 0; i < nvertices; i++)
30,720✔
906
                                        {
15,120✔
907
                                                this._reader.ReadNext();
15,120✔
908
                                                double x = this._reader.ValueAsDouble;
15,120✔
909
                                                this._reader.ReadNext();
15,120✔
910
                                                double y = this._reader.ValueAsDouble;
15,120✔
911
                                                this._reader.ReadNext();
15,120✔
912
                                                double z = this._reader.ValueAsDouble;
15,120✔
913
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
15,120✔
914
                                        }
15,120✔
915
                                        return true;
240✔
916
                                case 93:
917
                                        int size = this._reader.ValueAsInt;
240✔
918
                                        this._reader.ReadNext();
240✔
919

920
                                        int indexes = 0;
240✔
921
                                        for (int i = 0; i < size; i += indexes + 1)
33,120✔
922
                                        {
16,320✔
923
                                                indexes = this._reader.ValueAsInt;
16,320✔
924
                                                this._reader.ReadNext();
16,320✔
925

926
                                                int[] face = new int[indexes];
16,320✔
927
                                                for (int j = 0; j < indexes; j++)
157,440✔
928
                                                {
62,400✔
929
                                                        face[j] = this._reader.ValueAsInt;
62,400✔
930

931
                                                        if ((i + j + 2) < size)
62,400✔
932
                                                        {
62,160✔
933
                                                                this._reader.ReadNext();
62,160✔
934
                                                        }
62,160✔
935
                                                }
62,400✔
936

937
                                                tmp.CadObject.Faces.Add(face);
16,320✔
938
                                        }
16,320✔
939

940
                                        Debug.Assert(this._reader.Code == 90);
240✔
941

942
                                        return true;
240✔
943
                                case 94:
944
                                        int numEdges = this._reader.ValueAsInt;
240✔
945
                                        this._reader.ReadNext();
240✔
946
                                        for (int i = 0; i < numEdges; i++)
62,880✔
947
                                        {
31,200✔
948
                                                Mesh.Edge edge = new Mesh.Edge();
31,200✔
949

950
                                                edge.Start = this._reader.ValueAsInt;
31,200✔
951
                                                this._reader.ReadNext();
31,200✔
952
                                                edge.End = this._reader.ValueAsInt;
31,200✔
953

954
                                                if (i < numEdges - 1)
31,200✔
955
                                                {
30,960✔
956
                                                        this._reader.ReadNext();
30,960✔
957
                                                }
30,960✔
958

959
                                                tmp.CadObject.Edges.Add(edge);
31,200✔
960
                                        }
31,200✔
961

962
                                        Debug.Assert(this._reader.Code == 90);
240✔
963

964
                                        return true;
240✔
965
                                case 95:
966
                                        this._reader.ReadNext();
240✔
967
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
62,880✔
968
                                        {
31,200✔
969
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
31,200✔
970
                                                edge.Crease = this._reader.ValueAsDouble;
31,200✔
971

972
                                                tmp.CadObject.Edges[i] = edge;
31,200✔
973

974
                                                if (i < tmp.CadObject.Edges.Count - 1)
31,200✔
975
                                                {
30,960✔
976
                                                        this._reader.ReadNext();
30,960✔
977
                                                }
30,960✔
978
                                        }
31,200✔
979

980
                                        Debug.Assert(this._reader.Code == 140);
240✔
981

982
                                        return true;
240✔
983
                                default:
984
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
19,320✔
985
                        }
986
                }
21,120✔
987

988
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
989
                {
31,200✔
990
                        CadMLineTemplate tmp = template as CadMLineTemplate;
31,200✔
991

992
                        switch (this._reader.Code)
31,200✔
993
                        {
994
                                // 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.
995
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
996
                                case 2:
997
                                        tmp.MLineStyleName = this._reader.ValueAsString;
360✔
998
                                        return true;
360✔
999
                                case 72:
1000
                                        tmp.NVertex = this._reader.ValueAsInt;
360✔
1001
                                        return true;
360✔
1002
                                case 73:
1003
                                        tmp.NElements = this._reader.ValueAsInt;
360✔
1004
                                        return true;
360✔
1005
                                case 340:
1006
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
360✔
1007
                                        return true;
360✔
1008
                                default:
1009
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
29,760✔
1010
                                        {
5,040✔
1011
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,040✔
1012
                                        }
1013
                                        return true;
24,720✔
1014
                        }
1015
                }
31,200✔
1016

1017
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1018
                {
1,200✔
1019
                        CadShapeTemplate tmp = template as CadShapeTemplate;
1,200✔
1020

1021
                        switch (this._reader.Code)
1,200✔
1022
                        {
1023
                                case 2:
1024
                                        tmp.ShapeFileName = this._reader.ValueAsString;
120✔
1025
                                        return true;
120✔
1026
                                default:
1027
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
1,080✔
1028
                        }
1029
                }
1,200✔
1030

1031
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1032
                {
8,400✔
1033
                        CadSplineTemplate tmp = template as CadSplineTemplate;
8,400✔
1034

1035
                        XYZ controlPoint;
1036

1037
                        switch (this._reader.Code)
8,400!
1038
                        {
1039
                                case 10:
1040
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
960✔
1041
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
960✔
1042
                                        return true;
960✔
1043
                                case 20:
1044
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
960✔
1045
                                        controlPoint.Y = this._reader.ValueAsDouble;
960✔
1046
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
960✔
1047
                                        return true;
960✔
1048
                                case 30:
1049
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
960✔
1050
                                        controlPoint.Z = this._reader.ValueAsDouble;
960✔
1051
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
960✔
1052
                                        return true;
960✔
1053
                                case 40:
1054
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
1,920✔
1055
                                        return true;
1,920✔
1056
                                case 41:
1057
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1058
                                        return true;
×
1059
                                case 72:
1060
                                case 73:
1061
                                case 74:
1062
                                        return true;
720✔
1063
                                default:
1064
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,880✔
1065
                        }
1066
                }
8,400✔
1067

1068
                private bool readUnderlayEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
1069
                {
×
1070
                        CadPdfUnderlayTemplate tmp = template as CadPdfUnderlayTemplate;
×
1071

1072
                        switch (this._reader.Code)
×
1073
                        {
1074
                                case 340:
1075
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
×
1076
                                        return true;
×
1077
                                default:
1078
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1079
                        }
1080
                }
×
1081

1082
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1083
                {
125,366✔
1084
                        CadVertexTemplate tmp = template as CadVertexTemplate;
125,366✔
1085

1086
                        switch (this._reader.Code)
125,366✔
1087
                        {
1088
                                //Polyface mesh vertex index
1089
                                case 71:
1090
                                case 72:
1091
                                case 73:
1092
                                case 74:
1093
                                        return true;
980✔
1094
                                case 100:
1095
                                        switch (this._reader.ValueAsString)
4,080!
1096
                                        {
1097
                                                case DxfSubclassMarker.Vertex:
1098
                                                        return true;
1,200✔
1099
                                                case DxfSubclassMarker.PolylineVertex:
1100
                                                        tmp.SetVertexObject(new Vertex2D());
×
1101
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1102
                                                        return true;
×
1103
                                                case DxfSubclassMarker.Polyline3dVertex:
1104
                                                        tmp.SetVertexObject(new Vertex3D());
600✔
1105
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
600✔
1106
                                                        return true;
600✔
1107
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1108
                                                        tmp.SetVertexObject(new VertexFaceMesh());
600✔
1109
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
600✔
1110
                                                        return true;
600✔
1111
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1112
                                                        tmp.SetVertexObject(new VertexFaceRecord());
240✔
1113
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
240✔
1114
                                                        return true;
240✔
1115
                                                default:
1116
                                                        return false;
1,440✔
1117
                                        }
1118
                                default:
1119
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
120,306✔
1120
                        }
1121
                }
125,366✔
1122

1123
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1124
                {
38,856✔
1125
                        CadViewportTemplate tmp = template as CadViewportTemplate;
38,856✔
1126

1127
                        switch (this._reader.Code)
38,856!
1128
                        {
1129
                                //Undocumented
1130
                                case 67:
1131
                                case 68:
1132
                                        return true;
1,424✔
1133
                                case 69:
1134
                                        tmp.ViewportId = this._reader.ValueAsShort;
712✔
1135
                                        return true;
712✔
1136
                                case 331:
1137
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1138
                                        return true;
×
1139
                                case 348:
1140
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
448✔
1141
                                        return true;
448✔
1142
                                default:
1143
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
36,272✔
1144
                        }
1145
                }
38,856✔
1146

1147
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1148
                {
359,775✔
1149
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
359,775✔
1150

1151
                        switch (this._reader.Code)
359,775✔
1152
                        {
1153
                                default:
1154
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
359,775✔
1155
                        }
1156
                }
359,775✔
1157

1158
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1159
                {
12,645✔
1160
                        List<ExtendedDataRecord> records = new();
12,645✔
1161
                        edata.Add(this._reader.ValueAsString, records);
12,645✔
1162

1163
                        this._reader.ReadNext();
12,645✔
1164

1165
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
59,465✔
1166
                        {
50,620✔
1167
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
50,620✔
1168
                                {
3,800✔
1169
                                        this.readExtendedData(edata);
3,800✔
1170
                                        break;
3,800✔
1171
                                }
1172

1173
                                ExtendedDataRecord record;
1174
                                double x = 0;
46,820✔
1175
                                double y = 0;
46,820✔
1176
                                double z = 0;
46,820✔
1177

1178
                                switch (this._reader.DxfCode)
46,820!
1179
                                {
1180
                                        case DxfCode.ExtendedDataAsciiString:
1181
                                        case DxfCode.ExtendedDataRegAppName:
1182
                                                record = new ExtendedDataString(this._reader.ValueAsString);
11,870✔
1183
                                                break;
11,870✔
1184
                                        case DxfCode.ExtendedDataControlString:
1185
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
3,368✔
1186
                                                break;
3,368✔
1187
                                        case DxfCode.ExtendedDataLayerName:
1188
                                                record = new ExtendedDataLayer(this._reader.ValueAsHandle);
×
1189
                                                break;
×
1190
                                        case DxfCode.ExtendedDataBinaryChunk:
1191
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
2✔
1192
                                                break;
2✔
1193
                                        case DxfCode.ExtendedDataHandle:
1194
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
425✔
1195
                                                break;
425✔
1196
                                        case DxfCode.ExtendedDataXCoordinate:
1197
                                                x = this._reader.ValueAsDouble;
641✔
1198
                                                this._reader.ReadNext();
641✔
1199
                                                y = this._reader.ValueAsDouble;
641✔
1200
                                                this._reader.ReadNext();
641✔
1201
                                                z = this._reader.ValueAsDouble;
641✔
1202

1203
                                                record = new ExtendedDataCoordinate(
641✔
1204
                                                        new XYZ(
641✔
1205
                                                                x,
641✔
1206
                                                                y,
641✔
1207
                                                                z)
641✔
1208
                                                        );
641✔
1209
                                                break;
641✔
1210
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1211
                                                x = this._reader.ValueAsDouble;
280✔
1212
                                                this._reader.ReadNext();
280✔
1213
                                                y = this._reader.ValueAsDouble;
280✔
1214
                                                this._reader.ReadNext();
280✔
1215
                                                z = this._reader.ValueAsDouble;
280✔
1216

1217
                                                record = new ExtendedDataCoordinate(
280✔
1218
                                                        new XYZ(
280✔
1219
                                                                x,
280✔
1220
                                                                y,
280✔
1221
                                                                z)
280✔
1222
                                                        );
280✔
1223
                                                break;
280✔
1224
                                        case DxfCode.ExtendedDataWorldXDisp:
1225
                                                x = this._reader.ValueAsDouble;
×
1226
                                                this._reader.ReadNext();
×
1227
                                                y = this._reader.ValueAsDouble;
×
1228
                                                this._reader.ReadNext();
×
1229
                                                z = this._reader.ValueAsDouble;
×
1230

1231
                                                record = new ExtendedDataCoordinate(
×
1232
                                                        new XYZ(
×
1233
                                                                x,
×
1234
                                                                y,
×
1235
                                                                z)
×
1236
                                                        );
×
1237
                                                break;
×
1238
                                        case DxfCode.ExtendedDataWorldXDir:
1239
                                                x = this._reader.ValueAsDouble;
×
1240
                                                this._reader.ReadNext();
×
1241
                                                y = this._reader.ValueAsDouble;
×
1242
                                                this._reader.ReadNext();
×
1243
                                                z = this._reader.ValueAsDouble;
×
1244

1245
                                                record = new ExtendedDataCoordinate(
×
1246
                                                        new XYZ(
×
1247
                                                                x,
×
1248
                                                                y,
×
1249
                                                                z)
×
1250
                                                        );
×
1251
                                                break;
×
1252
                                        case DxfCode.ExtendedDataReal:
1253
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
6,960✔
1254
                                                break;
6,960✔
1255
                                        case DxfCode.ExtendedDataDist:
1256
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
×
1257
                                                break;
×
1258
                                        case DxfCode.ExtendedDataScale:
1259
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
×
1260
                                                break;
×
1261
                                        case DxfCode.ExtendedDataInteger16:
1262
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
19,778✔
1263
                                                break;
19,778✔
1264
                                        case DxfCode.ExtendedDataInteger32:
1265
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
2,936✔
1266
                                                break;
2,936✔
1267
                                        default:
1268
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
560✔
1269
                                                break;
560✔
1270
                                }
1271

1272
                                this._reader.ReadNext();
46,820✔
1273
                        }
46,820✔
1274
                }
12,645✔
1275

1276
                private void readLoops(CadHatchTemplate template, int count)
1277
                {
480✔
1278
                        if (this._reader.Code == 91)
480✔
1279
                                this._reader.ReadNext();
480✔
1280

1281
                        for (int i = 0; i < count; i++)
1,920✔
1282
                        {
480✔
1283
                                if (this._reader.Code != 92)
480!
1284
                                {
×
1285
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1286
                                        break;
×
1287
                                }
1288

1289
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
480✔
1290
                                if (path != null)
480✔
1291
                                        template.PathTempaltes.Add(path);
480✔
1292
                        }
480✔
1293
                }
480✔
1294

1295
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1296
                {
480✔
1297
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
480✔
1298
                        template.Path.Flags = (BoundaryPathFlags)this._reader.ValueAsInt;
480✔
1299

1300
                        if (template.Path.Flags.HasFlag(BoundaryPathFlags.Polyline))
480!
1301
                        {
×
1302
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
×
1303
                                template.Path.Edges.Add(pl);
×
1304
                        }
×
1305
                        else
1306
                        {
480✔
1307
                                this._reader.ReadNext();
480✔
1308

1309
                                if (this._reader.Code != 93)
480!
1310
                                {
×
1311
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1312
                                        return null;
×
1313
                                }
1314

1315
                                int edges = this._reader.ValueAsInt;
480✔
1316
                                this._reader.ReadNext();
480✔
1317

1318
                                for (int i = 0; i < edges; i++)
4,800✔
1319
                                {
1,920✔
1320
                                        var edge = this.readEdge();
1,920✔
1321
                                        if (edge != null)
1,920✔
1322
                                                template.Path.Edges.Add(edge);
1,920✔
1323
                                }
1,920✔
1324
                        }
480✔
1325

1326
                        bool end = false;
480✔
1327
                        while (!end)
1,920✔
1328
                        {
1,440✔
1329
                                switch (this._reader.Code)
1,440✔
1330
                                {
1331
                                        //Number of source boundary objects
1332
                                        case 97:
1333
                                                break;
480✔
1334
                                        case 330:
1335
                                                template.Handles.Add(this._reader.ValueAsHandle);
480✔
1336
                                                break;
480✔
1337
                                        default:
1338
                                                end = true;
480✔
1339
                                                continue;
480✔
1340
                                }
1341

1342
                                this._reader.ReadNext();
960✔
1343
                        }
960✔
1344

1345
                        return template;
480✔
1346
                }
480✔
1347

1348
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1349
                {
×
1350
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
×
1351

1352
                        this._reader.ReadNext();
×
1353

1354
                        if (this._reader.Code != 72)
×
1355
                        {
×
1356
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1357
                                return null;
×
1358
                        }
1359

1360
                        //72
1361
                        bool hasBulge = this._reader.ValueAsBool;
×
1362
                        this._reader.ReadNext();
×
1363

1364
                        //73
1365
                        bool isClosed = this._reader.ValueAsBool;
×
1366
                        this._reader.ReadNext();
×
1367

1368
                        //93
1369
                        int nvertices = this._reader.ValueAsInt;
×
1370
                        this._reader.ReadNext();
×
1371

1372
                        for (int i = 0; i < nvertices; i++)
×
1373
                        {
×
1374
                                double bulge = 0.0;
×
1375

1376
                                //10
1377
                                double x = this._reader.ValueAsDouble;
×
1378
                                this._reader.ReadNext();
×
1379
                                //20
1380
                                double y = this._reader.ValueAsDouble;
×
1381
                                this._reader.ReadNext();
×
1382

1383
                                if (hasBulge)
×
1384
                                {
×
1385
                                        //42
1386
                                        bulge = this._reader.ValueAsDouble;
×
1387
                                        this._reader.ReadNext();
×
1388
                                }
×
1389

1390
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
×
1391
                        }
×
1392

1393
                        return boundary;
×
1394
                }
×
1395

1396
                private Hatch.BoundaryPath.Edge readEdge()
1397
                {
1,920✔
1398
                        if (this._reader.Code != 72)
1,920!
1399
                        {
×
NEW
1400
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1401
                                return null;
×
1402
                        }
1403

1404
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
1,920✔
1405
                        this._reader.ReadNext();
1,920✔
1406

1407
                        switch (type)
1,920!
1408
                        {
1409
                                case Hatch.BoundaryPath.EdgeType.Line:
1410
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
1,920✔
1411
                                        while (true)
9,600✔
1412
                                        {
9,600✔
1413
                                                switch (this._reader.Code)
9,600✔
1414
                                                {
1415
                                                        case 10:
1416
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
1,920✔
1417
                                                                break;
1,920✔
1418
                                                        case 20:
1419
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
1,920✔
1420
                                                                break;
1,920✔
1421
                                                        case 11:
1422
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
1,920✔
1423
                                                                break;
1,920✔
1424
                                                        case 21:
1425
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
1,920✔
1426
                                                                break;
1,920✔
1427
                                                        default:
1428
                                                                return line;
1,920✔
1429
                                                }
1430

1431
                                                this._reader.ReadNext();
7,680✔
1432
                                        }
7,680✔
1433
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1434
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1435
                                        while (true)
×
1436
                                        {
×
1437
                                                switch (this._reader.Code)
×
1438
                                                {
1439
                                                        case 10:
1440
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1441
                                                                break;
×
1442
                                                        case 20:
1443
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1444
                                                                break;
×
1445
                                                        case 40:
1446
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1447
                                                                break;
×
1448
                                                        case 50:
1449
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1450
                                                                break;
×
1451
                                                        case 51:
1452
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1453
                                                                break;
×
1454
                                                        case 73:
1455
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1456
                                                                break;
×
1457
                                                        default:
1458
                                                                return arc;
×
1459
                                                }
1460

1461
                                                this._reader.ReadNext();
×
1462
                                        }
×
1463
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1464
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1465
                                        while (true)
×
1466
                                        {
×
1467
                                                switch (this._reader.Code)
×
1468
                                                {
1469
                                                        case 10:
1470
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1471
                                                                break;
×
1472
                                                        case 20:
1473
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1474
                                                                break;
×
1475
                                                        case 11:
1476
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1477
                                                                break;
×
1478
                                                        case 21:
1479
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1480
                                                                break;
×
1481
                                                        case 40:
1482
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1483
                                                                break;
×
1484
                                                        case 50:
1485
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1486
                                                                break;
×
1487
                                                        case 51:
1488
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1489
                                                                break;
×
1490
                                                        case 73:
1491
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1492
                                                                break;
×
1493
                                                        default:
1494
                                                                return ellipse;
×
1495
                                                }
1496

1497
                                                this._reader.ReadNext();
×
1498
                                        }
×
1499
                                case Hatch.BoundaryPath.EdgeType.Spline:
1500
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1501
                                        int nKnots = 0;
×
1502
                                        int nCtrlPoints = 0;
×
1503
                                        int nFitPoints = 0;
×
1504

1505
                                        XYZ controlPoint = new XYZ();
×
1506
                                        XY fitPoint = new XY();
×
1507

1508
                                        while (true)
×
1509
                                        {
×
1510
                                                switch (this._reader.Code)
×
1511
                                                {
1512
                                                        case 10:
1513
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1514
                                                                break;
×
1515
                                                        case 20:
1516
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1517
                                                                spline.ControlPoints.Add(controlPoint);
×
1518
                                                                break;
×
1519
                                                        case 11:
1520
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1521
                                                                break;
×
1522
                                                        case 21:
1523
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1524
                                                                spline.FitPoints.Add(fitPoint);
×
1525
                                                                break;
×
1526
                                                        case 42:
1527
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1528
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1529
                                                                break;
×
1530
                                                        case 12:
1531
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
1532
                                                                break;
×
1533
                                                        case 22:
1534
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
1535
                                                                break;
×
1536
                                                        case 13:
1537
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
1538
                                                                break;
×
1539
                                                        case 23:
1540
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
1541
                                                                break;
×
1542
                                                        case 94:
1543
                                                                spline.Degree = this._reader.ValueAsInt;
×
1544
                                                                break;
×
1545
                                                        case 73:
1546
                                                                spline.Rational = this._reader.ValueAsBool;
×
1547
                                                                break;
×
1548
                                                        case 74:
1549
                                                                spline.Periodic = this._reader.ValueAsBool;
×
1550
                                                                break;
×
1551
                                                        case 95:
1552
                                                                nKnots = this._reader.ValueAsInt;
×
1553
                                                                break;
×
1554
                                                        case 96:
1555
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
1556
                                                                break;
×
1557
                                                        case 97:
1558
                                                                nFitPoints = this._reader.ValueAsInt;
×
1559
                                                                break;
×
1560
                                                        case 40:
1561
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
1562
                                                                break;
×
1563
                                                        default:
1564
                                                                return spline;
×
1565
                                                }
1566

1567
                                                this._reader.ReadNext();
×
1568
                                        }
×
1569
                        }
1570

1571
                        return null;
×
1572
                }
1,920✔
1573

1574
                private void readDefinedGroups(CadTemplate template)
1575
                {
27,005✔
1576
                        this.readDefinedGroups(out ulong? xdict, out List<ulong> reactorsHandles);
27,005✔
1577

1578
                        template.XDictHandle = xdict;
27,005✔
1579
                        template.ReactorsHandles = reactorsHandles;
27,005✔
1580
                }
27,005✔
1581

1582
                private void readDefinedGroups(out ulong? xdictHandle, out List<ulong> reactors)
1583
                {
27,137✔
1584
                        xdictHandle = null;
27,137✔
1585
                        reactors = new List<ulong>();
27,137✔
1586

1587
                        switch (this._reader.ValueAsString)
27,137✔
1588
                        {
1589
                                case DxfFileToken.DictionaryToken:
1590
                                        this._reader.ReadNext();
5,219✔
1591
                                        xdictHandle = this._reader.ValueAsHandle;
5,219✔
1592
                                        this._reader.ReadNext();
5,219✔
1593
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
5,219✔
1594
                                        return;
5,219✔
1595
                                case DxfFileToken.ReactorsToken:
1596
                                        reactors = this.readReactors();
21,433✔
1597
                                        break;
21,433✔
1598
                                case DxfFileToken.BlkRefToken:
1599
                                default:
1600
                                        do
1601
                                        {
1,212✔
1602
                                                this._reader.ReadNext();
1,212✔
1603
                                        }
1,212✔
1604
                                        while (this._reader.DxfCode != DxfCode.ControlString);
1,212✔
1605
                                        return;
485✔
1606
                        }
1607
                }
27,137✔
1608

1609
                private List<ulong> readReactors()
1610
                {
21,433✔
1611
                        List<ulong> reactors = new List<ulong>();
21,433✔
1612

1613
                        this._reader.ReadNext();
21,433✔
1614

1615
                        while (this._reader.DxfCode != DxfCode.ControlString)
44,462✔
1616
                        {
23,029✔
1617
                                this._reader.ReadNext();
23,029✔
1618
                        }
23,029✔
1619

1620
                        return reactors;
21,433✔
1621
                }
21,433✔
1622

1623
                protected bool tryAssignCurrentValue(CadObject cadObject, DxfClassMap map)
1624
                {
1,773,615✔
1625
                        try
1626
                        {
1,773,615✔
1627
                                //Use this method only if the value is not a link between objects
1628
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
1,773,615✔
1629
                                {
654,289✔
1630
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
654,289✔
1631
                                        {
3,702✔
1632
                                                return true;
3,702✔
1633
                                        }
1634

1635
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
650,587!
1636
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
650,587✔
1637
                                        {
30,878✔
1638
                                                return false;
30,878✔
1639
                                        }
1640

1641
                                        object value = this._reader.Value;
619,709✔
1642

1643
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
619,709✔
1644
                                        {
3,975✔
1645
                                                value = (double)value * MathUtils.DegToRadFactor;
3,975✔
1646
                                        }
3,975✔
1647

1648
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
619,709✔
1649

1650
                                        return true;
619,709✔
1651
                                }
1652
                        }
1,119,326✔
1653
                        catch (Exception ex)
×
1654
                        {
×
1655
                                if (!this._builder.Configuration.Failsafe)
×
1656
                                {
×
1657
                                        throw ex;
×
1658
                                }
1659
                                else
1660
                                {
×
NEW
1661
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
1662
                                }
×
1663
                        }
×
1664

1665
                        return false;
1,119,326✔
1666
                }
1,773,615✔
1667
        }
1668
}
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