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

DomCR / ACadSharp / 17065159770

19 Aug 2025 09:16AM UTC coverage: 78.225% (-0.2%) from 78.427%
17065159770

push

github

web-flow
Merge pull request #725 from DomCR/issue-399_proxy-entities

issue 399

6509 of 9051 branches covered (71.91%)

Branch coverage included in aggregate %.

35 of 145 new or added lines in 8 files covered. (24.14%)

1 existing line in 1 file now uncovered.

25266 of 31569 relevant lines covered (80.03%)

104758.74 hits per line

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

83.23
/src/ACadSharp/IO/DXF/DxfStreamReader/DxfObjectsSectionReader.cs
1
using ACadSharp.Classes;
2
using ACadSharp.IO.Templates;
3
using ACadSharp.Objects;
4
using ACadSharp.Objects.Evaluations;
5
using CSMath;
6
using System;
7
using System.Diagnostics;
8
using System.IO;
9
using System.Linq;
10
using static ACadSharp.IO.Templates.CadEvaluationGraphTemplate;
11

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

18
                public DxfObjectsSectionReader(IDxfStreamReader reader, DxfDocumentBuilder builder)
19
                        : base(reader, builder)
230✔
20
                {
230✔
21
                }
230✔
22

23
                public override void Read()
24
                {
230✔
25
                        //Advance to the first value in the section
26
                        this._reader.ReadNext();
230✔
27

28
                        //Loop until the section ends
29
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
67,321✔
30
                        {
67,091✔
31
                                CadTemplate template = null;
67,091✔
32

33
                                try
34
                                {
67,091✔
35
                                        template = this.readObject();
67,091✔
36
                                }
67,091✔
37
                                catch (Exception ex)
×
38
                                {
×
39
                                        if (!this._builder.Configuration.Failsafe)
×
40
                                                throw;
×
41

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

44
                                        while (this._reader.DxfCode != DxfCode.Start)
×
45
                                                this._reader.ReadNext();
×
46
                                }
×
47

48
                                if (template == null)
67,091✔
49
                                        continue;
412✔
50

51
                                //Add the object and the template to the builder
52
                                this._builder.AddTemplate(template);
66,679✔
53
                        }
66,679✔
54
                }
230✔
55

56
                private CadTemplate readObject()
57
                {
67,091✔
58
                        switch (this._reader.ValueAsString)
67,091!
59
                        {
60
                                case DxfFileToken.ObjectDBColor:
61
                                        return this.readObjectCodes<BookColor>(new CadNonGraphicalObjectTemplate(new BookColor()), this.readBookColor);
216✔
62
                                case DxfFileToken.ObjectDictionary:
63
                                        return this.readObjectCodes<CadDictionary>(new CadDictionaryTemplate(), this.readDictionary);
22,376✔
64
                                case DxfFileToken.ObjectDictionaryWithDefault:
65
                                        return this.readObjectCodes<CadDictionaryWithDefault>(new CadDictionaryWithDefaultTemplate(), this.readDictionaryWithDefault);
218✔
66
                                case DxfFileToken.ObjectLayout:
67
                                        return this.readObjectCodes<Layout>(new CadLayoutTemplate(), this.readLayout);
894✔
68
                                case DxfFileToken.ObjectPlotSettings:
69
                                        return this.readObjectCodes<PlotSettings>(new CadNonGraphicalObjectTemplate(new PlotSettings()), this.readPlotSettings);
×
70
                                case DxfFileToken.ObjectEvalGraph:
71
                                        return this.readObjectCodes<EvaluationGraph>(new CadEvaluationGraphTemplate(), this.readEvaluationGraph);
216✔
72
                                case DxfFileToken.ObjectDictionaryVar:
73
                                        return this.readObjectCodes<DictionaryVariable>(new CadTemplate<DictionaryVariable>(new DictionaryVariable()), this.readObjectSubclassMap);
2,721✔
74
                                case DxfFileToken.ObjectPdfDefinition:
75
                                        return this.readObjectCodes<PdfUnderlayDefinition>(new CadNonGraphicalObjectTemplate(new PdfUnderlayDefinition()), this.readObjectSubclassMap);
216✔
76
                                case DxfFileToken.ObjectSortEntsTable:
77
                                        return this.readSortentsTable();
648✔
78
                                case DxfFileToken.ObjectProxyObject:
NEW
79
                                        return this.readObjectCodes<ProxyObject>(new CadNonGraphicalObjectTemplate(new ProxyObject()), this.readProxyObject);
×
80
                                case DxfFileToken.ObjectRasterVariables:
81
                                        return this.readObjectCodes<RasterVariables>(new CadNonGraphicalObjectTemplate(new RasterVariables()), this.readObjectSubclassMap);
216✔
82
                                case DxfFileToken.ObjectGroup:
83
                                        return this.readObjectCodes<Group>(new CadGroupTemplate(), this.readGroup);
432✔
84
                                case DxfFileToken.ObjectGeoData:
85
                                        return this.readObjectCodes<GeoData>(new CadGeoDataTemplate(), this.readGeoData);
2✔
86
                                case DxfFileToken.ObjectScale:
87
                                        return this.readObjectCodes<Scale>(new CadTemplate<Scale>(new Scale()), this.readScale);
7,398✔
88
                                case DxfFileToken.ObjectTableContent:
89
                                        return this.readObjectCodes<TableContent>(new CadTableContentTemplate(), this.readTableContent);
432✔
90
                                case DxfFileToken.ObjectVisualStyle:
91
                                        return this.readObjectCodes<VisualStyle>(new CadTemplate<VisualStyle>(new VisualStyle()), this.readVisualStyle);
5,232✔
92
                                case DxfFileToken.ObjectSpatialFilter:
93
                                        return this.readObjectCodes<SpatialFilter>(new CadSpatialFilterTemplate(), this.readSpatialFilter);
216✔
94
                                case DxfFileToken.ObjectXRecord:
95
                                        return this.readObjectCodes<XRecord>(new CadXRecordTemplate(), this.readXRecord);
17,474✔
96
                                default:
97
                                        DxfMap map = DxfMap.Create<CadObject>();
8,184✔
98
                                        CadUnknownNonGraphicalObjectTemplate unknownEntityTemplate = null;
8,184✔
99
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
8,184✔
100
                                        {
7,772✔
101
                                                this._builder.Notify($"NonGraphicalObject not supported read as an UnknownNonGraphicalObject: {this._reader.ValueAsString}", NotificationType.NotImplemented);
7,772✔
102
                                                unknownEntityTemplate = new CadUnknownNonGraphicalObjectTemplate(new UnknownNonGraphicalObject(dxfClass));
7,772✔
103
                                        }
7,772✔
104
                                        else
105
                                        {
412✔
106
                                                this._builder.Notify($"UnknownNonGraphicalObject not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
412✔
107
                                        }
412✔
108

109
                                        this._reader.ReadNext();
8,184✔
110

111
                                        do
112
                                        {
427,188✔
113
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
427,188✔
114
                                                {
44,896✔
115
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
44,896✔
116
                                                        if (isExtendedData)
44,896✔
117
                                                                continue;
72✔
118
                                                }
44,824✔
119

120
                                                this._reader.ReadNext();
427,116✔
121
                                        }
427,116✔
122
                                        while (this._reader.DxfCode != DxfCode.Start);
427,188✔
123

124
                                        return unknownEntityTemplate;
8,184✔
125
                        }
126
                }
67,091✔
127

128
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
129
                        where T : CadObject
130
                {
58,259✔
131
                        this._reader.ReadNext();
58,259✔
132

133
                        DxfMap map = DxfMap.Create<T>();
58,259✔
134

135
                        while (this._reader.DxfCode != DxfCode.Start)
1,880,536✔
136
                        {
1,822,277✔
137
                                if (!readObject(template, map))
1,822,277✔
138
                                {
1,066,541✔
139
                                        this.readCommonCodes(template, out bool isExtendedData, map);
1,066,541✔
140
                                        if (isExtendedData)
1,066,541✔
141
                                                continue;
5,533✔
142
                                }
1,061,008✔
143

144
                                if (this._reader.DxfCode != DxfCode.Start)
1,816,744✔
145
                                        this._reader.ReadNext();
1,799,054✔
146
                        }
1,816,744✔
147

148
                        return template;
58,259✔
149
                }
58,259✔
150

151
                private bool readProxyObject(CadTemplate template, DxfMap map)
NEW
152
                {
×
NEW
153
                        ProxyObject proxy = template.CadObject as ProxyObject;
×
154

NEW
155
                        switch (this._reader.Code)
×
156
                        {
157
                                case 90:
158
                                case 94:
159
                                //Undocumented
160
                                case 97:
161
                                case 71:
NEW
162
                                        return true;
×
163
                                case 95:
NEW
164
                                        int format = this._reader.ValueAsInt;
×
NEW
165
                                        proxy.Version = (ACadVersion)(format & 0xFFFF);
×
NEW
166
                                        proxy.MaintenanceVersion = (short)(format >> 16);
×
NEW
167
                                        return true;
×
168
                                case 91:
NEW
169
                                        var classId = this._reader.ValueAsShort;
×
NEW
170
                                        if (this._builder.DocumentToBuild.Classes.TryGetByClassNumber(classId, out DxfClass dxfClass))
×
NEW
171
                                        {
×
NEW
172
                                                proxy.DxfClass = dxfClass;
×
NEW
173
                                        }
×
NEW
174
                                        return true;
×
175
                                case 161:
NEW
176
                                        return true;
×
177
                                case 162:
NEW
178
                                        return true;
×
179
                                case 310:
NEW
180
                                        if (proxy.BinaryData == null)
×
NEW
181
                                        {
×
NEW
182
                                                proxy.BinaryData = new MemoryStream();
×
NEW
183
                                        }
×
NEW
184
                                        proxy.BinaryData.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
NEW
185
                                        return true;
×
186
                                case 311:
NEW
187
                                        if (proxy.Data == null)
×
NEW
188
                                        {
×
NEW
189
                                                proxy.Data = new MemoryStream();
×
NEW
190
                                        }
×
NEW
191
                                        proxy.Data.Write(this._reader.ValueAsBinaryChunk, 0, this._reader.ValueAsBinaryChunk.Length);
×
NEW
192
                                        return true;
×
193
                                default:
NEW
194
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.ProxyObject]);
×
195
                        }
NEW
196
                }
×
197

198
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
199
                {
19,350✔
200
                        switch (this._reader.Code)
19,350✔
201
                        {
202
                                default:
203
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
19,350✔
204
                        }
205
                }
19,350✔
206

207
                private bool readPlotSettings(CadTemplate template, DxfMap map)
208
                {
28,304✔
209
                        switch (this._reader.Code)
28,304✔
210
                        {
211
                                default:
212
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
28,304✔
213
                        }
214
                }
28,304✔
215

216
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
217
                {
1,728✔
218
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
1,728✔
219
                        EvaluationGraph evGraph = tmp.CadObject;
1,728✔
220

221
                        switch (this._reader.Code)
1,728✔
222
                        {
223
                                case 91:
224
                                        while (this._reader.Code == 91)
2,808✔
225
                                        {
2,592✔
226
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,592✔
227
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,592✔
228

229
                                                node.Index = this._reader.ValueAsInt;
2,592✔
230

231
                                                this._reader.ExpectedCode(93);
2,592✔
232
                                                node.Flags = this._reader.ValueAsInt;
2,592✔
233

234
                                                this._reader.ExpectedCode(95);
2,592✔
235
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,592✔
236

237
                                                this._reader.ExpectedCode(360);
2,592✔
238
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,592✔
239

240
                                                this._reader.ExpectedCode(92);
2,592✔
241
                                                node.Data1 = this._reader.ValueAsInt;
2,592✔
242
                                                this._reader.ExpectedCode(92);
2,592✔
243
                                                node.Data2 = this._reader.ValueAsInt;
2,592✔
244
                                                this._reader.ExpectedCode(92);
2,592✔
245
                                                node.Data3 = this._reader.ValueAsInt;
2,592✔
246
                                                this._reader.ExpectedCode(92);
2,592✔
247
                                                node.Data4 = this._reader.ValueAsInt;
2,592✔
248

249
                                                this._reader.ReadNext();
2,592✔
250

251
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,592✔
252
                                        }
2,592✔
253

254
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
255
                                case 92:
256
                                        //Edges
257
                                        while (this._reader.Code == 92)
2,376✔
258
                                        {
2,160✔
259
                                                this._reader.ExpectedCode(93);
2,160✔
260
                                                this._reader.ExpectedCode(94);
2,160✔
261
                                                this._reader.ExpectedCode(91);
2,160✔
262
                                                this._reader.ExpectedCode(91);
2,160✔
263
                                                this._reader.ExpectedCode(92);
2,160✔
264
                                                this._reader.ExpectedCode(92);
2,160✔
265
                                                this._reader.ExpectedCode(92);
2,160✔
266
                                                this._reader.ExpectedCode(92);
2,160✔
267
                                                this._reader.ExpectedCode(92);
2,160✔
268

269
                                                this._reader.ReadNext();
2,160✔
270
                                        }
2,160✔
271

272
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
273
                                default:
274
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
1,296✔
275
                        }
276
                }
1,728✔
277

278
                private bool readLayout(CadTemplate template, DxfMap map)
279
                {
57,610✔
280
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
57,610✔
281

282
                        switch (this._reader.Code)
57,610✔
283
                        {
284
                                case 330:
285
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,788✔
286
                                        return true;
1,788✔
287
                                case 331:
288
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
866✔
289
                                        return true;
866✔
290
                                default:
291
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
54,956✔
292
                                        {
28,304✔
293
                                                return this.readPlotSettings(template, map);
28,304✔
294
                                        }
295
                                        return true;
26,652✔
296
                        }
297
                }
57,610✔
298

299
                private bool readGroup(CadTemplate template, DxfMap map)
300
                {
5,616✔
301
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,616✔
302

303
                        switch (this._reader.Code)
5,616✔
304
                        {
305
                                case 70:
306
                                        return true;
432✔
307
                                case 340:
308
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,592✔
309
                                        return true;
2,592✔
310
                                default:
311
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,592✔
312
                        }
313
                }
5,616✔
314

315
                private bool readGeoData(CadTemplate template, DxfMap map)
316
                {
102✔
317
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
318

319
                        switch (this._reader.Code)
102✔
320
                        {
321
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
322
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
323
                                                tmp.CadObject.ReferencePoint.X,
1✔
324
                                                this._reader.ValueAsDouble,
1✔
325
                                                tmp.CadObject.ReferencePoint.Z
1✔
326
                                                );
1✔
327
                                        return true;
1✔
328
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
329
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
330
                                                this._reader.ValueAsDouble,
1✔
331
                                                tmp.CadObject.ReferencePoint.Y,
1✔
332
                                                tmp.CadObject.ReferencePoint.Z
1✔
333
                                                );
1✔
334
                                        return true;
1✔
335
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
336
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
337
                                                tmp.CadObject.ReferencePoint.X,
1✔
338
                                                tmp.CadObject.ReferencePoint.Y,
1✔
339
                                                this._reader.ValueAsDouble
1✔
340
                                                );
1✔
341
                                        return true;
1✔
342
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
343
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
344
                                        return true;
1✔
345
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
346
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
347
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
348
                                        return true;
1✔
349
                                // Number of Geo-Mesh points
350
                                case 93:
351
                                        var npts = this._reader.ValueAsInt;
3✔
352
                                        for (int i = 0; i < npts; i++)
54✔
353
                                        {
24✔
354
                                                this._reader.ReadNext();
24✔
355
                                                double sourceX = this._reader.ValueAsDouble;
24✔
356
                                                this._reader.ReadNext();
24✔
357
                                                double sourceY = this._reader.ValueAsDouble;
24✔
358

359
                                                this._reader.ReadNext();
24✔
360
                                                double destX = this._reader.ValueAsDouble;
24✔
361
                                                this._reader.ReadNext();
24✔
362
                                                double destY = this._reader.ValueAsDouble;
24✔
363

364
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
365
                                                {
24✔
366
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
367
                                                        Destination = new CSMath.XY(destX, destY)
24✔
368
                                                });
24✔
369
                                        }
24✔
370
                                        return true;
3✔
371
                                // Number of Geo-Mesh points
372
                                case 96:
373
                                        var nfaces = this._reader.ValueAsInt;
2✔
374
                                        for (int i = 0; i < nfaces; i++)
4!
375
                                        {
×
376
                                                this._reader.ReadNext();
×
377
                                                Debug.Assert(this._reader.Code == 97);
×
378
                                                int index1 = this._reader.ValueAsInt;
×
379
                                                this._reader.ReadNext();
×
380
                                                Debug.Assert(this._reader.Code == 98);
×
381
                                                int index2 = this._reader.ValueAsInt;
×
382
                                                this._reader.ReadNext();
×
383
                                                Debug.Assert(this._reader.Code == 99);
×
384
                                                int index3 = this._reader.ValueAsInt;
×
385

386
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
387
                                                {
×
388
                                                        Index1 = index1,
×
389
                                                        Index2 = index2,
×
390
                                                        Index3 = index3
×
391
                                                });
×
392
                                        }
×
393
                                        return true;
2✔
394
                                case 303:
395
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
396
                                        return true;
13✔
397
                                //Obsolete codes for version GeoDataVersion.R2009
398
                                case 3:
399
                                case 4:
400
                                case 14:
401
                                case 24:
402
                                case 15:
403
                                case 25:
404
                                case 43:
405
                                case 44:
406
                                case 45:
407
                                case 94:
408
                                case 293:
409
                                case 16:
410
                                case 26:
411
                                case 17:
412
                                case 27:
413
                                case 54:
414
                                case 140:
415
                                case 304:
416
                                case 292:
417
                                        return true;
19✔
418
                                default:
419
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
420
                        }
421
                }
102✔
422

423
                private bool readScale(CadTemplate template, DxfMap map)
424
                {
66,378✔
425
                        switch (this._reader.Code)
66,378✔
426
                        {
427
                                // Undocumented codes
428
                                case 70:
429
                                        //Always 0
430
                                        return true;
7,398✔
431
                                default:
432
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
58,980✔
433
                        }
434
                }
66,378✔
435

436
                private bool readTableContent(CadTemplate template, DxfMap map)
437
                {
999,648✔
438
                        switch (this._reader.Code)
999,648✔
439
                        {
440
                                default:
441
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.TableContent]);
999,648✔
442
                        }
443
                }
999,648✔
444

445
                private bool readVisualStyle(CadTemplate template, DxfMap map)
446
                {
389,764✔
447
                        switch (this._reader.Code)
389,764✔
448
                        {
449
                                // Undocumented codes
450
                                case 176:
451
                                case 177:
452
                                case 420:
453
                                        return true;
133,826✔
454
                                default:
455
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
255,938✔
456
                        }
457
                }
389,764✔
458

459
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
460
                {
4,536✔
461
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,536✔
462
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,536✔
463

464
                        switch (this._reader.Code)
4,536✔
465
                        {
466
                                case 10:
467
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
432✔
468
                                        return true;
432✔
469
                                case 20:
470
                                        var pt = filter.BoundaryPoints.LastOrDefault();
432✔
471
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
432✔
472
                                        return true;
432✔
473
                                case 40:
474
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
432!
475
                                        {
×
476
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
477
                                                tmp.HasFrontPlane = true;
×
478
                                        }
×
479

480
                                        double[] array = new double[16]
432✔
481
                                        {
432✔
482
                                                0.0, 0.0, 0.0, 0.0,
432✔
483
                                                0.0, 0.0, 0.0, 0.0,
432✔
484
                                                0.0, 0.0, 0.0, 0.0,
432✔
485
                                                0.0, 0.0, 0.0, 1.0
432✔
486
                                        };
432✔
487

488
                                        for (int i = 0; i < 12; i++)
11,232✔
489
                                        {
5,184✔
490
                                                array[i] = this._reader.ValueAsDouble;
5,184✔
491

492
                                                if (i < 11)
5,184✔
493
                                                {
4,752✔
494
                                                        this._reader.ReadNext();
4,752✔
495
                                                }
4,752✔
496
                                        }
5,184✔
497

498
                                        if (tmp.InsertTransformRead)
432!
499
                                        {
×
500
                                                filter.InsertTransform = new Matrix4(array);
×
501
                                                tmp.InsertTransformRead = true;
×
502
                                        }
×
503
                                        else
504
                                        {
432✔
505
                                                filter.InverseInsertTransform = new Matrix4(array);
432✔
506
                                        }
432✔
507

508
                                        return true;
432✔
509
                                case 73:
510
                                default:
511
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,240✔
512
                        }
513
                }
4,536✔
514

515
                private bool readXRecord(CadTemplate template, DxfMap map)
516
                {
67,160✔
517
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
67,160✔
518

519
                        switch (this._reader.Code)
67,160✔
520
                        {
521
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
17,474✔
522
                                        this.readXRecordEntries(tmp);
17,474✔
523
                                        return true;
17,474✔
524
                                default:
525
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
49,686✔
526
                        }
527
                }
67,160✔
528

529
                private void readXRecordEntries(CadXRecordTemplate template)
530
                {
17,474✔
531
                        this._reader.ReadNext();
17,474✔
532

533
                        while (this._reader.DxfCode != DxfCode.Start)
935,644✔
534
                        {
918,170✔
535
                                switch (this._reader.GroupCodeValue)
918,170!
536
                                {
537
                                        case GroupCodeValueType.Handle:
538
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
539
                                                break;
×
540
                                        default:
541
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
918,170✔
542
                                                break;
918,170✔
543
                                }
544

545
                                this._reader.ReadNext();
918,170✔
546
                        }
918,170✔
547
                }
17,474✔
548

549
                private bool readBookColor(CadTemplate template, DxfMap map)
550
                {
1,548✔
551
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,548✔
552
                        BookColor color = tmp.CadObject as BookColor;
1,548✔
553

554
                        switch (this._reader.Code)
1,548✔
555
                        {
556
                                case 430:
557
                                        color.Name = this._reader.ValueAsString;
180✔
558
                                        return true;
180✔
559
                                default:
560
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,368✔
561
                        }
562
                }
1,548✔
563

564
                private bool readDictionary(CadTemplate template, DxfMap map)
565
                {
208,835✔
566
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
208,835✔
567
                        CadDictionary cadDictionary = tmp.CadObject;
208,835✔
568

569
                        switch (this._reader.Code)
208,835✔
570
                        {
571
                                case 280:
572
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,249✔
573
                                        return true;
15,249✔
574
                                case 281:
575
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
22,594✔
576
                                        return true;
22,594✔
577
                                case 3:
578
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
46,834✔
579
                                        return true;
46,834✔
580
                                case 350: // Soft-owner ID/handle to entry object 
581
                                case 360: // Hard-owner ID/handle to entry object
582
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
46,834✔
583
                                        return true;
46,834✔
584
                                default:
585
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
77,324✔
586
                        }
587
                }
208,835✔
588

589
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
590
                {
1,962✔
591
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,962✔
592

593
                        switch (this._reader.Code)
1,962✔
594
                        {
595
                                case 340:
596
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
218✔
597
                                        return true;
218✔
598
                                default:
599
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,744!
600
                                        {
1,744✔
601
                                                return this.readDictionary(template, map);
1,744✔
602
                                        }
603
                                        return true;
×
604
                        }
605
                }
1,962✔
606

607
                private CadTemplate readSortentsTable()
608
                {
648✔
609
                        SortEntitiesTable sortTable = new SortEntitiesTable();
648✔
610
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
648✔
611

612
                        //Jump the 0 marker
613
                        this._reader.ReadNext();
648✔
614

615
                        this.readCommonObjectData(template);
648✔
616

617
                        System.Diagnostics.Debug.Assert(DxfSubclassMarker.SortentsTable == this._reader.ValueAsString);
648✔
618

619
                        //Jump the 100 marker
620
                        this._reader.ReadNext();
648✔
621

622
                        (ulong?, ulong?) pair = (null, null);
648✔
623

624
                        while (this._reader.DxfCode != DxfCode.Start)
4,752✔
625
                        {
4,104✔
626
                                switch (this._reader.Code)
4,104!
627
                                {
628
                                        case 5:
629
                                                pair.Item1 = this._reader.ValueAsHandle;
1,728✔
630
                                                break;
1,728✔
631
                                        case 330:
632
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
648✔
633
                                                break;
648✔
634
                                        case 331:
635
                                                pair.Item2 = this._reader.ValueAsHandle;
1,728✔
636
                                                break;
1,728✔
637
                                        default:
638
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
639
                                                break;
×
640
                                }
641

642
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,104✔
643
                                {
1,728✔
644
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,728✔
645
                                        pair = (null, null);
1,728✔
646
                                }
1,728✔
647

648
                                this._reader.ReadNext();
4,104✔
649
                        }
4,104✔
650

651
                        return template;
648✔
652
                }
648✔
653
        }
654
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc