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

DomCR / ACadSharp / 18679832337

21 Oct 2025 09:46AM UTC coverage: 77.883% (-0.2%) from 78.126%
18679832337

push

github

web-flow
Merge pull request #832 from DomCR/multileader-dxf

multileader dxf

6920 of 9695 branches covered (71.38%)

Branch coverage included in aggregate %.

341 of 429 new or added lines in 16 files covered. (79.49%)

77 existing lines in 8 files now uncovered.

26664 of 33426 relevant lines covered (79.77%)

110330.18 hits per line

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

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

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

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

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

29
                public abstract void Read();
30

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

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

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

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

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

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

111
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
112
                {
2,044,531✔
113
                        isExtendedData = false;
2,044,531✔
114

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

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

UNCOV
233
                                        this._reader.ReadNext();
×
234

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

379
                        switch (this._reader.Code)
158,040✔
380
                        {
381
                                case 2:
382
                                        tmp.BlockName = this._reader.ValueAsString;
480✔
383
                                        return true;
480✔
384
                                case 342:
385
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
480✔
386
                                        return true;
480✔
387
                                case 343:
388
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
480✔
389
                                        return true;
480✔
390
                                case 141:
391
                                        var row = new TableEntity.Row();
2,640✔
392
                                        row.Height = this._reader.ValueAsDouble;
2,640✔
393
                                        table.Rows.Add(row);
2,640✔
394
                                        return true;
2,640✔
395
                                case 142:
396
                                        var col = new TableEntity.Column();
1,920✔
397
                                        col.Width = this._reader.ValueAsDouble;
1,920✔
398
                                        table.Columns.Add(col);
1,920✔
399
                                        return true;
1,920✔
400
                                case 144:
401
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
480✔
402
                                        return true;
480✔
403
                                case 145:
404
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
9,840✔
405
                                        return true;
9,840✔
406
                                case 170:
407
                                        //Has data flag
408
                                        return true;
720✔
409
                                case 171:
410
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
9,840✔
411
                                        return true;
9,840✔
412
                                case 172:
413
                                        tmp.CurrentCell.FlagValue = this._reader.ValueAsInt;
9,840✔
414
                                        return true;
9,840✔
415
                                case 173:
416
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsInt;
9,840✔
417
                                        return true;
9,840✔
418
                                case 174:
419
                                        tmp.CurrentCell.Autofit = this._reader.ValueAsBool;
9,840✔
420
                                        return true;
9,840✔
421
                                case 175:
422
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
9,840✔
423
                                        return true;
9,840✔
424
                                case 176:
425
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
9,840✔
426
                                        return true;
9,840✔
427
                                case 178:
428
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
9,840✔
429
                                        return true;
9,840✔
430
                                case 179:
431
                                        //Unknown value
432
                                        return true;
480✔
433
                                case 301:
434
                                        var content = new TableEntity.CellContent();
6,560✔
435
                                        tmp.CurrentCell.Contents.Add(content);
6,560✔
436
                                        this.readCellValue(content);
6,560✔
437
                                        return true;
6,560✔
438
                                case 340:
439
                                        tmp.CurrentCellTemplate.BlockRecordHandle = this._reader.ValueAsHandle;
480✔
440
                                        return true;
480✔
441
                                default:
442
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
64,600✔
443
                                        {
62,920✔
444
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
62,920✔
445
                                        }
446
                                        return true;
1,680✔
447
                        }
448
                }
158,040✔
449

450
                private void readCellValue(TableEntity.CellContent content)
451
                {
6,560✔
452
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
453
                        {
6,560✔
454
                                this._reader.ReadNext();
6,560✔
455
                        }
6,560✔
456
                        else
457
                        {
×
458
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
459
                        }
460

461
                        while (this._reader.Code != 304
42,880✔
462
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
42,880✔
463
                        {
36,320✔
464
                                switch (this._reader.Code)
36,320!
465
                                {
466
                                        case 1:
467
                                                content.Value.Text = this._reader.ValueAsString;
1,920✔
468
                                                break;
1,920✔
469
                                        case 2:
470
                                                content.Value.Text += this._reader.ValueAsString;
×
471
                                                break;
×
472
                                        case 11:
473
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
160✔
474
                                                break;
160✔
475
                                        case 21:
476
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
160✔
477
                                                break;
160✔
478
                                        case 31:
479
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
160✔
480
                                                break;
160✔
481
                                        case 302:
482
                                                //TODO: Fix this assignation to cell value
483
                                                content.Value.Value = this._reader.ValueAsString;
6,560✔
484
                                                break;
6,560✔
485
                                        case 90:
486
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
6,560✔
487
                                                break;
6,560✔
488
                                        case 91:
489
                                                content.Value.Value = this._reader.ValueAsInt;
160✔
490
                                                break;
160✔
491
                                        case 93:
492
                                                content.Value.Flags = this._reader.ValueAsInt;
6,560✔
493
                                                break;
6,560✔
494
                                        case 94:
495
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
6,560✔
496
                                                break;
6,560✔
497
                                        case 140:
498
                                                content.Value.Value = this._reader.ValueAsDouble;
640✔
499
                                                break;
640✔
500
                                        case 300:
501
                                                content.Value.Format = this._reader.ValueAsString;
6,560✔
502
                                                break;
6,560✔
503
                                        default:
504
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
320✔
505
                                                break;
320✔
506
                                }
507

508
                                this._reader.ReadNext();
36,320✔
509
                        }
36,320✔
510
                }
6,560✔
511

512
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
513
                {
341,010✔
514
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
341,010✔
515
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
341,010✔
516

517
                        switch (this._reader.Code)
341,010✔
518
                        {
519
                                //TODO: Implement multiline text def codes
520
                                case 1 or 3 when tmp.CadObject is MText mtext:
30,306✔
521
                                        mtext.Value += this._reader.ValueAsString;
11,466✔
522
                                        return true;
11,466✔
523
                                case 50 when tmp.CadObject is MText mtext://Read only for MText
570!
524
                                        double angle = MathHelper.DegToRad(this._reader.ValueAsDouble);
×
525
                                        mtext.AlignmentPoint = new XYZ(System.Math.Cos(angle), System.Math.Sin(angle), 0.0);
×
526
                                        return true;
×
527
                                case 70:
528
                                case 74:
529
                                case 101:
530
                                        return true;
480✔
531
                                case 7:
532
                                        tmp.StyleName = this._reader.ValueAsString;
3,080✔
533
                                        return true;
3,080✔
534
                                default:
535
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
325,984✔
536
                        }
537
                }
341,010✔
538

539
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
540
                {
7,200✔
541
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
542

543
                        switch (this._reader.Code)
7,200✔
544
                        {
545
                                case 3:
546
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
547
                                        return true;
720✔
548
                                default:
549
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
550
                        }
551
                }
7,200✔
552

553
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
554
                {
80,560✔
555
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
556

557
                        switch (this._reader.Code)
80,560✔
558
                        {
559
                                case 2:
560
                                        tmp.BlockName = this._reader.ValueAsString;
3,080✔
561
                                        return true;
3,080✔
562
                                case 3:
563
                                        tmp.StyleName = this._reader.ValueAsString;
2,640✔
564
                                        return true;
2,640✔
565
                                case 50:
566
                                        var dim = new DimensionLinear();
280✔
567
                                        tmp.SetDimensionObject(dim);
280✔
568
                                        dim.Rotation = this._reader.ValueAsAngle;
280✔
569
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
280✔
570
                                        return true;
280✔
571
                                case 70:
572
                                        //Flags do not have set
573
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
3,080✔
574
                                        return true;
3,080✔
575
                                //Measurement - read only
576
                                case 42:
577
                                        return true;
2,640✔
578
                                //Undocumented codes
579
                                case 73:
580
                                case 74:
581
                                case 75:
582
                                case 90:
583
                                case 361:
584
                                        return true;
5,280✔
585
                                case 100:
586
                                        switch (this._reader.ValueAsString)
8,640✔
587
                                        {
588
                                                case DxfSubclassMarker.Dimension:
589
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
2,640✔
590
                                                case DxfSubclassMarker.AlignedDimension:
591
                                                        tmp.SetDimensionObject(new DimensionAligned());
1,200✔
592
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
1,200✔
593
                                                        return true;
1,200✔
594
                                                case DxfSubclassMarker.DiametricDimension:
595
                                                        tmp.SetDimensionObject(new DimensionDiameter());
240✔
596
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
240✔
597
                                                        return true;
240✔
598
                                                case DxfSubclassMarker.Angular2LineDimension:
599
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
240✔
600
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
240✔
601
                                                        return true;
240✔
602
                                                case DxfSubclassMarker.Angular3PointDimension:
603
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
240✔
604
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
240✔
605
                                                        return true;
240✔
606
                                                case DxfSubclassMarker.RadialDimension:
607
                                                        tmp.SetDimensionObject(new DimensionRadius());
240✔
608
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
240✔
609
                                                        return true;
240✔
610
                                                case DxfSubclassMarker.OrdinateDimension:
611
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
480✔
612
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
480✔
613
                                                        return true;
480✔
614
                                                case DxfSubclassMarker.LinearDimension:
615
                                                        return true;
720✔
616
                                                default:
617
                                                        return false;
2,640✔
618
                                        }
619
                                default:
620
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
54,920✔
621
                        }
622
                }
80,560✔
623

624
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
625
                {
48,000✔
626
                        CadHatchTemplate tmp = template as CadHatchTemplate;
48,000✔
627
                        Hatch hatch = tmp.CadObject;
48,000✔
628

629
                        bool isFirstSeed = true;
48,000✔
630
                        XY seedPoint = new XY();
48,000✔
631

632
                        switch (this._reader.Code)
48,000!
633
                        {
634
                                case 2:
635
                                        hatch.Pattern.Name = this._reader.ValueAsString;
1,920✔
636
                                        return true;
1,920✔
637
                                case 10:
638
                                        seedPoint.X = this._reader.ValueAsDouble;
3,120✔
639
                                        return true;
3,120✔
640
                                case 20:
641
                                        if (!isFirstSeed)
3,840!
642
                                        {
×
643
                                                seedPoint.Y = this._reader.ValueAsDouble;
×
644
                                                hatch.SeedPoints.Add(seedPoint);
×
645
                                        }
×
646
                                        return true;
3,840✔
647
                                case 30:
648
                                        hatch.Elevation = this._reader.ValueAsDouble;
1,920✔
649
                                        isFirstSeed = false;
1,920✔
650
                                        return true;
1,920✔
651
                                case 53:
652
                                        hatch.PatternAngle = this._reader.ValueAsAngle;
×
653
                                        return true;
×
654
                                //TODO: Check hatch undocumented codes
655
                                case 90:
656
                                        return true;
×
657
                                //Information about the hatch pattern
658
                                case 75:
659
                                        return true;
×
660
                                //Number of pattern definition lines
661
                                case 78:
662
                                        this.readPattern(hatch.Pattern, this._reader.ValueAsInt);
1,440✔
663
                                        return true;
1,440✔
664
                                //Number of boundary paths (loops)
665
                                case 91:
666
                                        this.readLoops(tmp, this._reader.ValueAsInt);
1,920✔
667
                                        return true;
1,920✔
668
                                //Number of seed points
669
                                case 98:
670
                                        return true;
480✔
671
                                case 450:
672
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
400✔
673
                                        return true;
400✔
674
                                case 451:
675
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
400✔
676
                                        return true;
400✔
677
                                case 452:
678
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
400✔
679
                                        return true;
400✔
680
                                case 453:
681
                                        //Number of colors
682
                                        return true;
400✔
683
                                case 460:
684
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
400✔
685
                                        return true;
400✔
686
                                case 461:
687
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
400✔
688
                                        return true;
400✔
689
                                case 462:
690
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
400✔
691
                                        return true;
400✔
692
                                case 463:
693
                                        GradientColor gradient = new GradientColor();
800✔
694
                                        gradient.Value = this._reader.ValueAsDouble;
800✔
695
                                        hatch.GradientColor.Colors.Add(gradient);
800✔
696
                                        return true;
800✔
697
                                case 63:
698
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
800✔
699
                                        if (colorByIndex != null)
800✔
700
                                        {
800✔
701
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
800✔
702
                                        }
800✔
703
                                        return true;
800✔
704
                                case 421:
705
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
800✔
706
                                        if (colorByRgb != null)
800✔
707
                                        {
800✔
708
                                                //TODO: Hatch assign color by true color
709
                                                //TODO: Is always duplicated by 63, is it needed??
710
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
711
                                        }
800✔
712
                                        return true;
800✔
713
                                case 470:
714
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
400✔
715
                                        return true;
400✔
716
                                default:
717
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,760✔
718
                        }
719
                }
48,000✔
720

721
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
722
                {
69,626✔
723
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
724

725
                        switch (this._reader.Code)
69,626✔
726
                        {
727
                                case 2:
728
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
729
                                        return true;
6,508✔
730
                                case 100:
731
                                        //AcDbEntity
732
                                        //AcDbBlockReference
733
                                        //AcDbMInsertBlock
734
                                        return true;
6,528✔
735
                                case 66:
736
                                        return true;
560✔
737
                                default:
738
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
739
                        }
740
                }
69,626✔
741

742
                private CadEntityTemplate readPolyline()
743
                {
12,348✔
744
                        CadPolyLineTemplate template = null;
12,348✔
745

746
                        if (this._builder.Version == ACadVersion.Unknown)
12,348!
747
                        {
×
748
                                var polyline = new Polyline2D();
×
749
                                template = new CadPolyLineTemplate(polyline);
×
750
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
×
751

752
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
×
753
                                {
×
754
                                        Vertex2D v = new Vertex2D();
×
755
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
×
756
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
×
757

758
                                        if (vertexTemplate.Vertex.Handle == 0)
×
759
                                        {
×
760
                                                polyline.Vertices.Add(v);
×
761
                                        }
×
762
                                        else
763
                                        {
×
764
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
×
765
                                                this._builder.AddTemplate(vertexTemplate);
×
766
                                        }
×
767
                                }
×
768

769
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
×
770
                                {
×
771
                                        var seqend = new Seqend();
×
772
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
×
773
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
×
774

775
                                        polyline.Vertices.Seqend = seqend;
×
776
                                }
×
777
                        }
×
778
                        else
779
                        {
12,348✔
780
                                template = new CadPolyLineTemplate();
12,348✔
781
                                this.readEntityCodes<Entity>(template, this.readPolyline);
12,348✔
782
                        }
12,348✔
783

784
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,348✔
785
                        {
11,868✔
786
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
11,868✔
787
                                return null;
11,868✔
788
                        }
789

790
                        return template;
480✔
791
                }
12,348✔
792

793
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
794
                {
88,672✔
795
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,672✔
796

797
                        switch (this._reader.Code)
88,672✔
798
                        {
799
                                //DXF: always 0
800
                                //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)
801
                                case 10:
802
                                case 20:
803
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
804
                                case 66:
805
                                //Polygon mesh M vertex count (optional; default = 0)
806
                                case 71:
807
                                //Polygon mesh N vertex count(optional; default = 0)
808
                                case 72:
809
                                //Smooth surface M density(optional; default = 0)
810
                                case 73:
811
                                //Smooth surface N density (optional; default = 0)
812
                                case 74:
813
                                        return true;
37,604✔
814
                                case 100:
815
                                        switch (this._reader.ValueAsString)
960!
816
                                        {
817
                                                case DxfSubclassMarker.Polyline:
818
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
819
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
820
                                                        return true;
×
821
                                                case DxfSubclassMarker.Polyline3d:
822
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
823
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
824
                                                        return true;
240✔
825
                                                case DxfSubclassMarker.PolyfaceMesh:
826
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
827
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
828
                                                        return true;
240✔
829
                                                default:
830
                                                        return false;
480✔
831
                                        }
832
                                default:
833
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,108✔
834
                        }
835
                }
88,672✔
836

837
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
838
                {
6,000✔
839
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
840

841
                        switch (this._reader.Code)
6,000✔
842
                        {
843
                                case 3:
844
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
240✔
845
                                        return true;
240✔
846
                                case 10:
847
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
960✔
848
                                        return true;
960✔
849
                                case 20:
850
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
851
                                        y.Y = this._reader.ValueAsDouble;
960✔
852
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
960✔
853
                                        return true;
960✔
854
                                case 30:
855
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
856
                                        z.Z = this._reader.ValueAsDouble;
960✔
857
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
960✔
858
                                        return true;
960✔
859
                                case 340:
860
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
240✔
861
                                        return true;
240✔
862
                                //Hook line flag - read only
863
                                case 75:
864
                                //Vertices count
865
                                case 76:
866
                                        return true;
480✔
867
                                default:
868
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,160✔
869
                        }
870
                }
6,000✔
871

872
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
873
                {
98,616✔
874
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
98,616✔
875

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

878
                        switch (this._reader.Code)
98,616!
879
                        {
880
                                case 10:
881
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
23,412✔
882
                                        return true;
23,412✔
883
                                case 20:
884
                                        if (last is not null)
23,412✔
885
                                        {
23,412✔
886
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
23,412✔
887
                                        }
23,412✔
888
                                        return true;
23,412✔
889
                                case 40:
890
                                        if (last is not null)
2,400✔
891
                                        {
2,400✔
892
                                                last.StartWidth = this._reader.ValueAsDouble;
2,400✔
893
                                        }
2,400✔
894
                                        return true;
2,400✔
895
                                case 41:
896
                                        if (last is not null)
2,400✔
897
                                        {
2,400✔
898
                                                last.EndWidth = this._reader.ValueAsDouble;
2,400✔
899
                                        }
2,400✔
900
                                        return true;
2,400✔
901
                                case 42:
902
                                        if (last is not null)
3,288✔
903
                                        {
3,288✔
904
                                                last.Bulge = this._reader.ValueAsDouble;
3,288✔
905
                                        }
3,288✔
906
                                        return true;
3,288✔
907
                                case 50:
908
                                        if (last is not null)
×
909
                                        {
×
910
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
911
                                        }
×
912
                                        return true;
×
913
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
914
                                case 66:
915
                                //Vertex count
916
                                case 90:
917
                                        return true;
5,256✔
918
                                case 91:
919
                                        if (last is not null)
×
920
                                        {
×
921
                                                last.Id = this._reader.ValueAsInt;
×
922
                                        }
×
923
                                        return true;
×
924
                                default:
925
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,448✔
926
                        }
927
                }
98,616✔
928

929
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
930
                {
42,240✔
931
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
932

933
                        switch (this._reader.Code)
42,240✔
934
                        {
935
                                case 100:
936
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
937
                                        {
480✔
938
                                                tmp.SubclassMarker = true;
480✔
939
                                        }
480✔
940
                                        return true;
960✔
941
                                //Count of sub-entity which property has been overridden
942
                                case 90:
943
                                        //TODO: process further entities
944
                                        return true;
480✔
945
                                case 92:
946
                                        if (!tmp.SubclassMarker)
720✔
947
                                        {
240✔
948
                                                return false;
240✔
949
                                        }
950

951
                                        int nvertices = this._reader.ValueAsInt;
480✔
952
                                        for (int i = 0; i < nvertices; i++)
61,440✔
953
                                        {
30,240✔
954
                                                this._reader.ReadNext();
30,240✔
955
                                                double x = this._reader.ValueAsDouble;
30,240✔
956
                                                this._reader.ReadNext();
30,240✔
957
                                                double y = this._reader.ValueAsDouble;
30,240✔
958
                                                this._reader.ReadNext();
30,240✔
959
                                                double z = this._reader.ValueAsDouble;
30,240✔
960
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
961
                                        }
30,240✔
962
                                        return true;
480✔
963
                                case 93:
964
                                        int size = this._reader.ValueAsInt;
480✔
965
                                        this._reader.ReadNext();
480✔
966

967
                                        int indexes = 0;
480✔
968
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
969
                                        {
32,640✔
970
                                                indexes = this._reader.ValueAsInt;
32,640✔
971
                                                this._reader.ReadNext();
32,640✔
972

973
                                                int[] face = new int[indexes];
32,640✔
974
                                                for (int j = 0; j < indexes; j++)
314,880✔
975
                                                {
124,800✔
976
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
977

978
                                                        if ((i + j + 2) < size)
124,800✔
979
                                                        {
124,320✔
980
                                                                this._reader.ReadNext();
124,320✔
981
                                                        }
124,320✔
982
                                                }
124,800✔
983

984
                                                tmp.CadObject.Faces.Add(face);
32,640✔
985
                                        }
32,640✔
986

987
                                        Debug.Assert(this._reader.Code == 90);
480✔
988

989
                                        return true;
480✔
990
                                case 94:
991
                                        int numEdges = this._reader.ValueAsInt;
480✔
992
                                        this._reader.ReadNext();
480✔
993
                                        for (int i = 0; i < numEdges; i++)
125,760✔
994
                                        {
62,400✔
995
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
996

997
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
998
                                                this._reader.ReadNext();
62,400✔
999
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1000

1001
                                                if (i < numEdges - 1)
62,400✔
1002
                                                {
61,920✔
1003
                                                        this._reader.ReadNext();
61,920✔
1004
                                                }
61,920✔
1005

1006
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1007
                                        }
62,400✔
1008

1009
                                        Debug.Assert(this._reader.Code == 90);
480✔
1010

1011
                                        return true;
480✔
1012
                                case 95:
1013
                                        this._reader.ReadNext();
480✔
1014
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1015
                                        {
62,400✔
1016
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1017
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1018

1019
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1020

1021
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1022
                                                {
61,920✔
1023
                                                        this._reader.ReadNext();
61,920✔
1024
                                                }
61,920✔
1025
                                        }
62,400✔
1026

1027
                                        Debug.Assert(this._reader.Code == 140);
480✔
1028

1029
                                        return true;
480✔
1030
                                default:
1031
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1032
                        }
1033
                }
42,240✔
1034

1035
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1036
                {
62,400✔
1037
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1038

1039
                        switch (this._reader.Code)
62,400✔
1040
                        {
1041
                                // 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.
1042
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1043
                                case 2:
1044
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1045
                                        return true;
720✔
1046
                                case 72:
1047
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1048
                                        return true;
720✔
1049
                                case 73:
1050
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1051
                                        return true;
720✔
1052
                                case 340:
1053
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1054
                                        return true;
720✔
1055
                                default:
1056
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1057
                                        {
10,080✔
1058
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1059
                                        }
1060
                                        return true;
49,440✔
1061
                        }
1062
                }
62,400✔
1063

1064
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1065
                {
169,440✔
1066
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1067

1068
                        switch (this._reader.Code)
169,440✔
1069
                        {
1070
                                case 270:
1071
                                        //f270 Version
1072
                                        return true;
1,800✔
1073
                                case 300:
1074
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1075
                                        return true;
3,600✔
1076
                                case 340:
1077
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1078
                                        return true;
3,600✔
1079
                                case 341:
1080
                                        tmp.LineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1081
                                        return true;
3,600✔
1082
                                case 343:
1083
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1084
                                        return true;
3,600✔
1085
                                default:
1086
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1087
                        }
1088
                }
169,440✔
1089

1090
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1091
                {
3,600✔
1092
                        this._reader.ReadNext();
3,600✔
1093

1094
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1095
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1096

1097
                        bool end = false;
3,600✔
1098
                        while (this._reader.DxfCode != DxfCode.Start)
201,600✔
1099
                        {
201,600✔
1100
                                switch (this._reader.Code)
201,600✔
1101
                                {
1102
                                        case 301 when this._reader.ValueAsString.Equals("}"):
3,600✔
1103
                                                end = true;
3,600✔
1104
                                                break;
3,600✔
1105
                                        case 302 when this._reader.ValueAsString.Equals("LEADER{"):
3,600✔
1106
                                                contextData.LeaderRoots.Add(this.readMultiLeaderLeader(template));
3,600✔
1107
                                                break;
3,600✔
1108
                                        case 340:
1109
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1110
                                                break;
3,600✔
1111
                                        default:
1112
                                                if (!this.tryAssignCurrentValue(contextData, map.SubClasses[contextData.SubclassMarker]))
190,800!
NEW
1113
                                                {
×
NEW
1114
                                                        this._builder.Notify($"[AcDbMLeaderObjectContextData] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
NEW
1115
                                                }
×
1116
                                                break;
190,800✔
1117
                                }
1118

1119
                                if (end)
201,600✔
1120
                                {
3,600✔
1121
                                        break;
3,600✔
1122
                                }
1123

1124
                                this._reader.ReadNext();
198,000✔
1125
                        }
198,000✔
1126
                }
3,600✔
1127

1128
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1129
                {
3,600✔
1130
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1131
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1132

1133
                        this._reader.ReadNext();
3,600✔
1134

1135
                        bool end = false;
3,600✔
1136
                        while (this._reader.DxfCode != DxfCode.Start)
45,000✔
1137
                        {
45,000✔
1138
                                switch (this._reader.Code)
45,000✔
1139
                                {
1140
                                        case 303 when this._reader.ValueAsString.Equals("}"):
3,600✔
1141
                                                end = true;
3,600✔
1142
                                                break;
3,600✔
1143
                                        case 304 when this._reader.ValueAsString.Equals("LEADER_LINE{"):
3,600✔
1144
                                                var lineTemplate = new LeaderLineTemplate();
3,600✔
1145
                                                template.LeaderLineTemplates.Add(lineTemplate);
3,600✔
1146
                                                root.Lines.Add(this.readMultiLeaderLine(lineTemplate));
3,600✔
1147
                                                break;
3,600✔
1148
                                        default:
1149
                                                if (!this.tryAssignCurrentValue(root, map))
37,800!
NEW
1150
                                                {
×
NEW
1151
                                                        this._builder.Notify($"[LeaderRoot] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
NEW
1152
                                                }
×
1153
                                                break;
37,800✔
1154
                                }
1155

1156
                                if (end)
45,000✔
1157
                                {
3,600✔
1158
                                        break;
3,600✔
1159
                                }
1160

1161
                                this._reader.ReadNext();
41,400✔
1162
                        }
41,400✔
1163

1164
                        return root;
3,600✔
1165
                }
3,600✔
1166

1167
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1168
                {
3,600✔
1169
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1170
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1171

1172
                        this._reader.ReadNext();
3,600✔
1173

1174
                        bool end = false;
3,600✔
1175
                        while (this._reader.DxfCode != DxfCode.Start)
18,000✔
1176
                        {
18,000✔
1177
                                switch (this._reader.Code)
18,000✔
1178
                                {
1179
                                        case 10:
1180
                                                XYZ pt = new XYZ(this._reader.ValueAsDouble, 0, 0);
3,600✔
1181
                                                line.Points.Add(pt);
3,600✔
1182
                                                break;
3,600✔
1183
                                        case 20:
1184
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1185
                                                pt.Y = this._reader.ValueAsDouble;
3,600✔
1186
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1187
                                                break;
3,600✔
1188
                                        case 30:
1189
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1190
                                                pt.Z = this._reader.ValueAsDouble;
3,600✔
1191
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1192
                                                break;
3,600✔
1193
                                        case 305 when this._reader.ValueAsString.Equals("}"):
3,600✔
1194
                                                end = true;
3,600✔
1195
                                                break;
3,600✔
1196
                                        default:
1197
                                                if (!this.tryAssignCurrentValue(line, map))
3,600!
NEW
1198
                                                {
×
NEW
1199
                                                        this._builder.Notify($"[LeaderLine] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
NEW
1200
                                                }
×
1201
                                                break;
3,600✔
1202
                                }
1203

1204
                                if (end)
18,000✔
1205
                                {
3,600✔
1206
                                        break;
3,600✔
1207
                                }
1208

1209
                                this._reader.ReadNext();
14,400✔
1210
                        }
14,400✔
1211

1212
                        return line;
3,600✔
1213
                }
3,600✔
1214

1215
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1216
                {
2,680✔
1217
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1218

1219
                        switch (this._reader.Code)
2,680✔
1220
                        {
1221
                                case 2:
1222
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1223
                                        return true;
280✔
1224
                                default:
1225
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1226
                        }
1227
                }
2,680✔
1228

1229
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1230
                {
14,160✔
1231
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1232
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1233

1234
                        switch (this._reader.Code)
14,160✔
1235
                        {
1236
                                case 91:
1237
                                        var nvertices = this._reader.ValueAsInt;
480✔
1238
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1239
                                        {
1,680✔
1240
                                                this._reader.ReadNext();
1,680✔
1241
                                                var x = this._reader.ValueAsDouble;
1,680✔
1242
                                                this._reader.ReadNext();
1,680✔
1243
                                                var y = this._reader.ValueAsDouble;
1,680✔
1244

1245
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1246
                                        }
1,680✔
1247

1248
                                        this._reader.ReadNext();
480✔
1249

1250
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1251
                                case 340:
1252
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1253
                                        return true;
480✔
1254
                                case 360:
1255
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1256
                                        return true;
480✔
1257
                                default:
1258
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1259
                        }
1260
                }
14,160✔
1261

1262
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1263
                {
342,410✔
1264
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1265
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1266

1267
                        switch (this._reader.Code)
342,410✔
1268
                        {
1269
                                case 2:
1270
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1271
                                        return true;
240✔
1272
                                case 290:
1273
                                        return true;
240✔
1274
                                default:
1275
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
341,930✔
1276
                        }
1277
                }
342,410✔
1278

1279
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1280
                {
41,040✔
1281
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1282

1283
                        switch (this._reader.Code)
41,040✔
1284
                        {
1285
                                case 350:
1286
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1287
                                        return true;
320✔
1288
                                default:
1289
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1290
                        }
1291
                }
41,040✔
1292

1293
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1294
                {
16,800✔
1295
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1296

1297
                        XYZ controlPoint;
1298
                        XYZ fitPoint;
1299

1300
                        switch (this._reader.Code)
16,800!
1301
                        {
1302
                                case 10:
1303
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1304
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1305
                                        return true;
1,920✔
1306
                                case 20:
1307
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1308
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1309
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1310
                                        return true;
1,920✔
1311
                                case 30:
1312
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1313
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1314
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1315
                                        return true;
1,920✔
1316
                                case 11:
1317
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1318
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1319
                                        return true;
×
1320
                                case 21:
1321
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1322
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1323
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1324
                                        return true;
×
1325
                                case 31:
1326
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1327
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1328
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1329
                                        return true;
×
1330
                                case 40:
1331
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1332
                                        return true;
3,840✔
1333
                                case 41:
1334
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1335
                                        return true;
×
1336
                                case 72:
1337
                                case 73:
1338
                                case 74:
1339
                                        return true;
1,440✔
1340
                                default:
1341
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1342
                        }
1343
                }
16,800✔
1344

1345
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1346
                        where T : PdfUnderlayDefinition
1347
                {
3,800✔
1348
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1349

1350
                        switch (this._reader.Code)
3,800✔
1351
                        {
1352
                                case 340:
1353
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1354
                                        return true;
240✔
1355
                                default:
1356
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1357
                        }
1358
                }
3,800✔
1359

1360
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1361
                {
280,766✔
1362
                        CadVertexTemplate tmp = template as CadVertexTemplate;
280,766✔
1363

1364
                        switch (this._reader.Code)
280,766✔
1365
                        {
1366
                                //Polyface mesh vertex index
1367
                                case 71:
1368
                                case 72:
1369
                                case 73:
1370
                                case 74:
1371
                                        return true;
1,960✔
1372
                                case 100:
1373
                                        switch (this._reader.ValueAsString)
8,160!
1374
                                        {
1375
                                                case DxfSubclassMarker.Vertex:
1376
                                                        return true;
2,400✔
1377
                                                case DxfSubclassMarker.PolylineVertex:
1378
                                                        tmp.SetVertexObject(new Vertex2D());
×
1379
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1380
                                                        return true;
×
1381
                                                case DxfSubclassMarker.Polyline3dVertex:
1382
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1383
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1384
                                                        return true;
1,200✔
1385
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1386
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1387
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1388
                                                        return true;
1,200✔
1389
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1390
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1391
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1392
                                                        return true;
480✔
1393
                                                default:
1394
                                                        return false;
2,880✔
1395
                                        }
1396
                                default:
1397
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
270,646✔
1398
                        }
1399
                }
280,766✔
1400

1401
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1402
                {
80,456✔
1403
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1404

1405
                        switch (this._reader.Code)
80,456!
1406
                        {
1407
                                //Undocumented
1408
                                case 67:
1409
                                case 68:
1410
                                        return true;
2,944✔
1411
                                case 69:
1412
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1413
                                        return true;
1,472✔
1414
                                case 331:
1415
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1416
                                        return true;
×
1417
                                case 348:
1418
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1419
                                        return true;
928✔
1420
                                default:
1421
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1422
                        }
1423
                }
80,456✔
1424

1425
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1426
                {
1,007,142✔
1427
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
1,007,142✔
1428

1429
                        switch (this._reader.Code)
1,007,142✔
1430
                        {
1431
                                default:
1432
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
1,007,142✔
1433
                        }
1434
                }
1,007,142✔
1435

1436
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1437
                {
42,721✔
1438
                        List<ExtendedDataRecord> records = new();
42,721✔
1439
                        edata.Add(this._reader.ValueAsString, records);
42,721✔
1440

1441
                        this._reader.ReadNext();
42,721✔
1442

1443
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,498✔
1444
                        {
298,543✔
1445
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
298,543✔
1446
                                {
12,766✔
1447
                                        this.readExtendedData(edata);
12,766✔
1448
                                        break;
12,766✔
1449
                                }
1450

1451
                                ExtendedDataRecord record = null;
285,777✔
1452
                                double x = 0;
285,777✔
1453
                                double y = 0;
285,777✔
1454
                                double z = 0;
285,777✔
1455

1456
                                switch (this._reader.DxfCode)
285,777✔
1457
                                {
1458
                                        case DxfCode.ExtendedDataAsciiString:
1459
                                        case DxfCode.ExtendedDataRegAppName:
1460
                                                record = new ExtendedDataString(this._reader.ValueAsString);
30,268✔
1461
                                                break;
30,268✔
1462
                                        case DxfCode.ExtendedDataControlString:
1463
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1464
                                                break;
15,848✔
1465
                                        case DxfCode.ExtendedDataLayerName:
1466
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1467
                                                {
266✔
1468
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1469
                                                }
266✔
1470
                                                else
1471
                                                {
14✔
1472
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1473
                                                }
14✔
1474
                                                break;
280✔
1475
                                        case DxfCode.ExtendedDataBinaryChunk:
1476
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1477
                                                break;
80✔
1478
                                        case DxfCode.ExtendedDataHandle:
1479
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1480
                                                break;
2,958✔
1481
                                        case DxfCode.ExtendedDataXCoordinate:
1482
                                                x = this._reader.ValueAsDouble;
2,984✔
1483
                                                this._reader.ReadNext();
2,984✔
1484
                                                y = this._reader.ValueAsDouble;
2,984✔
1485
                                                this._reader.ReadNext();
2,984✔
1486
                                                z = this._reader.ValueAsDouble;
2,984✔
1487

1488
                                                record = new ExtendedDataCoordinate(
2,984✔
1489
                                                        new XYZ(
2,984✔
1490
                                                                x,
2,984✔
1491
                                                                y,
2,984✔
1492
                                                                z)
2,984✔
1493
                                                        );
2,984✔
1494
                                                break;
2,984✔
1495
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1496
                                                x = this._reader.ValueAsDouble;
1,440✔
1497
                                                this._reader.ReadNext();
1,440✔
1498
                                                y = this._reader.ValueAsDouble;
1,440✔
1499
                                                this._reader.ReadNext();
1,440✔
1500
                                                z = this._reader.ValueAsDouble;
1,440✔
1501

1502
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1503
                                                        new XYZ(
1,440✔
1504
                                                                x,
1,440✔
1505
                                                                y,
1,440✔
1506
                                                                z)
1,440✔
1507
                                                        );
1,440✔
1508
                                                break;
1,440✔
1509
                                        case DxfCode.ExtendedDataWorldXDisp:
1510
                                                x = this._reader.ValueAsDouble;
280✔
1511
                                                this._reader.ReadNext();
280✔
1512
                                                y = this._reader.ValueAsDouble;
280✔
1513
                                                this._reader.ReadNext();
280✔
1514
                                                z = this._reader.ValueAsDouble;
280✔
1515

1516
                                                record = new ExtendedDataDisplacement(
280✔
1517
                                                        new XYZ(
280✔
1518
                                                                x,
280✔
1519
                                                                y,
280✔
1520
                                                                z)
280✔
1521
                                                        );
280✔
1522
                                                break;
280✔
1523
                                        case DxfCode.ExtendedDataWorldXDir:
1524
                                                x = this._reader.ValueAsDouble;
280✔
1525
                                                this._reader.ReadNext();
280✔
1526
                                                y = this._reader.ValueAsDouble;
280✔
1527
                                                this._reader.ReadNext();
280✔
1528
                                                z = this._reader.ValueAsDouble;
280✔
1529

1530
                                                record = new ExtendedDataDirection(
280✔
1531
                                                        new XYZ(
280✔
1532
                                                                x,
280✔
1533
                                                                y,
280✔
1534
                                                                z)
280✔
1535
                                                        );
280✔
1536
                                                break;
280✔
1537
                                        case DxfCode.ExtendedDataReal:
1538
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1539
                                                break;
140,536✔
1540
                                        case DxfCode.ExtendedDataDist:
1541
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1542
                                                break;
280✔
1543
                                        case DxfCode.ExtendedDataScale:
1544
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1545
                                                break;
280✔
1546
                                        case DxfCode.ExtendedDataInteger16:
1547
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
78,517✔
1548
                                                break;
78,517✔
1549
                                        case DxfCode.ExtendedDataInteger32:
1550
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
9,186✔
1551
                                                break;
9,186✔
1552
                                        default:
1553
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1554
                                                break;
2,560✔
1555
                                }
1556

1557
                                if (record != null)
285,777✔
1558
                                {
283,203✔
1559
                                        records.Add(record);
283,203✔
1560
                                }
283,203✔
1561

1562
                                this._reader.ReadNext();
285,777✔
1563
                        }
285,777✔
1564
                }
42,721✔
1565

1566
                private void readPattern(HatchPattern pattern, int nlines)
1567
                {
1,440✔
1568
                        //Jump 78 code
1569
                        this._reader.ReadNext();
1,440✔
1570

1571
                        for (int i = 0; i < nlines; i++)
218,400✔
1572
                        {
107,760✔
1573
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1574
                                XY basePoint = new XY();
107,760✔
1575
                                XY offset = new XY();
107,760✔
1576

1577
                                bool end = false;
107,760✔
1578
                                HashSet<int> codes = new();
107,760✔
1579

1580
                                while (!end)
755,760✔
1581
                                {
754,320✔
1582
                                        if (codes.Contains(this._reader.Code))
754,320✔
1583
                                        {
106,320✔
1584
                                                break;
106,320✔
1585
                                        }
1586
                                        else
1587
                                        {
648,000✔
1588
                                                codes.Add(this._reader.Code);
648,000✔
1589
                                        }
648,000✔
1590

1591
                                        switch (this._reader.Code)
648,000!
1592
                                        {
1593
                                                case 53:
1594
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1595
                                                        break;
107,760✔
1596
                                                case 43:
1597
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1598
                                                        break;
107,760✔
1599
                                                case 44:
1600
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1601
                                                        line.BasePoint = basePoint;
107,760✔
1602
                                                        break;
107,760✔
1603
                                                case 45:
1604
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1605
                                                        line.Offset = offset;
107,760✔
1606
                                                        break;
107,760✔
1607
                                                case 46:
1608
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1609
                                                        line.Offset = offset;
107,760✔
1610
                                                        break;
107,760✔
1611
                                                //Number of dash length items
1612
                                                case 79:
1613
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1614
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1615
                                                        {
215,040✔
1616
                                                                this._reader.ReadNext();
215,040✔
1617
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1618
                                                        }
215,040✔
1619
                                                        break;
107,760✔
1620
                                                case 49:
1621
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
1622
                                                        break;
×
1623
                                                default:
1624
                                                        end = true;
1,440✔
1625
                                                        break;
1,440✔
1626
                                        }
1627
                                        this._reader.ReadNext();
648,000✔
1628
                                }
648,000✔
1629

1630
                                pattern.Lines.Add(line);
107,760✔
1631
                        }
107,760✔
1632
                }
1,440✔
1633

1634
                private void readLoops(CadHatchTemplate template, int count)
1635
                {
1,920✔
1636
                        if (this._reader.Code == 91)
1,920✔
1637
                                this._reader.ReadNext();
1,920✔
1638

1639
                        for (int i = 0; i < count; i++)
7,680✔
1640
                        {
1,920✔
1641
                                if (this._reader.Code != 92)
1,920!
1642
                                {
×
1643
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1644
                                        break;
×
1645
                                }
1646

1647
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1648
                                if (path != null)
1,920✔
1649
                                        template.PathTempaltes.Add(path);
1,920✔
1650
                        }
1,920✔
1651
                }
1,920✔
1652

1653
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1654
                {
1,920✔
1655
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1656
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1657
                        template.Path.Flags = flags;
1,920✔
1658

1659
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1660
                        {
720✔
1661
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1662
                                template.Path.Edges.Add(pl);
720✔
1663
                        }
720✔
1664
                        else
1665
                        {
1,200✔
1666
                                this._reader.ReadNext();
1,200✔
1667

1668
                                if (this._reader.Code != 93)
1,200!
1669
                                {
×
1670
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1671
                                        return null;
×
1672
                                }
1673

1674
                                int edges = this._reader.ValueAsInt;
1,200✔
1675
                                this._reader.ReadNext();
1,200✔
1676

1677
                                for (int i = 0; i < edges; i++)
12,000✔
1678
                                {
4,800✔
1679
                                        var edge = this.readEdge();
4,800✔
1680
                                        if (edge != null)
4,800✔
1681
                                                template.Path.Edges.Add(edge);
4,800✔
1682
                                }
4,800✔
1683
                        }
1,200✔
1684

1685
                        bool end = false;
1,920✔
1686
                        while (!end)
7,440✔
1687
                        {
5,520✔
1688
                                switch (this._reader.Code)
5,520✔
1689
                                {
1690
                                        //Number of source boundary objects
1691
                                        case 97:
1692
                                                break;
1,920✔
1693
                                        case 330:
1694
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1695
                                                break;
1,680✔
1696
                                        default:
1697
                                                end = true;
1,920✔
1698
                                                continue;
1,920✔
1699
                                }
1700

1701
                                this._reader.ReadNext();
3,600✔
1702
                        }
3,600✔
1703

1704
                        return template;
1,920✔
1705
                }
1,920✔
1706

1707
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1708
                {
720✔
1709
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1710

1711
                        this._reader.ReadNext();
720✔
1712

1713
                        if (this._reader.Code != 72)
720!
1714
                        {
×
1715
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1716
                                return null;
×
1717
                        }
1718

1719
                        //72
1720
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1721
                        this._reader.ReadNext();
720✔
1722

1723
                        //73
1724
                        bool isClosed = this._reader.ValueAsBool;
720✔
1725
                        this._reader.ReadNext();
720✔
1726

1727
                        //93
1728
                        int nvertices = this._reader.ValueAsInt;
720✔
1729
                        this._reader.ReadNext();
720✔
1730

1731
                        for (int i = 0; i < nvertices; i++)
7,200✔
1732
                        {
2,880✔
1733
                                double bulge = 0.0;
2,880✔
1734

1735
                                //10
1736
                                double x = this._reader.ValueAsDouble;
2,880✔
1737
                                this._reader.ReadNext();
2,880✔
1738
                                //20
1739
                                double y = this._reader.ValueAsDouble;
2,880✔
1740
                                this._reader.ReadNext();
2,880✔
1741

1742
                                if (hasBulge)
2,880!
1743
                                {
×
1744
                                        //42
1745
                                        bulge = this._reader.ValueAsDouble;
×
1746
                                        this._reader.ReadNext();
×
1747
                                }
×
1748

1749
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1750
                        }
2,880✔
1751

1752
                        return boundary;
720✔
1753
                }
720✔
1754

1755
                private Hatch.BoundaryPath.Edge readEdge()
1756
                {
4,800✔
1757
                        if (this._reader.Code != 72)
4,800!
1758
                        {
×
1759
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1760
                                return null;
×
1761
                        }
1762

1763
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1764
                        this._reader.ReadNext();
4,800✔
1765

1766
                        switch (type)
4,800!
1767
                        {
1768
                                case Hatch.BoundaryPath.EdgeType.Line:
1769
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1770
                                        while (true)
24,000✔
1771
                                        {
24,000✔
1772
                                                switch (this._reader.Code)
24,000✔
1773
                                                {
1774
                                                        case 10:
1775
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1776
                                                                break;
4,800✔
1777
                                                        case 20:
1778
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1779
                                                                break;
4,800✔
1780
                                                        case 11:
1781
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1782
                                                                break;
4,800✔
1783
                                                        case 21:
1784
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1785
                                                                break;
4,800✔
1786
                                                        default:
1787
                                                                return line;
4,800✔
1788
                                                }
1789

1790
                                                this._reader.ReadNext();
19,200✔
1791
                                        }
19,200✔
1792
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1793
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1794
                                        while (true)
×
1795
                                        {
×
1796
                                                switch (this._reader.Code)
×
1797
                                                {
1798
                                                        case 10:
1799
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1800
                                                                break;
×
1801
                                                        case 20:
1802
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1803
                                                                break;
×
1804
                                                        case 40:
1805
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1806
                                                                break;
×
1807
                                                        case 50:
1808
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1809
                                                                break;
×
1810
                                                        case 51:
1811
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1812
                                                                break;
×
1813
                                                        case 73:
1814
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1815
                                                                break;
×
1816
                                                        default:
1817
                                                                return arc;
×
1818
                                                }
1819

1820
                                                this._reader.ReadNext();
×
1821
                                        }
×
1822
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1823
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1824
                                        while (true)
×
1825
                                        {
×
1826
                                                switch (this._reader.Code)
×
1827
                                                {
1828
                                                        case 10:
1829
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1830
                                                                break;
×
1831
                                                        case 20:
1832
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1833
                                                                break;
×
1834
                                                        case 11:
1835
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1836
                                                                break;
×
1837
                                                        case 21:
1838
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1839
                                                                break;
×
1840
                                                        case 40:
1841
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1842
                                                                break;
×
1843
                                                        case 50:
1844
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1845
                                                                break;
×
1846
                                                        case 51:
1847
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1848
                                                                break;
×
1849
                                                        case 73:
1850
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1851
                                                                break;
×
1852
                                                        default:
1853
                                                                return ellipse;
×
1854
                                                }
1855

1856
                                                this._reader.ReadNext();
×
1857
                                        }
×
1858
                                case Hatch.BoundaryPath.EdgeType.Spline:
1859
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1860
                                        int nKnots = 0;
×
1861
                                        int nCtrlPoints = 0;
×
1862
                                        int nFitPoints = 0;
×
1863

1864
                                        XYZ controlPoint = new XYZ();
×
1865
                                        XY fitPoint = new XY();
×
1866

1867
                                        while (true)
×
1868
                                        {
×
1869
                                                switch (this._reader.Code)
×
1870
                                                {
1871
                                                        case 10:
1872
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1873
                                                                break;
×
1874
                                                        case 20:
1875
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1876
                                                                spline.ControlPoints.Add(controlPoint);
×
1877
                                                                break;
×
1878
                                                        case 11:
1879
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1880
                                                                break;
×
1881
                                                        case 21:
1882
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1883
                                                                spline.FitPoints.Add(fitPoint);
×
1884
                                                                break;
×
1885
                                                        case 42:
1886
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1887
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1888
                                                                break;
×
1889
                                                        case 12:
1890
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
1891
                                                                break;
×
1892
                                                        case 22:
1893
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
1894
                                                                break;
×
1895
                                                        case 13:
1896
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
1897
                                                                break;
×
1898
                                                        case 23:
1899
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
1900
                                                                break;
×
1901
                                                        case 94:
1902
                                                                spline.Degree = this._reader.ValueAsInt;
×
1903
                                                                break;
×
1904
                                                        case 73:
1905
                                                                spline.Rational = this._reader.ValueAsBool;
×
1906
                                                                break;
×
1907
                                                        case 74:
1908
                                                                spline.Periodic = this._reader.ValueAsBool;
×
1909
                                                                break;
×
1910
                                                        case 95:
1911
                                                                nKnots = this._reader.ValueAsInt;
×
1912
                                                                break;
×
1913
                                                        case 96:
1914
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
1915
                                                                break;
×
1916
                                                        case 97:
1917
                                                                nFitPoints = this._reader.ValueAsInt;
×
1918
                                                                break;
×
1919
                                                        case 40:
1920
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
1921
                                                                break;
×
1922
                                                        default:
1923
                                                                return spline;
×
1924
                                                }
1925

1926
                                                this._reader.ReadNext();
×
1927
                                        }
×
1928
                        }
1929

1930
                        return null;
×
1931
                }
4,800✔
1932

1933
                private void readDefinedGroups(CadTemplate template)
1934
                {
67,424✔
1935
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
67,424✔
1936

1937
                        template.XDictHandle = xdict;
67,424✔
1938
                        template.ReactorsHandles.UnionWith(reactorsHandles);
67,424✔
1939
                }
67,424✔
1940

1941
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
1942
                {
67,666✔
1943
                        xdictHandle = null;
67,666✔
1944
                        reactors = new HashSet<ulong>();
67,666✔
1945

1946
                        switch (this._reader.ValueAsString)
67,666✔
1947
                        {
1948
                                case DxfFileToken.DictionaryToken:
1949
                                        this._reader.ReadNext();
12,845✔
1950
                                        xdictHandle = this._reader.ValueAsHandle;
12,845✔
1951
                                        this._reader.ReadNext();
12,845✔
1952
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
12,845✔
1953
                                        return;
12,845✔
1954
                                case DxfFileToken.ReactorsToken:
1955
                                        reactors = this.readReactors();
52,421✔
1956
                                        break;
52,421✔
1957
                                case DxfFileToken.BlkRefToken:
1958
                                default:
1959
                                        do
1960
                                        {
6,240✔
1961
                                                this._reader.ReadNext();
6,240✔
1962
                                        }
6,240✔
1963
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
1964
                                        return;
2,400✔
1965
                        }
1966
                }
67,666✔
1967

1968
                private HashSet<ulong> readReactors()
1969
                {
52,421✔
1970
                        HashSet<ulong> reactors = new();
52,421✔
1971

1972
                        this._reader.ReadNext();
52,421✔
1973

1974
                        while (this._reader.DxfCode != DxfCode.ControlString)
111,922✔
1975
                        {
59,501✔
1976
                                this._reader.ReadNext();
59,501✔
1977
                        }
59,501✔
1978

1979
                        return reactors;
52,421✔
1980
                }
52,421✔
1981

1982
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
1983
                {
5,814,762✔
1984
                        try
1985
                        {
5,814,762✔
1986
                                //Use this method only if the value is not a link between objects
1987
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
5,814,762✔
1988
                                {
2,383,939✔
1989
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,383,939✔
1990
                                        {
14,548✔
1991
                                                return true;
14,548✔
1992
                                        }
1993

1994
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,369,391!
1995
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,369,391✔
1996
                                        {
72,960✔
1997
                                                return false;
72,960✔
1998
                                        }
1999

2000
                                        object value = this._reader.Value;
2,296,431✔
2001

2002
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,296,431✔
2003
                                        {
17,428✔
2004
                                                value = MathHelper.DegToRad((double)value);
17,428✔
2005
                                        }
17,428✔
2006

2007
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,296,431✔
2008

2009
                                        return true;
2,296,431✔
2010
                                }
2011
                        }
3,430,823✔
2012
                        catch (Exception ex)
×
2013
                        {
×
2014
                                if (!this._builder.Configuration.Failsafe)
×
2015
                                {
×
2016
                                        throw ex;
×
2017
                                }
2018
                                else
2019
                                {
×
2020
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2021
                                }
×
2022
                        }
×
2023

2024
                        return false;
3,430,823✔
2025
                }
5,814,762✔
2026
        }
2027
}
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