Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Mask overlapping outlines is not removed in board view #20

Closed
kasbah opened this issue May 26, 2015 · 8 comments
Closed

Mask overlapping outlines is not removed in board view #20

kasbah opened this issue May 26, 2015 · 8 comments

Comments

@kasbah
Copy link
Contributor

kasbah commented May 26, 2015

The Bus Pirate v3.6 gerbers are a good example. The edges are rounded but the mask just keeps going.

@mcous
Copy link
Owner

mcous commented May 26, 2015

So this is an interesting problem, because the board outline gerber has a tiny, 0.0001in gap in the outline (at lines 454 and 455 in BusPirate-v3.6-SSOP.gko).

The board shape feature works by building a graph of adjacent outline points and walking them in order to create a manifold shape that can be filled to mask the board. If it fails to find a manifold shape it will fall back to just drawing the board as a rectangle with the outline indicated by a line.

Neither the old builder or the new builder has any sort of gap repair functionality, although this certainly provides a good case for when it would be needed.

@kasbah
Copy link
Contributor Author

kasbah commented May 26, 2015

I see (though I can't decipher the gerber format yet). There is a similar problem with the MC HCK gerbers (now in mm!) and I have seen it on a few other boards as well so I think closing gaps would be really good.

@mcous
Copy link
Owner

mcous commented May 26, 2015

I've looked at those MC HCK gerbers, and there's a slightly different problem with them: the outline is manifold, but it's drawn using three different tool sizes (line widths). The (new) outline builder splits shapes up by tool size for safety.

That being said, in this case the tool sizes are 0.1 mm, 0.0996mm, and 0.09906 mm, so I'm thinking by default the outline builder should combine tools that are within some size threshold, and also have an option to combine all tools.

With the tool sizes fixed up and run through new builder:
test-top

@kasbah
Copy link
Contributor Author

kasbah commented Jun 7, 2015

Neither the old builder or the new builder has any sort of gap repair functionality, although this certainly provides a good case for when it would be needed.

I looked into this a bit but I am really struggling. So the outline builder will crash on this (ith) points element because it's segments length is just one. Ok, but I am not quite sure how it and it's surrounding points describe a small gap and how I would repair it

i - 1:
{ x: 438.6,
  y: 617.6,
  segments: 
   [ { seg: 
        { start: 
           { x: 438.8,
             y: 609.9,
             segments: 
              [ { seg: [Object], rel: 'end' },
                { seg: [Circular], rel: 'start' },
                { seg: [Object], rel: 'end' },
                { seg: [Object], rel: 'start' } ] },
          end: [Circular] },
       rel: 'end' },
     { seg: 
        { start: [Circular],
          end: 
           { x: 438.8,
             y: 609.9,
             segments: 
              [ { seg: [Object], rel: 'end' },
                { seg: [Object], rel: 'start' },
                { seg: [Circular], rel: 'end' },
                { seg: [Object], rel: 'start' } ] } },
       rel: 'start' } ] } 
i:
{ x: 438.7,
  y: 617.6,
  segments: 
   [ { seg: 
        { start: [Circular],
          end: 
           { x: 438.7,
             y: 1759.3,
             segments: [ { seg: [Circular], rel: 'end' } ] } },
       rel: 'start' } ] } 
i + 1:
{ x: 438.7,
  y: 1759.3,
  segments: 
   [ { seg: 
        { start: 
           { x: 438.7,
             y: 617.6,
             segments: [ { seg: [Circular], rel: 'start' } ] },
          end: [Circular] },
       rel: 'end' } ] } 

@mcous
Copy link
Owner

mcous commented Jun 7, 2015

So the gap is the fact that Point i-1 and Point i were created as separate points.

I haven't tried anything with this yet, but I think the key to gap filling will be this line and this line in build-board-outline.coffee. Those two lines are responsible for checking if a given point has been recorded already, and if they could be expanded to check not only points with the exact same coordinates but also coordinates within some tiny distance, we might be able to fix our problem.

@kasbah
Copy link
Contributor Author

kasbah commented Jun 7, 2015

I had an incling that was it and did try this:

diff --git a/src/build-board-outline.coffee b/src/build-board-outline.coffee
index 5deed2d..26dc413 100644
--- a/src/build-board-outline.coffee
+++ b/src/build-board-outline.coffee
@@ -67,7 +69,10 @@ module.exports = (outline) ->
     if i >= outline.length then break
     else
       start = find points, { x: x, y: y }
-      if not start? then newStart = true; start = new Point x, y
+      if not start?
+        start = find points, (p) ->
+          Math.abs(p.x - x) <= 0.1 && Math.abs(p.y - y) <= 0.1
+        if not start? then newStart = true; start = new Point x, y

     # check our current character again to get the end of the segment
     if outline[i] is 'L'
@@ -91,7 +96,10 @@ module.exports = (outline) ->
       # set the path start if ncessary
       if not pathStart? then pathStart = start
       end = find points, { x: x, y: y }
-      if not end? then newEnd = true; end = new Point x, y
+      if not end?
+        end = find points, (p) ->
+          Math.abs(p.x - x) <= 0.1 && Math.abs(p.y - y) <= 0.1
+        if not end? then newEnd = true; end = new Point x, y

But that made the whole board disappear and trying it with a threshold of 0.01 still has the same points as without the new comparison step.

@mcous
Copy link
Owner

mcous commented Jun 7, 2015

The whole board disappearing is interesting and sounds like you might be on the right track and hitting a different bug entirely. what does the board mechanical mask layer SVG look like?

@kasbah
Copy link
Contributor Author

kasbah commented Jun 7, 2015

This is the top.svg and this is the top-out_2 layer with the fill colors and stroke-widths changed:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants