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

DomCR / ACadSharp / 19855047891

02 Dec 2025 10:16AM UTC coverage: 78.014% (+0.1%) from 77.892%
19855047891

push

github

web-flow
Merge pull request #581 from DomCR/issue-574_implement-material

Implement Material

7581 of 10537 branches covered (71.95%)

Branch coverage included in aggregate %.

310 of 353 new or added lines in 9 files covered. (87.82%)

10 existing lines in 2 files now uncovered.

28119 of 35224 relevant lines covered (79.83%)

162438.97 hits per line

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

84.07
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.Classes;
2
using ACadSharp.Entities;
3
using ACadSharp.IO.Templates;
4
using ACadSharp.Objects;
5
using ACadSharp.Objects.Evaluations;
6
using CSMath;
7
using System;
8
using System.Collections.Generic;
9
using System.Diagnostics;
10
using System.IO;
11
using System.Linq;
12
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
13
using static ACadSharp.IO.Templates.CadTableEntityTemplate;
14

15
namespace ACadSharp.IO.DXF
16
{
17
        internal class DxfObjectsSectionReader : DxfSectionReaderBase
18
        {
19
                public delegate bool ReadObjectDelegate<T>(CadTemplate template, DxfMap map) where T : CadObject;
20

21
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
22
                        : base(reader, builder)
242✔
23
                {
242✔
24
                }
242✔
25

26
                public override void Read()
27
                {
242✔
28
                        //Advance to the first value in the section
29
                        this._reader.ReadNext();
242✔
30

31
                        //Loop until the section ends
32
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
91,456✔
33
                        {
91,214✔
34
                                CadTemplate template = null;
91,214✔
35

36
                                try
37
                                {
91,214✔
38
                                        template = this.readObject();
91,214✔
39
                                }
91,214✔
40
                                catch (Exception ex)
×
41
                                {
×
42
                                        if (!this._builder.Configuration.Failsafe)
×
43
                                                throw;
×
44

45
                                        this._builder.Notify($"Error while reading an object at line {this._reader.Position}", NotificationType.Error, ex);
×
46

47
                                        while (this._reader.DxfCode != DxfCode.Start)
×
48
                                                this._reader.ReadNext();
×
49
                                }
×
50

51
                                if (template == null)
91,214✔
52
                                        continue;
×
53

54
                                //Add the object and the template to the builder
55
                                this._builder.AddTemplate(template);
91,214✔
56
                        }
91,214✔
57
                }
242✔
58

59
                private CadTemplate readObject()
60
                {
91,214✔
61
                        switch (this._reader.ValueAsString)
91,214!
62
                        {
63
                                case DxfFileToken.ObjectPlaceholder:
64
                                        return this.readObjectCodes<AcdbPlaceHolder>(new CadNonGraphicalObjectTemplate(new AcdbPlaceHolder()), this.readObjectSubclassMap);
230✔
65
                                case DxfFileToken.ObjectDBColor:
66
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
228✔
67
                                case DxfFileToken.ObjectDictionary:
68
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
25,124✔
69
                                case DxfFileToken.ObjectDictionaryWithDefault:
70
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
230✔
71
                                case DxfFileToken.ObjectLayout:
72
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
942✔
73
                                case DxfFileToken.ObjectPlotSettings:
74
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
75
                                case DxfFileToken.ObjectEvalGraph:
76
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
532✔
77
                                case DxfFileToken.ObjectImageDefinition:
78
                                        return this.readObjectCodes<ImageDefinition>(new CadNonGraphicalObjectTemplate(new ImageDefinition()), this.readObjectSubclassMap);
228✔
79
                                case DxfFileToken.ObjectDictionaryVar:
80
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
3,282✔
81
                                case DxfFileToken.ObjectPdfDefinition:
82
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
228✔
83
                                case DxfFileToken.ObjectSortEntsTable:
84
                                        return this.readSortentsTable();
684✔
85
                                case DxfFileToken.ObjectImageDefinitionReactor:
86
                                        return this.readObjectCodes<ImageDefinitionReactor>(new CadNonGraphicalObjectTemplate(new ImageDefinitionReactor()), this.readObjectSubclassMap);
228✔
87
                                case DxfFileToken.ObjectProxyObject:
88
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
89
                                case DxfFileToken.ObjectRasterVariables:
90
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
228✔
91
                                case DxfFileToken.ObjectGroup:
92
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
456✔
93
                                case DxfFileToken.ObjectGeoData:
94
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
95
                                case DxfFileToken.ObjectMaterial:
96
                                        return this.readObjectCodes<Material>(new CadMaterialTemplate(), this.readMaterial);
2,514✔
97
                                case DxfFileToken.ObjectScale:
98
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,794✔
99
                                case DxfFileToken.ObjectTableContent:
100
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
380✔
101
                                case DxfFileToken.ObjectVisualStyle:
102
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,520✔
103
                                case DxfFileToken.ObjectSpatialFilter:
104
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
228✔
105
                                case DxfFileToken.ObjectMLineStyle:
106
                                        return this.readObjectCodes<MLineStyle>(new CadMLineStyleTemplate(), this.readMLineStyle);
242✔
107
                                case DxfFileToken.ObjectMLeaderStyle:
108
                                        return this.readObjectCodes<MultiLeaderStyle>(new CadMLeaderStyleTemplate(), this.readMLeaderStyle);
472✔
109
                                case DxfFileToken.ObjectXRecord:
110
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
34,288✔
111
                                default:
112
                                        DxfMap map = DxfMap.Create<CadObject>();
7,154✔
113
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
7,154✔
114
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
7,154!
115
                                        {
7,154✔
116
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
7,154✔
117
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
7,154✔
118
                                        }
7,154✔
119
                                        else
120
                                        {
×
121
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
122
                                        }
×
123

124
                                        this._reader.ReadNext();
7,154✔
125

126
                                        do
127
                                        {
356,804✔
128
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
356,804!
129
                                                {
36,492✔
130
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
36,492✔
131
                                                        if (isExtendedData)
36,492✔
132
                                                                continue;
24✔
133
                                                }
36,468✔
134

135
                                                this._reader.ReadNext();
356,780✔
136
                                        }
356,780✔
137
                                        while (this._reader.DxfCode != DxfCode.Start);
356,804✔
138

139
                                        return unknownEntityTemplate;
7,154✔
140
                        }
141
                }
91,214✔
142

143
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
144
                        where T : CadObject
145
                {
83,376✔
146
                        this._reader.ReadNext();
83,376✔
147

148
                        DxfMap map = DxfMap.Create<T>();
83,376✔
149

150
                        while (this._reader.DxfCode != DxfCode.Start)
1,142,023✔
151
                        {
1,058,647✔
152
                                if (!readObject(template, map))
1,058,647✔
153
                                {
374,737✔
154
                                        this.readCommonCodes(template, out bool isExtendedData, map);
374,737✔
155
                                        if (isExtendedData)
374,737✔
156
                                                continue;
8,123✔
157
                                }
366,614✔
158

159
                                if (this.lockPointer)
1,050,524✔
160
                                {
1,368✔
161
                                        this.lockPointer = false;
1,368✔
162
                                        continue;
1,368✔
163
                                }
164

165
                                if (this._reader.DxfCode != DxfCode.Start)
1,049,156✔
166
                                {
1,014,336✔
167
                                        this._reader.ReadNext();
1,014,336✔
168
                                }
1,014,336✔
169
                        }
1,049,156✔
170

171
                        return template;
83,376✔
172
                }
83,376✔
173

174
                private bool readProxyObject(CadTemplate template, DxfMap map)
175
                {
×
176
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
177

178
                        switch (this._reader.Code)
×
179
                        {
180
                                case 90:
181
                                case 94:
182
                                //Undocumented
183
                                case 97:
184
                                case 71:
185
                                        return true;
×
186
                                case 95:
187
                                        int format = this._reader.ValueAsInt;
×
188
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
189
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
190
                                        return true;
×
191
                                case 91:
192
                                        var classId = this._reader.ValueAsShort;
×
193
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
194
                                        {
×
195
                                                proxy.DxfClass = dxfClass;
×
196
                                        }
×
197
                                        return true;
×
198
                                case 161:
199
                                        return true;
×
200
                                case 162:
201
                                        return true;
×
202
                                case 310:
203
                                        if (proxy.BinaryData == null)
×
204
                                        {
×
205
                                                proxy.BinaryData = new MemoryStream();
×
206
                                        }
×
207
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
208
                                        return true;
×
209
                                case 311:
210
                                        if (proxy.Data == null)
×
211
                                        {
×
212
                                                proxy.Data = new MemoryStream();
×
213
                                        }
×
214
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
215
                                        return true;
×
216
                                default:
217
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
218
                        }
219
                }
×
220

221
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
222
                {
27,438✔
223
                        switch (this._reader.Code)
27,438✔
224
                        {
225
                                default:
226
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
27,438✔
227
                        }
228
                }
27,438✔
229

230
                private bool readPlotSettings(CadTemplate template, DxfMap map)
231
                {
29,830✔
232
                        switch (this._reader.Code)
29,830✔
233
                        {
234
                                default:
235
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
29,830✔
236
                        }
237
                }
29,830✔
238

239
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
240
                {
3,648✔
241
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
3,648✔
242
                        EvaluationGraph evGraph = tmp.CadObject;
3,648✔
243

244
                        switch (this._reader.Code)
3,648✔
245
                        {
246
                                case 91:
247
                                        while (this._reader.Code == 91)
3,572✔
248
                                        {
3,040✔
249
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
3,040✔
250
                                                EvaluationGraph.Node node = nodeTemplate.Node;
3,040✔
251

252
                                                node.Index = this._reader.ValueAsInt;
3,040✔
253

254
                                                this._reader.ExpectedCode(93);
3,040✔
255
                                                node.Flags = this._reader.ValueAsInt;
3,040✔
256

257
                                                this._reader.ExpectedCode(95);
3,040✔
258
                                                node.NextNodeIndex = this._reader.ValueAsInt;
3,040✔
259

260
                                                this._reader.ExpectedCode(360);
3,040✔
261
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
3,040✔
262

263
                                                this._reader.ExpectedCode(92);
3,040✔
264
                                                node.Data1 = this._reader.ValueAsInt;
3,040✔
265
                                                this._reader.ExpectedCode(92);
3,040✔
266
                                                node.Data2 = this._reader.ValueAsInt;
3,040✔
267
                                                this._reader.ExpectedCode(92);
3,040✔
268
                                                node.Data3 = this._reader.ValueAsInt;
3,040✔
269
                                                this._reader.ExpectedCode(92);
3,040✔
270
                                                node.Data4 = this._reader.ValueAsInt;
3,040✔
271

272
                                                this._reader.ReadNext();
3,040✔
273

274
                                                tmp.NodeTemplates.Add(nodeTemplate);
3,040✔
275
                                        }
3,040✔
276

277
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
532✔
278
                                case 92:
279
                                        //Edges
280
                                        while (this._reader.Code == 92)
2,508✔
281
                                        {
2,280✔
282
                                                this._reader.ExpectedCode(93);
2,280✔
283
                                                this._reader.ExpectedCode(94);
2,280✔
284
                                                this._reader.ExpectedCode(91);
2,280✔
285
                                                this._reader.ExpectedCode(91);
2,280✔
286
                                                this._reader.ExpectedCode(92);
2,280✔
287
                                                this._reader.ExpectedCode(92);
2,280✔
288
                                                this._reader.ExpectedCode(92);
2,280✔
289
                                                this._reader.ExpectedCode(92);
2,280✔
290
                                                this._reader.ExpectedCode(92);
2,280✔
291

292
                                                this._reader.ReadNext();
2,280✔
293
                                        }
2,280✔
294

295
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
228✔
296
                                default:
297
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
2,888✔
298
                        }
299
                }
3,648✔
300

301
                private bool readLayout(CadTemplate template, DxfMap map)
302
                {
60,712✔
303
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
60,712✔
304

305
                        switch (this._reader.Code)
60,712✔
306
                        {
307
                                case 330:
308
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,884✔
309
                                        return true;
1,884✔
310
                                case 331:
311
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
914✔
312
                                        return true;
914✔
313
                                default:
314
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
57,914✔
315
                                        {
29,830✔
316
                                                return this.readPlotSettings(template, map);
29,830✔
317
                                        }
318
                                        return true;
28,084✔
319
                        }
320
                }
60,712✔
321

322
                private bool readGroup(CadTemplate template, DxfMap map)
323
                {
5,928✔
324
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,928✔
325

326
                        switch (this._reader.Code)
5,928✔
327
                        {
328
                                case 70:
329
                                        return true;
456✔
330
                                case 340:
331
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,736✔
332
                                        return true;
2,736✔
333
                                default:
334
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,736✔
335
                        }
336
                }
5,928✔
337

338
                private bool readGeoData(CadTemplate template, DxfMap map)
339
                {
102✔
340
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
341

342
                        switch (this._reader.Code)
102✔
343
                        {
344
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
345
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
346
                                                tmp.CadObject.ReferencePoint.X,
1✔
347
                                                this._reader.ValueAsDouble,
1✔
348
                                                tmp.CadObject.ReferencePoint.Z
1✔
349
                                                );
1✔
350
                                        return true;
1✔
351
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
352
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
353
                                                this._reader.ValueAsDouble,
1✔
354
                                                tmp.CadObject.ReferencePoint.Y,
1✔
355
                                                tmp.CadObject.ReferencePoint.Z
1✔
356
                                                );
1✔
357
                                        return true;
1✔
358
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
359
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
360
                                                tmp.CadObject.ReferencePoint.X,
1✔
361
                                                tmp.CadObject.ReferencePoint.Y,
1✔
362
                                                this._reader.ValueAsDouble
1✔
363
                                                );
1✔
364
                                        return true;
1✔
365
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
366
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
367
                                        return true;
1✔
368
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
369
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
370
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
371
                                        return true;
1✔
372
                                // Number of Geo-Mesh points
373
                                case 93:
374
                                        var npts = this._reader.ValueAsInt;
3✔
375
                                        for (int i = 0; i < npts; i++)
54✔
376
                                        {
24✔
377
                                                this._reader.ReadNext();
24✔
378
                                                double sourceX = this._reader.ValueAsDouble;
24✔
379
                                                this._reader.ReadNext();
24✔
380
                                                double sourceY = this._reader.ValueAsDouble;
24✔
381

382
                                                this._reader.ReadNext();
24✔
383
                                                double destX = this._reader.ValueAsDouble;
24✔
384
                                                this._reader.ReadNext();
24✔
385
                                                double destY = this._reader.ValueAsDouble;
24✔
386

387
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
388
                                                {
24✔
389
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
390
                                                        Destination = new CSMath.XY(destX, destY)
24✔
391
                                                });
24✔
392
                                        }
24✔
393
                                        return true;
3✔
394
                                // Number of Geo-Mesh points
395
                                case 96:
396
                                        var nfaces = this._reader.ValueAsInt;
2✔
397
                                        for (int i = 0; i < nfaces; i++)
4!
398
                                        {
×
399
                                                this._reader.ReadNext();
×
400
                                                Debug.Assert(this._reader.Code == 97);
×
401
                                                int index1 = this._reader.ValueAsInt;
×
402
                                                this._reader.ReadNext();
×
403
                                                Debug.Assert(this._reader.Code == 98);
×
404
                                                int index2 = this._reader.ValueAsInt;
×
405
                                                this._reader.ReadNext();
×
406
                                                Debug.Assert(this._reader.Code == 99);
×
407
                                                int index3 = this._reader.ValueAsInt;
×
408

409
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
410
                                                {
×
411
                                                        Index1 = index1,
×
412
                                                        Index2 = index2,
×
413
                                                        Index3 = index3
×
414
                                                });
×
415
                                        }
×
416
                                        return true;
2✔
417
                                case 303:
418
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
419
                                        return true;
13✔
420
                                //Obsolete codes for version GeoDataVersion.R2009
421
                                case 3:
422
                                case 4:
423
                                case 14:
424
                                case 24:
425
                                case 15:
426
                                case 25:
427
                                case 43:
428
                                case 44:
429
                                case 45:
430
                                case 94:
431
                                case 293:
432
                                case 16:
433
                                case 26:
434
                                case 17:
435
                                case 27:
436
                                case 54:
437
                                case 140:
438
                                case 304:
439
                                case 292:
440
                                        return true;
19✔
441
                                default:
442
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
443
                        }
444
                }
102✔
445

446
                private bool readMaterial(CadTemplate template, DxfMap map)
447
                {
49,908✔
448
                        CadMaterialTemplate tmp = template as CadMaterialTemplate;
49,908✔
449
                        List<double> arr = null;
49,908✔
450

451
                        switch (this._reader.Code)
49,908!
452
                        {
453
                                case 43:
454
                                        arr = new();
1,598✔
455
                                        for (int i = 0; i < 16; i++)
54,332✔
456
                                        {
25,568✔
457
                                                Debug.Assert(this._reader.Code == 43);
25,568✔
458

459
                                                arr.Add(this._reader.ValueAsDouble);
25,568✔
460

461
                                                this._reader.ReadNext();
25,568✔
462
                                        }
25,568✔
463

464
                                        tmp.CadObject.DiffuseMatrix = new CSMath.Matrix4(arr.ToArray());
1,598✔
465
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,598✔
466
                                case 47:
NEW
467
                                        arr = new();
×
NEW
468
                                        for (int i = 0; i < 16; i++)
×
NEW
469
                                        {
×
NEW
470
                                                Debug.Assert(this._reader.Code == 47);
×
471

NEW
472
                                                arr.Add(this._reader.ValueAsDouble);
×
473

NEW
474
                                                this._reader.ReadNext();
×
NEW
475
                                        }
×
476

NEW
477
                                        tmp.CadObject.SpecularMatrix = new CSMath.Matrix4(arr.ToArray());
×
NEW
478
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
479
                                case 49:
480
                                        arr = new();
230✔
481
                                        for (int i = 0; i < 16; i++)
7,820✔
482
                                        {
3,680✔
483
                                                Debug.Assert(this._reader.Code == 49);
3,680✔
484

485
                                                arr.Add(this._reader.ValueAsDouble);
3,680✔
486

487
                                                this._reader.ReadNext();
3,680✔
488
                                        }
3,680✔
489

490
                                        tmp.CadObject.ReflectionMatrix = new CSMath.Matrix4(arr.ToArray());
230✔
491
                                        return this.checkObjectEnd(template, map, this.readMaterial);
230✔
492
                                case 142:
493
                                        arr = new();
230✔
494
                                        for (int i = 0; i < 16; i++)
7,820✔
495
                                        {
3,680✔
496
                                                Debug.Assert(this._reader.Code == 142);
3,680✔
497

498
                                                arr.Add(this._reader.ValueAsDouble);
3,680✔
499

500
                                                this._reader.ReadNext();
3,680✔
501
                                        }
3,680✔
502

503
                                        tmp.CadObject.OpacityMatrix = new CSMath.Matrix4(arr.ToArray());
230✔
504
                                        return this.checkObjectEnd(template, map, this.readMaterial);
230✔
505
                                case 144:
506
                                        arr = new();
1,370✔
507
                                        for (int i = 0; i < 16; i++)
46,580✔
508
                                        {
21,920✔
509
                                                Debug.Assert(this._reader.Code == 144);
21,920✔
510

511
                                                arr.Add(this._reader.ValueAsDouble);
21,920✔
512

513
                                                this._reader.ReadNext();
21,920✔
514
                                        }
21,920✔
515

516
                                        tmp.CadObject.BumpMatrix = new CSMath.Matrix4(arr.ToArray());
1,370✔
517
                                        return this.checkObjectEnd(template, map, this.readMaterial);
1,370✔
518
                                case 147:
NEW
519
                                        arr = new();
×
NEW
520
                                        for (int i = 0; i < 16; i++)
×
NEW
521
                                        {
×
NEW
522
                                                Debug.Assert(this._reader.Code == 147);
×
523

NEW
524
                                                arr.Add(this._reader.ValueAsDouble);
×
525

NEW
526
                                                this._reader.ReadNext();
×
NEW
527
                                        }
×
528

NEW
529
                                        tmp.CadObject.RefractionMatrix = new CSMath.Matrix4(arr.ToArray());
×
NEW
530
                                        return this.checkObjectEnd(template, map, this.readMaterial);
×
531
                                default:
532
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
46,480✔
533
                        }
534
                }
49,908✔
535

536
                private bool readScale(CadTemplate template, DxfMap map)
537
                {
69,942✔
538
                        switch (this._reader.Code)
69,942✔
539
                        {
540
                                // Undocumented codes
541
                                case 70:
542
                                        //Always 0
543
                                        return true;
7,794✔
544
                                default:
545
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
62,148✔
546
                        }
547
                }
69,942✔
548

549
                private void readLinkedData(CadTemplate template, DxfMap map)
550
                {
380✔
551
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
380✔
552
                        LinkedData linkedData = tmp.CadObject;
380✔
553

554
                        this._reader.ReadNext();
380✔
555

556
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
1,140!
557
                        {
760✔
558
                                switch (this._reader.Code)
760✔
559
                                {
560
                                        default:
561
                                                if (!this.tryAssignCurrentValue(linkedData, map.SubClasses[DxfSubclassMarker.LinkedData]))
760!
562
                                                {
×
563
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedData)} {this._reader.Position}.", NotificationType.None);
×
564
                                                }
×
565
                                                break;
760✔
566
                                }
567

568
                                this._reader.ReadNext();
760✔
569
                        }
760✔
570
                }
380✔
571

572
                private bool readTableContent(CadTemplate template, DxfMap map)
573
                {
2,812✔
574
                        switch (this._reader.Code)
2,812✔
575
                        {
576
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.TableContent, StringComparison.InvariantCultureIgnoreCase):
1,444✔
577
                                        this.readTableContentSubclass(template, map);
304✔
578
                                        this.lockPointer = true;
304✔
579
                                        return true;
304✔
580
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.FormattedTableData, StringComparison.InvariantCultureIgnoreCase):
1,140✔
581
                                        this.readFormattedTableDataSubclass(template, map);
304✔
582
                                        this.lockPointer = true;
304✔
583
                                        return true;
304✔
584
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedTableData, StringComparison.InvariantCultureIgnoreCase):
836✔
585
                                        this.readLinkedTableDataSubclass(template, map);
380✔
586
                                        this.lockPointer = true;
380✔
587
                                        return true;
380✔
588
                                case 100 when this._reader.ValueAsString.Equals(DxfSubclassMarker.LinkedData, StringComparison.InvariantCultureIgnoreCase):
456✔
589
                                        this.readLinkedData(template, map);
380✔
590
                                        this.lockPointer = true;
380✔
591
                                        return true;
380✔
592
                                default:
593
                                        return false;
1,444✔
594
                        }
595
                }
2,812✔
596

597
                private void readTableContentSubclass(CadTemplate template, DxfMap map)
598
                {
304✔
599
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
304✔
600
                        TableContent tableContent = tmp.CadObject;
304✔
601

602
                        this._reader.ReadNext();
304✔
603

604
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
608✔
605
                        {
304✔
606
                                switch (this._reader.Code)
304!
607
                                {
608
                                        case 340:
609
                                                tmp.SytleHandle = this._reader.ValueAsHandle;
304✔
610
                                                break;
304✔
611
                                        default:
612
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.TableContent]))
×
613
                                                {
×
614
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableContentSubclass)} {this._reader.Position}.", NotificationType.None);
×
615
                                                }
×
616
                                                break;
×
617
                                }
618

619
                                this._reader.ReadNext();
304✔
620
                        }
304✔
621
                }
304✔
622

623
                private void readFormattedTableDataSubclass(CadTemplate template, DxfMap map)
624
                {
304✔
625
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
304✔
626
                        FormattedTableData formattedTable = tmp.CadObject;
304✔
627

628
                        this._reader.ReadNext();
304✔
629

630
                        TableEntity.CellRange cellRange = null;
304✔
631
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
2,736!
632
                        {
2,432✔
633
                                switch (this._reader.Code)
2,432!
634
                                {
635
                                        case 90:
636
                                                break;
304✔
637
                                        case 91:
638
                                                if (cellRange == null)
456✔
639
                                                {
456✔
640
                                                        cellRange = new();
456✔
641
                                                        formattedTable.MergedCellRanges.Add(cellRange);
456✔
642
                                                }
456✔
643
                                                cellRange.TopRowIndex = this._reader.ValueAsInt;
456✔
644
                                                break;
456✔
645
                                        case 92:
646
                                                if (cellRange == null)
456!
647
                                                {
×
648
                                                        cellRange = new();
×
649
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
650
                                                }
×
651
                                                cellRange.LeftColumnIndex = this._reader.ValueAsInt;
456✔
652
                                                break;
456✔
653
                                        case 93:
654
                                                if (cellRange == null)
456!
655
                                                {
×
656
                                                        cellRange = new();
×
657
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
658
                                                }
×
659
                                                cellRange.BottomRowIndex = this._reader.ValueAsInt;
456✔
660
                                                break;
456✔
661
                                        case 94:
662
                                                if (cellRange == null)
456!
663
                                                {
×
664
                                                        cellRange = new();
×
665
                                                        formattedTable.MergedCellRanges.Add(cellRange);
×
666
                                                }
×
667
                                                cellRange.RightColumnIndex = this._reader.ValueAsInt;
456✔
668
                                                cellRange = null;
456✔
669
                                                break;
456✔
670
                                        case 300 when this._reader.ValueAsString.Equals("TABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
304!
671
                                                this.readStyleOverride(new CadCellStyleTemplate(formattedTable.CellStyleOverride));
304✔
672
                                                break;
304✔
673
                                        default:
674
                                                if (!this.tryAssignCurrentValue(formattedTable, map.SubClasses[DxfSubclassMarker.FormattedTableData]))
×
675
                                                {
×
676
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
×
677
                                                }
×
678
                                                break;
×
679
                                }
680

681
                                this._reader.ReadNext();
2,432✔
682
                        }
2,432✔
683
                }
304✔
684

685
                private void readLinkedTableDataSubclass(CadTemplate template, DxfMap map)
686
                {
380✔
687
                        CadTableContentTemplate tmp = template as CadTableContentTemplate;
380✔
688
                        TableContent tableContent = tmp.CadObject;
380✔
689

690
                        this._reader.ReadNext();
380✔
691

692
                        while (this._reader.DxfCode != DxfCode.Start && this._reader.DxfCode != DxfCode.Subclass)
5,016!
693
                        {
4,636✔
694
                                switch (this._reader.Code)
4,636✔
695
                                {
696
                                        case 90:
697
                                                //Column count
698
                                                break;
380✔
699
                                        case 91:
700
                                                //Row count
701
                                                break;
380✔
702
                                        //Unknown
703
                                        case 92:
704
                                                break;
304✔
705
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumn, StringComparison.InvariantCultureIgnoreCase):
1,444✔
706
                                                //Read Column
707
                                                this.readTableColumn();
1,444✔
708
                                                break;
1,444✔
709
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRow, StringComparison.InvariantCultureIgnoreCase):
1,748✔
710
                                                //Read Row
711
                                                this.readTableRow();
1,748✔
712
                                                break;
1,748✔
713
                                        default:
714
                                                if (!this.tryAssignCurrentValue(tableContent, map.SubClasses[DxfSubclassMarker.LinkedTableData]))
380✔
715
                                                {
380✔
716
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableDataSubclass)} {this._reader.Position}.", NotificationType.None);
380✔
717
                                                }
380✔
718
                                                break;
380✔
719
                                }
720

721
                                this._reader.ReadNext();
4,636✔
722
                        }
4,636✔
723
                }
380✔
724

725

726
                private TableEntity.Column readTableColumn()
727
                {
1,444✔
728
                        this._reader.ReadNext();
1,444✔
729

730
                        TableEntity.Column column = new TableEntity.Column();
1,444✔
731

732
                        bool end = false;
1,444✔
733
                        while (this._reader.DxfCode != DxfCode.Start)
4,332!
734
                        {
4,332✔
735
                                switch (this._reader.Code)
4,332!
736
                                {
737
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
4,332✔
738
                                                this.readLinkedTableColumn(column);
1,444✔
739
                                                break;
1,444✔
740
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
2,888✔
741
                                                this.readFormattedTableColumn(column);
1,444✔
742
                                                break;
1,444✔
743
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableColumnBegin, StringComparison.InvariantCultureIgnoreCase):
1,444!
744
                                                this.readTableColumn(column);
1,444✔
745
                                                end = true;
1,444✔
746
                                                break;
1,444✔
747
                                        default:
748
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
749
                                                break;
×
750
                                }
751

752
                                if (end)
4,332✔
753
                                {
1,444✔
754
                                        return column;
1,444✔
755
                                }
756

757
                                this._reader.ReadNext();
2,888✔
758
                        }
2,888✔
759

760
                        return column;
×
761
                }
1,444✔
762

763
                private TableEntity.Row readTableRow()
764
                {
1,748✔
765
                        this._reader.ReadNext();
1,748✔
766

767
                        TableEntity.Row row = new TableEntity.Row();
1,748✔
768

769
                        bool end = false;
1,748✔
770
                        while (this._reader.DxfCode != DxfCode.Start)
14,136✔
771
                        {
14,060✔
772
                                switch (this._reader.Code)
14,060✔
773
                                {
774
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
7,144✔
775
                                                this.readLinkedTableRow(row);
1,824✔
776
                                                break;
1,824✔
777
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
5,320✔
778
                                                this.readFormattedTableRow(row);
1,672✔
779
                                                break;
1,672✔
780
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectTableRowBegin, StringComparison.InvariantCultureIgnoreCase):
3,648✔
781
                                                this.readTableRow(row);
1,672✔
782
                                                end = true;
1,672✔
783
                                                break;
1,672✔
784
                                        default:
785
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
8,892✔
786
                                                break;
8,892✔
787
                                }
788

789
                                if (end)
14,060✔
790
                                {
1,672✔
791
                                        return row;
1,672✔
792
                                }
793

794
                                this._reader.ReadNext();
12,388✔
795
                        }
12,388✔
796

797
                        return row;
76✔
798
                }
1,748✔
799

800
                private void readTableRow(TableEntity.Row row)
801
                {
1,672✔
802
                        this._reader.ReadNext();
1,672✔
803

804
                        bool end = false;
1,672✔
805
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
806
                        {
5,016✔
807
                                switch (this._reader.Code)
5,016!
808
                                {
809
                                        case 40:
810
                                                row.Height = this._reader.ValueAsDouble;
1,672✔
811
                                                break;
1,672✔
812
                                        case 90:
813
                                                //styleID
814
                                                break;
1,672✔
815
                                        case 309:
816
                                                end = this._reader.ValueAsString.Equals("TABLEROW_END", StringComparison.InvariantCultureIgnoreCase);
1,672✔
817
                                                break;
1,672✔
818
                                        default:
819
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableRow)} method.", NotificationType.None);
×
820
                                                break;
×
821
                                }
822

823
                                if (end)
5,016✔
824
                                {
1,672✔
825
                                        break;
1,672✔
826
                                }
827

828
                                this._reader.ReadNext();
3,344✔
829
                        }
3,344✔
830
                }
1,672✔
831

832
                private void readFormattedTableRow(TableEntity.Row row)
833
                {
1,672✔
834
                        this._reader.ReadNext();
1,672✔
835

836
                        bool end = false;
1,672✔
837
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
838
                        {
5,016✔
839
                                switch (this._reader.Code)
5,016!
840
                                {
841
                                        case 300 when this._reader.ValueAsString.Equals("ROWTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,672!
842
                                                break;
1,672✔
843
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,672!
844
                                                this.readStyleOverride(new CadCellStyleTemplate(row.CellStyleOverride));
1,672✔
845
                                                break;
1,672✔
846
                                        case 309:
847
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATAROW_END", StringComparison.InvariantCultureIgnoreCase);
1,672✔
848
                                                break;
1,672✔
849
                                        default:
850
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableRow)} method.", NotificationType.None);
×
851
                                                break;
×
852
                                }
853

854
                                if (end)
5,016✔
855
                                {
1,672✔
856
                                        break;
1,672✔
857
                                }
858

859
                                this._reader.ReadNext();
3,344✔
860
                        }
3,344✔
861
                }
1,672✔
862

863
                private void readTableColumn(TableEntity.Column column)
864
                {
1,444✔
865
                        this._reader.ReadNext();
1,444✔
866

867
                        bool end = false;
1,444✔
868
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
869
                        {
4,332✔
870
                                switch (this._reader.Code)
4,332!
871
                                {
872
                                        case 1 when this._reader.ValueAsString.Equals("TABLECOLUMN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
873
                                                break;
×
874
                                        case 1:
875
                                                end = true;
×
876
                                                break;
×
877
                                        case 40:
878
                                                column.Width = this._reader.ValueAsDouble;
1,444✔
879
                                                break;
1,444✔
880
                                        case 90:
881
                                                //StyleId
882
                                                break;
1,444✔
883
                                        case 309:
884
                                                end = this._reader.ValueAsString.Equals("TABLECOLUMN_END", StringComparison.InvariantCultureIgnoreCase);
1,444✔
885
                                                break;
1,444✔
886
                                        default:
887
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableColumn)} method.", NotificationType.None);
×
888
                                                break;
×
889
                                }
890

891
                                if (end)
4,332✔
892
                                {
1,444✔
893
                                        break;
1,444✔
894
                                }
895

896
                                this._reader.ReadNext();
2,888✔
897
                        }
2,888✔
898
                }
1,444✔
899

900
                private void readLinkedTableColumn(TableEntity.Column column)
901
                {
1,444✔
902
                        this._reader.ReadNext();
1,444✔
903

904
                        bool end = false;
1,444✔
905
                        while (this._reader.DxfCode != DxfCode.Start)
5,776✔
906
                        {
5,776✔
907
                                switch (this._reader.Code)
5,776!
908
                                {
909
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_BEGIN, StringComparison.InvariantCultureIgnoreCase):
×
910
                                                break;
×
911
                                        case 1:
912
                                                end = true;
×
913
                                                break;
×
914
                                        case 91:
915
                                                column.CustomData = this._reader.ValueAsInt;
1,444✔
916
                                                break;
1,444✔
917
                                        case 300:
918
                                                column.Name = this._reader.ValueAsString;
1,444✔
919
                                                break;
1,444✔
920
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,444!
921
                                                this.readCustomData();
1,444✔
922
                                                break;
1,444✔
923
                                        case 309:
924
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
925
                                                break;
1,444✔
926
                                        default:
927
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableColumn)} method.", NotificationType.None);
×
928
                                                break;
×
929
                                }
930

931
                                if (end)
5,776✔
932
                                {
1,444✔
933
                                        break;
1,444✔
934
                                }
935

936
                                this._reader.ReadNext();
4,332✔
937
                        }
4,332✔
938
                }
1,444✔
939

940
                private void readLinkedTableRow(TableEntity.Row row)
941
                {
1,824✔
942
                        this._reader.ReadNext();
1,824✔
943

944
                        bool end = false;
1,824✔
945
                        while (this._reader.DxfCode != DxfCode.Start)
14,972✔
946
                        {
14,820✔
947
                                switch (this._reader.Code)
14,820!
948
                                {
949
                                        case 1 when this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_BEGIN, StringComparison.InvariantCultureIgnoreCase):
✔
950
                                                break;
×
951
                                        case 90:
952
                                                break;
1,824✔
953
                                        case 91:
954
                                                row.CustomData = this._reader.ValueAsInt;
1,672✔
955
                                                break;
1,672✔
956
                                        case 300 when this._reader.ValueAsString.Equals(DxfFileToken.ObjectCell, StringComparison.InvariantCultureIgnoreCase):
6,384✔
957
                                                this.readCell();
6,384✔
958
                                                break;
6,384✔
959
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
1,672✔
960
                                                this.readCustomData();
1,672✔
961
                                                break;
1,672✔
962
                                        case 309:
963
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.LinkedTableDataRow_END, StringComparison.InvariantCultureIgnoreCase);
1,672✔
964
                                                break;
1,672✔
965
                                        default:
966
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableRow)} method.", NotificationType.None);
1,596✔
967
                                                break;
1,596✔
968
                                }
969

970
                                if (end)
14,820✔
971
                                {
1,672✔
972
                                        break;
1,672✔
973
                                }
974

975
                                this._reader.ReadNext();
13,148✔
976
                        }
13,148✔
977
                }
1,824✔
978

979
                private TableEntity.Cell readCell()
980
                {
6,384✔
981
                        this._reader.ReadNext();
6,384✔
982

983
                        TableEntity.Cell cell = new TableEntity.Cell();
6,384✔
984
                        CadTableCellTemplate template = new CadTableCellTemplate(cell);
6,384✔
985

986
                        bool end = false;
6,384✔
987
                        while (this._reader.DxfCode != DxfCode.Start)
20,140✔
988
                        {
19,988✔
989
                                switch (this._reader.Code)
19,988✔
990
                                {
991
                                        case 1 when this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
18,848✔
992
                                                this.readLinkedTableCell(cell);
6,384✔
993
                                                break;
6,384✔
994
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
12,464✔
995
                                                this.readFormattedTableCell(cell);
6,232✔
996
                                                break;
6,232✔
997
                                        case 1 when this._reader.ValueAsString.Equals("TABLECELL_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232✔
998
                                                this.readTableCell(cell);
6,232✔
999
                                                end = true;
6,232✔
1000
                                                break;
6,232✔
1001
                                        default:
1002
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCell)} method.", NotificationType.None);
1,140✔
1003
                                                break;
1,140✔
1004
                                }
1005

1006
                                if (end)
19,988✔
1007
                                {
6,232✔
1008
                                        return cell;
6,232✔
1009
                                }
1010

1011
                                this._reader.ReadNext();
13,756✔
1012
                        }
13,756✔
1013

1014
                        return cell;
152✔
1015
                }
6,384✔
1016

1017
                private void readTableCell(TableEntity.Cell cell)
1018
                {
6,232✔
1019
                        var map = DxfClassMap.Create(cell.GetType(), "TABLECELL_BEGIN");
6,232✔
1020

1021
                        this._reader.ReadNext();
6,232✔
1022

1023
                        bool end = false;
6,232✔
1024
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
1025
                        {
19,456✔
1026
                                switch (this._reader.Code)
19,456✔
1027
                                {
1028
                                        //Unknown
1029
                                        case 40:
1030
                                        case 41:
1031
                                                break;
304✔
1032
                                        case 309:
1033
                                                end = this._reader.ValueAsString.Equals("TABLECELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
1034
                                                break;
6,232✔
1035
                                        case 330:
1036
                                                //Unknown handle
1037
                                                break;
152✔
1038
                                        default:
1039
                                                if (!this.tryAssignCurrentValue(cell, map))
12,768!
1040
                                                {
×
1041
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readTableCell)} {this._reader.Position}.", NotificationType.None);
×
1042
                                                }
×
1043
                                                break;
12,768✔
1044
                                }
1045

1046
                                if (end)
19,456✔
1047
                                {
6,232✔
1048
                                        break;
6,232✔
1049
                                }
1050

1051
                                this._reader.ReadNext();
13,224✔
1052
                        }
13,224✔
1053
                }
6,232✔
1054

1055
                private void readFormattedTableCell(TableEntity.Cell cell)
1056
                {
6,232✔
1057
                        var map = DxfClassMap.Create(cell.GetType(), "FORMATTEDTABLEDATACELL_BEGIN");
6,232✔
1058

1059
                        this._reader.ReadNext();
6,232✔
1060

1061
                        bool end = false;
6,232✔
1062
                        while (this._reader.DxfCode != DxfCode.Start)
12,464✔
1063
                        {
12,464✔
1064
                                switch (this._reader.Code)
12,464!
1065
                                {
1066
                                        case 300 when this._reader.ValueAsString.Equals("CELLTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
6,232!
1067
                                                this.readCellTableFormat(cell);
6,232✔
1068
                                                continue;
6,232✔
1069
                                        case 309:
1070
                                                end = this._reader.ValueAsString.Equals("FORMATTEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
1071
                                                break;
6,232✔
1072
                                        default:
1073
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1074
                                                {
×
1075
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableCell)} {this._reader.Position}.", NotificationType.None);
×
1076
                                                }
×
1077
                                                break;
×
1078
                                }
1079

1080
                                if (end)
6,232!
1081
                                {
6,232✔
1082
                                        break;
6,232✔
1083
                                }
1084

1085
                                this._reader.ReadNext();
×
1086
                        }
×
1087
                }
6,232✔
1088

1089
                private void readCellTableFormat(TableEntity.Cell cell)
1090
                {
6,232✔
1091
                        var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
6,232✔
1092

1093
                        this._reader.ReadNext();
6,232✔
1094

1095
                        bool end = false;
6,232✔
1096
                        while (this._reader.Code == 1)
12,464✔
1097
                        {
6,232✔
1098
                                switch (this._reader.Code)
6,232!
1099
                                {
1100
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
6,232!
1101
                                                this.readStyleOverride(new CadCellStyleTemplate(cell.StyleOverride));
6,232✔
1102
                                                break;
6,232✔
1103
                                        case 1 when this._reader.ValueAsString.Equals("CELLSTYLE_BEGIN", StringComparison.InvariantCultureIgnoreCase):
×
1104
                                                this.readCellStyle(new CadCellStyleTemplate());
×
1105
                                                break;
×
1106
                                        default:
1107
                                                if (!this.tryAssignCurrentValue(cell, map))
×
1108
                                                {
×
1109
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellTableFormat)} {this._reader.Position}.", NotificationType.None);
×
1110
                                                }
×
1111
                                                break;
×
1112
                                }
1113

1114
                                if (end)
6,232!
1115
                                {
×
1116
                                        break;
×
1117
                                }
1118

1119
                                this._reader.ReadNext();
6,232✔
1120
                        }
6,232✔
1121
                }
6,232✔
1122

1123
                private void readCellStyle(CadCellStyleTemplate template)
1124
                {
×
1125
                        //var map = DxfClassMap.Create(cell.GetType(), "CELLTABLEFORMAT");
1126

1127
                        this._reader.ReadNext();
×
1128

1129
                        bool end = false;
×
1130
                        while (this._reader.Code != 1)
×
1131
                        {
×
1132
                                switch (this._reader.Code)
×
1133
                                {
1134
                                        case 309:
1135
                                                end = this._reader.ValueAsString.Equals("CELLSTYLE_END", StringComparison.InvariantCultureIgnoreCase);
×
1136
                                                break;
×
1137
                                        default:
1138
                                                //if (!this.tryAssignCurrentValue(cell, map))
1139
                                                {
×
1140
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellStyle)} {this._reader.Position}.", NotificationType.None);
×
1141
                                                }
×
1142
                                                break;
×
1143
                                }
1144

1145
                                if (end)
×
1146
                                {
×
1147
                                        break;
×
1148
                                }
1149

1150
                                this._reader.ReadNext();
×
1151
                        }
×
1152
                }
×
1153

1154
                private void readLinkedTableCell(TableEntity.Cell cell)
1155
                {
6,384✔
1156
                        var map = DxfClassMap.Create(cell.GetType(), "LINKEDTABLEDATACELL_BEGIN");
6,384✔
1157

1158
                        this._reader.ReadNext();
6,384✔
1159

1160
                        bool end = false;
6,384✔
1161
                        while (this._reader.DxfCode != DxfCode.Start)
63,992✔
1162
                        {
63,840✔
1163
                                switch (this._reader.Code)
63,840✔
1164
                                {
1165
                                        case 95:
1166
                                                //BL 95 Number of cell contents
1167
                                                break;
6,232✔
1168
                                        case 301 when this._reader.ValueAsString.Equals(DxfFileToken.CustomData, StringComparison.InvariantCultureIgnoreCase):
6,384✔
1169
                                                this.readCustomData();
6,384✔
1170
                                                break;
6,384✔
1171
                                        case 302 when this._reader.ValueAsString.Equals("CONTENT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
1172
                                                var c = this.readLinkedTableCellContent();
4,864✔
1173
                                                break;
4,864✔
1174
                                        case 309:
1175
                                                end = this._reader.ValueAsString.Equals("LINKEDTABLEDATACELL_END", StringComparison.InvariantCultureIgnoreCase);
6,232✔
1176
                                                break;
6,232✔
1177
                                        default:
1178
                                                if (!this.tryAssignCurrentValue(cell, map))
40,128✔
1179
                                                {
13,832✔
1180
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCell)} {this._reader.Position}.", NotificationType.None);
13,832✔
1181
                                                }
13,832✔
1182
                                                break;
40,128✔
1183
                                }
1184

1185
                                if (end)
63,840✔
1186
                                {
6,232✔
1187
                                        break;
6,232✔
1188
                                }
1189

1190
                                this._reader.ReadNext();
57,608✔
1191
                        }
57,608✔
1192
                }
6,384✔
1193

1194
                private CadTableCellContentTemplate readLinkedTableCellContent()
1195
                {
4,864✔
1196
                        TableEntity.CellContent content = new TableEntity.CellContent();
4,864✔
1197
                        CadTableCellContentTemplate template = new CadTableCellContentTemplate(content);
4,864✔
1198
                        var map = DxfClassMap.Create(content.GetType(), "CONTENT");
4,864✔
1199

1200
                        this._reader.ReadNext();
4,864✔
1201

1202
                        bool end = false;
4,864✔
1203
                        while (this._reader.DxfCode != DxfCode.Start)
9,728✔
1204
                        {
9,728✔
1205
                                switch (this._reader.Code)
9,728!
1206
                                {
1207
                                        case 1 when this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,728✔
1208
                                                readFormattedCellContent();
4,864✔
1209
                                                end = true;
4,864✔
1210
                                                break;
4,864✔
1211
                                        case 1 when this._reader.ValueAsString.Equals("CELLCONTENT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
4,864!
1212
                                                readCellContent(template);
4,864✔
1213
                                                break;
4,864✔
1214
                                        default:
1215
                                                if (!this.tryAssignCurrentValue(content, map))
×
1216
                                                {
×
1217
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readLinkedTableCellContent)} {this._reader.Position}.", NotificationType.None);
×
1218
                                                }
×
1219
                                                break;
×
1220
                                }
1221

1222
                                if (end)
9,728✔
1223
                                {
4,864✔
1224
                                        break;
4,864✔
1225
                                }
1226

1227
                                this._reader.ReadNext();
4,864✔
1228
                        }
4,864✔
1229

1230
                        return template;
4,864✔
1231
                }
4,864✔
1232

1233
                private void readCellContent(CadTableCellContentTemplate template)
1234
                {
4,864✔
1235
                        TableEntity.CellContent content = template.Content;
4,864✔
1236
                        var map = DxfClassMap.Create(content.GetType(), "CELLCONTENT_BEGIN");
4,864✔
1237

1238
                        this._reader.ReadNext();
4,864✔
1239

1240
                        bool end = false;
4,864✔
1241
                        while (this._reader.DxfCode != DxfCode.Start)
19,456✔
1242
                        {
19,456✔
1243
                                switch (this._reader.Code)
19,456✔
1244
                                {
1245
                                        case 91:
1246
                                                break;
4,864✔
1247
                                        case 300 when this._reader.ValueAsString.Equals("VALUE", StringComparison.InvariantCultureIgnoreCase):
4,408✔
1248
                                                this.readDataMapValue();
4,408✔
1249
                                                break;
4,408✔
1250
                                        case 309:
1251
                                                end = this._reader.ValueAsString.Equals("CELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
1252
                                                break;
4,864✔
1253
                                        case 340:
1254
                                                template.BlockRecordHandle = this._reader.ValueAsHandle;
456✔
1255
                                                break;
456✔
1256
                                        default:
1257
                                                if (!this.tryAssignCurrentValue(content, map))
4,864!
1258
                                                {
×
1259
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellContent)} {this._reader.Position}.", NotificationType.None);
×
1260
                                                }
×
1261
                                                break;
4,864✔
1262
                                }
1263

1264
                                if (end)
19,456✔
1265
                                {
4,864✔
1266
                                        break;
4,864✔
1267
                                }
1268

1269
                                this._reader.ReadNext();
14,592✔
1270
                        }
14,592✔
1271
                }
4,864✔
1272

1273
                private void readFormattedCellContent()
1274
                {
4,864✔
1275
                        TableEntity.ContentFormat format = new();
4,864✔
1276
                        CadTableCellContentFormatTemplate template = new CadTableCellContentFormatTemplate(format);
4,864✔
1277
                        var map = DxfClassMap.Create(format.GetType(), "FORMATTEDCELLCONTENT");
4,864✔
1278

1279
                        this._reader.ReadNext();
4,864✔
1280

1281
                        bool end = false;
4,864✔
1282
                        while (this._reader.DxfCode != DxfCode.Start)
14,592✔
1283
                        {
14,592✔
1284
                                switch (this._reader.Code)
14,592✔
1285
                                {
1286
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
4,864✔
1287
                                                readContentFormat(template);
4,864✔
1288
                                                break;
4,864✔
1289
                                        case 309:
1290
                                                end = this._reader.ValueAsString.Equals("FORMATTEDCELLCONTENT_END", StringComparison.InvariantCultureIgnoreCase);
4,864✔
1291
                                                break;
4,864✔
1292
                                        default:
1293
                                                if (!this.tryAssignCurrentValue(format, map))
4,864!
1294
                                                {
×
1295
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedCellContent)} method.", NotificationType.None);
×
1296
                                                }
×
1297
                                                break;
4,864✔
1298
                                }
1299

1300
                                if (end)
14,592✔
1301
                                {
4,864✔
1302
                                        break;
4,864✔
1303
                                }
1304

1305
                                this._reader.ReadNext();
9,728✔
1306
                        }
9,728✔
1307
                }
4,864✔
1308

1309
                private void readContentFormat(CadTableCellContentFormatTemplate template)
1310
                {
11,400✔
1311
                        var format = template.Format;
11,400✔
1312
                        var map = DxfClassMap.Create(format.GetType(), "CONTENTFORMAT_BEGIN");
11,400✔
1313

1314
                        this._reader.ReadNext();
11,400✔
1315

1316
                        bool end = false;
11,400✔
1317
                        while (this._reader.DxfCode != DxfCode.Start)
148,200✔
1318
                        {
148,200✔
1319
                                switch (this._reader.Code)
148,200✔
1320
                                {
1321
                                        case 1 when this._reader.ValueAsString.Equals("CONTENTFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
11,400✔
1322
                                                break;
11,400✔
1323
                                        case 309:
1324
                                                end = this._reader.ValueAsString.Equals("CONTENTFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
11,400✔
1325
                                                break;
11,400✔
1326
                                        case 340:
1327
                                                template.TextStyleHandle = this._reader.ValueAsHandle;
11,400✔
1328
                                                break;
11,400✔
1329
                                        default:
1330
                                                if (!this.tryAssignCurrentValue(format, map))
114,000!
1331
                                                {
×
1332
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readContentFormat)} method.", NotificationType.None);
×
1333
                                                }
×
1334
                                                break;
114,000✔
1335
                                }
1336

1337
                                if (end)
148,200✔
1338
                                {
11,400✔
1339
                                        break;
11,400✔
1340
                                }
1341

1342
                                this._reader.ReadNext();
136,800✔
1343
                        }
136,800✔
1344
                }
11,400✔
1345

1346
                private void readFormattedTableColumn(TableEntity.Column column)
1347
                {
1,444✔
1348
                        this._reader.ReadNext();
1,444✔
1349

1350
                        bool end = false;
1,444✔
1351
                        while (this._reader.DxfCode != DxfCode.Start)
4,332✔
1352
                        {
4,332✔
1353
                                switch (this._reader.Code)
4,332!
1354
                                {
1355
                                        case 300 when this._reader.ValueAsString.Equals("COLUMNTABLEFORMAT", StringComparison.InvariantCultureIgnoreCase):
1,444!
1356
                                                break;
1,444✔
1357
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
1,444!
1358
                                                this.readStyleOverride(new CadCellStyleTemplate(column.CellStyleOverride));
1,444✔
1359
                                                break;
1,444✔
1360
                                        case 309:
1361
                                                end = this._reader.ValueAsString.Equals(DxfFileToken.FormattedTableDataColumn_END, StringComparison.InvariantCultureIgnoreCase);
1,444✔
1362
                                                break;
1,444✔
1363
                                        default:
1364
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readFormattedTableColumn)} method.", NotificationType.None);
×
1365
                                                break;
×
1366
                                }
1367

1368
                                if (end)
4,332✔
1369
                                {
1,444✔
1370
                                        break;
1,444✔
1371
                                }
1372

1373
                                this._reader.ReadNext();
2,888✔
1374
                        }
2,888✔
1375
                }
1,444✔
1376

1377
                private void readStyleOverride(CadCellStyleTemplate template)
1378
                {
9,652✔
1379
                        var style = template.Format as TableEntity.CellStyle;
9,652✔
1380
                        var mapstyle = DxfClassMap.Create(style.GetType(), "TABLEFORMAT_STYLE");
9,652✔
1381
                        var mapformat = DxfClassMap.Create(typeof(TableEntity.ContentFormat), "TABLEFORMAT_BEGIN");
9,652✔
1382

1383
                        this._reader.ReadNext();
9,652✔
1384

1385
                        bool end = false;
9,652✔
1386
                        TableEntity.CellEdgeFlags currBorder = TableEntity.CellEdgeFlags.Unknown;
9,652✔
1387
                        while (this._reader.DxfCode != DxfCode.Start)
106,324✔
1388
                        {
106,324✔
1389
                                switch (this._reader.Code)
106,324✔
1390
                                {
1391
                                        case 95:
1392
                                                currBorder = (TableEntity.CellEdgeFlags)this._reader.ValueAsInt;
13,984✔
1393
                                                break;
13,984✔
1394
                                        case 1 when this._reader.ValueAsString.Equals("TABLEFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
304✔
1395
                                                break;
304✔
1396
                                        case 300 when this._reader.ValueAsString.Equals("CONTENTFORMAT", StringComparison.InvariantCultureIgnoreCase):
6,536✔
1397
                                                readContentFormat(new CadTableCellContentFormatTemplate(new TableEntity.ContentFormat()));
6,536✔
1398
                                                break;
6,536✔
1399
                                        case 301 when this._reader.ValueAsString.Equals("MARGIN", StringComparison.InvariantCultureIgnoreCase):
3,344✔
1400
                                                this.readCellMargin(template);
3,344✔
1401
                                                break;
3,344✔
1402
                                        case 302 when this._reader.ValueAsString.Equals("GRIDFORMAT", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1403
                                                TableEntity.CellBorder border = new TableEntity.CellBorder(currBorder);
13,984✔
1404
                                                this.readGridFormat(template, border);
13,984✔
1405
                                                break;
13,984✔
1406
                                        case 309:
1407
                                                end = this._reader.ValueAsString.Equals("TABLEFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
9,652✔
1408
                                                break;
9,652✔
1409
                                        default:
1410
                                                if (!this.tryAssignCurrentValue(style, mapstyle) && !this.tryAssignCurrentValue(style, mapformat))
58,520!
1411
                                                {
×
1412
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readStyleOverride)} method.", NotificationType.None);
×
1413
                                                }
×
1414
                                                break;
58,520✔
1415
                                }
1416

1417
                                if (end)
106,324✔
1418
                                {
9,652✔
1419
                                        break;
9,652✔
1420
                                }
1421

1422
                                this._reader.ReadNext();
96,672✔
1423
                        }
96,672✔
1424
                }
9,652✔
1425

1426
                private void readGridFormat(CadCellStyleTemplate template, TableEntity.CellBorder border)
1427
                {
13,984✔
1428
                        var map = DxfClassMap.Create(border.GetType(), nameof(TableEntity.CellBorder));
13,984✔
1429

1430
                        this._reader.ReadNext();
13,984✔
1431

1432
                        bool end = false;
13,984✔
1433
                        while (this._reader.DxfCode != DxfCode.Start)
125,856✔
1434
                        {
125,856✔
1435
                                switch (this._reader.Code)
125,856✔
1436
                                {
1437
                                        case 1 when this._reader.ValueAsString.Equals("GRIDFORMAT_BEGIN", StringComparison.InvariantCultureIgnoreCase):
13,984✔
1438
                                                break;
13,984✔
1439
                                        case 340:
1440
                                                template.BorderLinetypePairs.Add(new Tuple<TableEntity.CellBorder, ulong>(border, this._reader.ValueAsHandle));
13,984✔
1441
                                                break;
13,984✔
1442
                                        case 309:
1443
                                                end = this._reader.ValueAsString.Equals("GRIDFORMAT_END", StringComparison.InvariantCultureIgnoreCase);
13,984✔
1444
                                                break;
13,984✔
1445
                                        default:
1446
                                                if (!this.tryAssignCurrentValue(border, map))
83,904!
1447
                                                {
×
1448
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readGridFormat)} method.", NotificationType.None);
×
1449
                                                }
×
1450
                                                break;
83,904✔
1451
                                }
1452

1453
                                if (end)
125,856✔
1454
                                {
13,984✔
1455
                                        break;
13,984✔
1456
                                }
1457

1458
                                this._reader.ReadNext();
111,872✔
1459
                        }
111,872✔
1460
                }
13,984✔
1461

1462
                private void readCellMargin(CadCellStyleTemplate template)
1463
                {
3,344✔
1464
                        var style = template.Format as TableEntity.CellStyle;
3,344✔
1465

1466
                        this._reader.ReadNext();
3,344✔
1467

1468
                        bool end = false;
3,344✔
1469
                        int i = 0;
3,344✔
1470
                        while (this._reader.DxfCode != DxfCode.Start)
26,752✔
1471
                        {
26,752✔
1472
                                switch (this._reader.Code)
26,752!
1473
                                {
1474
                                        case 1 when this._reader.ValueAsString.Equals("CELLMARGIN_BEGIN", StringComparison.InvariantCultureIgnoreCase):
3,344!
1475
                                                break;
3,344✔
1476
                                        case 40:
1477
                                                switch (i)
20,064✔
1478
                                                {
1479
                                                        case 0:
1480
                                                                style.VerticalMargin = this._reader.ValueAsDouble;
3,344✔
1481
                                                                break;
3,344✔
1482
                                                        case 1:
1483
                                                                style.HorizontalMargin = this._reader.ValueAsDouble;
3,344✔
1484
                                                                break;
3,344✔
1485
                                                        case 2:
1486
                                                                style.BottomMargin = this._reader.ValueAsDouble;
3,344✔
1487
                                                                break;
3,344✔
1488
                                                        case 3:
1489
                                                                style.RightMargin = this._reader.ValueAsDouble;
3,344✔
1490
                                                                break;
3,344✔
1491
                                                        case 4:
1492
                                                                style.MarginHorizontalSpacing = this._reader.ValueAsDouble;
3,344✔
1493
                                                                break;
3,344✔
1494
                                                        case 5:
1495
                                                                style.MarginVerticalSpacing = this._reader.ValueAsDouble;
3,344✔
1496
                                                                break;
3,344✔
1497
                                                }
1498

1499
                                                i++;
20,064✔
1500
                                                break;
20,064✔
1501
                                        case 309:
1502
                                                end = this._reader.ValueAsString.Equals("CELLMARGIN_END", StringComparison.InvariantCultureIgnoreCase);
3,344✔
1503
                                                break;
3,344✔
1504
                                        default:
1505
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCellMargin)} method.", NotificationType.None);
×
1506
                                                break;
×
1507
                                }
1508

1509
                                if (end)
26,752✔
1510
                                {
3,344✔
1511
                                        break;
3,344✔
1512
                                }
1513

1514
                                this._reader.ReadNext();
23,408✔
1515
                        }
23,408✔
1516
                }
3,344✔
1517

1518
                private void readCustomData()
1519
                {
9,500✔
1520
                        this._reader.ReadNext();
9,500✔
1521

1522
                        int ndata = 0;
9,500✔
1523
                        bool end = false;
9,500✔
1524
                        while (this._reader.DxfCode != DxfCode.Start)
88,388✔
1525
                        {
88,236✔
1526
                                switch (this._reader.Code)
88,236✔
1527
                                {
1528
                                        case 1 when this._reader.ValueAsString.Equals("DATAMAP_BEGIN", StringComparison.InvariantCultureIgnoreCase):
9,500✔
1529
                                                break;
9,500✔
1530
                                        case 90:
1531
                                                ndata = this._reader.ValueAsInt;
9,652✔
1532
                                                break;
9,652✔
1533
                                        case 300:
1534
                                                //Name
1535
                                                break;
6,232✔
1536
                                        case 301 when this._reader.ValueAsString.Equals("DATAMAP_VALUE", StringComparison.InvariantCultureIgnoreCase):
6,232✔
1537
                                                this.readDataMapValue();
6,232✔
1538
                                                break;
6,232✔
1539
                                        case 309:
1540
                                                end = this._reader.ValueAsString.Equals("DATAMAP_END", StringComparison.InvariantCultureIgnoreCase);
9,348✔
1541
                                                break;
9,348✔
1542
                                        default:
1543
                                                this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readCustomData)} method.", NotificationType.None);
47,272✔
1544
                                                break;
47,272✔
1545
                                }
1546

1547
                                if (end)
88,236✔
1548
                                {
9,348✔
1549
                                        break;
9,348✔
1550
                                }
1551

1552
                                this._reader.ReadNext();
78,888✔
1553
                        }
78,888✔
1554
                }
9,500✔
1555

1556
                private void readDataMapValue()
1557
                {
10,640✔
1558
                        TableEntity.CellValue value = new TableEntity.CellValue();
10,640✔
1559
                        var map = DxfClassMap.Create(value.GetType(), "DATAMAP_VALUE");
10,640✔
1560

1561
                        this._reader.ReadNext();
10,640✔
1562

1563
                        bool end = false;
10,640✔
1564
                        while (this._reader.DxfCode != DxfCode.Start)
392,160✔
1565
                        {
392,008✔
1566
                                switch (this._reader.Code)
392,008✔
1567
                                {
1568
                                        case 11:
1569
                                        case 21:
1570
                                        case 31:
1571
                                                //Value as point
1572
                                                break;
912✔
1573
                                        case 91:
1574
                                        case 92:
1575
                                                //Value as int
1576
                                                break;
46,208✔
1577
                                        case 140:
1578
                                                //Value as double
1579
                                                break;
15,732✔
1580
                                        case 310:
1581
                                                //Value as byte array
1582
                                                break;
304✔
1583
                                        case 304:
1584
                                                end = this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.InvariantCultureIgnoreCase);
10,488✔
1585
                                                break;
10,488✔
1586
                                        default:
1587
                                                if (!this.tryAssignCurrentValue(value, map))
318,364✔
1588
                                                {
126,920✔
1589
                                                        this._builder.Notify($"Unhandled dxf code {this._reader.Code} value {this._reader.ValueAsString} at {nameof(readDataMapValue)} method.", NotificationType.None);
126,920✔
1590
                                                }
126,920✔
1591
                                                break;
318,364✔
1592
                                }
1593

1594
                                if (end)
392,008✔
1595
                                {
10,488✔
1596
                                        break;
10,488✔
1597
                                }
1598

1599
                                this._reader.ReadNext();
381,520✔
1600
                        }
381,520✔
1601
                }
10,640✔
1602

1603
                private bool readVisualStyle(CadTemplate template, DxfMap map)
1604
                {
411,192✔
1605
                        switch (this._reader.Code)
411,192✔
1606
                        {
1607
                                // Undocumented codes
1608
                                case 176:
1609
                                case 177:
1610
                                case 420:
1611
                                        return true;
141,178✔
1612
                                default:
1613
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
270,014✔
1614
                        }
1615
                }
411,192✔
1616

1617
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
1618
                {
4,788✔
1619
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,788✔
1620
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,788✔
1621

1622
                        switch (this._reader.Code)
4,788✔
1623
                        {
1624
                                case 10:
1625
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
456✔
1626
                                        return true;
456✔
1627
                                case 20:
1628
                                        var pt = filter.BoundaryPoints.LastOrDefault();
456✔
1629
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
456✔
1630
                                        return true;
456✔
1631
                                case 40:
1632
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
456!
1633
                                        {
×
1634
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
1635
                                                tmp.HasFrontPlane = true;
×
1636
                                        }
×
1637

1638
                                        double[] array = new double[16]
456✔
1639
                                        {
456✔
1640
                                                0.0, 0.0, 0.0, 0.0,
456✔
1641
                                                0.0, 0.0, 0.0, 0.0,
456✔
1642
                                                0.0, 0.0, 0.0, 0.0,
456✔
1643
                                                0.0, 0.0, 0.0, 1.0
456✔
1644
                                        };
456✔
1645

1646
                                        for (int i = 0; i < 12; i++)
11,856✔
1647
                                        {
5,472✔
1648
                                                array[i] = this._reader.ValueAsDouble;
5,472✔
1649

1650
                                                if (i < 11)
5,472✔
1651
                                                {
5,016✔
1652
                                                        this._reader.ReadNext();
5,016✔
1653
                                                }
5,016✔
1654
                                        }
5,472✔
1655

1656
                                        if (tmp.InsertTransformRead)
456!
1657
                                        {
×
1658
                                                filter.InsertTransform = new Matrix4(array);
×
1659
                                                tmp.InsertTransformRead = true;
×
1660
                                        }
×
1661
                                        else
1662
                                        {
456✔
1663
                                                filter.InverseInsertTransform = new Matrix4(array);
456✔
1664
                                        }
456✔
1665

1666
                                        return true;
456✔
1667
                                case 73:
1668
                                default:
1669
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,420✔
1670
                        }
1671
                }
4,788✔
1672

1673
                private bool readMLineStyle(CadTemplate template, DxfMap map)
1674
                {
4,090✔
1675
                        var tmp = template as CadMLineStyleTemplate;
4,090✔
1676
                        var mLineStyle = template.CadObject as MLineStyle;
4,090✔
1677

1678
                        switch (this._reader.Code)
4,090✔
1679
                        {
1680
                                case 6:
1681
                                        var t = tmp.ElementTemplates.LastOrDefault();
484✔
1682
                                        if (t == null)
484!
1683
                                        {
×
1684
                                                return true;
×
1685
                                        }
1686
                                        t.LineTypeName = this._reader.ValueAsString;
484✔
1687
                                        return true;
484✔
1688
                                case 49:
1689
                                        MLineStyle.Element element = new MLineStyle.Element();
484✔
1690
                                        CadMLineStyleTemplate.ElementTemplate elementTemplate = new CadMLineStyleTemplate.ElementTemplate(element);
484✔
1691
                                        element.Offset = this._reader.ValueAsDouble;
484✔
1692

1693
                                        tmp.ElementTemplates.Add(elementTemplate);
484✔
1694
                                        mLineStyle.AddElement(element);
484✔
1695
                                        return true;
484✔
1696
                                default:
1697
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
3,122✔
1698
                        }
1699
                }
4,090✔
1700

1701
                private bool readMLeaderStyle(CadTemplate template, DxfMap map)
1702
                {
21,648✔
1703
                        var tmp = template as CadMLeaderStyleTemplate;
21,648✔
1704

1705
                        switch (this._reader.Code)
21,648✔
1706
                        {
1707
                                case 179:
1708
                                        return true;
242✔
1709
                                case 340:
1710
                                        tmp.LeaderLineTypeHandle = this._reader.ValueAsHandle;
472✔
1711
                                        return true;
472✔
1712
                                case 342:
1713
                                        tmp.MTextStyleHandle = this._reader.ValueAsHandle;
472✔
1714
                                        return true;
472✔
1715
                                default:
1716
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
20,462✔
1717
                        }
1718
                }
21,648✔
1719

1720
                private bool readXRecord(CadTemplate template, DxfMap map)
1721
                {
134,264✔
1722
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
134,264✔
1723

1724
                        switch (this._reader.Code)
134,264✔
1725
                        {
1726
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
34,288✔
1727
                                        this.readXRecordEntries(tmp);
34,288✔
1728
                                        return true;
34,288✔
1729
                                default:
1730
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
99,976✔
1731
                        }
1732
                }
134,264✔
1733

1734
                private void readXRecordEntries(CadXRecordTemplate template)
1735
                {
34,288✔
1736
                        this._reader.ReadNext();
34,288✔
1737

1738
                        while (this._reader.DxfCode != DxfCode.Start)
2,865,868✔
1739
                        {
2,831,580✔
1740
                                switch (this._reader.GroupCodeValue)
2,831,580!
1741
                                {
1742
                                        case GroupCodeValueType.Handle:
1743
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
1744
                                                break;
×
1745
                                        default:
1746
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
2,831,580✔
1747
                                                break;
2,831,580✔
1748
                                }
1749

1750
                                this._reader.ReadNext();
2,831,580✔
1751
                        }
2,831,580✔
1752
                }
34,288✔
1753

1754
                private bool readBookColor(CadTemplate template, DxfMap map)
1755
                {
1,634✔
1756
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,634✔
1757
                        BookColor color = tmp.CadObject as BookColor;
1,634✔
1758

1759
                        switch (this._reader.Code)
1,634✔
1760
                        {
1761
                                case 430:
1762
                                        color.Name = this._reader.ValueAsString;
190✔
1763
                                        return true;
190✔
1764
                                default:
1765
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,444✔
1766
                        }
1767
                }
1,634✔
1768

1769
                private bool readDictionary(CadTemplate template, DxfMap map)
1770
                {
263,967✔
1771
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
263,967✔
1772
                        CadDictionary cadDictionary = tmp.CadObject;
263,967✔
1773

1774
                        switch (this._reader.Code)
263,967✔
1775
                        {
1776
                                case 280:
1777
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
17,755✔
1778
                                        return true;
17,755✔
1779
                                case 281:
1780
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
25,354✔
1781
                                        return true;
25,354✔
1782
                                case 3:
1783
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
67,515✔
1784
                                        return true;
67,515✔
1785
                                case 350: // Soft-owner ID/handle to entry object 
1786
                                case 360: // Hard-owner ID/handle to entry object
1787
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
67,515✔
1788
                                        return true;
67,515✔
1789
                                default:
1790
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
85,828✔
1791
                        }
1792
                }
263,967✔
1793

1794
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
1795
                {
2,070✔
1796
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
2,070✔
1797

1798
                        switch (this._reader.Code)
2,070✔
1799
                        {
1800
                                case 340:
1801
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
230✔
1802
                                        return true;
230✔
1803
                                default:
1804
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,840!
1805
                                        {
1,840✔
1806
                                                return this.readDictionary(template, map);
1,840✔
1807
                                        }
1808
                                        return true;
×
1809
                        }
1810
                }
2,070✔
1811

1812
                private CadTemplate readSortentsTable()
1813
                {
684✔
1814
                        SortEntitiesTable sortTable = new SortEntitiesTable();
684✔
1815
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
684✔
1816

1817
                        //Jump the 0 marker
1818
                        this._reader.ReadNext();
684✔
1819

1820
                        this.readCommonObjectData(template);
684✔
1821

1822
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
684✔
1823

1824
                        //Jump the 100 marker
1825
                        this._reader.ReadNext();
684✔
1826

1827
                        (ulong?, ulong?) pair = (null, null);
684✔
1828

1829
                        while (this._reader.DxfCode != DxfCode.Start)
5,016✔
1830
                        {
4,332✔
1831
                                switch (this._reader.Code)
4,332!
1832
                                {
1833
                                        case 5:
1834
                                                pair.Item1 = this._reader.ValueAsHandle;
1,824✔
1835
                                                break;
1,824✔
1836
                                        case 330:
1837
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
684✔
1838
                                                break;
684✔
1839
                                        case 331:
1840
                                                pair.Item2 = this._reader.ValueAsHandle;
1,824✔
1841
                                                break;
1,824✔
1842
                                        default:
1843
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
1844
                                                break;
×
1845
                                }
1846

1847
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,332✔
1848
                                {
1,824✔
1849
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,824✔
1850
                                        pair = (null, null);
1,824✔
1851
                                }
1,824✔
1852

1853
                                this._reader.ReadNext();
4,332✔
1854
                        }
4,332✔
1855

1856
                        return template;
684✔
1857
                }
684✔
1858
        }
1859
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc