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

DomCR / ACadSharp / 19782869074

29 Nov 2025 10:48AM UTC coverage: 77.931% (-0.1%) from 78.074%
19782869074

Pull #752

github

web-flow
Merge 29c4c0483 into 2e85a0799
Pull Request #752: Issue 750 ole2frame

7509 of 10459 branches covered (71.79%)

Branch coverage included in aggregate %.

14 of 88 new or added lines in 6 files covered. (15.91%)

39 existing lines in 3 files now uncovered.

27839 of 34899 relevant lines covered (79.77%)

97649.26 hits per line

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

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

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

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

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

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

32
                public abstract void Read();
33

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

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

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

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

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

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

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

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

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

238
                                        this._reader.ReadNext();
×
239

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

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

253
                                        return unknownEntityTemplate;
×
254
                        }
255
                }
174,378✔
256

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

262
                        DxfMap map = DxfMap.Create<T>();
228,564✔
263

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

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

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

283
                        return template;
228,564✔
284
                }
228,564✔
285

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

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

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

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

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

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

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

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

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

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

534
                private void readCellValue(TableEntity.CellContent content)
535
                {
6,560✔
536
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
6,560!
537
                        {
6,560✔
538
                                this._reader.ReadNext();
6,560✔
539
                        }
6,560✔
540
                        else
541
                        {
×
542
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
543
                        }
544

545
                        while (this._reader.Code != 304
42,880✔
546
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
42,880✔
547
                        {
36,320✔
548
                                switch (this._reader.Code)
36,320!
549
                                {
550
                                        case 1:
551
                                                content.Value.Text = this._reader.ValueAsString;
1,920✔
552
                                                break;
1,920✔
553
                                        case 2:
554
                                                content.Value.Text += this._reader.ValueAsString;
×
555
                                                break;
×
556
                                        case 11:
557
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
160✔
558
                                                break;
160✔
559
                                        case 21:
560
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
160✔
561
                                                break;
160✔
562
                                        case 31:
563
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
160✔
564
                                                break;
160✔
565
                                        case 302:
566
                                                //TODO: Fix this assignation to cell value
567
                                                content.Value.Value = this._reader.ValueAsString;
6,560✔
568
                                                break;
6,560✔
569
                                        case 90:
570
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
6,560✔
571
                                                break;
6,560✔
572
                                        case 91:
573
                                                content.Value.Value = this._reader.ValueAsInt;
160✔
574
                                                break;
160✔
575
                                        case 92:
576
                                                //Extended cell flags (from AutoCAD 2007)
577
                                                break;
160✔
578
                                        case 93:
579
                                                content.Value.Flags = this._reader.ValueAsInt;
6,560✔
580
                                                break;
6,560✔
581
                                        case 94:
582
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
6,560✔
583
                                                break;
6,560✔
584
                                        case 140:
585
                                                content.Value.Value = this._reader.ValueAsDouble;
640✔
586
                                                break;
640✔
587
                                        case 300:
588
                                                content.Value.Format = this._reader.ValueAsString;
6,560✔
589
                                                break;
6,560✔
590
                                        case 310:
591
                                                //Data for proxy entity graphics (multiple lines; 256-character maximum per line)
592
                                                break;
160✔
593
                                        default:
594
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
595
                                                break;
×
596
                                }
597

598
                                this._reader.ReadNext();
36,320✔
599
                        }
36,320✔
600
                }
6,560✔
601

602
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
603
                {
341,010✔
604
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
341,010✔
605
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
341,010✔
606

607
                        switch (this._reader.Code)
341,010✔
608
                        {
609
                                //TODO: Implement multiline text def codes
610
                                case 1 or 3 when tmp.CadObject is MText mtext:
30,306✔
611
                                        mtext.Value += this._reader.ValueAsString;
11,466✔
612
                                        return true;
11,466✔
613
                                case 50 when tmp.CadObject is MText mtext://Read only for MText
570!
614
                                        double angle = MathHelper.DegToRad(this._reader.ValueAsDouble);
×
615
                                        mtext.AlignmentPoint = new XYZ(System.Math.Cos(angle), System.Math.Sin(angle), 0.0);
×
616
                                        return true;
×
617
                                case 70:
618
                                case 74:
619
                                case 101:
620
                                        return true;
480✔
621
                                case 7:
622
                                        tmp.StyleName = this._reader.ValueAsString;
3,080✔
623
                                        return true;
3,080✔
624
                                default:
625
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
325,984✔
626
                        }
627
                }
341,010✔
628

629
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
630
                {
7,200✔
631
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
7,200✔
632

633
                        switch (this._reader.Code)
7,200✔
634
                        {
635
                                case 3:
636
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
720✔
637
                                        return true;
720✔
638
                                default:
639
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
6,480✔
640
                        }
641
                }
7,200✔
642

643
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
644
                {
80,560✔
645
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
80,560✔
646

647
                        switch (this._reader.Code)
80,560✔
648
                        {
649
                                case 2:
650
                                        tmp.BlockName = this._reader.ValueAsString;
3,080✔
651
                                        return true;
3,080✔
652
                                case 3:
653
                                        tmp.StyleName = this._reader.ValueAsString;
2,640✔
654
                                        return true;
2,640✔
655
                                case 50:
656
                                        var dim = new DimensionLinear();
280✔
657
                                        tmp.SetDimensionObject(dim);
280✔
658
                                        dim.Rotation = this._reader.ValueAsAngle;
280✔
659
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
280✔
660
                                        return true;
280✔
661
                                case 70:
662
                                        //Flags do not have set
663
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
3,080✔
664
                                        return true;
3,080✔
665
                                //Measurement - read only
666
                                case 42:
667
                                        return true;
2,640✔
668
                                //Undocumented codes
669
                                case 73:
670
                                case 74:
671
                                case 75:
672
                                case 90:
673
                                case 361:
674
                                        return true;
5,280✔
675
                                case 100:
676
                                        switch (this._reader.ValueAsString)
8,640✔
677
                                        {
678
                                                case DxfSubclassMarker.Dimension:
679
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
2,640✔
680
                                                case DxfSubclassMarker.AlignedDimension:
681
                                                        tmp.SetDimensionObject(new DimensionAligned());
1,200✔
682
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
1,200✔
683
                                                        return true;
1,200✔
684
                                                case DxfSubclassMarker.DiametricDimension:
685
                                                        tmp.SetDimensionObject(new DimensionDiameter());
240✔
686
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
240✔
687
                                                        return true;
240✔
688
                                                case DxfSubclassMarker.Angular2LineDimension:
689
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
240✔
690
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
240✔
691
                                                        return true;
240✔
692
                                                case DxfSubclassMarker.Angular3PointDimension:
693
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
240✔
694
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
240✔
695
                                                        return true;
240✔
696
                                                case DxfSubclassMarker.RadialDimension:
697
                                                        tmp.SetDimensionObject(new DimensionRadius());
240✔
698
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
240✔
699
                                                        return true;
240✔
700
                                                case DxfSubclassMarker.OrdinateDimension:
701
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
480✔
702
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
480✔
703
                                                        return true;
480✔
704
                                                case DxfSubclassMarker.LinearDimension:
705
                                                        return true;
720✔
706
                                                default:
707
                                                        return false;
2,640✔
708
                                        }
709
                                default:
710
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
54,920✔
711
                        }
712
                }
80,560✔
713

714
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
715
                {
51,360✔
716
                        CadHatchTemplate tmp = template as CadHatchTemplate;
51,360✔
717
                        Hatch hatch = tmp.CadObject;
51,360✔
718

719
                        XY seedPoint = new XY();
51,360✔
720

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

810
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
811
                {
69,626✔
812
                        CadInsertTemplate tmp = template as CadInsertTemplate;
69,626✔
813

814
                        switch (this._reader.Code)
69,626✔
815
                        {
816
                                case 2:
817
                                        tmp.BlockName = this._reader.ValueAsString;
6,508✔
818
                                        return true;
6,508✔
819
                                case 100:
820
                                        //AcDbEntity
821
                                        //AcDbBlockReference
822
                                        //AcDbMInsertBlock
823
                                        return true;
6,528✔
824
                                case 66:
825
                                        return true;
560✔
826
                                default:
827
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]);
56,030✔
828
                        }
829
                }
69,626✔
830

831
                private CadEntityTemplate readPolyline()
832
                {
12,348✔
833
                        CadPolyLineTemplate template = null;
12,348✔
834

835
                        if (this._builder.Version == ACadVersion.Unknown
12,348!
836
                                || this._builder.Version == ACadVersion.AC1009)
12,348✔
837
                        {
11,868✔
838
                                var polyline = new Polyline2D();
11,868✔
839
                                template = new CadPolyLineTemplate(polyline);
11,868✔
840
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
11,868✔
841

842
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
54,108!
843
                                {
42,240✔
844
                                        Vertex2D v = new Vertex2D();
42,240✔
845
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
42,240✔
846
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
42,240✔
847

848
                                        if (vertexTemplate.Vertex.Handle == 0)
42,240!
849
                                        {
×
850
                                                polyline.Vertices.Add(v);
×
851
                                        }
×
852
                                        else
853
                                        {
42,240✔
854
                                                template.OwnedObjectsHandlers.Add(vertexTemplate.Vertex.Handle);
42,240✔
855
                                                this._builder.AddTemplate(vertexTemplate);
42,240✔
856
                                        }
42,240✔
857
                                }
42,240✔
858

859
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
23,736!
860
                                {
11,868✔
861
                                        var seqend = new Seqend();
11,868✔
862
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
11,868✔
863
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
11,868✔
864

865
                                        polyline.Vertices.Seqend = seqend;
11,868✔
866
                                }
11,868✔
867
                        }
11,868✔
868
                        else
869
                        {
480✔
870
                                template = new CadPolyLineTemplate();
480✔
871
                                this.readEntityCodes<Entity>(template, this.readPolyline);
480✔
872
                        }
480✔
873

874
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
12,348!
875
                        {
×
876
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
×
877
                                return null;
×
878
                        }
879

880
                        return template;
12,348✔
881
                }
12,348✔
882

883
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
884
                {
88,672✔
885
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
88,672✔
886

887
                        switch (this._reader.Code)
88,672✔
888
                        {
889
                                //DXF: always 0
890
                                //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)
891
                                case 10:
892
                                case 20:
893
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
894
                                case 66:
895
                                //Polygon mesh M vertex count (optional; default = 0)
896
                                case 71:
897
                                //Polygon mesh N vertex count(optional; default = 0)
898
                                case 72:
899
                                //Smooth surface M density(optional; default = 0)
900
                                case 73:
901
                                //Smooth surface N density (optional; default = 0)
902
                                case 74:
903
                                        return true;
37,604✔
904
                                case 100:
905
                                        switch (this._reader.ValueAsString)
960!
906
                                        {
907
                                                case DxfSubclassMarker.Polyline:
908
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
909
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
910
                                                        return true;
×
911
                                                case DxfSubclassMarker.Polyline3d:
912
                                                        tmp.SetPolyLineObject(new Polyline3D());
240✔
913
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
240✔
914
                                                        return true;
240✔
915
                                                case DxfSubclassMarker.PolyfaceMesh:
916
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
240✔
917
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
240✔
918
                                                        return true;
240✔
919
                                                default:
920
                                                        return false;
480✔
921
                                        }
922
                                default:
923
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
50,108✔
924
                        }
925
                }
88,672✔
926

927
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
928
                {
6,000✔
929
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
6,000✔
930

931
                        switch (this._reader.Code)
6,000✔
932
                        {
933
                                case 3:
934
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
240✔
935
                                        return true;
240✔
936
                                case 10:
937
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
960✔
938
                                        return true;
960✔
939
                                case 20:
940
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
941
                                        y.Y = this._reader.ValueAsDouble;
960✔
942
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
960✔
943
                                        return true;
960✔
944
                                case 30:
945
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
960✔
946
                                        z.Z = this._reader.ValueAsDouble;
960✔
947
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
960✔
948
                                        return true;
960✔
949
                                case 340:
950
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
240✔
951
                                        return true;
240✔
952
                                //Hook line flag - read only
953
                                case 75:
954
                                //Vertices count
955
                                case 76:
956
                                        return true;
480✔
957
                                default:
958
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,160✔
959
                        }
960
                }
6,000✔
961

962
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
963
                {
98,616✔
964
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
98,616✔
965

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

968
                        switch (this._reader.Code)
98,616!
969
                        {
970
                                case 10:
971
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
23,412✔
972
                                        return true;
23,412✔
973
                                case 20:
974
                                        if (last is not null)
23,412✔
975
                                        {
23,412✔
976
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
23,412✔
977
                                        }
23,412✔
978
                                        return true;
23,412✔
979
                                case 40:
980
                                        if (last is not null)
2,400✔
981
                                        {
2,400✔
982
                                                last.StartWidth = this._reader.ValueAsDouble;
2,400✔
983
                                        }
2,400✔
984
                                        return true;
2,400✔
985
                                case 41:
986
                                        if (last is not null)
2,400✔
987
                                        {
2,400✔
988
                                                last.EndWidth = this._reader.ValueAsDouble;
2,400✔
989
                                        }
2,400✔
990
                                        return true;
2,400✔
991
                                case 42:
992
                                        if (last is not null)
3,288✔
993
                                        {
3,288✔
994
                                                last.Bulge = this._reader.ValueAsDouble;
3,288✔
995
                                        }
3,288✔
996
                                        return true;
3,288✔
997
                                case 50:
998
                                        if (last is not null)
×
999
                                        {
×
1000
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
1001
                                        }
×
1002
                                        return true;
×
1003
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
1004
                                case 66:
1005
                                //Vertex count
1006
                                case 90:
1007
                                        return true;
5,256✔
1008
                                case 91:
1009
                                        if (last is not null)
×
1010
                                        {
×
1011
                                                last.Id = this._reader.ValueAsInt;
×
1012
                                        }
×
1013
                                        return true;
×
1014
                                default:
1015
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,448✔
1016
                        }
1017
                }
98,616✔
1018

1019
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
1020
                {
42,240✔
1021
                        CadMeshTemplate tmp = template as CadMeshTemplate;
42,240✔
1022

1023
                        switch (this._reader.Code)
42,240✔
1024
                        {
1025
                                case 100:
1026
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
960✔
1027
                                        {
480✔
1028
                                                tmp.SubclassMarker = true;
480✔
1029
                                        }
480✔
1030
                                        return true;
960✔
1031
                                //Count of sub-entity which property has been overridden
1032
                                case 90:
1033
                                        //TODO: process further entities
1034
                                        return true;
480✔
1035
                                case 92:
1036
                                        if (!tmp.SubclassMarker)
720✔
1037
                                        {
240✔
1038
                                                return false;
240✔
1039
                                        }
1040

1041
                                        int nvertices = this._reader.ValueAsInt;
480✔
1042
                                        for (int i = 0; i < nvertices; i++)
61,440✔
1043
                                        {
30,240✔
1044
                                                this._reader.ReadNext();
30,240✔
1045
                                                double x = this._reader.ValueAsDouble;
30,240✔
1046
                                                this._reader.ReadNext();
30,240✔
1047
                                                double y = this._reader.ValueAsDouble;
30,240✔
1048
                                                this._reader.ReadNext();
30,240✔
1049
                                                double z = this._reader.ValueAsDouble;
30,240✔
1050
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
30,240✔
1051
                                        }
30,240✔
1052
                                        return true;
480✔
1053
                                case 93:
1054
                                        int size = this._reader.ValueAsInt;
480✔
1055
                                        this._reader.ReadNext();
480✔
1056

1057
                                        int indexes = 0;
480✔
1058
                                        for (int i = 0; i < size; i += indexes + 1)
66,240✔
1059
                                        {
32,640✔
1060
                                                indexes = this._reader.ValueAsInt;
32,640✔
1061
                                                this._reader.ReadNext();
32,640✔
1062

1063
                                                int[] face = new int[indexes];
32,640✔
1064
                                                for (int j = 0; j < indexes; j++)
314,880✔
1065
                                                {
124,800✔
1066
                                                        face[j] = this._reader.ValueAsInt;
124,800✔
1067

1068
                                                        if ((i + j + 2) < size)
124,800✔
1069
                                                        {
124,320✔
1070
                                                                this._reader.ReadNext();
124,320✔
1071
                                                        }
124,320✔
1072
                                                }
124,800✔
1073

1074
                                                tmp.CadObject.Faces.Add(face);
32,640✔
1075
                                        }
32,640✔
1076

1077
                                        Debug.Assert(this._reader.Code == 90);
480✔
1078

1079
                                        return true;
480✔
1080
                                case 94:
1081
                                        int numEdges = this._reader.ValueAsInt;
480✔
1082
                                        this._reader.ReadNext();
480✔
1083
                                        for (int i = 0; i < numEdges; i++)
125,760✔
1084
                                        {
62,400✔
1085
                                                Mesh.Edge edge = new Mesh.Edge();
62,400✔
1086

1087
                                                edge.Start = this._reader.ValueAsInt;
62,400✔
1088
                                                this._reader.ReadNext();
62,400✔
1089
                                                edge.End = this._reader.ValueAsInt;
62,400✔
1090

1091
                                                if (i < numEdges - 1)
62,400✔
1092
                                                {
61,920✔
1093
                                                        this._reader.ReadNext();
61,920✔
1094
                                                }
61,920✔
1095

1096
                                                tmp.CadObject.Edges.Add(edge);
62,400✔
1097
                                        }
62,400✔
1098

1099
                                        Debug.Assert(this._reader.Code == 90);
480✔
1100

1101
                                        return true;
480✔
1102
                                case 95:
1103
                                        this._reader.ReadNext();
480✔
1104
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
125,760✔
1105
                                        {
62,400✔
1106
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
62,400✔
1107
                                                edge.Crease = this._reader.ValueAsDouble;
62,400✔
1108

1109
                                                tmp.CadObject.Edges[i] = edge;
62,400✔
1110

1111
                                                if (i < tmp.CadObject.Edges.Count - 1)
62,400✔
1112
                                                {
61,920✔
1113
                                                        this._reader.ReadNext();
61,920✔
1114
                                                }
61,920✔
1115
                                        }
62,400✔
1116

1117
                                        Debug.Assert(this._reader.Code == 140);
480✔
1118

1119
                                        return true;
480✔
1120
                                default:
1121
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
38,640✔
1122
                        }
1123
                }
42,240✔
1124

1125
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
1126
                {
62,400✔
1127
                        CadMLineTemplate tmp = template as CadMLineTemplate;
62,400✔
1128

1129
                        switch (this._reader.Code)
62,400✔
1130
                        {
1131
                                // 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.
1132
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
1133
                                case 2:
1134
                                        tmp.MLineStyleName = this._reader.ValueAsString;
720✔
1135
                                        return true;
720✔
1136
                                case 72:
1137
                                        tmp.NVertex = this._reader.ValueAsInt;
720✔
1138
                                        return true;
720✔
1139
                                case 73:
1140
                                        tmp.NElements = this._reader.ValueAsInt;
720✔
1141
                                        return true;
720✔
1142
                                case 340:
1143
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
720✔
1144
                                        return true;
720✔
1145
                                default:
1146
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
59,520✔
1147
                                        {
10,080✔
1148
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
10,080✔
1149
                                        }
1150
                                        return true;
49,440✔
1151
                        }
1152
                }
62,400✔
1153

1154
                private bool readMLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
1155
                {
169,440✔
1156
                        CadMLeaderTemplate tmp = template as CadMLeaderTemplate;
169,440✔
1157

1158
                        switch (this._reader.Code)
169,440✔
1159
                        {
1160
                                case 270:
1161
                                        //f270 Version
1162
                                        return true;
1,800✔
1163
                                case 300:
1164
                                        this.readMultiLeaderObjectContextData(tmp.CadMLeaderAnnotContextTemplate);
3,600✔
1165
                                        return true;
3,600✔
1166
                                case 340:
1167
                                        tmp.LeaderStyleHandle = this._reader.ValueAsHandle;
3,600✔
1168
                                        return true;
3,600✔
1169
                                case 341:
1170
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
3,600✔
1171
                                        return true;
3,600✔
1172
                                case 343:
1173
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1174
                                        return true;
3,600✔
1175
                                default:
1176
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
153,240✔
1177
                        }
1178
                }
169,440✔
1179

1180
                private void readMultiLeaderObjectContextData(CadMLeaderAnnotContextTemplate template)
1181
                {
3,600✔
1182
                        this._reader.ReadNext();
3,600✔
1183

1184
                        DxfMap map = DxfMap.Create<MultiLeaderObjectContextData>();
3,600✔
1185
                        var contextData = template.CadObject as MultiLeaderObjectContextData;
3,600✔
1186

1187
                        bool end = false;
3,600✔
1188
                        while (this._reader.DxfCode != DxfCode.Start)
201,600✔
1189
                        {
201,600✔
1190
                                switch (this._reader.Code)
201,600✔
1191
                                {
1192
                                        case 301 when this._reader.ValueAsString.Equals("}"):
3,600✔
1193
                                                end = true;
3,600✔
1194
                                                break;
3,600✔
1195
                                        case 302 when this._reader.ValueAsString.Equals("LEADER{"):
3,600✔
1196
                                                contextData.LeaderRoots.Add(this.readMultiLeaderLeader(template));
3,600✔
1197
                                                break;
3,600✔
1198
                                        case 340:
1199
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
3,600✔
1200
                                                break;
3,600✔
1201
                                        default:
1202
                                                if (!this.tryAssignCurrentValue(contextData, map.SubClasses[contextData.SubclassMarker]))
190,800!
1203
                                                {
×
1204
                                                        this._builder.Notify($"[AcDbMLeaderObjectContextData] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1205
                                                }
×
1206
                                                break;
190,800✔
1207
                                }
1208

1209
                                if (end)
201,600✔
1210
                                {
3,600✔
1211
                                        break;
3,600✔
1212
                                }
1213

1214
                                this._reader.ReadNext();
198,000✔
1215
                        }
198,000✔
1216
                }
3,600✔
1217

1218
                private MultiLeaderObjectContextData.LeaderRoot readMultiLeaderLeader(CadMLeaderAnnotContextTemplate template)
1219
                {
3,600✔
1220
                        MultiLeaderObjectContextData.LeaderRoot root = new();
3,600✔
1221
                        var map = DxfClassMap.Create(root.GetType(), nameof(MultiLeaderObjectContextData.LeaderRoot));
3,600✔
1222

1223
                        this._reader.ReadNext();
3,600✔
1224

1225
                        bool end = false;
3,600✔
1226
                        while (this._reader.DxfCode != DxfCode.Start)
45,000✔
1227
                        {
45,000✔
1228
                                switch (this._reader.Code)
45,000✔
1229
                                {
1230
                                        case 303 when this._reader.ValueAsString.Equals("}"):
3,600✔
1231
                                                end = true;
3,600✔
1232
                                                break;
3,600✔
1233
                                        case 304 when this._reader.ValueAsString.Equals("LEADER_LINE{"):
3,600✔
1234
                                                var lineTemplate = new LeaderLineTemplate();
3,600✔
1235
                                                template.LeaderLineTemplates.Add(lineTemplate);
3,600✔
1236
                                                root.Lines.Add(this.readMultiLeaderLine(lineTemplate));
3,600✔
1237
                                                break;
3,600✔
1238
                                        default:
1239
                                                if (!this.tryAssignCurrentValue(root, map))
37,800!
1240
                                                {
×
1241
                                                        this._builder.Notify($"[LeaderRoot] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1242
                                                }
×
1243
                                                break;
37,800✔
1244
                                }
1245

1246
                                if (end)
45,000✔
1247
                                {
3,600✔
1248
                                        break;
3,600✔
1249
                                }
1250

1251
                                this._reader.ReadNext();
41,400✔
1252
                        }
41,400✔
1253

1254
                        return root;
3,600✔
1255
                }
3,600✔
1256

1257
                private MultiLeaderObjectContextData.LeaderLine readMultiLeaderLine(LeaderLineTemplate template)
1258
                {
3,600✔
1259
                        MultiLeaderObjectContextData.LeaderLine line = template.LeaderLine;
3,600✔
1260
                        var map = DxfClassMap.Create(line.GetType(), nameof(MultiLeaderObjectContextData.LeaderLine));
3,600✔
1261

1262
                        this._reader.ReadNext();
3,600✔
1263

1264
                        bool end = false;
3,600✔
1265
                        while (this._reader.DxfCode != DxfCode.Start)
18,000✔
1266
                        {
18,000✔
1267
                                switch (this._reader.Code)
18,000✔
1268
                                {
1269
                                        case 10:
1270
                                                XYZ pt = new XYZ(this._reader.ValueAsDouble, 0, 0);
3,600✔
1271
                                                line.Points.Add(pt);
3,600✔
1272
                                                break;
3,600✔
1273
                                        case 20:
1274
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1275
                                                pt.Y = this._reader.ValueAsDouble;
3,600✔
1276
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1277
                                                break;
3,600✔
1278
                                        case 30:
1279
                                                pt = line.Points[line.Points.Count - 1];
3,600✔
1280
                                                pt.Z = this._reader.ValueAsDouble;
3,600✔
1281
                                                line.Points[line.Points.Count - 1] = pt;
3,600✔
1282
                                                break;
3,600✔
1283
                                        case 305 when this._reader.ValueAsString.Equals("}"):
3,600✔
1284
                                                end = true;
3,600✔
1285
                                                break;
3,600✔
1286
                                        default:
1287
                                                if (!this.tryAssignCurrentValue(line, map))
3,600!
1288
                                                {
×
1289
                                                        this._builder.Notify($"[LeaderLine] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
1290
                                                }
×
1291
                                                break;
3,600✔
1292
                                }
1293

1294
                                if (end)
18,000✔
1295
                                {
3,600✔
1296
                                        break;
3,600✔
1297
                                }
1298

1299
                                this._reader.ReadNext();
14,400✔
1300
                        }
14,400✔
1301

1302
                        return line;
3,600✔
1303
                }
3,600✔
1304

1305
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1306
                {
2,680✔
1307
                        CadShapeTemplate tmp = template as CadShapeTemplate;
2,680✔
1308

1309
                        switch (this._reader.Code)
2,680✔
1310
                        {
1311
                                case 2:
1312
                                        tmp.ShapeFileName = this._reader.ValueAsString;
280✔
1313
                                        return true;
280✔
1314
                                default:
1315
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
2,400✔
1316
                        }
1317
                }
2,680✔
1318

1319
                private bool readWipeoutBase(CadEntityTemplate template, DxfMap map, string subclass = null)
1320
                {
14,160✔
1321
                        CadWipeoutBaseTemplate tmp = template as CadWipeoutBaseTemplate;
14,160✔
1322
                        CadWipeoutBase wipeout = tmp.CadObject as CadWipeoutBase;
14,160✔
1323

1324
                        switch (this._reader.Code)
14,160✔
1325
                        {
1326
                                case 91:
1327
                                        var nvertices = this._reader.ValueAsInt;
480✔
1328
                                        for (int i = 0; i < nvertices; i++)
4,320✔
1329
                                        {
1,680✔
1330
                                                this._reader.ReadNext();
1,680✔
1331
                                                var x = this._reader.ValueAsDouble;
1,680✔
1332
                                                this._reader.ReadNext();
1,680✔
1333
                                                var y = this._reader.ValueAsDouble;
1,680✔
1334

1335
                                                wipeout.ClipBoundaryVertices.Add(new XY(x, y));
1,680✔
1336
                                        }
1,680✔
1337

1338
                                        this._reader.ReadNext();
480✔
1339

1340
                                        return this.checkEntityEnd(template, map, subclass, this.readWipeoutBase);
480✔
1341
                                case 340:
1342
                                        tmp.ImgDefHandle = this._reader.ValueAsHandle;
480✔
1343
                                        return true;
480✔
1344
                                case 360:
1345
                                        tmp.ImgReactorHandle = this._reader.ValueAsHandle;
480✔
1346
                                        return true;
480✔
1347
                                default:
1348
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
12,720✔
1349
                        }
1350
                }
14,160✔
1351

1352
                private bool readOle2Frame(CadEntityTemplate template, DxfMap map, string subclass = null)
NEW
1353
                {
×
NEW
1354
                        CadOle2FrameTemplate tmp = template as CadOle2FrameTemplate;
×
1355

NEW
1356
                        switch (this._reader.Code)
×
1357
                        {
1358
                                //End of data
1359
                                case 1:
1360
                                //Length of binary data
1361
                                case 90:
1362
                                //Undocumented
1363
                                case 73:
NEW
1364
                                        return true;
×
1365
                                case 310:
NEW
1366
                                        tmp.Chunks.Add(this._reader.ValueAsBinaryChunk);
×
NEW
1367
                                        return true;
×
1368
                                default:
NEW
1369
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1370
                        }
NEW
1371
                }
×
1372

1373
                private bool readModelerGeometry(CadEntityTemplate template, DxfMap map, string subclass = null)
1374
                {
342,410✔
1375
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
342,410✔
1376
                        var geometry = template.CadObject as ModelerGeometry;
342,410✔
1377

1378
                        switch (this._reader.Code)
342,410✔
1379
                        {
1380
                                case 2:
1381
                                        geometry.Guid = new Guid(this._reader.ValueAsString);
240✔
1382
                                        return true;
240✔
1383
                                case 290:
1384
                                        return true;
240✔
1385
                                default:
1386
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
341,930✔
1387
                        }
1388
                }
342,410✔
1389

1390
                private bool readSolid3d(CadEntityTemplate template, DxfMap map, string subclass = null)
1391
                {
41,040✔
1392
                        CadSolid3DTemplate tmp = template as CadSolid3DTemplate;
41,040✔
1393

1394
                        switch (this._reader.Code)
41,040✔
1395
                        {
1396
                                case 350:
1397
                                        tmp.HistoryHandle = this._reader.ValueAsHandle;
320✔
1398
                                        return true;
320✔
1399
                                default:
1400
                                        return this.readModelerGeometry(template, map, DxfSubclassMarker.ModelerGeometry);
40,720✔
1401
                        }
1402
                }
41,040✔
1403

1404
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1405
                {
16,800✔
1406
                        CadSplineTemplate tmp = template as CadSplineTemplate;
16,800✔
1407

1408
                        XYZ controlPoint;
1409
                        XYZ fitPoint;
1410

1411
                        switch (this._reader.Code)
16,800!
1412
                        {
1413
                                case 10:
1414
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
1,920✔
1415
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
1,920✔
1416
                                        return true;
1,920✔
1417
                                case 20:
1418
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1419
                                        controlPoint.Y = this._reader.ValueAsDouble;
1,920✔
1420
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1421
                                        return true;
1,920✔
1422
                                case 30:
1423
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
1,920✔
1424
                                        controlPoint.Z = this._reader.ValueAsDouble;
1,920✔
1425
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
1,920✔
1426
                                        return true;
1,920✔
1427
                                case 11:
1428
                                        fitPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1429
                                        tmp.CadObject.FitPoints.Add(fitPoint);
×
1430
                                        return true;
×
1431
                                case 21:
1432
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1433
                                        fitPoint.Y = this._reader.ValueAsDouble;
×
1434
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1435
                                        return true;
×
1436
                                case 31:
1437
                                        fitPoint = tmp.CadObject.FitPoints.LastOrDefault();
×
1438
                                        fitPoint.Z = this._reader.ValueAsDouble;
×
1439
                                        tmp.CadObject.FitPoints[tmp.CadObject.FitPoints.Count - 1] = fitPoint;
×
1440
                                        return true;
×
1441
                                case 40:
1442
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
3,840✔
1443
                                        return true;
3,840✔
1444
                                case 41:
1445
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1446
                                        return true;
×
1447
                                case 72:
1448
                                case 73:
1449
                                case 74:
1450
                                        return true;
1,440✔
1451
                                default:
1452
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
5,760✔
1453
                        }
1454
                }
16,800✔
1455

1456
                private bool readUnderlayEntity<T>(CadEntityTemplate template, DxfMap map, string subclass = null)
1457
                        where T : PdfUnderlayDefinition
1458
                {
3,800✔
1459
                        CadUnderlayTemplate<T> tmp = template as CadUnderlayTemplate<T>;
3,800✔
1460

1461
                        switch (this._reader.Code)
3,800✔
1462
                        {
1463
                                case 340:
1464
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
240✔
1465
                                        return true;
240✔
1466
                                default:
1467
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,560✔
1468
                        }
1469
                }
3,800✔
1470

1471
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1472
                {
280,766✔
1473
                        CadVertexTemplate tmp = template as CadVertexTemplate;
280,766✔
1474

1475
                        switch (this._reader.Code)
280,766✔
1476
                        {
1477
                                //Polyface mesh vertex index
1478
                                case 71:
1479
                                case 72:
1480
                                case 73:
1481
                                case 74:
1482
                                        return true;
1,960✔
1483
                                case 100:
1484
                                        switch (this._reader.ValueAsString)
8,160!
1485
                                        {
1486
                                                case DxfSubclassMarker.Vertex:
1487
                                                        return true;
2,400✔
1488
                                                case DxfSubclassMarker.PolylineVertex:
1489
                                                        tmp.SetVertexObject(new Vertex2D());
×
1490
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1491
                                                        return true;
×
1492
                                                case DxfSubclassMarker.Polyline3dVertex:
1493
                                                        tmp.SetVertexObject(new Vertex3D());
1,200✔
1494
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
1,200✔
1495
                                                        return true;
1,200✔
1496
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1497
                                                        tmp.SetVertexObject(new VertexFaceMesh());
1,200✔
1498
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
1,200✔
1499
                                                        return true;
1,200✔
1500
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1501
                                                        tmp.SetVertexObject(new VertexFaceRecord());
480✔
1502
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
480✔
1503
                                                        return true;
480✔
1504
                                                default:
1505
                                                        return false;
2,880✔
1506
                                        }
1507
                                default:
1508
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
270,646✔
1509
                        }
1510
                }
280,766✔
1511

1512
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1513
                {
80,456✔
1514
                        CadViewportTemplate tmp = template as CadViewportTemplate;
80,456✔
1515

1516
                        switch (this._reader.Code)
80,456!
1517
                        {
1518
                                //Undocumented
1519
                                case 67:
1520
                                case 68:
1521
                                        return true;
2,944✔
1522
                                case 69:
1523
                                        tmp.ViewportId = this._reader.ValueAsShort;
1,472✔
1524
                                        return true;
1,472✔
1525
                                case 331:
1526
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1527
                                        return true;
×
1528
                                case 348:
1529
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
928✔
1530
                                        return true;
928✔
1531
                                default:
1532
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
75,112✔
1533
                        }
1534
                }
80,456✔
1535

1536
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1537
                {
961,240✔
1538
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
961,240✔
1539

1540
                        switch (this._reader.Code)
961,240✔
1541
                        {
1542
                                default:
1543
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
961,240✔
1544
                        }
1545
                }
961,240✔
1546

1547
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1548
                {
42,721✔
1549
                        List<ExtendedDataRecord> records = new();
42,721✔
1550
                        edata.Add(this._reader.ValueAsString, records);
42,721✔
1551

1552
                        this._reader.ReadNext();
42,721✔
1553

1554
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
328,498✔
1555
                        {
298,543✔
1556
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
298,543✔
1557
                                {
12,766✔
1558
                                        this.readExtendedData(edata);
12,766✔
1559
                                        break;
12,766✔
1560
                                }
1561

1562
                                ExtendedDataRecord record = null;
285,777✔
1563
                                double x = 0;
285,777✔
1564
                                double y = 0;
285,777✔
1565
                                double z = 0;
285,777✔
1566

1567
                                switch (this._reader.DxfCode)
285,777✔
1568
                                {
1569
                                        case DxfCode.ExtendedDataAsciiString:
1570
                                        case DxfCode.ExtendedDataRegAppName:
1571
                                                record = new ExtendedDataString(this._reader.ValueAsString);
30,268✔
1572
                                                break;
30,268✔
1573
                                        case DxfCode.ExtendedDataControlString:
1574
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
15,848✔
1575
                                                break;
15,848✔
1576
                                        case DxfCode.ExtendedDataLayerName:
1577
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
280✔
1578
                                                {
266✔
1579
                                                        record = new ExtendedDataLayer(layer.Handle);
266✔
1580
                                                }
266✔
1581
                                                else
1582
                                                {
14✔
1583
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
14✔
1584
                                                }
14✔
1585
                                                break;
280✔
1586
                                        case DxfCode.ExtendedDataBinaryChunk:
1587
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
80✔
1588
                                                break;
80✔
1589
                                        case DxfCode.ExtendedDataHandle:
1590
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
2,958✔
1591
                                                break;
2,958✔
1592
                                        case DxfCode.ExtendedDataXCoordinate:
1593
                                                x = this._reader.ValueAsDouble;
2,984✔
1594
                                                this._reader.ReadNext();
2,984✔
1595
                                                y = this._reader.ValueAsDouble;
2,984✔
1596
                                                this._reader.ReadNext();
2,984✔
1597
                                                z = this._reader.ValueAsDouble;
2,984✔
1598

1599
                                                record = new ExtendedDataCoordinate(
2,984✔
1600
                                                        new XYZ(
2,984✔
1601
                                                                x,
2,984✔
1602
                                                                y,
2,984✔
1603
                                                                z)
2,984✔
1604
                                                        );
2,984✔
1605
                                                break;
2,984✔
1606
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1607
                                                x = this._reader.ValueAsDouble;
1,440✔
1608
                                                this._reader.ReadNext();
1,440✔
1609
                                                y = this._reader.ValueAsDouble;
1,440✔
1610
                                                this._reader.ReadNext();
1,440✔
1611
                                                z = this._reader.ValueAsDouble;
1,440✔
1612

1613
                                                record = new ExtendedDataWorldCoordinate(
1,440✔
1614
                                                        new XYZ(
1,440✔
1615
                                                                x,
1,440✔
1616
                                                                y,
1,440✔
1617
                                                                z)
1,440✔
1618
                                                        );
1,440✔
1619
                                                break;
1,440✔
1620
                                        case DxfCode.ExtendedDataWorldXDisp:
1621
                                                x = this._reader.ValueAsDouble;
280✔
1622
                                                this._reader.ReadNext();
280✔
1623
                                                y = this._reader.ValueAsDouble;
280✔
1624
                                                this._reader.ReadNext();
280✔
1625
                                                z = this._reader.ValueAsDouble;
280✔
1626

1627
                                                record = new ExtendedDataDisplacement(
280✔
1628
                                                        new XYZ(
280✔
1629
                                                                x,
280✔
1630
                                                                y,
280✔
1631
                                                                z)
280✔
1632
                                                        );
280✔
1633
                                                break;
280✔
1634
                                        case DxfCode.ExtendedDataWorldXDir:
1635
                                                x = this._reader.ValueAsDouble;
280✔
1636
                                                this._reader.ReadNext();
280✔
1637
                                                y = this._reader.ValueAsDouble;
280✔
1638
                                                this._reader.ReadNext();
280✔
1639
                                                z = this._reader.ValueAsDouble;
280✔
1640

1641
                                                record = new ExtendedDataDirection(
280✔
1642
                                                        new XYZ(
280✔
1643
                                                                x,
280✔
1644
                                                                y,
280✔
1645
                                                                z)
280✔
1646
                                                        );
280✔
1647
                                                break;
280✔
1648
                                        case DxfCode.ExtendedDataReal:
1649
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
140,536✔
1650
                                                break;
140,536✔
1651
                                        case DxfCode.ExtendedDataDist:
1652
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
280✔
1653
                                                break;
280✔
1654
                                        case DxfCode.ExtendedDataScale:
1655
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
280✔
1656
                                                break;
280✔
1657
                                        case DxfCode.ExtendedDataInteger16:
1658
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
78,517✔
1659
                                                break;
78,517✔
1660
                                        case DxfCode.ExtendedDataInteger32:
1661
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
9,186✔
1662
                                                break;
9,186✔
1663
                                        default:
1664
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
2,560✔
1665
                                                break;
2,560✔
1666
                                }
1667

1668
                                if (record != null)
285,777✔
1669
                                {
283,203✔
1670
                                        records.Add(record);
283,203✔
1671
                                }
283,203✔
1672

1673
                                this._reader.ReadNext();
285,777✔
1674
                        }
285,777✔
1675
                }
42,721✔
1676

1677
                private void readPattern(HatchPattern pattern, int nlines)
1678
                {
1,440✔
1679
                        //Jump 78 code
1680
                        this._reader.ReadNext();
1,440✔
1681

1682
                        for (int i = 0; i < nlines; i++)
218,400✔
1683
                        {
107,760✔
1684
                                HatchPattern.Line line = new HatchPattern.Line();
107,760✔
1685
                                XY basePoint = new XY();
107,760✔
1686
                                XY offset = new XY();
107,760✔
1687

1688
                                bool end = false;
107,760✔
1689
                                HashSet<int> codes = new();
107,760✔
1690

1691
                                while (!end)
755,760✔
1692
                                {
754,320✔
1693
                                        if (codes.Contains(this._reader.Code))
754,320✔
1694
                                        {
106,320✔
1695
                                                break;
106,320✔
1696
                                        }
1697
                                        else
1698
                                        {
648,000✔
1699
                                                codes.Add(this._reader.Code);
648,000✔
1700
                                        }
648,000✔
1701

1702
                                        switch (this._reader.Code)
648,000!
1703
                                        {
1704
                                                case 53:
1705
                                                        line.Angle = this._reader.ValueAsAngle;
107,760✔
1706
                                                        break;
107,760✔
1707
                                                case 43:
1708
                                                        basePoint.X = this._reader.ValueAsDouble;
107,760✔
1709
                                                        break;
107,760✔
1710
                                                case 44:
1711
                                                        basePoint.Y = this._reader.ValueAsDouble;
107,760✔
1712
                                                        line.BasePoint = basePoint;
107,760✔
1713
                                                        break;
107,760✔
1714
                                                case 45:
1715
                                                        offset.X = this._reader.ValueAsDouble;
107,760✔
1716
                                                        line.Offset = offset;
107,760✔
1717
                                                        break;
107,760✔
1718
                                                case 46:
1719
                                                        offset.Y = this._reader.ValueAsDouble;
107,760✔
1720
                                                        line.Offset = offset;
107,760✔
1721
                                                        break;
107,760✔
1722
                                                //Number of dash length items
1723
                                                case 79:
1724
                                                        int ndash = this._reader.ValueAsInt;
107,760✔
1725
                                                        for (int j = 0; j < ndash; j++)
645,600✔
1726
                                                        {
215,040✔
1727
                                                                this._reader.ReadNext();
215,040✔
1728
                                                                line.DashLengths.Add(this._reader.ValueAsDouble);
215,040✔
1729
                                                        }
215,040✔
1730
                                                        break;
107,760✔
1731
                                                case 49:
1732
                                                        line.DashLengths.Add(this._reader.ValueAsDouble);
×
1733
                                                        break;
×
1734
                                                default:
1735
                                                        end = true;
1,440✔
1736
                                                        break;
1,440✔
1737
                                        }
1738
                                        this._reader.ReadNext();
648,000✔
1739
                                }
648,000✔
1740

1741
                                pattern.Lines.Add(line);
107,760✔
1742
                        }
107,760✔
1743
                }
1,440✔
1744

1745
                private void readLoops(CadHatchTemplate template, int count)
1746
                {
1,920✔
1747
                        if (this._reader.Code == 91)
1,920✔
1748
                                this._reader.ReadNext();
1,920✔
1749

1750
                        for (int i = 0; i < count; i++)
7,680✔
1751
                        {
1,920✔
1752
                                if (this._reader.Code != 92)
1,920!
1753
                                {
×
1754
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1755
                                        break;
×
1756
                                }
1757

1758
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
1,920✔
1759
                                if (path != null)
1,920✔
1760
                                        template.PathTemplates.Add(path);
1,920✔
1761
                        }
1,920✔
1762
                }
1,920✔
1763

1764
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1765
                {
1,920✔
1766
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
1,920✔
1767
                        var flags = (BoundaryPathFlags)this._reader.ValueAsInt;
1,920✔
1768
                        template.Path.Flags = flags;
1,920✔
1769

1770
                        if (flags.HasFlag(BoundaryPathFlags.Polyline))
1,920✔
1771
                        {
720✔
1772
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
720✔
1773
                                template.Path.Edges.Add(pl);
720✔
1774
                        }
720✔
1775
                        else
1776
                        {
1,200✔
1777
                                this._reader.ReadNext();
1,200✔
1778

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

1785
                                int edges = this._reader.ValueAsInt;
1,200✔
1786
                                this._reader.ReadNext();
1,200✔
1787

1788
                                for (int i = 0; i < edges; i++)
12,000✔
1789
                                {
4,800✔
1790
                                        var edge = this.readEdge();
4,800✔
1791
                                        if (edge != null)
4,800✔
1792
                                                template.Path.Edges.Add(edge);
4,800✔
1793
                                }
4,800✔
1794
                        }
1,200✔
1795

1796
                        bool end = false;
1,920✔
1797
                        while (!end)
7,440✔
1798
                        {
5,520✔
1799
                                switch (this._reader.Code)
5,520✔
1800
                                {
1801
                                        //Number of source boundary objects
1802
                                        case 97:
1803
                                                break;
1,920✔
1804
                                        case 330:
1805
                                                template.Handles.Add(this._reader.ValueAsHandle);
1,680✔
1806
                                                break;
1,680✔
1807
                                        default:
1808
                                                end = true;
1,920✔
1809
                                                continue;
1,920✔
1810
                                }
1811

1812
                                this._reader.ReadNext();
3,600✔
1813
                        }
3,600✔
1814

1815
                        return template;
1,920✔
1816
                }
1,920✔
1817

1818
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1819
                {
720✔
1820
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
720✔
1821

1822
                        this._reader.ReadNext();
720✔
1823

1824
                        if (this._reader.Code != 72)
720!
1825
                        {
×
1826
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1827
                                return null;
×
1828
                        }
1829

1830
                        //72
1831
                        bool hasBulge = this._reader.ValueAsBool;
720✔
1832
                        this._reader.ReadNext();
720✔
1833

1834
                        //73
1835
                        bool isClosed = this._reader.ValueAsBool;
720✔
1836
                        this._reader.ReadNext();
720✔
1837

1838
                        //93
1839
                        int nvertices = this._reader.ValueAsInt;
720✔
1840
                        this._reader.ReadNext();
720✔
1841

1842
                        for (int i = 0; i < nvertices; i++)
7,200✔
1843
                        {
2,880✔
1844
                                double bulge = 0.0;
2,880✔
1845

1846
                                //10
1847
                                double x = this._reader.ValueAsDouble;
2,880✔
1848
                                this._reader.ReadNext();
2,880✔
1849
                                //20
1850
                                double y = this._reader.ValueAsDouble;
2,880✔
1851
                                this._reader.ReadNext();
2,880✔
1852

1853
                                if (hasBulge)
2,880!
1854
                                {
×
1855
                                        //42
1856
                                        bulge = this._reader.ValueAsDouble;
×
1857
                                        this._reader.ReadNext();
×
1858
                                }
×
1859

1860
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
2,880✔
1861
                        }
2,880✔
1862

1863
                        return boundary;
720✔
1864
                }
720✔
1865

1866
                private Hatch.BoundaryPath.Edge readEdge()
1867
                {
4,800✔
1868
                        if (this._reader.Code != 72)
4,800!
1869
                        {
×
1870
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1871
                                return null;
×
1872
                        }
1873

1874
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
4,800✔
1875
                        this._reader.ReadNext();
4,800✔
1876

1877
                        switch (type)
4,800!
1878
                        {
1879
                                case Hatch.BoundaryPath.EdgeType.Line:
1880
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
4,800✔
1881
                                        while (true)
24,000✔
1882
                                        {
24,000✔
1883
                                                switch (this._reader.Code)
24,000✔
1884
                                                {
1885
                                                        case 10:
1886
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
4,800✔
1887
                                                                break;
4,800✔
1888
                                                        case 20:
1889
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
4,800✔
1890
                                                                break;
4,800✔
1891
                                                        case 11:
1892
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
4,800✔
1893
                                                                break;
4,800✔
1894
                                                        case 21:
1895
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
4,800✔
1896
                                                                break;
4,800✔
1897
                                                        default:
1898
                                                                return line;
4,800✔
1899
                                                }
1900

1901
                                                this._reader.ReadNext();
19,200✔
1902
                                        }
19,200✔
1903
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1904
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1905
                                        while (true)
×
1906
                                        {
×
1907
                                                switch (this._reader.Code)
×
1908
                                                {
1909
                                                        case 10:
1910
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1911
                                                                break;
×
1912
                                                        case 20:
1913
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1914
                                                                break;
×
1915
                                                        case 40:
1916
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1917
                                                                break;
×
1918
                                                        case 50:
1919
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1920
                                                                break;
×
1921
                                                        case 51:
1922
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1923
                                                                break;
×
1924
                                                        case 73:
1925
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1926
                                                                break;
×
1927
                                                        default:
1928
                                                                return arc;
×
1929
                                                }
1930

1931
                                                this._reader.ReadNext();
×
1932
                                        }
×
1933
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1934
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1935
                                        while (true)
×
1936
                                        {
×
1937
                                                switch (this._reader.Code)
×
1938
                                                {
1939
                                                        case 10:
1940
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1941
                                                                break;
×
1942
                                                        case 20:
1943
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1944
                                                                break;
×
1945
                                                        case 11:
1946
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1947
                                                                break;
×
1948
                                                        case 21:
1949
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1950
                                                                break;
×
1951
                                                        case 40:
1952
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1953
                                                                break;
×
1954
                                                        case 50:
1955
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1956
                                                                break;
×
1957
                                                        case 51:
1958
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1959
                                                                break;
×
1960
                                                        case 73:
1961
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1962
                                                                break;
×
1963
                                                        default:
1964
                                                                return ellipse;
×
1965
                                                }
1966

1967
                                                this._reader.ReadNext();
×
1968
                                        }
×
1969
                                case Hatch.BoundaryPath.EdgeType.Spline:
1970
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1971
                                        int nKnots = 0;
×
1972
                                        int nCtrlPoints = 0;
×
1973
                                        int nFitPoints = 0;
×
1974

1975
                                        XYZ controlPoint = new XYZ();
×
1976
                                        XY fitPoint = new XY();
×
1977

1978
                                        while (true)
×
1979
                                        {
×
1980
                                                switch (this._reader.Code)
×
1981
                                                {
1982
                                                        case 10:
1983
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1984
                                                                break;
×
1985
                                                        case 20:
1986
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1987
                                                                spline.ControlPoints.Add(controlPoint);
×
1988
                                                                break;
×
1989
                                                        case 11:
1990
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1991
                                                                break;
×
1992
                                                        case 21:
1993
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1994
                                                                spline.FitPoints.Add(fitPoint);
×
1995
                                                                break;
×
1996
                                                        case 42:
1997
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1998
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1999
                                                                break;
×
2000
                                                        case 12:
2001
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
2002
                                                                break;
×
2003
                                                        case 22:
2004
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
2005
                                                                break;
×
2006
                                                        case 13:
2007
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
2008
                                                                break;
×
2009
                                                        case 23:
2010
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
2011
                                                                break;
×
2012
                                                        case 94:
2013
                                                                spline.Degree = this._reader.ValueAsInt;
×
2014
                                                                break;
×
2015
                                                        case 73:
2016
                                                                spline.Rational = this._reader.ValueAsBool;
×
2017
                                                                break;
×
2018
                                                        case 74:
2019
                                                                spline.Periodic = this._reader.ValueAsBool;
×
2020
                                                                break;
×
2021
                                                        case 95:
2022
                                                                nKnots = this._reader.ValueAsInt;
×
2023
                                                                break;
×
2024
                                                        case 96:
2025
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
2026
                                                                break;
×
2027
                                                        case 97:
2028
                                                                nFitPoints = this._reader.ValueAsInt;
×
2029
                                                                break;
×
2030
                                                        case 40:
2031
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
2032
                                                                break;
×
2033
                                                        default:
2034
                                                                return spline;
×
2035
                                                }
2036

2037
                                                this._reader.ReadNext();
×
2038
                                        }
×
2039
                        }
2040

2041
                        return null;
×
2042
                }
4,800✔
2043

2044
                private void readDefinedGroups(CadTemplate template)
2045
                {
67,764✔
2046
                        this.readDefinedGroups(out ulong? xdict, out HashSet<ulong> reactorsHandles);
67,764✔
2047

2048
                        template.XDictHandle = xdict;
67,764✔
2049
                        template.ReactorsHandles.UnionWith(reactorsHandles);
67,764✔
2050
                }
67,764✔
2051

2052
                private void readDefinedGroups(out ulong? xdictHandle, out HashSet<ulong> reactors)
2053
                {
68,006✔
2054
                        xdictHandle = null;
68,006✔
2055
                        reactors = new HashSet<ulong>();
68,006✔
2056

2057
                        switch (this._reader.ValueAsString)
68,006✔
2058
                        {
2059
                                case DxfFileToken.DictionaryToken:
2060
                                        this._reader.ReadNext();
12,845✔
2061
                                        xdictHandle = this._reader.ValueAsHandle;
12,845✔
2062
                                        this._reader.ReadNext();
12,845✔
2063
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
12,845✔
2064
                                        return;
12,845✔
2065
                                case DxfFileToken.ReactorsToken:
2066
                                        reactors = this.readReactors();
52,761✔
2067
                                        break;
52,761✔
2068
                                case DxfFileToken.BlkRefToken:
2069
                                default:
2070
                                        do
2071
                                        {
6,240✔
2072
                                                this._reader.ReadNext();
6,240✔
2073
                                        }
6,240✔
2074
                                        while (this._reader.DxfCode != DxfCode.ControlString);
6,240✔
2075
                                        return;
2,400✔
2076
                        }
2077
                }
68,006✔
2078

2079
                private HashSet<ulong> readReactors()
2080
                {
52,761✔
2081
                        HashSet<ulong> reactors = new();
52,761✔
2082

2083
                        this._reader.ReadNext();
52,761✔
2084

2085
                        while (this._reader.DxfCode != DxfCode.ControlString)
112,806✔
2086
                        {
60,045✔
2087
                                this._reader.ReadNext();
60,045✔
2088
                        }
60,045✔
2089

2090
                        return reactors;
52,761✔
2091
                }
52,761✔
2092

2093
                protected bool tryAssignCurrentValue(object cadObject, DxfClassMap map)
2094
                {
5,210,956✔
2095
                        try
2096
                        {
5,210,956✔
2097
                                //Use this method only if the value is not a link between objects
2098
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
5,210,956✔
2099
                                {
2,785,767✔
2100
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
2,785,767✔
2101
                                        {
14,790✔
2102
                                                return true;
14,790✔
2103
                                        }
2104

2105
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
2,770,977✔
2106
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
2,770,977✔
2107
                                        {
17,370✔
2108
                                                return false;
17,370✔
2109
                                        }
2110

2111
                                        object value = this._reader.Value;
2,753,607✔
2112

2113
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
2,753,607✔
2114
                                        {
29,312✔
2115
                                                value = MathHelper.DegToRad((double)value);
29,312✔
2116
                                        }
29,312✔
2117

2118
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
2,753,607✔
2119

2120
                                        return true;
2,753,607✔
2121
                                }
2122
                        }
2,425,189✔
2123
                        catch (Exception ex)
×
2124
                        {
×
2125
                                if (!this._builder.Configuration.Failsafe)
×
2126
                                {
×
2127
                                        throw ex;
×
2128
                                }
2129
                                else
2130
                                {
×
2131
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
2132
                                }
×
2133
                        }
×
2134

2135
                        return false;
2,425,189✔
2136
                }
5,210,956✔
2137
        }
2138
}
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