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

DomCR / ACadSharp / 17737836230

15 Sep 2025 03:12PM UTC coverage: 2.092% (-76.2%) from 78.245%
17737836230

push

github

web-flow
Merge pull request #790 from DomCR/addflag-refactor

addflag refactor

141 of 9225 branches covered (1.53%)

Branch coverage included in aggregate %.

0 of 93 new or added lines in 10 files covered. (0.0%)

24910 existing lines in 372 files now uncovered.

724 of 32119 relevant lines covered (2.25%)

5.76 hits per line

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

0.0
/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)
UNCOV
19
                        : base(reader, builder)
×
UNCOV
20
                {
×
UNCOV
21
                }
×
22

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

28
                        //Loop until the section ends
UNCOV
29
                        while (this._reader.ValueAsString != DxfFileToken.EndSection)
×
UNCOV
30
                        {
×
UNCOV
31
                                CadTemplate template = null;
×
32

33
                                try
UNCOV
34
                                {
×
UNCOV
35
                                        template = this.readObject();
×
UNCOV
36
                                }
×
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

UNCOV
48
                                if (template == null)
×
UNCOV
49
                                        continue;
×
50

51
                                //Add the object and the template to the builder
UNCOV
52
                                this._builder.AddTemplate(template);
×
UNCOV
53
                        }
×
UNCOV
54
                }
×
55

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

UNCOV
109
                                        this._reader.ReadNext();
×
110

111
                                        do
UNCOV
112
                                        {
×
UNCOV
113
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
×
UNCOV
114
                                                {
×
UNCOV
115
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
×
UNCOV
116
                                                        if (isExtendedData)
×
UNCOV
117
                                                                continue;
×
UNCOV
118
                                                }
×
119

UNCOV
120
                                                this._reader.ReadNext();
×
UNCOV
121
                                        }
×
UNCOV
122
                                        while (this._reader.DxfCode != DxfCode.Start);
×
123

UNCOV
124
                                        return unknownEntityTemplate;
×
125
                        }
UNCOV
126
                }
×
127

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

UNCOV
133
                        DxfMap map = DxfMap.Create<T>();
×
134

UNCOV
135
                        while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
136
                        {
×
UNCOV
137
                                if (!readObject(template, map))
×
UNCOV
138
                                {
×
UNCOV
139
                                        this.readCommonCodes(template, out bool isExtendedData, map);
×
UNCOV
140
                                        if (isExtendedData)
×
UNCOV
141
                                                continue;
×
UNCOV
142
                                }
×
143

UNCOV
144
                                if (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
145
                                        this._reader.ReadNext();
×
UNCOV
146
                        }
×
147

UNCOV
148
                        return template;
×
UNCOV
149
                }
×
150

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

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

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

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

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

UNCOV
221
                        switch (this._reader.Code)
×
222
                        {
223
                                case 91:
UNCOV
224
                                        while (this._reader.Code == 91)
×
UNCOV
225
                                        {
×
UNCOV
226
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
×
UNCOV
227
                                                EvaluationGraph.Node node = nodeTemplate.Node;
×
228

UNCOV
229
                                                node.Index = this._reader.ValueAsInt;
×
230

UNCOV
231
                                                this._reader.ExpectedCode(93);
×
UNCOV
232
                                                node.Flags = this._reader.ValueAsInt;
×
233

UNCOV
234
                                                this._reader.ExpectedCode(95);
×
UNCOV
235
                                                node.NextNodeIndex = this._reader.ValueAsInt;
×
236

UNCOV
237
                                                this._reader.ExpectedCode(360);
×
UNCOV
238
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
×
239

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

UNCOV
249
                                                this._reader.ReadNext();
×
250

UNCOV
251
                                                tmp.NodeTemplates.Add(nodeTemplate);
×
UNCOV
252
                                        }
×
253

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

UNCOV
269
                                                this._reader.ReadNext();
×
UNCOV
270
                                        }
×
271

UNCOV
272
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
×
273
                                default:
UNCOV
274
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
×
275
                        }
UNCOV
276
                }
×
277

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

UNCOV
282
                        switch (this._reader.Code)
×
283
                        {
284
                                case 330:
UNCOV
285
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
×
UNCOV
286
                                        return true;
×
287
                                case 331:
UNCOV
288
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
×
UNCOV
289
                                        return true;
×
290
                                default:
UNCOV
291
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
×
UNCOV
292
                                        {
×
UNCOV
293
                                                return this.readPlotSettings(template, map);
×
294
                                        }
UNCOV
295
                                        return true;
×
296
                        }
UNCOV
297
                }
×
298

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

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

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

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

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

UNCOV
364
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
×
UNCOV
365
                                                {
×
UNCOV
366
                                                        Source = new CSMath.XY(sourceX, sourceY),
×
UNCOV
367
                                                        Destination = new CSMath.XY(destX, destY)
×
UNCOV
368
                                                });
×
UNCOV
369
                                        }
×
UNCOV
370
                                        return true;
×
371
                                // Number of Geo-Mesh points
372
                                case 96:
UNCOV
373
                                        var nfaces = this._reader.ValueAsInt;
×
UNCOV
374
                                        for (int i = 0; i < nfaces; i++)
×
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
                                        }
×
UNCOV
393
                                        return true;
×
394
                                case 303:
UNCOV
395
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
×
UNCOV
396
                                        return true;
×
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:
UNCOV
417
                                        return true;
×
418
                                default:
UNCOV
419
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
420
                        }
UNCOV
421
                }
×
422

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

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

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

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

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

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

UNCOV
488
                                        for (int i = 0; i < 12; i++)
×
UNCOV
489
                                        {
×
UNCOV
490
                                                array[i] = this._reader.ValueAsDouble;
×
491

UNCOV
492
                                                if (i < 11)
×
UNCOV
493
                                                {
×
UNCOV
494
                                                        this._reader.ReadNext();
×
UNCOV
495
                                                }
×
UNCOV
496
                                        }
×
497

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

UNCOV
508
                                        return true;
×
509
                                case 73:
510
                                default:
UNCOV
511
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
×
512
                        }
UNCOV
513
                }
×
514

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

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

529
                private void readXRecordEntries(CadXRecordTemplate template)
UNCOV
530
                {
×
UNCOV
531
                        this._reader.ReadNext();
×
532

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

UNCOV
545
                                this._reader.ReadNext();
×
UNCOV
546
                        }
×
UNCOV
547
                }
×
548

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

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

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

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

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

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

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

612
                        //Jump the 0 marker
UNCOV
613
                        this._reader.ReadNext();
×
614

UNCOV
615
                        this.readCommonObjectData(template);
×
616

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

619
                        //Jump the 100 marker
UNCOV
620
                        this._reader.ReadNext();
×
621

UNCOV
622
                        (ulong?, ulong?) pair = (null, null);
×
623

UNCOV
624
                        while (this._reader.DxfCode != DxfCode.Start)
×
UNCOV
625
                        {
×
UNCOV
626
                                switch (this._reader.Code)
×
627
                                {
628
                                        case 5:
UNCOV
629
                                                pair.Item1 = this._reader.ValueAsHandle;
×
UNCOV
630
                                                break;
×
631
                                        case 330:
UNCOV
632
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
×
UNCOV
633
                                                break;
×
634
                                        case 331:
UNCOV
635
                                                pair.Item2 = this._reader.ValueAsHandle;
×
UNCOV
636
                                                break;
×
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

UNCOV
642
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
×
UNCOV
643
                                {
×
UNCOV
644
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
×
UNCOV
645
                                        pair = (null, null);
×
UNCOV
646
                                }
×
647

UNCOV
648
                                this._reader.ReadNext();
×
UNCOV
649
                        }
×
650

UNCOV
651
                        return template;
×
UNCOV
652
                }
×
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