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

DomCR / ACadSharp / 16808321049

07 Aug 2025 03:06PM UTC coverage: 78.476% (+3.3%) from 75.198%
16808321049

push

github

web-flow
Merge pull request #726 from DomCR/issue-719_xclip-SPATIAL_FILTER

issue-719 SPATIAL_FILTER

6487 of 8986 branches covered (72.19%)

Branch coverage included in aggregate %.

181 of 243 new or added lines in 13 files covered. (74.49%)

171 existing lines in 3 files now uncovered.

25243 of 31447 relevant lines covered (80.27%)

105162.02 hits per line

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

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

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

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

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

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

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

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

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

46
                                if (template == null)
67,091✔
47
                                        continue;
412✔
48

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

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

103
                                        this._reader.ReadNext();
8,184✔
104

105
                                        do
106
                                        {
427,188✔
107
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
427,188✔
108
                                                {
44,896✔
109
                                                        this.readCommonCodes(unknownEntityTemplate, out bool isExtendedData, map);
44,896✔
110
                                                        if (isExtendedData)
44,896✔
111
                                                                continue;
72✔
112
                                                }
44,824✔
113

114
                                                this._reader.ReadNext();
427,116✔
115
                                        }
427,116✔
116
                                        while (this._reader.DxfCode != DxfCode.Start);
427,188✔
117

118
                                        return unknownEntityTemplate;
8,184✔
119
                        }
120
                }
67,091✔
121

122
                protected CadTemplate readObjectCodes<T>(CadTemplate template, ReadObjectDelegate<T> readObject)
123
                        where T : CadObject
124
                {
58,259✔
125
                        this._reader.ReadNext();
58,259✔
126

127
                        DxfMap map = DxfMap.Create<T>();
58,259✔
128

129
                        while (this._reader.DxfCode != DxfCode.Start)
1,880,536✔
130
                        {
1,822,277✔
131
                                if (!readObject(template, map))
1,822,277✔
132
                                {
1,066,541✔
133
                                        this.readCommonCodes(template, out bool isExtendedData, map);
1,066,541✔
134
                                        if (isExtendedData)
1,066,541✔
135
                                                continue;
5,533✔
136
                                }
1,061,008✔
137

138
                                if (this._reader.DxfCode != DxfCode.Start)
1,816,744✔
139
                                        this._reader.ReadNext();
1,799,054✔
140
                        }
1,816,744✔
141

142
                        return template;
58,259✔
143
                }
58,259✔
144

145
                private bool readObjectSubclassMap(CadTemplate template, DxfMap map)
146
                {
19,350✔
147
                        switch (this._reader.Code)
19,350✔
148
                        {
149
                                default:
150
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
19,350✔
151
                        }
152
                }
19,350✔
153

154
                private bool readPlotSettings(CadTemplate template, DxfMap map)
155
                {
28,304✔
156
                        switch (this._reader.Code)
28,304✔
157
                        {
158
                                default:
159
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.PlotSettings]);
28,304✔
160
                        }
161
                }
28,304✔
162

163
                private bool readEvaluationGraph(CadTemplate template, DxfMap map)
164
                {
1,728✔
165
                        CadEvaluationGraphTemplate tmp = template as CadEvaluationGraphTemplate;
1,728✔
166
                        EvaluationGraph evGraph = tmp.CadObject;
1,728✔
167

168
                        switch (this._reader.Code)
1,728✔
169
                        {
170
                                case 91:
171
                                        while (this._reader.Code == 91)
2,808✔
172
                                        {
2,592✔
173
                                                GraphNodeTemplate nodeTemplate = new GraphNodeTemplate();
2,592✔
174
                                                EvaluationGraph.Node node = nodeTemplate.Node;
2,592✔
175

176
                                                node.Index = this._reader.ValueAsInt;
2,592✔
177

178
                                                this._reader.ExpectedCode(93);
2,592✔
179
                                                node.Flags = this._reader.ValueAsInt;
2,592✔
180

181
                                                this._reader.ExpectedCode(95);
2,592✔
182
                                                node.NextNodeIndex = this._reader.ValueAsInt;
2,592✔
183

184
                                                this._reader.ExpectedCode(360);
2,592✔
185
                                                nodeTemplate.ExpressionHandle = this._reader.ValueAsHandle;
2,592✔
186

187
                                                this._reader.ExpectedCode(92);
2,592✔
188
                                                node.Data1 = this._reader.ValueAsInt;
2,592✔
189
                                                this._reader.ExpectedCode(92);
2,592✔
190
                                                node.Data2 = this._reader.ValueAsInt;
2,592✔
191
                                                this._reader.ExpectedCode(92);
2,592✔
192
                                                node.Data3 = this._reader.ValueAsInt;
2,592✔
193
                                                this._reader.ExpectedCode(92);
2,592✔
194
                                                node.Data4 = this._reader.ValueAsInt;
2,592✔
195

196
                                                this._reader.ReadNext();
2,592✔
197

198
                                                tmp.NodeTemplates.Add(nodeTemplate);
2,592✔
199
                                        }
2,592✔
200

201
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
202
                                case 92:
203
                                        //Edges
204
                                        while (this._reader.Code == 92)
2,376✔
205
                                        {
2,160✔
206
                                                this._reader.ExpectedCode(93);
2,160✔
207
                                                this._reader.ExpectedCode(94);
2,160✔
208
                                                this._reader.ExpectedCode(91);
2,160✔
209
                                                this._reader.ExpectedCode(91);
2,160✔
210
                                                this._reader.ExpectedCode(92);
2,160✔
211
                                                this._reader.ExpectedCode(92);
2,160✔
212
                                                this._reader.ExpectedCode(92);
2,160✔
213
                                                this._reader.ExpectedCode(92);
2,160✔
214
                                                this._reader.ExpectedCode(92);
2,160✔
215

216
                                                this._reader.ReadNext();
2,160✔
217
                                        }
2,160✔
218

219
                                        return this.checkObjectEnd(template, map, this.readEvaluationGraph);
216✔
220
                                default:
221
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.EvalGraph]);
1,296✔
222
                        }
223
                }
1,728✔
224

225
                private bool readLayout(CadTemplate template, DxfMap map)
226
                {
57,610✔
227
                        CadLayoutTemplate tmp = template as CadLayoutTemplate;
57,610✔
228

229
                        switch (this._reader.Code)
57,610✔
230
                        {
231
                                case 330:
232
                                        tmp.PaperSpaceBlockHandle = this._reader.ValueAsHandle;
1,788✔
233
                                        return true;
1,788✔
234
                                case 331:
235
                                        tmp.LasActiveViewportHandle = (this._reader.ValueAsHandle);
866✔
236
                                        return true;
866✔
237
                                default:
238
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Layout]))
54,956✔
239
                                        {
28,304✔
240
                                                return this.readPlotSettings(template, map);
28,304✔
241
                                        }
242
                                        return true;
26,652✔
243
                        }
244
                }
57,610✔
245

246
                private bool readGroup(CadTemplate template, DxfMap map)
247
                {
5,616✔
248
                        CadGroupTemplate tmp = template as CadGroupTemplate;
5,616✔
249

250
                        switch (this._reader.Code)
5,616✔
251
                        {
252
                                case 70:
253
                                        return true;
432✔
254
                                case 340:
255
                                        tmp.Handles.Add(this._reader.ValueAsHandle);
2,592✔
256
                                        return true;
2,592✔
257
                                default:
258
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
2,592✔
259
                        }
260
                }
5,616✔
261

262
                private bool readGeoData(CadTemplate template, DxfMap map)
263
                {
102✔
264
                        CadGeoDataTemplate tmp = template as CadGeoDataTemplate;
102✔
265

266
                        switch (this._reader.Code)
102✔
267
                        {
268
                                case 40 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
269
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
270
                                                tmp.CadObject.ReferencePoint.X,
1✔
271
                                                this._reader.ValueAsDouble,
1✔
272
                                                tmp.CadObject.ReferencePoint.Z
1✔
273
                                                );
1✔
274
                                        return true;
1✔
275
                                case 41 when tmp.CadObject.Version == GeoDataVersion.R2009:
2✔
276
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
277
                                                this._reader.ValueAsDouble,
1✔
278
                                                tmp.CadObject.ReferencePoint.Y,
1✔
279
                                                tmp.CadObject.ReferencePoint.Z
1✔
280
                                                );
1✔
281
                                        return true;
1✔
282
                                case 42 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
283
                                        tmp.CadObject.ReferencePoint = new CSMath.XYZ(
1✔
284
                                                tmp.CadObject.ReferencePoint.X,
1✔
285
                                                tmp.CadObject.ReferencePoint.Y,
1✔
286
                                                this._reader.ValueAsDouble
1✔
287
                                                );
1✔
288
                                        return true;
1✔
289
                                case 46 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
290
                                        tmp.CadObject.HorizontalUnitScale = this._reader.ValueAsDouble;
1✔
291
                                        return true;
1✔
292
                                case 52 when tmp.CadObject.Version == GeoDataVersion.R2009:
1✔
293
                                        double angle = System.Math.PI / 2.0 - this._reader.ValueAsAngle;
1✔
294
                                        tmp.CadObject.NorthDirection = new CSMath.XY(Math.Cos(angle), Math.Sin(angle));
1✔
295
                                        return true;
1✔
296
                                // Number of Geo-Mesh points
297
                                case 93:
298
                                        var npts = this._reader.ValueAsInt;
3✔
299
                                        for (int i = 0; i < npts; i++)
54✔
300
                                        {
24✔
301
                                                this._reader.ReadNext();
24✔
302
                                                double sourceX = this._reader.ValueAsDouble;
24✔
303
                                                this._reader.ReadNext();
24✔
304
                                                double sourceY = this._reader.ValueAsDouble;
24✔
305

306
                                                this._reader.ReadNext();
24✔
307
                                                double destX = this._reader.ValueAsDouble;
24✔
308
                                                this._reader.ReadNext();
24✔
309
                                                double destY = this._reader.ValueAsDouble;
24✔
310

311
                                                tmp.CadObject.Points.Add(new GeoData.GeoMeshPoint
24✔
312
                                                {
24✔
313
                                                        Source = new CSMath.XY(sourceX, sourceY),
24✔
314
                                                        Destination = new CSMath.XY(destX, destY)
24✔
315
                                                });
24✔
316
                                        }
24✔
317
                                        return true;
3✔
318
                                // Number of Geo-Mesh points
319
                                case 96:
320
                                        var nfaces = this._reader.ValueAsInt;
2✔
321
                                        for (int i = 0; i < nfaces; i++)
4!
322
                                        {
×
323
                                                this._reader.ReadNext();
×
324
                                                Debug.Assert(this._reader.Code == 97);
×
325
                                                int index1 = this._reader.ValueAsInt;
×
326
                                                this._reader.ReadNext();
×
327
                                                Debug.Assert(this._reader.Code == 98);
×
328
                                                int index2 = this._reader.ValueAsInt;
×
329
                                                this._reader.ReadNext();
×
330
                                                Debug.Assert(this._reader.Code == 99);
×
331
                                                int index3 = this._reader.ValueAsInt;
×
332

333
                                                tmp.CadObject.Faces.Add(new GeoData.GeoMeshFace
×
334
                                                {
×
335
                                                        Index1 = index1,
×
336
                                                        Index2 = index2,
×
337
                                                        Index3 = index3
×
338
                                                });
×
339
                                        }
×
340
                                        return true;
2✔
341
                                case 303:
342
                                        tmp.CadObject.CoordinateSystemDefinition += this._reader.ValueAsString;
13✔
343
                                        return true;
13✔
344
                                //Obsolete codes for version GeoDataVersion.R2009
345
                                case 3:
346
                                case 4:
347
                                case 14:
348
                                case 24:
349
                                case 15:
350
                                case 25:
351
                                case 43:
352
                                case 44:
353
                                case 45:
354
                                case 94:
355
                                case 293:
356
                                case 16:
357
                                case 26:
358
                                case 17:
359
                                case 27:
360
                                case 54:
361
                                case 140:
362
                                case 304:
363
                                case 292:
364
                                        return true;
19✔
365
                                default:
366
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
60✔
367
                        }
368
                }
102✔
369

370
                private bool readScale(CadTemplate template, DxfMap map)
371
                {
66,378✔
372
                        switch (this._reader.Code)
66,378✔
373
                        {
374
                                // Undocumented codes
375
                                case 70:
376
                                        //Always 0
377
                                        return true;
7,398✔
378
                                default:
379
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Scale]);
58,980✔
380
                        }
381
                }
66,378✔
382

383
                private bool readTableContent(CadTemplate template, DxfMap map)
384
                {
999,648✔
385
                        switch (this._reader.Code)
999,648✔
386
                        {
387
                                default:
388
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.TableContent]);
999,648✔
389
                        }
390
                }
999,648✔
391

392
                private bool readVisualStyle(CadTemplate template, DxfMap map)
393
                {
389,764✔
394
                        switch (this._reader.Code)
389,764✔
395
                        {
396
                                // Undocumented codes
397
                                case 176:
398
                                case 177:
399
                                case 420:
400
                                        return true;
133,826✔
401
                                default:
402
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.VisualStyle]);
255,938✔
403
                        }
404
                }
389,764✔
405

406
                private bool readSpatialFilter(CadTemplate template, DxfMap map)
407
                {
4,536✔
408
                        CadSpatialFilterTemplate tmp = template as CadSpatialFilterTemplate;
4,536✔
409
                        SpatialFilter filter = tmp.CadObject as SpatialFilter;
4,536✔
410

411
                        switch (this._reader.Code)
4,536✔
412
                        {
413
                                case 10:
414
                                        filter.BoundaryPoints.Add(new CSMath.XY(this._reader.ValueAsDouble, 0));
432✔
415
                                        return true;
432✔
416
                                case 20:
417
                                        var pt = filter.BoundaryPoints.LastOrDefault();
432✔
418
                                        filter.BoundaryPoints.Add(new CSMath.XY(pt.X, this._reader.ValueAsDouble));
432✔
419
                                        return true;
432✔
420
                                case 40:
421
                                        if (filter.ClipFrontPlane && !tmp.HasFrontPlane)
432!
NEW
422
                                        {
×
NEW
423
                                                filter.FrontDistance = this._reader.ValueAsDouble;
×
NEW
424
                                                tmp.HasFrontPlane = true;
×
NEW
425
                                        }
×
426

427
                                        double[] array = new double[16]
432✔
428
                                        {
432✔
429
                                                0.0, 0.0, 0.0, 0.0,
432✔
430
                                                0.0, 0.0, 0.0, 0.0,
432✔
431
                                                0.0, 0.0, 0.0, 0.0,
432✔
432
                                                0.0, 0.0, 0.0, 1.0
432✔
433
                                        };
432✔
434

435
                                        for (int i = 0; i < 12; i++)
11,232✔
436
                                        {
5,184✔
437
                                                array[i] = this._reader.ValueAsDouble;
5,184✔
438

439
                                                if (i < 11)
5,184✔
440
                                                {
4,752✔
441
                                                        this._reader.ReadNext();
4,752✔
442
                                                }
4,752✔
443
                                        }
5,184✔
444

445
                                        if (tmp.InsertTransformRead)
432!
NEW
446
                                        {
×
NEW
447
                                                filter.InsertTransform = new Matrix4(array);
×
NEW
448
                                                tmp.InsertTransformRead = true;
×
NEW
449
                                        }
×
450
                                        else
451
                                        {
432✔
452
                                                filter.InverseInsertTransform = new Matrix4(array);
432✔
453
                                        }
432✔
454

455
                                        return true;
432✔
456
                                case 73:
457
                                default:
458
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.SpatialFilter]);
3,240✔
459
                        }
460
                }
4,536✔
461

462
                private bool readXRecord(CadTemplate template, DxfMap map)
463
                {
67,160✔
464
                        CadXRecordTemplate tmp = template as CadXRecordTemplate;
67,160✔
465

466
                        switch (this._reader.Code)
67,160✔
467
                        {
468
                                case 100 when this._reader.ValueAsString == DxfSubclassMarker.XRecord:
17,474✔
469
                                        this.readXRecordEntries(tmp);
17,474✔
470
                                        return true;
17,474✔
471
                                default:
472
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.XRecord]);
49,686✔
473
                        }
474
                }
67,160✔
475

476
                private void readXRecordEntries(CadXRecordTemplate template)
477
                {
17,474✔
478
                        this._reader.ReadNext();
17,474✔
479

480
                        while (this._reader.DxfCode != DxfCode.Start)
935,644✔
481
                        {
918,170✔
482
                                switch (this._reader.GroupCodeValue)
918,170!
483
                                {
484
                                        case GroupCodeValueType.Handle:
485
                                                template.AddHandleReference(this._reader.Code, this._reader.ValueAsHandle);
×
486
                                                break;
×
487
                                        default:
488
                                                template.CadObject.CreateEntry(this._reader.Code, this._reader.Value);
918,170✔
489
                                                break;
918,170✔
490
                                }
491

492
                                this._reader.ReadNext();
918,170✔
493
                        }
918,170✔
494
                }
17,474✔
495

496
                private bool readBookColor(CadTemplate template, DxfMap map)
497
                {
1,548✔
498
                        CadNonGraphicalObjectTemplate tmp = template as CadNonGraphicalObjectTemplate;
1,548✔
499
                        BookColor color = tmp.CadObject as BookColor;
1,548✔
500

501
                        switch (this._reader.Code)
1,548✔
502
                        {
503
                                case 430:
504
                                        color.Name = this._reader.ValueAsString;
180✔
505
                                        return true;
180✔
506
                                default:
507
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DbColor]);
1,368✔
508
                        }
509
                }
1,548✔
510

511
                private bool readDictionary(CadTemplate template, DxfMap map)
512
                {
208,835✔
513
                        CadDictionaryTemplate tmp = template as CadDictionaryTemplate;
208,835✔
514
                        CadDictionary cadDictionary = tmp.CadObject;
208,835✔
515

516
                        switch (this._reader.Code)
208,835✔
517
                        {
518
                                case 280:
519
                                        cadDictionary.HardOwnerFlag = this._reader.ValueAsBool;
15,249✔
520
                                        return true;
15,249✔
521
                                case 281:
522
                                        cadDictionary.ClonningFlags = (DictionaryCloningFlags)this._reader.Value;
22,594✔
523
                                        return true;
22,594✔
524
                                case 3:
525
                                        tmp.Entries.Add(this._reader.ValueAsString, null);
46,834✔
526
                                        return true;
46,834✔
527
                                case 350: // Soft-owner ID/handle to entry object 
528
                                case 360: // Hard-owner ID/handle to entry object
529
                                        tmp.Entries[tmp.Entries.LastOrDefault().Key] = this._reader.ValueAsHandle;
46,834✔
530
                                        return true;
46,834✔
531
                                default:
532
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dictionary]);
77,324✔
533
                        }
534
                }
208,835✔
535

536
                private bool readDictionaryWithDefault(CadTemplate template, DxfMap map)
537
                {
1,962✔
538
                        CadDictionaryWithDefaultTemplate tmp = template as CadDictionaryWithDefaultTemplate;
1,962✔
539

540
                        switch (this._reader.Code)
1,962✔
541
                        {
542
                                case 340:
543
                                        tmp.DefaultEntryHandle = this._reader.ValueAsHandle;
218✔
544
                                        return true;
218✔
545
                                default:
546
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.DictionaryWithDefault]))
1,744!
547
                                        {
1,744✔
548
                                                return this.readDictionary(template, map);
1,744✔
549
                                        }
550
                                        return true;
×
551
                        }
552
                }
1,962✔
553

554
                private CadTemplate readSortentsTable()
555
                {
648✔
556
                        SortEntitiesTable sortTable = new SortEntitiesTable();
648✔
557
                        CadSortensTableTemplate template = new CadSortensTableTemplate(sortTable);
648✔
558

559
                        //Jump the 0 marker
560
                        this._reader.ReadNext();
648✔
561

562
                        this.readCommonObjectData(template);
648✔
563

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

566
                        //Jump the 100 marker
567
                        this._reader.ReadNext();
648✔
568

569
                        (ulong?, ulong?) pair = (null, null);
648✔
570

571
                        while (this._reader.DxfCode != DxfCode.Start)
4,752✔
572
                        {
4,104✔
573
                                switch (this._reader.Code)
4,104!
574
                                {
575
                                        case 5:
576
                                                pair.Item1 = this._reader.ValueAsHandle;
1,728✔
577
                                                break;
1,728✔
578
                                        case 330:
579
                                                template.BlockOwnerHandle = this._reader.ValueAsHandle;
648✔
580
                                                break;
648✔
581
                                        case 331:
582
                                                pair.Item2 = this._reader.ValueAsHandle;
1,728✔
583
                                                break;
1,728✔
584
                                        default:
585
                                                this._builder.Notify($"Group Code not handled {this._reader.GroupCodeValue} for {typeof(SortEntitiesTable)}, code : {this._reader.Code} | value : {this._reader.ValueAsString}");
×
586
                                                break;
×
587
                                }
588

589
                                if (pair.Item1.HasValue && pair.Item2.HasValue)
4,104✔
590
                                {
1,728✔
591
                                        template.Values.Add((pair.Item1.Value, pair.Item2.Value));
1,728✔
592
                                        pair = (null, null);
1,728✔
593
                                }
1,728✔
594

595
                                this._reader.ReadNext();
4,104✔
596
                        }
4,104✔
597

598
                        return template;
648✔
599
                }
648✔
600
        }
601
}
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