tracespace / gerber-to-svg

gerber-to-svg development moved to tracespace/tracespace
https://github.com/tracespace/tracespace
MIT License
81 stars 20 forks source link

add option to merge all tools #19

Closed kasbah closed 9 years ago

kasbah commented 9 years ago

As discussed on mcous/svgerber#20

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.23%) to 91.59% when pulling 6bda79d3e3550151e2b32549e121f5c4e7ebd162 on kasbah:feat-merge-tools into c6dc1d61b3db067379d2a88d5cecb7184b557334 on mcous:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.23%) to 91.59% when pulling edecf8b5b38ef1c65101380b4af4f2d919fdc73d on kasbah:feat-merge-tools into c6dc1d61b3db067379d2a88d5cecb7184b557334 on mcous:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.23%) to 91.59% when pulling edecf8b5b38ef1c65101380b4af4f2d919fdc73d on kasbah:feat-merge-tools into c6dc1d61b3db067379d2a88d5cecb7184b557334 on mcous:master.

mcous commented 9 years ago

Sorry, I think you may have misunderstood my comments in mcous/svgerber#20. When I said "the outline builder should... have an option to combine all tools" I was referring to mcous/svgerber/src/build-board-outline.coffee and mcous/svgerber/src/build-board.coffee, not to this library.

I think merging tools is a job best left for a post-processing tool, not for the image generation library. I feel this way mostly because it's hard to define what this will do in all situations (and Gerber lets you get into some weird situations) when told to merge tools. I'm going to close this request accordingly. Also, for future reference, any code changes should be accompanied by new unit tests to verify their functionality.

kasbah commented 9 years ago

What if this had an option to specify the tool width to be used everywhere? Say gerber2svg --line-width=20. What weird situations could that result in? I think this option is really useful for outline layers in general.

mcous commented 9 years ago

A tool in Gerber is one of several shapes: a circle, a rectangle, an obround (ellipse-like), a polygon, or a macro made up of several shapes. Some tools (all circles and certain rectangles) may be "stroked" in different ways to create a line, and all tools may be "flashed" to create a pad.

One example of a weird situation (that I've seen happen): an outline layer has several tools defined, the first of which is a tool macro. This tool is not used in the layer, but if you "merged" the tools, how would it handle creating a line with this tool (which is unstrokable according to Gerber rules) when the file specifies a stroke originally intended for a different tool? You could go in and create extra checks for this situation, but then you'd have to do that for every other similar situation. You'd also have to decide what would happen in a file with flashes and stokes. Would a merge tool option only merge the tools for strokes, or would all flashes also be the same tool? And so on.

I consider this library to have a singular focus: to convert one vector image format (Gerber) to another vector image format (SVG) as accurately as possible. Any conversion options available are there to correct for assumptions that the library will make in the absence of information in the file.

With a layer that you know is an outline, I think it makes more sense to process the image, and then set all the SVG paths to the same stroke-width. The end result is the same, and the conversion library remains eas(ier) to understand and maintain.