Menu

#69 Fix handling of single-quadrant arcs (G74*)

Unstable (example)
open
nobody
7
2019-08-14
2018-04-07
Danilo
No

This patch fixes the rendering of single-quadrant arcs. Gerbv does not render them correctly.

Background

With this Gerber file:

%FSLAX66Y66*%
%MOMM*%
G04 --- Apertures --- *
%ADD10C,1*%
G04 --- Use Aperture D10 --- *
D10*
G04 --- CCW Circular Interpolation --- *
G03*
G04 --- Draw arc --- *
X46721021Y66920000D02*
G74*
X46721021Y58920000I7491334J4000000D01*
M02*

...a single quadrant arc should be drawn. Here's the illustration in geogebra:

screenshot

As you can see, there are four possible centerpoints. Two of them have an angle of <=90°. Unfortunately gerbv picks the wrong one:

gerbv screenshot

The reason is that gerbv only considers x/y distance between the start and end point to pick a centerpoint. But that can give false results. You also need to consider the arc deviation (length difference from the centerpoint to start and end points). The arc with the lowest deviation should be picked.

You can find some more information in the commit message. I rewrote the single quadrant function to pick the correct centerpoint quadrant. Once the correct quadrant is chosen, the single quadrant arc can be handled just like a multi quadrant arc. Thus, the angle calculation code could be removed in this commit in favor of a call to calc_cirseg_mq, resulting in less duplication of rendering logic.Once the correct quadrant is chosen, the single quadrant arc can be handled just like a multi quadrant arc. Thus, the angle calculation code could be removed in this commit in favor of a call to calc_cirseg_mq, resulting in less duplication of rendering logic.

1 Attachments

Discussion

  • Danilo

    Danilo - 2018-04-07

    Here's a screenshot of the reference Gerber viewer (https://gerber.ucamco.com/) rendering the example above:

    screenshot

    I also attached another file that can be used to test the rendering. This is what it should look like:

    screenshot2

     
  • Sergey Alyoshin

    Sergey Alyoshin - 2018-04-21

    With this patch there is a problem with arcs in example/nollezappare/EtchLayer2Bottom.gdo

     
  • Eyal

    Eyal - 2018-09-17

    Please test with start point equal to stop point. In that case, single quadrant should output just a dot and multiquadrant should draw an entire circle.

    Why calculate all possiblities and put them in an array? You could just calculate them in a loop and store the best-so-far centerpoint.

    Also, you must check that the width and height calculations are correct. I saw some bad cases in my testing.

     

    Last edit: Eyal 2018-09-17
  • Danilo

    Danilo - 2019-08-14

    Sorry for not replying so far. Thanks for the feedback!

    Right now I can't really find time to fix the patch. Maybe someone else can pick up this bug?

     

Log in to post a comment.