Skip to content

Explode a bulge over a zero-length segment as a line - #1339

Open
komal0000 wants to merge 1 commit into
DomCR:masterfrom
komal0000:fix/explode-zero-length-bulge
Open

komal0000 wants to merge 1 commit into
DomCR:masterfrom
komal0000:fix/explode-zero-length-bulge

Conversation

@komal0000

Copy link
Copy Markdown
Contributor

Description

PolylineExtensions.Explode() throws ArgumentOutOfRangeException: The radius must be greater than 0. when a vertex has a bulge but the next vertex is at the same location (a zero-length segment). Explode() decides between a line and an arc only from Bulge, so it calls Arc.CreateFromBulge with two equal points, which produces a zero radius.

This change treats a bulged segment with equal start and end points as a line, the same way a zero-length straight segment is already exploded. @ghostid suggested the same approach in the issue.

Tasks done in this PR

  • Something awesome.
  • An evil bug have been defeated.
  • Code cleanup and maintenance has been done.

Related Issues / Pull Requests

Notes for reviewer

  • New test LwPolylineTests.ExplodeBulgeOverZeroLengthSegment fails on master with the exception from the issue and passes with the fix.
  • dotnet test src/ACadSharp.Tests -f net9.0: 2489 passed. AddCadObjectStressTest and RemoveCadObjectStressTest fail on my machine with and without this change (timing assertions), so they're unrelated.
  • PolyLine.Explode(IPolyline) (internal static) holds a copy of the same loop but has no callers, so I left it alone.
  • I used an AI assistant while working on this change. I reviewed the code and tests myself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PolylineExtensions.Explode() : System.ArgumentOutOfRangeException: The radius must be greater than 0.

1 participant