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

Gerber: Always use multi-quadrant mode #504

Merged
merged 2 commits into from
Aug 28, 2019
Merged

Conversation

dbrgn
Copy link
Member

@dbrgn dbrgn commented Aug 23, 2019

@ubruhin here's a first attempt at fixing this issue.

The spec says:

Another option is not to use very small arcs, e.g. by replacing them with
draws - the error is very small and draws are stable.

Right now I'm replacing arcs shorter than 0.01mm (point-to-point) with straight lines.

We probably need to handle some special cases, right? A full circle has start==end with angle=360, right? We should probably still draw arcs if start and end are identical.

I guess we can ignore cases where the two points are closer together than 0.01mm with a lage angle, right?

Fixes #247.

@dbrgn dbrgn added the bug label Aug 23, 2019
@dbrgn dbrgn requested a review from ubruhin August 23, 2019 18:41
@dbrgn dbrgn added the export Issues related to any data export label Aug 23, 2019
Copy link
Member

@ubruhin ubruhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

We probably need to handle some special cases, right? A full circle has start==end with angle=360, right? We should probably still draw arcs if start and end are identical.

Yes of course.

I guess we can ignore cases where the two points are closer together than 0.01mm with a lage angle, right?

Hmm I'm not sure about that. It seems to be quite difficult to find good criteria when to replace arcs by straight lines :( I just took a quick look at KiCad and I couldn't find code which avoids the numerical instability, it looks like they simply always use multiquadrant mode without handling special cases.

Maybe it would indeed be reasonable to simply ignore the numerical instability. The risk of doing something wrong when handling special cases might be higher than the risk of really getting wrong arcs in the Gerber output (with a resolution of 1nm it's extremely unlikely to ever draw some arcs in LibrePCB which really lead to issues due to numerical instability). Or what do you think @dbrgn?

libs/librepcb/common/cam/gerbergenerator.cpp Outdated Show resolved Hide resolved
libs/librepcb/common/cam/gerbergenerator.cpp Outdated Show resolved Hide resolved
libs/librepcb/common/cam/gerbergenerator.cpp Outdated Show resolved Hide resolved
libs/librepcb/common/cam/gerbergenerator.h Outdated Show resolved Hide resolved
@dbrgn
Copy link
Member Author

dbrgn commented Aug 25, 2019

Maybe it would indeed be reasonable to simply ignore the numerical instability. The risk of doing something wrong when handling special cases might be higher than the risk of really getting wrong arcs in the Gerber output

I agree and removed the special case handling. We're already using FSLAX66 format.

Other issues should be handled now.

@dbrgn dbrgn requested a review from ubruhin August 25, 2019 13:35
Copy link
Member

@ubruhin ubruhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! 👍

@dbrgn
Copy link
Member Author

dbrgn commented Aug 27, 2019

@ubruhin ok, rebased & squashed!

@ubruhin ubruhin added this to the 0.1.3 milestone Aug 27, 2019
@ubruhin ubruhin merged commit 9150f41 into master Aug 28, 2019
@ubruhin ubruhin deleted the 247-gerber-multiquadrant branch August 28, 2019 05:49
ubruhin added a commit that referenced this pull request Nov 17, 2019
Gerber: Always use multi-quadrant mode
(cherry picked from commit 9150f41)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug export Issues related to any data export
Development

Successfully merging this pull request may close these issues.

Don't use single quadrant mode arcs in Gerber generator
2 participants