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

Gerber: Always use multi-quadrant mode #504

merged 2 commits into from Aug 28, 2019

Conversation

@dbrgn
Copy link
Member

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 Aug 23, 2019
@dbrgn dbrgn added the gerber label Aug 23, 2019
Copy link
Member

ubruhin left a comment

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

This comment has been minimized.

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 Aug 25, 2019
Copy link
Member

ubruhin left a comment

Looks good, thanks! 👍

@dbrgn dbrgn force-pushed the 247-gerber-multiquadrant branch from 87c8c63 to cd44610 Aug 27, 2019
@dbrgn

This comment has been minimized.

Copy link
Member Author

dbrgn commented Aug 27, 2019

@ubruhin ok, rebased & squashed!

@dbrgn dbrgn force-pushed the 247-gerber-multiquadrant branch from cd44610 to 2b79c7d Aug 27, 2019
@dbrgn dbrgn force-pushed the 247-gerber-multiquadrant branch from 2b79c7d to 16a80e7 Aug 27, 2019
@ubruhin ubruhin added this to the 0.1.3 milestone Aug 27, 2019
@ubruhin ubruhin merged commit 9150f41 into master Aug 28, 2019
11 checks passed
11 checks passed
LibrePCB Build #20190827.6 succeeded
Details
LibrePCB (Doxygen) Doxygen succeeded
Details
LibrePCB (Linux Ubuntu_1404_GCC) Linux Ubuntu_1404_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1604_GCC) Linux Ubuntu_1604_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1604_Qt_5_12_3_GCC) Linux Ubuntu_1604_Qt_5_12_3_GCC succeeded
Details
LibrePCB (Linux Ubuntu_1804_Clang) Linux Ubuntu_1804_Clang succeeded
Details
LibrePCB (Linux Ubuntu_1904_GCC9) Linux Ubuntu_1904_GCC9 succeeded
Details
LibrePCB (Stylecheck) Stylecheck succeeded
Details
LibrePCB (macOS) macOS succeeded
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@ubruhin ubruhin deleted the 247-gerber-multiquadrant branch Aug 28, 2019
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
Projects
None yet
2 participants
You can’t perform that action at this time.