Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Dec 19, 2024
1 parent 8bc0ca3 commit dff3c4d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 45 deletions.
49 changes: 29 additions & 20 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -4732,48 +4740,49 @@ private CadTemplate readDimStyle()

private CadTemplate readViewportEntityControl()
{
return null;

DwgViewportEntityControlTemplate template = new DwgViewportEntityControlTemplate();
CadViewportEntityControlTemplate template = new CadViewportEntityControlTemplate();

this.readCommonNonEntityData(template);

//Common:
//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()
Expand Down
23 changes: 23 additions & 0 deletions src/ACadSharp/IO/Templates/CadViewportEntityControlTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;

namespace ACadSharp.IO.Templates
{
internal class CadViewportEntityControlTemplate : CadTemplate
{
public List<ulong> EntryHandles { get; } = new List<ulong>();

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; }
}
}
}
10 changes: 5 additions & 5 deletions src/ACadSharp/IO/Templates/CadViewportTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ internal class CadViewportTemplate : CadEntityTemplate<Viewport>

public ulong? VisualStyleHandle { get; set; }

public short? ViewportId { get; internal set; }
public short? ViewportId { get; set; }

public ulong? BlockHandle { get; set; }

public List<ulong> FrozenLayerHandles { get; set; } = new List<ulong>();

Expand All @@ -29,16 +31,14 @@ 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}");
}

if (builder.TryGetCadObject<Entity>(this.BoundaryHandle, out Entity entity))
{
viewport.Boundary = entity;
this.CadObject.Boundary = entity;
}
else if (this.BoundaryHandle.HasValue && this.BoundaryHandle > 0)
{
Expand Down Expand Up @@ -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
{
Expand Down
20 changes: 0 additions & 20 deletions src/ACadSharp/IO/Templates/DwgViewportEntityControlTemplate.cs

This file was deleted.

0 comments on commit dff3c4d

Please sign in to comment.