From dff3c4dd2f8d63777d0020eb532146b28c250106 Mon Sep 17 00:00:00 2001 From: DomCR Date: Thu, 19 Dec 2024 16:26:02 +0100 Subject: [PATCH] fix --- .../DWG/DwgStreamReaders/DwgObjectReader.cs | 49 +++++++++++-------- .../CadViewportEntityControlTemplate.cs | 23 +++++++++ .../IO/Templates/CadViewportTemplate.cs | 10 ++-- .../DwgViewportEntityControlTemplate.cs | 20 -------- 4 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 src/ACadSharp/IO/Templates/CadViewportEntityControlTemplate.cs delete mode 100644 src/ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs diff --git a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index ac5c81df..adf78481 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -504,13 +504,17 @@ private void readXrefDependantBit(TableEntry entry) //Xdep B 70 dependent on an xref. (16 bit) if (((uint)xrefindex & 0b100000000) > 0) + { entry.Flags |= StandardFlags.XrefDependent; + } } else { //64-flag B 70 The 64-bit of the 70 group. if (this._objectReader.ReadBit()) + { entry.Flags |= StandardFlags.Referenced; + } //xrefindex + 1 BS 70 subtract one from this value when read. //After that, -1 indicates that this reference did not come from an xref, @@ -519,7 +523,9 @@ private void readXrefDependantBit(TableEntry entry) //Xdep B 70 dependent on an xref. (16 bit) if (this._objectReader.ReadBit()) + { entry.Flags |= StandardFlags.XrefDependent; + } } } @@ -2449,8 +2455,10 @@ private CadTemplate readViewport() //R13 - R14 Only: if (this.R13_14Only) + { //H VIEWPORT ENT HEADER(hard pointer) template.ViewportHeaderHandle = this.handleReference(); + } //R2000 +: if (this.R2000Plus) @@ -4732,9 +4740,7 @@ private CadTemplate readDimStyle() private CadTemplate readViewportEntityControl() { - return null; - - DwgViewportEntityControlTemplate template = new DwgViewportEntityControlTemplate(); + CadViewportEntityControlTemplate template = new CadViewportEntityControlTemplate(); this.readCommonNonEntityData(template); @@ -4742,38 +4748,41 @@ private CadTemplate readViewportEntityControl() //Numentries BL 70 int numentries = this._objectReader.ReadBitLong(); for (int i = 0; i < numentries; ++i) + { //Handle refs H NULL(soft pointer) xdicobjhandle(hard owner) the apps(soft owner) template.EntryHandles.Add(this.handleReference()); + } return template; } private CadTemplate readViewportEntityHeader() { - //Viewport viewport = new Viewport(); - //DwgViewportTemplate template = new DwgViewportTemplate(viewport); + Viewport viewport = new Viewport(); + CadViewportTemplate template = new CadViewportTemplate(viewport); - //this.readCommonNonEntityData(template); + this.readCommonNonEntityData(template); - ////Common: - ////Entry name TV 2 - //viewport.StyleSheetName = this._textReader.ReadVariableText(); + //Common: + //Entry name TV 2 + viewport.StyleSheetName = this._textReader.ReadVariableText(); + this._objectReader.ReadBit(); + this._objectReader.ReadBitShort(); + this._objectReader.ReadBit(); //this.readXrefDependantBit(viewport); - ////1 flag B The 1 bit of the 70 group - //this._objectReader.ReadBit(); - - ////Handle refs H viewport entity control (soft pointer) - //this.handleReference(); - ////xdicobjhandle (hard owner) - //this.handleReference(); - ////External reference block handle (hard pointer) - //this.handleReference(); + //1 flag B The 1 bit of the 70 group + this._objectReader.ReadBit(); - //TODO: transform the viewport ent into the viewport + //Handle refs H viewport entity control (soft pointer) + this.handleReference(); + //xdicobjhandle (hard owner) + this.handleReference(); + //External reference block handle (hard pointer) + template.BlockHandle = this.handleReference(); - return null; + return template; } private CadTemplate readGroup() diff --git a/src/ACadSharp/IO/Templates/CadViewportEntityControlTemplate.cs b/src/ACadSharp/IO/Templates/CadViewportEntityControlTemplate.cs new file mode 100644 index 00000000..adf2ca16 --- /dev/null +++ b/src/ACadSharp/IO/Templates/CadViewportEntityControlTemplate.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace ACadSharp.IO.Templates +{ + internal class CadViewportEntityControlTemplate : CadTemplate + { + public List EntryHandles { get; } = new List(); + + public CadViewportEntityControlTemplate() : base(new VPEntityPlaceholder()) { } + + public override void Build(CadDocumentBuilder builder) + { + base.Build(builder); + } + + public class VPEntityPlaceholder : CadObject + { + public override ObjectType ObjectType { get; } + + public override string SubclassMarker { get; } + } + } +} diff --git a/src/ACadSharp/IO/Templates/CadViewportTemplate.cs b/src/ACadSharp/IO/Templates/CadViewportTemplate.cs index b6404c12..abb564da 100644 --- a/src/ACadSharp/IO/Templates/CadViewportTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadViewportTemplate.cs @@ -17,7 +17,9 @@ internal class CadViewportTemplate : CadEntityTemplate public ulong? VisualStyleHandle { get; set; } - public short? ViewportId { get; internal set; } + public short? ViewportId { get; set; } + + public ulong? BlockHandle { get; set; } public List FrozenLayerHandles { get; set; } = new List(); @@ -29,8 +31,6 @@ public override void Build(CadDocumentBuilder builder) { base.Build(builder); - Viewport viewport = this.CadObject as Viewport; - if (this.ViewportHeaderHandle.HasValue && this.ViewportHeaderHandle > 0) { builder.Notify($"ViewportHeaderHandle not implemented for Viewport, handle {this.ViewportHeaderHandle}"); @@ -38,7 +38,7 @@ public override void Build(CadDocumentBuilder builder) if (builder.TryGetCadObject(this.BoundaryHandle, out Entity entity)) { - viewport.Boundary = entity; + this.CadObject.Boundary = entity; } else if (this.BoundaryHandle.HasValue && this.BoundaryHandle > 0) { @@ -74,7 +74,7 @@ public override void Build(CadDocumentBuilder builder) { if (builder.TryGetCadObject(handle, out Layer layer)) { - viewport.FrozenLayers.Add(layer); + this.CadObject.FrozenLayers.Add(layer); } else { diff --git a/src/ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs b/src/ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs deleted file mode 100644 index d0c32f56..00000000 --- a/src/ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs +++ /dev/null @@ -1,20 +0,0 @@ -using ACadSharp.Entities; -using ACadSharp.IO.DWG; -using System; -using System.Collections.Generic; - -namespace ACadSharp.IO.Templates -{ - internal class DwgViewportEntityControlTemplate : CadTemplate - { - public List EntryHandles { get; } = new List(); - - public DwgViewportEntityControlTemplate() : base(null) { } - - public override void Build(CadDocumentBuilder builder) - { - base.Build(builder); - - } - } -}