www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2014/01/14/15:20:10

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Message-ID: <52D59BDA.2040008@zoot.drehmel.com>
Date: Tue, 14 Jan 2014 21:19:38 +0100
From: Robert Drehmel <robert AT zoot DOT drehmel DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
MIME-Version: 1.0
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] New router pictures
References: <1389363489 DOT 2427 DOT 5 DOT camel AT AMD64X2 DOT fritz DOT box> <lb11t3$v8m$1 AT ger DOT gmane DOT org> <1389632128 DOT 2414 DOT 50 DOT camel AT AMD64X2 DOT fritz DOT box> <52D4532C DOT 2040100 AT neurotica DOT com> <1389653121 DOT 2066 DOT 15 DOT camel AT AMD64X2 DOT fritz DOT box> <20140114074240 DOT GA2384 AT visitor2 DOT iram DOT es>
In-Reply-To: <20140114074240.GA2384@visitor2.iram.es>
X-Provags-ID: V02:K0:6vhQt7/CP2qDMNFQXFee8HRGp9SoPDQ7p8048vB6LM/
TIbBQmrYH2SsBI6i1D+jcCA6gSzQyrOtyw4Xq5zuyEXArFqwYl
M3VJf7JWnjlfJXkacdY3FQhW4xR3M0aQ2dKS8HtHArWnI+FgGA
HOGt9c2RwhGWvdUovabo/1BmW3g6g5X+XV8WkaMKKdm3OmiXIz
a0KrEYWKi3W9jdTrgVot5DGUbpmXQjEOW4C7V/UUY+WdrZNRPO
wT48m8EwVEsSFVIqTAVB4MUANq+sO4tVNCAkuLP6/nlX627IDv
01S3ch3MtYflyl9L0flfu9T6BPIk6WbFb53+QPut5bu6JWk26C
hG1rybkfsBf0z/mWzCQ0puvqfg77vKTqVO4GSFHYV
Reply-To: geda-user AT delorie DOT com

This is a multi-part message in MIME format.
--------------090406090707050701000200
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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.

Best regards,
Robert


--------------090406090707050701000200
Content-Type: text/x-patch;
 name="polygon.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="polygon.c.diff"

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

--------------090406090707050701000200--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019