Mail Archives: geda-user/2014/01/16/01:51:11
On Tue, Jan 14, 2014 at 09:19:38PM +0100, Robert Drehmel wrote:
> On 01/14/2014 08:42 AM, Gabriel Paubert wrote:
> >It's certainly not related to the GL drawing, I also see it with the
> >lesstif interface. I believe that this is a polygon dicer bug, and that
> >the nm conversion has nothing to do with it.
> >
> >I have attached two files which show the bug. On the first one, the
> >bug disappears temporarily if you type th delete key (to remove the
> >selected line) and then "u" to undo the changes. But it reappears
> >after saving and reloading the file. On a board I'm designing, I got
> >quite a few instances of the bug.
> >
> >The second file is the simplest test case I could come up with: a
> >single 0603 resistor and a single line segment. It can't get much
> >simpler than that. Just select the line and copy it from the first
> >pad to the second and the bug repeats. It seems to be very reproducible.
> >
> >I've been trying to enable the polygon debug code, but I don't really
> >understand the output.
>
> The attached patch fixes the provided test cases for me. It merges
> the pad clearance polygons with the accumulated POLYAREA, instead of
> subtracting them directly. It's quite possible that the patch is masking
> the bug by changing the order in which polygons are subtracted, though.
Thanks for the patch. It indeed fixes my testcases and the original
board from which I distilled them.
Best regards,
Gabriel
>
> Best regards,
> Robert
>
> diff --git a/src/polygon.c b/src/polygon.c
> index 5f17fd0..8204384 100644
> --- a/src/polygon.c
> +++ b/src/polygon.c
> @@ -107,6 +107,7 @@ dicer output is used for HIDs which cannot render things with holes
>
> #define UNSUBTRACT_BLOAT 10
> #define SUBTRACT_PIN_VIA_BATCH_SIZE 100
> +#define SUBTRACT_PAD_BATCH_SIZE 100
> #define SUBTRACT_LINE_BATCH_SIZE 20
>
> static double rotate_circle_seg[4];
> @@ -845,6 +846,15 @@ SubtractText (TextType * text, PolygonType * p)
> return Subtract (np, p, true);
> }
>
> +static POLYAREA *
> +PadPoly (PadType * pad)
> +{
> + if (TEST_FLAG (SQUAREFLAG, pad))
> + return SquarePadPoly (pad, pad->Thickness + pad->Clearance);
> + else
> + return LinePoly ((LineType *) pad, pad->Thickness + pad->Clearance);
> +}
> +
> static int
> SubtractPad (PadType * pad, PolygonType * p)
> {
> @@ -852,18 +862,8 @@ SubtractPad (PadType * pad, PolygonType * p)
>
> if (pad->Clearance == 0)
> return 0;
> - if (TEST_FLAG (SQUAREFLAG, pad))
> - {
> - if (!
> - (np = SquarePadPoly (pad, pad->Thickness + pad->Clearance)))
> - return -1;
> - }
> - else
> - {
> - if (!
> - (np = LinePoly ((LineType *) pad, pad->Thickness + pad->Clearance)))
> - return -1;
> - }
> + if ((np = PadPoly (pad)) == NULL)
> + return -1;
> return Subtract (np, p, true);
> }
>
> @@ -922,7 +922,6 @@ pin_sub_callback (const BoxType * b, void *cl)
>
> poly_Boolean_free (info->accumulate, np, &merged, PBO_UNITE);
> info->accumulate = merged;
> -
> info->batch_size ++;
>
> if (info->batch_size == SUBTRACT_PIN_VIA_BATCH_SIZE)
> @@ -954,21 +953,28 @@ pad_sub_callback (const BoxType * b, void *cl)
> {
> PadType *pad = (PadType *) b;
> struct cpInfo *info = (struct cpInfo *) cl;
> - PolygonType *polygon;
> + POLYAREA *np;
> + POLYAREA *merged;
>
> /* don't subtract the object that was put back! */
> if (b == info->other)
> return 0;
> if (pad->Clearance == 0)
> return 0;
> - polygon = info->polygon;
> - if (XOR (TEST_FLAG (ONSOLDERFLAG, pad), !info->solder))
> - {
> - if (SubtractPad (pad, polygon) < 0)
> - longjmp (info->env, 1);
> - return 1;
> - }
> - return 0;
> + if (!XOR (TEST_FLAG (ONSOLDERFLAG, pad), !info->solder))
> + return 0;
> +
> + if ((np = PadPoly (pad)) == NULL)
> + longjmp (info->env, 1);
> +
> + poly_Boolean_free (info->accumulate, np, &merged, PBO_UNITE);
> + info->accumulate = merged;
> + info->batch_size++;
> +
> + if (info->batch_size == SUBTRACT_PAD_BATCH_SIZE)
> + subtract_accumulated (info, info->polygon);
> +
> + return 1;
> }
>
> static int
- Raw text -