Skip to content

Dxf read Hatch boundary error #287

@chihsiliu1966

Description

@chihsiliu1966

private HatchBoundaryPath ReadEdgePolylineBoundaryPath()
{
HatchBoundaryPath.Polyline poly = new HatchBoundaryPath.Polyline();

this.chunk.Next();

bool hasBulge = this.chunk.ReadShort() != 0; // code 72
this.chunk.Next();

// is polyline closed
// poly.IsClosed = this.chunk.ReadShort() != 0; // code 73, this value must always be true
this.chunk.Next();

int numVertexes = this.chunk.ReadInt(); // code 93
poly.Vertexes = new Vector3[numVertexes];
this.chunk.Next();

for (int i = 0; i < numVertexes; i++)
{
    double bulge = 0.0;
    double x = this.chunk.ReadDouble(); // code 10
    this.chunk.Next();
    double y = this.chunk.ReadDouble(); // code 20
    this.chunk.Next();
    if (hasBulge)
    {
        bulge = this.chunk.ReadDouble(); // code 42
        this.chunk.Next();
    }
    poly.Vertexes[i] = new Vector3(x, y, bulge);
}
poly.IsClosed = true;//kai????  <----  add this line
HatchBoundaryPath path = new HatchBoundaryPath(new List<HatchBoundaryPath.Edge> {poly});

// read all referenced entities
Debug.Assert(this.chunk.Code == 97, "The reference count code 97 was expected.");
int numBoundaryObjects = this.chunk.ReadInt();
this.hatchContours.Add(path, new List<string>(numBoundaryObjects));
this.chunk.Next();
for (int i = 0; i < numBoundaryObjects; i++)
{
    Debug.Assert(this.chunk.Code == 330, "The reference handle code 330 was expected.");
    this.hatchContours[path].Add(this.chunk.ReadString());
    this.chunk.Next();
}

return path;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions