Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dwg entity mesh #341

Merged
merged 6 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ACadSharp/Entities/Mesh.Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public struct Edge
/// </summary>
public double? Crease { get; set; }

/// <summary>
/// Edge constructor with the start and end of the edge.
/// </summary>
/// <param name="start"></param>
/// <param name="end"></param>
public Edge(int start, int end)
{
this.Start = start;
this.End = end;
}

public override string ToString()
{
string str = $"{this.Start}|{this.End}";
Expand Down
55 changes: 48 additions & 7 deletions ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ private CadTemplate readMultiLeaderStyle()
mLeaderStyle.TextAngle = (TextAngleType)this._objectReader.ReadBitShort();

} // END IF IsNewFormat OR DXF file
// BS 176 Text alignment type
// BS 176 Text alignment type
mLeaderStyle.TextAlignment = (TextAlignmentType)this._objectReader.ReadBitShort();
// CMC 93 Text color
mLeaderStyle.TextColor = this._mergedReaders.ReadCmColor();
Expand All @@ -3329,7 +3329,7 @@ private CadTemplate readMultiLeaderStyle()
// B 297 Always align text left
mLeaderStyle.TextAlignAlwaysLeft = this._objectReader.ReadBit();
}// END IF IsNewFormat OR DXF file
// BD 46 Align space
// BD 46 Align space
mLeaderStyle.AlignSpace = this._objectReader.ReadBitDouble();
// H 343 Block handle (hard pointer)
template.BlockContentHandle = this.handleReference();
Expand Down Expand Up @@ -5347,20 +5347,61 @@ private CadTemplate readMesh()
Mesh mesh = new Mesh();
CadMeshTemplate template = new CadMeshTemplate(mesh);

#if TEST
this.readCommonEntityData(template);

//Same order as dxf?

//71 BS Version
mesh.Version = this._objectReader.ReadBitShort();
//72 BS BlendCrease
mesh.BlendCrease = this._objectReader.ReadBitShort();
mesh.BlendCrease = this._objectReader.ReadBit();
//91 BL SubdivisionLevel
mesh.SubdivisionLevel = this._objectReader.ReadBitLong();

var dict = DwgStreamReaderBase.Explore(this._objectReader);
#endif
//92 BL nvertices
int nvertices = this._objectReader.ReadBitLong();
for (int i = 0; i < nvertices; i++)
{
//10 3BD vertice
XYZ v = this._objectReader.Read3BitDouble();
mesh.Vertices.Add(v);
}

return null;
//Faces
int nfaces = this._objectReader.ReadBitLong();
for (int i = 0; i < nfaces; i++)
{
int faceSize = _objectReader.ReadBitLong();
int[] arr = new int[faceSize];
for (int j = 0; j < faceSize; j++)
{
arr[j] = _objectReader.ReadBitLong();
}

i += faceSize;

mesh.Faces.Add(arr.ToArray());
}

//Edges
int nedges = _objectReader.ReadBitLong();
for (int k = 0; k < nedges; k++)
{
int start = _objectReader.ReadBitLong();
int end = _objectReader.ReadBitLong();
mesh.Edges.Add(new Mesh.Edge(start, end));
}

//Crease
int ncrease = _objectReader.ReadBitLong();
for (int l = 0; l < ncrease; l++)
{
Mesh.Edge edge = mesh.Edges[l];
edge.Crease = _objectReader.ReadBitDouble();
mesh.Edges[l] = edge;
}

return template;
}

private CadTemplate readPlaceHolder()
Expand Down
Loading