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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

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

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

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

18
                protected readonly IDxfStreamReader _reader;
19
                protected readonly DxfDocumentBuilder _builder;
20

21
                public DxfSectionReaderBase(IDxfStreamReader reader, DxfDocumentBuilder builder)
×
22
                {
×
23
                        this._reader = reader;
×
24
                        this._builder = builder;
×
25
                }
×
26

27
                public abstract void Read();
28

29
                protected void readCommonObjectData(out string name, out ulong handle, out ulong? ownerHandle, out ulong? xdictHandle, out List<ulong> reactors)
30
                {
×
31
                        name = null;
×
32
                        handle = 0;
×
33
                        ownerHandle = null;
×
34
                        xdictHandle = null;
×
35
                        reactors = new List<ulong>();
×
36

37
                        if (this._reader.DxfCode == DxfCode.Start
×
38
                                        || this._reader.DxfCode == DxfCode.Subclass)
×
39
                                this._reader.ReadNext();
×
40

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

73
                                this._reader.ReadNext();
×
74
                        }
×
75
                }
×
76

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

105
                                this._reader.ReadNext();
×
106
                        }
×
107
                }
×
108

109
                protected void readCommonCodes(CadTemplate template, out bool isExtendedData, DxfMap map = null)
110
                {
×
111
                        isExtendedData = false;
×
112

113
                        switch (this._reader.Code)
×
114
                        {
115
                                //Handle
116
                                case 5:
117
                                        template.CadObject.Handle = this._reader.ValueAsHandle;
×
118
                                        break;
×
119
                                //Check with mapper
120
                                case 100:
121
                                        if (map != null && !map.SubClasses.ContainsKey(this._reader.ValueAsString))
×
122
                                                this._builder.Notify($"[{template.CadObject.ObjectName}] Unidentified subclass {this._reader.ValueAsString}", NotificationType.Warning);
×
123
                                        break;
×
124
                                //Start of application - defined group
125
                                case 102:
126
                                        this.readDefinedGroups(template);
×
127
                                        break;
×
128
                                //Soft - pointer ID / handle to owner BLOCK_RECORD object
129
                                case 330:
130
                                        template.OwnerHandle = this._reader.ValueAsHandle;
×
131
                                        break;
×
132
                                case 1001:
133
                                        isExtendedData = true;
×
134
                                        this.readExtendedData(template.EDataTemplateByAppName);
×
135
                                        break;
×
136
                                default:
137
                                        this._builder.Notify($"[{template.CadObject.SubclassMarker}] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
138
                                        break;
×
139
                        }
140
                }
×
141

142
                protected CadEntityTemplate readEntity()
143
                {
×
144
                        switch (this._reader.ValueAsString)
×
145
                        {
146
                                case DxfFileToken.EntityAttribute:
147
                                        return this.readEntityCodes<AttributeEntity>(new CadAttributeTemplate(new AttributeEntity()), this.readAttributeDefinition);
×
148
                                case DxfFileToken.EntityAttributeDefinition:
149
                                        return this.readEntityCodes<AttributeDefinition>(new CadAttributeTemplate(new AttributeDefinition()), this.readAttributeDefinition);
×
150
                                case DxfFileToken.EntityArc:
151
                                        return this.readEntityCodes<Arc>(new CadEntityTemplate<Arc>(), this.readArc);
×
152
                                case DxfFileToken.EntityCircle:
153
                                        return this.readEntityCodes<Circle>(new CadEntityTemplate<Circle>(), this.readEntitySubclassMap);
×
154
                                case DxfFileToken.EntityDimension:
155
                                        return this.readEntityCodes<Dimension>(new CadDimensionTemplate(), this.readDimension);
×
156
                                case DxfFileToken.Entity3DFace:
157
                                        return this.readEntityCodes<Face3D>(new CadEntityTemplate<Face3D>(), this.readEntitySubclassMap);
×
158
                                case DxfFileToken.EntityEllipse:
159
                                        return this.readEntityCodes<Ellipse>(new CadEntityTemplate<Ellipse>(), this.readEntitySubclassMap);
×
160
                                case DxfFileToken.EntityLeader:
161
                                        return this.readEntityCodes<Leader>(new CadLeaderTemplate(), this.readLeader);
×
162
                                case DxfFileToken.EntityLine:
163
                                        return this.readEntityCodes<Line>(new CadEntityTemplate<Line>(), this.readEntitySubclassMap);
×
164
                                case DxfFileToken.EntityLwPolyline:
165
                                        return this.readEntityCodes<LwPolyline>(new CadEntityTemplate<LwPolyline>(), this.readLwPolyline);
×
166
                                case DxfFileToken.EntityMesh:
167
                                        return this.readEntityCodes<Mesh>(new CadMeshTemplate(), this.readMesh);
×
168
                                case DxfFileToken.EntityHatch:
169
                                        return this.readEntityCodes<Hatch>(new CadHatchTemplate(), this.readHatch);
×
170
                                case DxfFileToken.EntityInsert:
171
                                        return this.readEntityCodes<Insert>(new CadInsertTemplate(), this.readInsert);
×
172
                                case DxfFileToken.EntityMText:
173
                                        return this.readEntityCodes<MText>(new CadTextEntityTemplate(new MText()), this.readTextEntity);
×
174
                                case DxfFileToken.EntityMLine:
175
                                        return this.readEntityCodes<MLine>(new CadMLineTemplate(), this.readMLine);
×
176
                                case DxfFileToken.EntityPdfUnderlay:
177
                                        return this.readEntityCodes<PdfUnderlay>(new CadPdfUnderlayTemplate(), this.readUnderlayEntity);
×
178
                                case DxfFileToken.EntityPoint:
179
                                        return this.readEntityCodes<Point>(new CadEntityTemplate<Point>(), this.readEntitySubclassMap);
×
180
                                case DxfFileToken.EntityPolyline:
181
                                        return this.readPolyline();
×
182
                                case DxfFileToken.EntityRay:
183
                                        return this.readEntityCodes<Ray>(new CadEntityTemplate<Ray>(), this.readEntitySubclassMap);
×
184
                                case DxfFileToken.EndSequence:
185
                                        return this.readEntityCodes<Seqend>(new CadEntityTemplate<Seqend>(), this.readEntitySubclassMap);
×
186
                                case DxfFileToken.EntitySolid:
187
                                        return this.readEntityCodes<Solid>(new CadEntityTemplate<Solid>(), this.readEntitySubclassMap);
×
188
                                case DxfFileToken.EntityTable:
189
                                        return this.readEntityCodes<TableEntity>(new CadTableEntityTemplate(), this.readTableEntity);
×
190
                                case DxfFileToken.EntityText:
191
                                        return this.readEntityCodes<TextEntity>(new CadTextEntityTemplate(new TextEntity()), this.readTextEntity);
×
192
                                case DxfFileToken.EntityTolerance:
193
                                        return this.readEntityCodes<Tolerance>(new CadToleranceTemplate(new Tolerance()), this.readTolerance);
×
194
                                case DxfFileToken.EntityVertex:
195
                                        return this.readEntityCodes<Entity>(new CadVertexTemplate(), this.readVertex);
×
196
                                case DxfFileToken.EntityViewport:
197
                                        return this.readEntityCodes<Viewport>(new CadViewportTemplate(), this.readViewport);
×
198
                                case DxfFileToken.EntityShape:
199
                                        return this.readEntityCodes<Shape>(new CadShapeTemplate(new Shape()), this.readShape);
×
200
                                case DxfFileToken.EntitySpline:
201
                                        return this.readEntityCodes<Spline>(new CadSplineTemplate(), this.readSpline);
×
202
                                case DxfFileToken.EntityXline:
203
                                        return this.readEntityCodes<XLine>(new CadEntityTemplate<XLine>(), this.readEntitySubclassMap);
×
204
                                default:
205
                                        DxfMap map = DxfMap.Create<Entity>();
×
206
                                        CadUnknownEntityTemplate unknownEntityTemplate = null;
×
207
                                        if (this._builder.DocumentToBuild.Classes.TryGetByName(this._reader.ValueAsString, out Classes.DxfClass dxfClass))
×
208
                                        {
×
209
                                                this._builder.Notify($"Entity not supported read as an UnknownEntity: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
210
                                                unknownEntityTemplate = new CadUnknownEntityTemplate(new UnknownEntity(dxfClass));
×
211
                                        }
×
212
                                        else
213
                                        {
×
214
                                                this._builder.Notify($"Entity not supported: {this._reader.ValueAsString}", NotificationType.NotImplemented);
×
215
                                        }
×
216

217
                                        this._reader.ReadNext();
×
218

219
                                        do
220
                                        {
×
221
                                                if (unknownEntityTemplate != null && this._builder.KeepUnknownEntities)
×
222
                                                {
×
223
                                                        this.readCommonEntityCodes(unknownEntityTemplate, out bool isExtendedData, map);
×
224
                                                        if (isExtendedData)
×
225
                                                                continue;
×
226
                                                }
×
227

228
                                                this._reader.ReadNext();
×
229
                                        }
×
230
                                        while (this._reader.DxfCode != DxfCode.Start);
×
231

232
                                        return unknownEntityTemplate;
×
233
                        }
234
                }
×
235

236
                protected CadEntityTemplate readEntityCodes<T>(CadEntityTemplate template, ReadEntityDelegate<T> readEntity)
237
                        where T : Entity
238
                {
×
239
                        this._reader.ReadNext();
×
240

241
                        DxfMap map = DxfMap.Create<T>();
×
242

243
                        while (this._reader.DxfCode != DxfCode.Start)
×
244
                        {
×
245
                                if (!readEntity(template, map))
×
246
                                {
×
247
                                        this.readCommonEntityCodes(template, out bool isExtendedData, map);
×
248
                                        if (isExtendedData)
×
249
                                                continue;
×
250
                                }
×
251

252
                                if (this._reader.DxfCode != DxfCode.Start)
×
253
                                        this._reader.ReadNext();
×
254
                        }
×
255

256
                        return template;
×
257
                }
×
258

259
                protected void readCommonEntityCodes(CadEntityTemplate template, out bool isExtendedData, DxfMap map = null)
260
                {
×
261
                        isExtendedData = false;
×
262
                        switch (this._reader.Code)
×
263
                        {
264
                                case 6:
265
                                        template.LineTypeName = this._reader.ValueAsString;
×
266
                                        break;
×
267
                                case 8:
268
                                        template.LayerName = this._reader.ValueAsString;
×
269
                                        break;
×
270
                                //Absent or zero indicates entity is in model space. 1 indicates entity is in paper space (optional).
271
                                case 67:
272
                                        break;
×
273
                                //Number of bytes Proxy entity graphics data
274
                                case 92:
275
                                case 160:
276
                                //Proxy entity graphics data
277
                                case 310:
278
                                        break;
×
279
                                case 347:
280
                                        template.MaterialHandle = this._reader.ValueAsHandle;
×
281
                                        break;
×
282
                                case 430:
283
                                        template.BookColorName = this._reader.ValueAsString;
×
284
                                        break;
×
285
                                default:
286
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Entity]))
×
287
                                        {
×
288
                                                this.readCommonCodes(template, out isExtendedData, map);
×
289
                                        }
×
290
                                        break;
×
291
                        }
292
                }
×
293

294
                private bool readArc(CadEntityTemplate template, DxfMap map, string subclass = null)
295
                {
×
296
                        switch (this._reader.Code)
×
297
                        {
298
                                default:
299
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Arc]))
×
300
                                        {
×
301
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.Circle);
×
302
                                        }
303
                                        return true;
×
304
                        }
305
                }
×
306

307
                private bool readAttributeDefinition(CadEntityTemplate template, DxfMap map, string subclass = null)
308
                {
×
309
                        DxfClassMap emap = map.SubClasses[template.CadObject.SubclassMarker];
×
310
                        CadAttributeTemplate tmp = template as CadAttributeTemplate;
×
311

312
                        switch (this._reader.Code)
×
313
                        {
314
                                case 44:
315
                                case 46:
316
                                        return true;
×
317
                                case 101:
318
                                        var att = tmp.CadObject as AttributeBase;
×
319
                                        att.MText = new MText();
×
320
                                        CadTextEntityTemplate mtextTemplate = new CadTextEntityTemplate(att.MText);
×
321
                                        tmp.MTextTemplate = mtextTemplate;
×
322
                                        this.readEntityCodes<MText>(mtextTemplate, this.readTextEntity);
×
323
                                        return true;
×
324
                                default:
325
                                        if (!this.tryAssignCurrentValue(template.CadObject, emap))
×
326
                                        {
×
327
                                                return this.readTextEntity(template, map, DxfSubclassMarker.Text);
×
328
                                        }
329
                                        return true;
×
330
                        }
331
                }
×
332

333
                private bool readTableEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
334
                {
×
335
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
×
336
                        CadTableEntityTemplate tmp = template as CadTableEntityTemplate;
×
337
                        TableEntity table = tmp.CadObject as TableEntity;
×
338

339
                        switch (this._reader.Code)
×
340
                        {
341
                                case 2:
342
                                        tmp.BlockName = this._reader.ValueAsString;
×
343
                                        return true;
×
344
                                case 342:
345
                                        tmp.StyleHandle = this._reader.ValueAsHandle;
×
346
                                        return true;
×
347
                                case 343:
348
                                        tmp.BlockOwnerHandle = this._reader.ValueAsHandle;
×
349
                                        return true;
×
350
                                case 141:
351
                                        var row = new TableEntity.Row();
×
352
                                        row.Height = this._reader.ValueAsDouble;
×
353
                                        table.Rows.Add(row);
×
354
                                        return true;
×
355
                                case 142:
356
                                        var col = new TableEntity.Column();
×
357
                                        col.Width = this._reader.ValueAsDouble;
×
358
                                        table.Columns.Add(col);
×
359
                                        return true;
×
360
                                case 144:
361
                                        tmp.CurrentCellTemplate.FormatTextHeight = this._reader.ValueAsDouble;
×
362
                                        return true;
×
363
                                case 145:
364
                                        tmp.CurrentCell.Rotation = this._reader.ValueAsDouble;
×
365
                                        return true;
×
366
                                case 170:
367
                                        //Has data flag
368
                                        return true;
×
369
                                case 171:
370
                                        tmp.CreateCell((TableEntity.CellType)this._reader.ValueAsInt);
×
371
                                        return true;
×
372
                                case 172:
373
                                        tmp.CurrentCell.FlagValue = this._reader.ValueAsInt;
×
374
                                        return true;
×
375
                                case 173:
376
                                        tmp.CurrentCell.MergedValue = this._reader.ValueAsInt;
×
377
                                        return true;
×
378
                                case 174:
379
                                        tmp.CurrentCell.Autofit = this._reader.ValueAsBool;
×
380
                                        return true;
×
381
                                case 175:
382
                                        tmp.CurrentCell.BorderWidth = this._reader.ValueAsInt;
×
383
                                        return true;
×
384
                                case 176:
385
                                        tmp.CurrentCell.BorderHeight = this._reader.ValueAsInt;
×
386
                                        return true;
×
387
                                case 178:
388
                                        tmp.CurrentCell.VirtualEdgeFlag = this._reader.ValueAsShort;
×
389
                                        return true;
×
390
                                case 179:
391
                                        //Unknown value
392
                                        return true;
×
393
                                case 301:
394
                                        var content = new TableEntity.CellContent();
×
395
                                        tmp.CurrentCell.Contents.Add(content);
×
396
                                        this.readCellValue(content);
×
397
                                        return true;
×
398
                                case 340:
399
                                        tmp.CurrentCellTemplate.BlockRecordHandle = this._reader.ValueAsHandle;
×
400
                                        return true;
×
401
                                default:
402
                                        if (!this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Insert]))
×
403
                                        {
×
404
                                                return this.readEntitySubclassMap(template, map, DxfSubclassMarker.TableEntity);
×
405
                                        }
406
                                        return true;
×
407
                        }
408
                }
×
409

410
                private void readCellValue(TableEntity.CellContent content)
411
                {
×
412
                        if (this._reader.ValueAsString.Equals("CELL_VALUE", StringComparison.OrdinalIgnoreCase))
×
413
                        {
×
414
                                this._reader.ReadNext();
×
415
                        }
×
416
                        else
417
                        {
×
418
                                throw new Exceptions.DxfException($"Expected value not found CELL_VALUE", this._reader.Position);
×
419
                        }
420

421
                        while (this._reader.Code != 304
×
422
                                && !this._reader.ValueAsString.Equals("ACVALUE_END", StringComparison.OrdinalIgnoreCase))
×
423
                        {
×
424
                                switch (this._reader.Code)
×
425
                                {
426
                                        case 1:
427
                                                content.Value.Text = this._reader.ValueAsString;
×
428
                                                break;
×
429
                                        case 2:
430
                                                content.Value.Text += this._reader.ValueAsString;
×
431
                                                break;
×
432
                                        case 11:
433
                                                content.Value.Value = new XYZ(this._reader.ValueAsDouble, 0, 0);
×
434
                                                break;
×
435
                                        case 21:
436
                                                content.Value.Value = new XYZ(0, this._reader.ValueAsDouble, 0);
×
437
                                                break;
×
438
                                        case 31:
439
                                                content.Value.Value = new XYZ(0, 0, this._reader.ValueAsDouble);
×
440
                                                break;
×
441
                                        case 302:
442
                                                //TODO: Fix this assignation to cell value
443
                                                content.Value.Value = this._reader.ValueAsString;
×
444
                                                break;
×
445
                                        case 90:
446
                                                content.Value.ValueType = (TableEntity.CellValueType)this._reader.ValueAsInt;
×
447
                                                break;
×
448
                                        case 91:
449
                                                content.Value.Value = this._reader.ValueAsInt;
×
450
                                                break;
×
451
                                        case 93:
452
                                                content.Value.Flags = this._reader.ValueAsInt;
×
453
                                                break;
×
454
                                        case 94:
455
                                                content.Value.Units = (TableEntity.ValueUnitType)this._reader.ValueAsInt;
×
456
                                                break;
×
457
                                        case 140:
458
                                                content.Value.Value = this._reader.ValueAsDouble;
×
459
                                                break;
×
460
                                        case 300:
461
                                                content.Value.Format = this._reader.ValueAsString;
×
462
                                                break;
×
463
                                        default:
464
                                                this._builder.Notify($"[CELL_VALUE] Unhandled dxf code {this._reader.Code} with value {this._reader.ValueAsString}", NotificationType.None);
×
465
                                                break;
×
466
                                }
467

468
                                this._reader.ReadNext();
×
469
                        }
×
470
                }
×
471

472
                private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
473
                {
×
474
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
×
475
                        CadTextEntityTemplate tmp = template as CadTextEntityTemplate;
×
476

477
                        switch (this._reader.Code)
×
478
                        {
479
                                //TODO: Implement multiline text def codes
480
                                case 1 or 3 when tmp.CadObject is MText mtext:
×
481
                                        mtext.Value += this._reader.ValueAsString;
×
482
                                        return true;
×
483
                                case 70:
484
                                case 74:
485
                                case 101:
486
                                        return true;
×
487
                                case 7:
488
                                        tmp.StyleName = this._reader.ValueAsString;
×
489
                                        return true;
×
490
                                default:
491
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
×
492
                        }
493
                }
×
494

495
                private bool readTolerance(CadEntityTemplate template, DxfMap map, string subclass = null)
496
                {
×
497
                        CadToleranceTemplate tmp = template as CadToleranceTemplate;
×
498

499
                        switch (this._reader.Code)
×
500
                        {
501
                                case 3:
502
                                        tmp.DimensionStyleName = this._reader.ValueAsString;
×
503
                                        return true;
×
504
                                default:
505
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
506
                        }
507
                }
×
508

509
                private bool readDimension(CadEntityTemplate template, DxfMap map, string subclass = null)
510
                {
×
511
                        CadDimensionTemplate tmp = template as CadDimensionTemplate;
×
512

513
                        switch (this._reader.Code)
×
514
                        {
515
                                case 2:
516
                                        tmp.BlockName = this._reader.ValueAsString;
×
517
                                        return true;
×
518
                                case 3:
519
                                        tmp.StyleName = this._reader.ValueAsString;
×
520
                                        return true;
×
521
                                case 50:
522
                                        var dim = new DimensionLinear();
×
523
                                        tmp.SetDimensionObject(dim);
×
524
                                        dim.Rotation = CSMath.MathHelper.DegToRad(this._reader.ValueAsDouble);
×
525
                                        map.SubClasses.Add(DxfSubclassMarker.LinearDimension, DxfClassMap.Create<DimensionLinear>());
×
526
                                        return true;
×
527
                                case 70:
528
                                        //Flags do not have set
529
                                        tmp.SetDimensionFlags((DimensionType)this._reader.ValueAsShort);
×
530
                                        return true;
×
531
                                //Measurement - read only
532
                                case 42:
533
                                        return true;
×
534
                                //Undocumented codes
535
                                case 73:
536
                                case 74:
537
                                case 75:
538
                                case 90:
539
                                case 361:
540
                                        return true;
×
541
                                case 100:
542
                                        switch (this._reader.ValueAsString)
×
543
                                        {
544
                                                case DxfSubclassMarker.Dimension:
545
                                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Dimension]);
×
546
                                                case DxfSubclassMarker.AlignedDimension:
547
                                                        tmp.SetDimensionObject(new DimensionAligned());
×
548
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAligned>());
×
549
                                                        return true;
×
550
                                                case DxfSubclassMarker.DiametricDimension:
551
                                                        tmp.SetDimensionObject(new DimensionDiameter());
×
552
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionDiameter>());
×
553
                                                        return true;
×
554
                                                case DxfSubclassMarker.Angular2LineDimension:
555
                                                        tmp.SetDimensionObject(new DimensionAngular2Line());
×
556
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular2Line>());
×
557
                                                        return true;
×
558
                                                case DxfSubclassMarker.Angular3PointDimension:
559
                                                        tmp.SetDimensionObject(new DimensionAngular3Pt());
×
560
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionAngular3Pt>());
×
561
                                                        return true;
×
562
                                                case DxfSubclassMarker.RadialDimension:
563
                                                        tmp.SetDimensionObject(new DimensionRadius());
×
564
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionRadius>());
×
565
                                                        return true;
×
566
                                                case DxfSubclassMarker.OrdinateDimension:
567
                                                        tmp.SetDimensionObject(new DimensionOrdinate());
×
568
                                                        map.SubClasses.Add(this._reader.ValueAsString, DxfClassMap.Create<DimensionOrdinate>());
×
569
                                                        return true;
×
570
                                                case DxfSubclassMarker.LinearDimension:
571
                                                        return true;
×
572
                                                default:
573
                                                        return false;
×
574
                                        }
575
                                default:
576
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
577
                        }
578
                }
×
579

580
                protected bool readHatch(CadEntityTemplate template, DxfMap map, string subclass = null)
581
                {
×
582
                        CadHatchTemplate tmp = template as CadHatchTemplate;
×
583
                        Hatch hatch = tmp.CadObject;
×
584

585
                        bool isFirstSeed = true;
×
586
                        XY seedPoint = new XY();
×
587

588
                        switch (this._reader.Code)
×
589
                        {
590
                                case 2:
591
                                        tmp.HatchPatternName = this._reader.ValueAsString;
×
592
                                        return true;
×
593
                                case 10:
594
                                        seedPoint.X = this._reader.ValueAsDouble;
×
595
                                        return true;
×
596
                                case 20:
597
                                        if (!isFirstSeed)
×
598
                                        {
×
599
                                                seedPoint.Y = this._reader.ValueAsDouble;
×
600
                                                hatch.SeedPoints.Add(seedPoint);
×
601
                                        }
×
602
                                        return true;
×
603
                                case 30:
604
                                        hatch.Elevation = this._reader.ValueAsDouble;
×
605
                                        isFirstSeed = false;
×
606
                                        return true;
×
607
                                //TODO: Check hatch undocumented codes
608
                                case 43:
609
                                case 44:
610
                                case 45:
611
                                case 46:
612
                                case 49:
613
                                case 53:
614
                                case 79:
615
                                case 90:
616
                                        return true;
×
617
                                //Information about the hatch pattern
618
                                case 75:
619
                                        return true;
×
620
                                //Number of pattern definition lines
621
                                case 78:
622
                                        return true;
×
623
                                //Number of boundary paths (loops)
624
                                case 91:
625
                                        this.readLoops(tmp, this._reader.ValueAsInt);
×
626
                                        return true;
×
627
                                //Number of seed points
628
                                case 98:
629
                                        return true;
×
630
                                case 450:
631
                                        hatch.GradientColor.Enabled = this._reader.ValueAsBool;
×
632
                                        return true;
×
633
                                case 451:
634
                                        hatch.GradientColor.Reserved = this._reader.ValueAsInt;
×
635
                                        return true;
×
636
                                case 452:
637
                                        hatch.GradientColor.IsSingleColorGradient = this._reader.ValueAsBool;
×
638
                                        return true;
×
639
                                case 453:
640
                                        //Number of colors
641
                                        return true;
×
642
                                case 460:
643
                                        hatch.GradientColor.Angle = this._reader.ValueAsDouble;
×
644
                                        return true;
×
645
                                case 461:
646
                                        hatch.GradientColor.Shift = this._reader.ValueAsDouble;
×
647
                                        return true;
×
648
                                case 462:
649
                                        hatch.GradientColor.ColorTint = this._reader.ValueAsDouble;
×
650
                                        return true;
×
651
                                case 463:
652
                                        GradientColor gradient = new GradientColor();
×
653
                                        gradient.Value = this._reader.ValueAsDouble;
×
654
                                        hatch.GradientColor.Colors.Add(gradient);
×
655
                                        return true;
×
656
                                case 63:
657
                                        GradientColor colorByIndex = hatch.GradientColor.Colors.LastOrDefault();
×
658
                                        if (colorByIndex != null)
×
659
                                        {
×
660
                                                colorByIndex.Color = new Color((short)this._reader.ValueAsUShort);
×
661
                                        }
×
662
                                        return true;
×
663
                                case 421:
664
                                        GradientColor colorByRgb = hatch.GradientColor.Colors.LastOrDefault();
×
665
                                        if (colorByRgb != null)
×
666
                                        {
×
667
                                                //TODO: Hatch assign color by true color
668
                                                //TODO: Is always duplicated by 63, is it needed??
669
                                                //colorByRgb.Color = new Color(this._reader.LastValueAsShort);
670
                                        }
×
671
                                        return true;
×
672
                                case 470:
673
                                        hatch.GradientColor.Name = this._reader.ValueAsString;
×
674
                                        return true;
×
675
                                default:
676
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[template.CadObject.SubclassMarker]);
×
677
                        }
678
                }
×
679

680
                private bool readInsert(CadEntityTemplate template, DxfMap map, string subclass = null)
681
                {
×
682
                        CadInsertTemplate tmp = template as CadInsertTemplate;
×
683

684
                        switch (this._reader.Code)
×
685
                        {
686
                                case 2:
687
                                        tmp.BlockName = this._reader.ValueAsString;
×
688
                                        return true;
×
689
                                case 66:
690
                                        return true;
×
691
                                default:
692
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
693
                        }
694
                }
×
695

696
                private CadEntityTemplate readPolyline()
697
                {
×
698
                        CadPolyLineTemplate template = null;
×
699

700
                        if (this._builder.Version == ACadVersion.Unknown)
×
701
                        {
×
702
                                var polyline = new Polyline2D();
×
703
                                template = new CadPolyLineTemplate(polyline);
×
704
                                this.readEntityCodes<Polyline2D>(template, this.readPolyline);
×
705

706
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EntityVertex)
×
707
                                {
×
708
                                        Vertex2D v = new Vertex2D();
×
709
                                        CadVertexTemplate vertexTemplate = new CadVertexTemplate(v);
×
710
                                        this.readEntityCodes<Vertex2D>(vertexTemplate, this.readVertex);
×
711

712
                                        if (vertexTemplate.Vertex.Handle == 0)
×
713
                                        {
×
714
                                                template.PolyLine.Vertices.Add(vertexTemplate.Vertex);
×
715
                                        }
×
716
                                        else
717
                                        {
×
718
                                                template.VertexHandles.Add(vertexTemplate.Vertex.Handle);
×
719
                                                this._builder.AddTemplate(vertexTemplate);
×
720
                                        }
×
721
                                }
×
722

723
                                while (this._reader.Code == 0 && this._reader.ValueAsString == DxfFileToken.EndSequence)
×
724
                                {
×
725
                                        var seqend = new Seqend();
×
726
                                        var seqendTemplate = new CadEntityTemplate<Seqend>(seqend);
×
727
                                        this.readEntityCodes<Seqend>(seqendTemplate, this.readEntitySubclassMap);
×
728

729
                                        this._builder.AddTemplate(seqendTemplate);
×
730

731
                                        template.SeqendHandle = seqend.Handle;
×
732
                                }
×
733
                        }
×
734
                        else
735
                        {
×
736
                                template = new CadPolyLineTemplate();
×
737
                                this.readEntityCodes<Entity>(template, this.readPolyline);
×
738
                        }
×
739

740
                        if (template.CadObject is CadPolyLineTemplate.PolyLinePlaceholder)
×
741
                        {
×
742
                                this._builder.Notify($"[{DxfFileToken.EntityPolyline}] Subclass not found, entity discarded", NotificationType.Warning);
×
743
                                return null;
×
744
                        }
745

746
                        return template;
×
747
                }
×
748

749
                private bool readPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
750
                {
×
751
                        CadPolyLineTemplate tmp = template as CadPolyLineTemplate;
×
752

753
                        switch (this._reader.Code)
×
754
                        {
755
                                //DXF: always 0
756
                                //APP: a “dummy” point; the X and Y values are always 0, and the Z value is the polyline's elevation (in OCS when 2D, WCS when 3D)
757
                                case 10:
758
                                case 20:
759
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
760
                                case 66:
761
                                //Polygon mesh M vertex count (optional; default = 0)
762
                                case 71:
763
                                //Polygon mesh N vertex count(optional; default = 0)
764
                                case 72:
765
                                //Smooth surface M density(optional; default = 0)
766
                                case 73:
767
                                //Smooth surface N density (optional; default = 0)
768
                                case 74:
769
                                        return true;
×
770
                                case 100:
771
                                        switch (this._reader.ValueAsString)
×
772
                                        {
773
                                                case DxfSubclassMarker.Polyline:
774
                                                        tmp.SetPolyLineObject(new Polyline2D());
×
775
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline, DxfClassMap.Create<Polyline2D>());
×
776
                                                        return true;
×
777
                                                case DxfSubclassMarker.Polyline3d:
778
                                                        tmp.SetPolyLineObject(new Polyline3D());
×
779
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3d, DxfClassMap.Create<Polyline3D>());
×
780
                                                        return true;
×
781
                                                case DxfSubclassMarker.PolyfaceMesh:
782
                                                        tmp.SetPolyLineObject(new PolyfaceMesh());
×
783
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMesh, DxfClassMap.Create<PolyfaceMesh>());
×
784
                                                        return true;
×
785
                                                default:
786
                                                        return false;
×
787
                                        }
788
                                default:
789
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
790
                        }
791
                }
×
792

793
                private bool readLeader(CadEntityTemplate template, DxfMap map, string subclass = null)
794
                {
×
795
                        CadLeaderTemplate tmp = template as CadLeaderTemplate;
×
796

797
                        switch (this._reader.Code)
×
798
                        {
799
                                case 3:
800
                                        tmp.DIMSTYLEName = this._reader.ValueAsString;
×
801
                                        return true;
×
802
                                case 10:
803
                                        tmp.CadObject.Vertices.Add(new XYZ(this._reader.ValueAsDouble, 0, 0));
×
804
                                        return true;
×
805
                                case 20:
806
                                        XYZ y = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
×
807
                                        y.Y = this._reader.ValueAsDouble;
×
808
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = y;
×
809
                                        return true;
×
810
                                case 30:
811
                                        XYZ z = tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1];
×
812
                                        z.Z = this._reader.ValueAsDouble;
×
813
                                        tmp.CadObject.Vertices[tmp.CadObject.Vertices.Count - 1] = z;
×
814
                                        return true;
×
815
                                case 340:
816
                                        tmp.AnnotationHandle = this._reader.ValueAsHandle;
×
817
                                        return true;
×
818
                                //Vertices count
819
                                case 76:
820
                                        return true;
×
821
                                default:
822
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
823
                        }
824
                }
×
825

826
                private bool readLwPolyline(CadEntityTemplate template, DxfMap map, string subclass = null)
827
                {
×
828
                        CadEntityTemplate<LwPolyline> tmp = template as CadEntityTemplate<LwPolyline>;
×
829

830
                        LwPolyline.Vertex last = tmp.CadObject.Vertices.LastOrDefault();
×
831

832
                        switch (this._reader.Code)
×
833
                        {
834
                                case 10:
835
                                        tmp.CadObject.Vertices.Add(new LwPolyline.Vertex(new XY(this._reader.ValueAsDouble, 0)));
×
836
                                        return true;
×
837
                                case 20:
838
                                        if (last is not null)
×
839
                                        {
×
840
                                                last.Location = new XY(last.Location.X, this._reader.ValueAsDouble);
×
841
                                        }
×
842
                                        return true;
×
843
                                case 40:
844
                                        if (last is not null)
×
845
                                        {
×
846
                                                last.StartWidth = this._reader.ValueAsDouble;
×
847
                                        }
×
848
                                        return true;
×
849
                                case 41:
850
                                        if (last is not null)
×
851
                                        {
×
852
                                                last.EndWidth = this._reader.ValueAsDouble;
×
853
                                        }
×
854
                                        return true;
×
855
                                case 42:
856
                                        if (last is not null)
×
857
                                        {
×
858
                                                last.Bulge = this._reader.ValueAsDouble;
×
859
                                        }
×
860
                                        return true;
×
861
                                case 50:
862
                                        if (last is not null)
×
863
                                        {
×
864
                                                last.CurveTangent = this._reader.ValueAsDouble;
×
865
                                        }
×
866
                                        return true;
×
867
                                //Obsolete; formerly an “entities follow flag” (optional; ignore if present)
868
                                case 66:
869
                                //Vertex count
870
                                case 90:
871
                                        return true;
×
872
                                case 91:
873
                                        if (last is not null)
×
874
                                        {
×
875
                                                last.Id = this._reader.ValueAsInt;
×
876
                                        }
×
877
                                        return true;
×
878
                                default:
879
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
880
                        }
881
                }
×
882

883
                private bool readMesh(CadEntityTemplate template, DxfMap map, string subclass = null)
884
                {
×
885
                        CadMeshTemplate tmp = template as CadMeshTemplate;
×
886

887
                        switch (this._reader.Code)
×
888
                        {
889
                                case 100:
890
                                        if (this._reader.ValueAsString.Equals(DxfSubclassMarker.Mesh, StringComparison.OrdinalIgnoreCase))
×
891
                                        {
×
892
                                                tmp.SubclassMarker = true;
×
893
                                        }
×
894
                                        return true;
×
895
                                //Count of sub-entity which property has been overridden
896
                                case 90:
897
                                        //TODO: process further entities
898
                                        return true;
×
899
                                case 92:
900
                                        if (!tmp.SubclassMarker)
×
901
                                        {
×
902
                                                return false;
×
903
                                        }
904

905
                                        int nvertices = this._reader.ValueAsInt;
×
906
                                        for (int i = 0; i < nvertices; i++)
×
907
                                        {
×
908
                                                this._reader.ReadNext();
×
909
                                                double x = this._reader.ValueAsDouble;
×
910
                                                this._reader.ReadNext();
×
911
                                                double y = this._reader.ValueAsDouble;
×
912
                                                this._reader.ReadNext();
×
913
                                                double z = this._reader.ValueAsDouble;
×
914
                                                tmp.CadObject.Vertices.Add(new XYZ(x, y, z));
×
915
                                        }
×
916
                                        return true;
×
917
                                case 93:
918
                                        int size = this._reader.ValueAsInt;
×
919
                                        this._reader.ReadNext();
×
920

921
                                        int indexes = 0;
×
922
                                        for (int i = 0; i < size; i += indexes + 1)
×
923
                                        {
×
924
                                                indexes = this._reader.ValueAsInt;
×
925
                                                this._reader.ReadNext();
×
926

927
                                                int[] face = new int[indexes];
×
928
                                                for (int j = 0; j < indexes; j++)
×
929
                                                {
×
930
                                                        face[j] = this._reader.ValueAsInt;
×
931

932
                                                        if ((i + j + 2) < size)
×
933
                                                        {
×
934
                                                                this._reader.ReadNext();
×
935
                                                        }
×
936
                                                }
×
937

938
                                                tmp.CadObject.Faces.Add(face);
×
939
                                        }
×
940

941
                                        Debug.Assert(this._reader.Code == 90);
×
942

943
                                        return true;
×
944
                                case 94:
945
                                        int numEdges = this._reader.ValueAsInt;
×
946
                                        this._reader.ReadNext();
×
947
                                        for (int i = 0; i < numEdges; i++)
×
948
                                        {
×
949
                                                Mesh.Edge edge = new Mesh.Edge();
×
950

951
                                                edge.Start = this._reader.ValueAsInt;
×
952
                                                this._reader.ReadNext();
×
953
                                                edge.End = this._reader.ValueAsInt;
×
954

955
                                                if (i < numEdges - 1)
×
956
                                                {
×
957
                                                        this._reader.ReadNext();
×
958
                                                }
×
959

960
                                                tmp.CadObject.Edges.Add(edge);
×
961
                                        }
×
962

963
                                        Debug.Assert(this._reader.Code == 90);
×
964

965
                                        return true;
×
966
                                case 95:
967
                                        this._reader.ReadNext();
×
968
                                        for (int i = 0; i < tmp.CadObject.Edges.Count; i++)
×
969
                                        {
×
970
                                                Mesh.Edge edge = tmp.CadObject.Edges[i];
×
971
                                                edge.Crease = this._reader.ValueAsDouble;
×
972

973
                                                tmp.CadObject.Edges[i] = edge;
×
974

975
                                                if (i < tmp.CadObject.Edges.Count - 1)
×
976
                                                {
×
977
                                                        this._reader.ReadNext();
×
978
                                                }
×
979
                                        }
×
980

981
                                        Debug.Assert(this._reader.Code == 140);
×
982

983
                                        return true;
×
984
                                default:
985
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
986
                        }
987
                }
×
988

989
                private bool readMLine(CadEntityTemplate template, DxfMap map, string subclass = null)
990
                {
×
991
                        CadMLineTemplate tmp = template as CadMLineTemplate;
×
992

993
                        switch (this._reader.Code)
×
994
                        {
995
                                // String of up to 32 characters. The name of the style used for this mline. An entry for this style must exist in the MLINESTYLE dictionary.
996
                                // Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
997
                                case 2:
998
                                        tmp.MLineStyleName = this._reader.ValueAsString;
×
999
                                        return true;
×
1000
                                case 72:
1001
                                        tmp.NVertex = this._reader.ValueAsInt;
×
1002
                                        return true;
×
1003
                                case 73:
1004
                                        tmp.NElements = this._reader.ValueAsInt;
×
1005
                                        return true;
×
1006
                                case 340:
1007
                                        tmp.MLineStyleHandle = this._reader.ValueAsHandle;
×
1008
                                        return true;
×
1009
                                default:
1010
                                        if (!tmp.TryReadVertex(this._reader.Code, this._reader.Value))
×
1011
                                        {
×
1012
                                                return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1013
                                        }
1014
                                        return true;
×
1015
                        }
1016
                }
×
1017

1018
                private bool readShape(CadEntityTemplate template, DxfMap map, string subclass = null)
1019
                {
×
1020
                        CadShapeTemplate tmp = template as CadShapeTemplate;
×
1021

1022
                        switch (this._reader.Code)
×
1023
                        {
1024
                                case 2:
1025
                                        tmp.ShapeFileName = this._reader.ValueAsString;
×
1026
                                        return true;
×
1027
                                default:
1028
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1029
                        }
1030
                }
×
1031

1032
                private bool readSpline(CadEntityTemplate template, DxfMap map, string subclass = null)
1033
                {
×
1034
                        CadSplineTemplate tmp = template as CadSplineTemplate;
×
1035

1036
                        XYZ controlPoint;
1037

1038
                        switch (this._reader.Code)
×
1039
                        {
1040
                                case 10:
1041
                                        controlPoint = new CSMath.XYZ(this._reader.ValueAsDouble, 0, 0);
×
1042
                                        tmp.CadObject.ControlPoints.Add(controlPoint);
×
1043
                                        return true;
×
1044
                                case 20:
1045
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
×
1046
                                        controlPoint.Y = this._reader.ValueAsDouble;
×
1047
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
×
1048
                                        return true;
×
1049
                                case 30:
1050
                                        controlPoint = tmp.CadObject.ControlPoints.LastOrDefault();
×
1051
                                        controlPoint.Z = this._reader.ValueAsDouble;
×
1052
                                        tmp.CadObject.ControlPoints[tmp.CadObject.ControlPoints.Count - 1] = controlPoint;
×
1053
                                        return true;
×
1054
                                case 40:
1055
                                        tmp.CadObject.Knots.Add(this._reader.ValueAsDouble);
×
1056
                                        return true;
×
1057
                                case 41:
1058
                                        tmp.CadObject.Weights.Add(this._reader.ValueAsDouble);
×
1059
                                        return true;
×
1060
                                case 72:
1061
                                case 73:
1062
                                case 74:
1063
                                        return true;
×
1064
                                default:
1065
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1066
                        }
1067
                }
×
1068

1069
                private bool readUnderlayEntity(CadEntityTemplate template, DxfMap map, string subclass = null)
1070
                {
×
1071
                        CadPdfUnderlayTemplate tmp = template as CadPdfUnderlayTemplate;
×
1072

1073
                        switch (this._reader.Code)
×
1074
                        {
1075
                                case 340:
1076
                                        tmp.DefinitionHandle = this._reader.ValueAsHandle;
×
1077
                                        return true;
×
1078
                                default:
1079
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1080
                        }
1081
                }
×
1082

1083
                private bool readVertex(CadEntityTemplate template, DxfMap map, string subclass = null)
1084
                {
×
1085
                        CadVertexTemplate tmp = template as CadVertexTemplate;
×
1086

1087
                        switch (this._reader.Code)
×
1088
                        {
1089
                                //Polyface mesh vertex index
1090
                                case 71:
1091
                                case 72:
1092
                                case 73:
1093
                                case 74:
1094
                                        return true;
×
1095
                                case 100:
1096
                                        switch (this._reader.ValueAsString)
×
1097
                                        {
1098
                                                case DxfSubclassMarker.Vertex:
1099
                                                        return true;
×
1100
                                                case DxfSubclassMarker.PolylineVertex:
1101
                                                        tmp.SetVertexObject(new Vertex2D());
×
1102
                                                        map.SubClasses.Add(DxfSubclassMarker.PolylineVertex, DxfClassMap.Create<Vertex2D>());
×
1103
                                                        return true;
×
1104
                                                case DxfSubclassMarker.Polyline3dVertex:
1105
                                                        tmp.SetVertexObject(new Vertex3D());
×
1106
                                                        map.SubClasses.Add(DxfSubclassMarker.Polyline3dVertex, DxfClassMap.Create<Vertex3D>());
×
1107
                                                        return true;
×
1108
                                                case DxfSubclassMarker.PolyfaceMeshVertex:
1109
                                                        tmp.SetVertexObject(new VertexFaceMesh());
×
1110
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshVertex, DxfClassMap.Create<VertexFaceMesh>());
×
1111
                                                        return true;
×
1112
                                                case DxfSubclassMarker.PolyfaceMeshFace:
1113
                                                        tmp.SetVertexObject(new VertexFaceRecord());
×
1114
                                                        map.SubClasses.Add(DxfSubclassMarker.PolyfaceMeshFace, DxfClassMap.Create<VertexFaceRecord>());
×
1115
                                                        return true;
×
1116
                                                default:
1117
                                                        return false;
×
1118
                                        }
1119
                                default:
1120
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[tmp.CadObject.SubclassMarker]);
×
1121
                        }
1122
                }
×
1123

1124
                private bool readViewport(CadEntityTemplate template, DxfMap map, string subclass = null)
1125
                {
×
1126
                        CadViewportTemplate tmp = template as CadViewportTemplate;
×
1127

1128
                        switch (this._reader.Code)
×
1129
                        {
1130
                                //Undocumented
1131
                                case 67:
1132
                                case 68:
1133
                                        return true;
×
1134
                                case 69:
1135
                                        tmp.ViewportId = this._reader.ValueAsShort;
×
1136
                                        return true;
×
1137
                                case 331:
1138
                                        tmp.FrozenLayerHandles.Add(this._reader.ValueAsHandle);
×
1139
                                        return true;
×
1140
                                case 348:
1141
                                        tmp.VisualStyleHandle = this._reader.ValueAsHandle;
×
1142
                                        return true;
×
1143
                                default:
1144
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[DxfSubclassMarker.Viewport]);
×
1145
                        }
1146
                }
×
1147

1148
                private bool readEntitySubclassMap(CadEntityTemplate template, DxfMap map, string subclass = null)
1149
                {
×
1150
                        string mapName = string.IsNullOrEmpty(subclass) ? template.CadObject.SubclassMarker : subclass;
×
1151

1152
                        switch (this._reader.Code)
×
1153
                        {
1154
                                default:
1155
                                        return this.tryAssignCurrentValue(template.CadObject, map.SubClasses[mapName]);
×
1156
                        }
1157
                }
×
1158

1159
                protected void readExtendedData(Dictionary<string, List<ExtendedDataRecord>> edata)
1160
                {
×
1161
                        List<ExtendedDataRecord> records = new();
×
1162
                        edata.Add(this._reader.ValueAsString, records);
×
1163

1164
                        this._reader.ReadNext();
×
1165

1166
                        while (this._reader.DxfCode >= DxfCode.ExtendedDataAsciiString)
×
1167
                        {
×
1168
                                if (this._reader.DxfCode == DxfCode.ExtendedDataRegAppName)
×
1169
                                {
×
1170
                                        this.readExtendedData(edata);
×
1171
                                        break;
×
1172
                                }
1173

1174
                                ExtendedDataRecord record = null;
×
1175
                                double x = 0;
×
1176
                                double y = 0;
×
1177
                                double z = 0;
×
1178

1179
                                switch (this._reader.DxfCode)
×
1180
                                {
1181
                                        case DxfCode.ExtendedDataAsciiString:
1182
                                        case DxfCode.ExtendedDataRegAppName:
1183
                                                record = new ExtendedDataString(this._reader.ValueAsString);
×
1184
                                                break;
×
1185
                                        case DxfCode.ExtendedDataControlString:
1186
                                                record = new ExtendedDataControlString(this._reader.ValueAsString == "}");
×
1187
                                                break;
×
1188
                                        case DxfCode.ExtendedDataLayerName:
1189
                                                if (this._builder.Layers.TryGetValue(this._reader.ValueAsString, out Layer layer))
×
1190
                                                {
×
1191
                                                        record = new ExtendedDataLayer(layer.Handle);
×
1192
                                                }
×
1193
                                                else
1194
                                                {
×
1195
                                                        this._builder.Notify($"[XData] Could not found the linked Layer {this._reader.ValueAsString}.", NotificationType.Warning);
×
1196
                                                }
×
1197
                                                break;
×
1198
                                        case DxfCode.ExtendedDataBinaryChunk:
1199
                                                record = new ExtendedDataBinaryChunk(this._reader.ValueAsBinaryChunk);
×
1200
                                                break;
×
1201
                                        case DxfCode.ExtendedDataHandle:
1202
                                                record = new ExtendedDataHandle(this._reader.ValueAsHandle);
×
1203
                                                break;
×
1204
                                        case DxfCode.ExtendedDataXCoordinate:
1205
                                                x = this._reader.ValueAsDouble;
×
1206
                                                this._reader.ReadNext();
×
1207
                                                y = this._reader.ValueAsDouble;
×
1208
                                                this._reader.ReadNext();
×
1209
                                                z = this._reader.ValueAsDouble;
×
1210

1211
                                                record = new ExtendedDataCoordinate(
×
1212
                                                        new XYZ(
×
1213
                                                                x,
×
1214
                                                                y,
×
1215
                                                                z)
×
1216
                                                        );
×
1217
                                                break;
×
1218
                                        case DxfCode.ExtendedDataWorldXCoordinate:
1219
                                                x = this._reader.ValueAsDouble;
×
1220
                                                this._reader.ReadNext();
×
1221
                                                y = this._reader.ValueAsDouble;
×
1222
                                                this._reader.ReadNext();
×
1223
                                                z = this._reader.ValueAsDouble;
×
1224

1225
                                                record = new ExtendedDataWorldCoordinate(
×
1226
                                                        new XYZ(
×
1227
                                                                x,
×
1228
                                                                y,
×
1229
                                                                z)
×
1230
                                                        );
×
1231
                                                break;
×
1232
                                        case DxfCode.ExtendedDataWorldXDisp:
1233
                                                x = this._reader.ValueAsDouble;
×
1234
                                                this._reader.ReadNext();
×
1235
                                                y = this._reader.ValueAsDouble;
×
1236
                                                this._reader.ReadNext();
×
1237
                                                z = this._reader.ValueAsDouble;
×
1238

1239
                                                record = new ExtendedDataDisplacement(
×
1240
                                                        new XYZ(
×
1241
                                                                x,
×
1242
                                                                y,
×
1243
                                                                z)
×
1244
                                                        );
×
1245
                                                break;
×
1246
                                        case DxfCode.ExtendedDataWorldXDir:
1247
                                                x = this._reader.ValueAsDouble;
×
1248
                                                this._reader.ReadNext();
×
1249
                                                y = this._reader.ValueAsDouble;
×
1250
                                                this._reader.ReadNext();
×
1251
                                                z = this._reader.ValueAsDouble;
×
1252

1253
                                                record = new ExtendedDataDirection(
×
1254
                                                        new XYZ(
×
1255
                                                                x,
×
1256
                                                                y,
×
1257
                                                                z)
×
1258
                                                        );
×
1259
                                                break;
×
1260
                                        case DxfCode.ExtendedDataReal:
1261
                                                record = new ExtendedDataReal(this._reader.ValueAsDouble);
×
1262
                                                break;
×
1263
                                        case DxfCode.ExtendedDataDist:
1264
                                                record = new ExtendedDataDistance(this._reader.ValueAsDouble);
×
1265
                                                break;
×
1266
                                        case DxfCode.ExtendedDataScale:
1267
                                                record = new ExtendedDataScale(this._reader.ValueAsDouble);
×
1268
                                                break;
×
1269
                                        case DxfCode.ExtendedDataInteger16:
1270
                                                record = new ExtendedDataInteger16(this._reader.ValueAsShort);
×
1271
                                                break;
×
1272
                                        case DxfCode.ExtendedDataInteger32:
1273
                                                record = new ExtendedDataInteger32((int)this._reader.ValueAsInt);
×
1274
                                                break;
×
1275
                                        default:
1276
                                                this._builder.Notify($"Unknown code for extended data: {this._reader.DxfCode}", NotificationType.Warning);
×
1277
                                                break;
×
1278
                                }
1279

1280
                                if (record != null)
×
1281
                                {
×
1282
                                        records.Add(record);
×
1283
                                }
×
1284

1285
                                this._reader.ReadNext();
×
1286
                        }
×
1287
                }
×
1288

1289
                private void readLoops(CadHatchTemplate template, int count)
1290
                {
×
1291
                        if (this._reader.Code == 91)
×
1292
                                this._reader.ReadNext();
×
1293

1294
                        for (int i = 0; i < count; i++)
×
1295
                        {
×
1296
                                if (this._reader.Code != 92)
×
1297
                                {
×
1298
                                        this._builder.Notify($"Boundary path should start with code 92 but was {this._reader.Code}");
×
1299
                                        break;
×
1300
                                }
1301

1302
                                CadHatchTemplate.CadBoundaryPathTemplate path = this.readLoop();
×
1303
                                if (path != null)
×
1304
                                        template.PathTempaltes.Add(path);
×
1305
                        }
×
1306
                }
×
1307

1308
                private CadHatchTemplate.CadBoundaryPathTemplate readLoop()
1309
                {
×
1310
                        CadHatchTemplate.CadBoundaryPathTemplate template = new CadHatchTemplate.CadBoundaryPathTemplate();
×
1311
                        template.Path.Flags = (BoundaryPathFlags)this._reader.ValueAsInt;
×
1312

1313
                        if (template.Path.Flags.HasFlag(BoundaryPathFlags.Polyline))
×
1314
                        {
×
1315
                                Hatch.BoundaryPath.Polyline pl = this.readPolylineBoundary();
×
1316
                                template.Path.Edges.Add(pl);
×
1317
                        }
×
1318
                        else
1319
                        {
×
1320
                                this._reader.ReadNext();
×
1321

1322
                                if (this._reader.Code != 93)
×
1323
                                {
×
1324
                                        this._builder.Notify($"Edge Boundary path should start with code 93 but was {this._reader.Code}");
×
1325
                                        return null;
×
1326
                                }
1327

1328
                                int edges = this._reader.ValueAsInt;
×
1329
                                this._reader.ReadNext();
×
1330

1331
                                for (int i = 0; i < edges; i++)
×
1332
                                {
×
1333
                                        var edge = this.readEdge();
×
1334
                                        if (edge != null)
×
1335
                                                template.Path.Edges.Add(edge);
×
1336
                                }
×
1337
                        }
×
1338

1339
                        bool end = false;
×
1340
                        while (!end)
×
1341
                        {
×
1342
                                switch (this._reader.Code)
×
1343
                                {
1344
                                        //Number of source boundary objects
1345
                                        case 97:
1346
                                                break;
×
1347
                                        case 330:
1348
                                                template.Handles.Add(this._reader.ValueAsHandle);
×
1349
                                                break;
×
1350
                                        default:
1351
                                                end = true;
×
1352
                                                continue;
×
1353
                                }
1354

1355
                                this._reader.ReadNext();
×
1356
                        }
×
1357

1358
                        return template;
×
1359
                }
×
1360

1361
                private Hatch.BoundaryPath.Polyline readPolylineBoundary()
1362
                {
×
1363
                        Hatch.BoundaryPath.Polyline boundary = new Hatch.BoundaryPath.Polyline();
×
1364

1365
                        this._reader.ReadNext();
×
1366

1367
                        if (this._reader.Code != 72)
×
1368
                        {
×
1369
                                this._builder.Notify($"Polyline Boundary path should start with code 72 but was {this._reader.Code}");
×
1370
                                return null;
×
1371
                        }
1372

1373
                        //72
1374
                        bool hasBulge = this._reader.ValueAsBool;
×
1375
                        this._reader.ReadNext();
×
1376

1377
                        //73
1378
                        bool isClosed = this._reader.ValueAsBool;
×
1379
                        this._reader.ReadNext();
×
1380

1381
                        //93
1382
                        int nvertices = this._reader.ValueAsInt;
×
1383
                        this._reader.ReadNext();
×
1384

1385
                        for (int i = 0; i < nvertices; i++)
×
1386
                        {
×
1387
                                double bulge = 0.0;
×
1388

1389
                                //10
1390
                                double x = this._reader.ValueAsDouble;
×
1391
                                this._reader.ReadNext();
×
1392
                                //20
1393
                                double y = this._reader.ValueAsDouble;
×
1394
                                this._reader.ReadNext();
×
1395

1396
                                if (hasBulge)
×
1397
                                {
×
1398
                                        //42
1399
                                        bulge = this._reader.ValueAsDouble;
×
1400
                                        this._reader.ReadNext();
×
1401
                                }
×
1402

1403
                                boundary.Vertices.Add(new XYZ(x, y, bulge));
×
1404
                        }
×
1405

1406
                        return boundary;
×
1407
                }
×
1408

1409
                private Hatch.BoundaryPath.Edge readEdge()
1410
                {
×
1411
                        if (this._reader.Code != 72)
×
1412
                        {
×
1413
                                this._builder.Notify($"Edge Boundary path should define the type with code 72 but was {this._reader.Code}");
×
1414
                                return null;
×
1415
                        }
1416

1417
                        Hatch.BoundaryPath.EdgeType type = (Hatch.BoundaryPath.EdgeType)this._reader.ValueAsInt;
×
1418
                        this._reader.ReadNext();
×
1419

1420
                        switch (type)
×
1421
                        {
1422
                                case Hatch.BoundaryPath.EdgeType.Line:
1423
                                        Hatch.BoundaryPath.Line line = new Hatch.BoundaryPath.Line();
×
1424
                                        while (true)
×
1425
                                        {
×
1426
                                                switch (this._reader.Code)
×
1427
                                                {
1428
                                                        case 10:
1429
                                                                line.Start = new XY(this._reader.ValueAsDouble, line.Start.Y);
×
1430
                                                                break;
×
1431
                                                        case 20:
1432
                                                                line.Start = new XY(line.Start.X, this._reader.ValueAsDouble);
×
1433
                                                                break;
×
1434
                                                        case 11:
1435
                                                                line.End = new XY(this._reader.ValueAsDouble, line.End.Y);
×
1436
                                                                break;
×
1437
                                                        case 21:
1438
                                                                line.End = new XY(line.End.X, this._reader.ValueAsDouble);
×
1439
                                                                break;
×
1440
                                                        default:
1441
                                                                return line;
×
1442
                                                }
1443

1444
                                                this._reader.ReadNext();
×
1445
                                        }
×
1446
                                case Hatch.BoundaryPath.EdgeType.CircularArc:
1447
                                        Hatch.BoundaryPath.Arc arc = new Hatch.BoundaryPath.Arc();
×
1448
                                        while (true)
×
1449
                                        {
×
1450
                                                switch (this._reader.Code)
×
1451
                                                {
1452
                                                        case 10:
1453
                                                                arc.Center = new XY(this._reader.ValueAsDouble, arc.Center.Y);
×
1454
                                                                break;
×
1455
                                                        case 20:
1456
                                                                arc.Center = new XY(arc.Center.X, this._reader.ValueAsDouble);
×
1457
                                                                break;
×
1458
                                                        case 40:
1459
                                                                arc.Radius = this._reader.ValueAsDouble;
×
1460
                                                                break;
×
1461
                                                        case 50:
1462
                                                                arc.StartAngle = this._reader.ValueAsDouble;
×
1463
                                                                break;
×
1464
                                                        case 51:
1465
                                                                arc.EndAngle = this._reader.ValueAsDouble;
×
1466
                                                                break;
×
1467
                                                        case 73:
1468
                                                                arc.CounterClockWise = this._reader.ValueAsBool;
×
1469
                                                                break;
×
1470
                                                        default:
1471
                                                                return arc;
×
1472
                                                }
1473

1474
                                                this._reader.ReadNext();
×
1475
                                        }
×
1476
                                case Hatch.BoundaryPath.EdgeType.EllipticArc:
1477
                                        Hatch.BoundaryPath.Ellipse ellipse = new Hatch.BoundaryPath.Ellipse();
×
1478
                                        while (true)
×
1479
                                        {
×
1480
                                                switch (this._reader.Code)
×
1481
                                                {
1482
                                                        case 10:
1483
                                                                ellipse.Center = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1484
                                                                break;
×
1485
                                                        case 20:
1486
                                                                ellipse.Center = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1487
                                                                break;
×
1488
                                                        case 11:
1489
                                                                ellipse.MajorAxisEndPoint = new XY(this._reader.ValueAsDouble, ellipse.Center.Y);
×
1490
                                                                break;
×
1491
                                                        case 21:
1492
                                                                ellipse.MajorAxisEndPoint = new XY(ellipse.Center.X, this._reader.ValueAsDouble);
×
1493
                                                                break;
×
1494
                                                        case 40:
1495
                                                                ellipse.MinorToMajorRatio = this._reader.ValueAsDouble;
×
1496
                                                                break;
×
1497
                                                        case 50:
1498
                                                                ellipse.StartAngle = this._reader.ValueAsDouble;
×
1499
                                                                break;
×
1500
                                                        case 51:
1501
                                                                ellipse.EndAngle = this._reader.ValueAsDouble;
×
1502
                                                                break;
×
1503
                                                        case 73:
1504
                                                                ellipse.CounterClockWise = this._reader.ValueAsBool;
×
1505
                                                                break;
×
1506
                                                        default:
1507
                                                                return ellipse;
×
1508
                                                }
1509

1510
                                                this._reader.ReadNext();
×
1511
                                        }
×
1512
                                case Hatch.BoundaryPath.EdgeType.Spline:
1513
                                        Hatch.BoundaryPath.Spline spline = new Hatch.BoundaryPath.Spline();
×
1514
                                        int nKnots = 0;
×
1515
                                        int nCtrlPoints = 0;
×
1516
                                        int nFitPoints = 0;
×
1517

1518
                                        XYZ controlPoint = new XYZ();
×
1519
                                        XY fitPoint = new XY();
×
1520

1521
                                        while (true)
×
1522
                                        {
×
1523
                                                switch (this._reader.Code)
×
1524
                                                {
1525
                                                        case 10:
1526
                                                                controlPoint = new XYZ(this._reader.ValueAsDouble, 0, 1);
×
1527
                                                                break;
×
1528
                                                        case 20:
1529
                                                                controlPoint = new XYZ(controlPoint.X, this._reader.ValueAsDouble, controlPoint.Z);
×
1530
                                                                spline.ControlPoints.Add(controlPoint);
×
1531
                                                                break;
×
1532
                                                        case 11:
1533
                                                                fitPoint = new XY(this._reader.ValueAsDouble, 0);
×
1534
                                                                break;
×
1535
                                                        case 21:
1536
                                                                fitPoint = new XY(fitPoint.X, this._reader.ValueAsDouble);
×
1537
                                                                spline.FitPoints.Add(fitPoint);
×
1538
                                                                break;
×
1539
                                                        case 42:
1540
                                                                var last = spline.ControlPoints[spline.ControlPoints.Count - 1];
×
1541
                                                                spline.ControlPoints[spline.ControlPoints.Count - 1] = new XYZ(last.X, last.Y, this._reader.ValueAsDouble);
×
1542
                                                                break;
×
1543
                                                        case 12:
1544
                                                                spline.StartTangent = new XY(this._reader.ValueAsDouble, spline.StartTangent.Y);
×
1545
                                                                break;
×
1546
                                                        case 22:
1547
                                                                spline.StartTangent = new XY(spline.StartTangent.X, this._reader.ValueAsDouble);
×
1548
                                                                break;
×
1549
                                                        case 13:
1550
                                                                spline.EndTangent = new XY(this._reader.ValueAsDouble, spline.EndTangent.Y);
×
1551
                                                                break;
×
1552
                                                        case 23:
1553
                                                                spline.EndTangent = new XY(spline.EndTangent.X, this._reader.ValueAsDouble);
×
1554
                                                                break;
×
1555
                                                        case 94:
1556
                                                                spline.Degree = this._reader.ValueAsInt;
×
1557
                                                                break;
×
1558
                                                        case 73:
1559
                                                                spline.Rational = this._reader.ValueAsBool;
×
1560
                                                                break;
×
1561
                                                        case 74:
1562
                                                                spline.Periodic = this._reader.ValueAsBool;
×
1563
                                                                break;
×
1564
                                                        case 95:
1565
                                                                nKnots = this._reader.ValueAsInt;
×
1566
                                                                break;
×
1567
                                                        case 96:
1568
                                                                nCtrlPoints = this._reader.ValueAsInt;
×
1569
                                                                break;
×
1570
                                                        case 97:
1571
                                                                nFitPoints = this._reader.ValueAsInt;
×
1572
                                                                break;
×
1573
                                                        case 40:
1574
                                                                spline.Knots.Add(this._reader.ValueAsDouble);
×
1575
                                                                break;
×
1576
                                                        default:
1577
                                                                return spline;
×
1578
                                                }
1579

1580
                                                this._reader.ReadNext();
×
1581
                                        }
×
1582
                        }
1583

1584
                        return null;
×
1585
                }
×
1586

1587
                private void readDefinedGroups(CadTemplate template)
1588
                {
×
1589
                        this.readDefinedGroups(out ulong? xdict, out List<ulong> reactorsHandles);
×
1590

1591
                        template.XDictHandle = xdict;
×
1592
                        template.ReactorsHandles = reactorsHandles;
×
1593
                }
×
1594

1595
                private void readDefinedGroups(out ulong? xdictHandle, out List<ulong> reactors)
1596
                {
×
1597
                        xdictHandle = null;
×
1598
                        reactors = new List<ulong>();
×
1599

1600
                        switch (this._reader.ValueAsString)
×
1601
                        {
1602
                                case DxfFileToken.DictionaryToken:
1603
                                        this._reader.ReadNext();
×
1604
                                        xdictHandle = this._reader.ValueAsHandle;
×
1605
                                        this._reader.ReadNext();
×
1606
                                        Debug.Assert(this._reader.DxfCode == DxfCode.ControlString);
×
1607
                                        return;
×
1608
                                case DxfFileToken.ReactorsToken:
1609
                                        reactors = this.readReactors();
×
1610
                                        break;
×
1611
                                case DxfFileToken.BlkRefToken:
1612
                                default:
1613
                                        do
1614
                                        {
×
1615
                                                this._reader.ReadNext();
×
1616
                                        }
×
1617
                                        while (this._reader.DxfCode != DxfCode.ControlString);
×
1618
                                        return;
×
1619
                        }
1620
                }
×
1621

1622
                private List<ulong> readReactors()
1623
                {
×
1624
                        List<ulong> reactors = new List<ulong>();
×
1625

1626
                        this._reader.ReadNext();
×
1627

1628
                        while (this._reader.DxfCode != DxfCode.ControlString)
×
1629
                        {
×
1630
                                this._reader.ReadNext();
×
1631
                        }
×
1632

1633
                        return reactors;
×
1634
                }
×
1635

1636
                protected bool tryAssignCurrentValue(CadObject cadObject, DxfClassMap map)
1637
                {
×
1638
                        try
1639
                        {
×
1640
                                //Use this method only if the value is not a link between objects
1641
                                if (map.DxfProperties.TryGetValue(this._reader.Code, out DxfProperty dxfProperty))
×
1642
                                {
×
1643
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Count))
×
1644
                                        {
×
1645
                                                return true;
×
1646
                                        }
1647

1648
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Handle)
×
1649
                                                || dxfProperty.ReferenceType.HasFlag(DxfReferenceType.Name))
×
1650
                                        {
×
1651
                                                return false;
×
1652
                                        }
1653

1654
                                        object value = this._reader.Value;
×
1655

1656
                                        if (dxfProperty.ReferenceType.HasFlag(DxfReferenceType.IsAngle))
×
1657
                                        {
×
1658
                                                value = (double)value * MathUtils.DegToRadFactor;
×
1659
                                        }
×
1660

1661
                                        dxfProperty.SetValue(this._reader.Code, cadObject, value);
×
1662

1663
                                        return true;
×
1664
                                }
1665
                        }
×
1666
                        catch (Exception ex)
×
1667
                        {
×
1668
                                if (!this._builder.Configuration.Failsafe)
×
1669
                                {
×
1670
                                        throw ex;
×
1671
                                }
1672
                                else
1673
                                {
×
1674
                                        this._builder.Notify("An error occurred while assigning a property using mapper", NotificationType.Error, ex);
×
1675
                                }
×
1676
                        }
×
1677

1678
                        return false;
×
1679
                }
×
1680
        }
1681
}
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