Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/ACadSharp.Tests/Entities/LwPolylineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ public void ExplodeClosedInLines()
}
}

[Fact]
public void ExplodeBulgeOverZeroLengthSegment()
{
LwPolyline lwPolyline = new LwPolyline();
lwPolyline.Vertices.Add(new LwPolyline.Vertex(new XY(0, 0)) { Bulge = 1.0 });
lwPolyline.Vertices.Add(new LwPolyline.Vertex(new XY(0, 0)));
lwPolyline.Vertices.Add(new LwPolyline.Vertex(new XY(10, 0)));

List<Entity> entities = lwPolyline.Explode().ToList();

Assert.Equal(2, entities.Count);
Line l = Assert.IsType<Line>(entities[0]);
Assert.Equal(XYZ.Zero, l.StartPoint);
Assert.Equal(XYZ.Zero, l.EndPoint);
Assert.IsType<Line>(entities[1]);
}

public override void GetBoundingBoxTest()
{
}
Expand Down
9 changes: 5 additions & 4 deletions src/ACadSharp/Extensions/PolylineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ public static IEnumerable<Entity> Explode(this IPolyline polyline)
break;
}

XY p1 = curr.Location.Convert<XY>();
XY p2 = next.Location.Convert<XY>();

Entity e = null;
if (curr.Bulge == 0)
//A bulge over a zero-length segment has no arc to create
if (curr.Bulge == 0 || p1.Equals(p2))
{
//Is a line
e = new Line
Expand All @@ -46,9 +50,6 @@ public static IEnumerable<Entity> Explode(this IPolyline polyline)
}
else
{
XY p1 = curr.Location.Convert<XY>();
XY p2 = next.Location.Convert<XY>();

//Is an arc
Arc arc = Arc.CreateFromBulge(p1, p2, curr.Bulge);
arc.Center = new XYZ(arc.Center.X, arc.Center.Y, polyline.Elevation);
Expand Down