Giter Site home page Giter Site logo

wholder / gerberplot Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 5.0 225 KB

This code began as rewrite of the "Plotter" portion of Philipp Knirsch's "Gerber RS-274D/X file viewer in Java" (see: http://www.wizards.de/phil/java/rs274x.html) but, the current code has been extensively rewritten and expanded to use Java's Shape-based graphics and fix numerous small issues I found with the original code

License: MIT License

Java 100.00%

gerberplot's Introduction

GerberPlot

This code began as rewrite of the "Plotter" portion of Philipp Knirsch's "Gerber RS-274D/X file viewer in Java" (see: http://www.wizards.de/phil/java/rs274x.html) but, the current code has been extensively rewritten and expanded to use Java's Shape-based graphics and fix numerous small issues I found with the original code. I've also added more features from version 2017.05 of the Gerber Format Specification by Ucamco, such as partial support for AD-type Macros and implemented many of the Aperture primitives needed for this. Note: some of the Aperture primitives remain untested, as I've yet to find a Gerber design that uses them. The untested code is noted in the source for the flashAperture() method.

Internally, the code first converts the Gerber file into a list of Shape-based objects in the drawItems List. Then, if renderMode is set to DRAW_IMAGE (the default when started), it draws this list of shapes directly to the screen. However, if renderMode is set to RENDER_FILLED or RENDER_OUTLINE, getBoardArea() is called to compute an Area shape by using the java.awt.geom.Area class's 2D constructive geometry operations add() and subtract(). This converts all the individual shapes in the drawItems List into a single Area() shape that contains all the geometry of the PCB design. Unfortunately, computing this Area becomes exponentially inefficient with larger Gerber files because, as each new shape is added, or subtracted its takes increasingly more time to calculate all the intersections. So, a progress bar is displayed to show the progress of the calculation. Once the Area is computed, however, it can be resized and redrawn very quickly. I have some ideas how to make this process more efficient, but have not yet had time to try them out.

Purpose of this Code

I developed GerberPlot as part of an experiment into trying to use an inexpensive paper cutting machine, such as the Silhouette Curio™ as a means to create PCBs by cutting a thin layer of copper foil applied to a substrate (see image above), or cut solder mask stencils out of Kapton™ film. If successsful, I plan to integrate this code into my LaserCut program, which is a 2D, CAD-like program I'm also developing. These experiments are still ongoing, but I decided to publish the code in the hope that someone else might find it useful for some other purpose, too.

Requirements

Java 8 JDK, or later must be installed in order to compile the code. There is also a Runnable JAR file included in the checked in code that you can download. On a Mac, just double click the GerberPlot.jar file and it should start. Then, use File->Open Gerber File to open a file and then use the Options menu to select different render modes. Note: you may have to select the GerberPlot.jar file, then do a right click and select "Open" the first time you run the file to satisfy Mac OS' security checks. You should also be able to run the JAR file on Windows or Linux systems, but you'll need to have a Java 8 JRE, or later installed and follow the appropriate process for each needed to run an executable JAR file.

Limitations

I've tried to adhere as close as possible to the latest revision of the Ucamco spec, version, 2017.05, which means my code may not parse some older Gerber files, such as ones that reply on on undocumented behavior, or deprecated operations. In particular, G36/G37 regions specified like this:

G36*G01X-0001Y-0001D02*X1076D01*Y0226*X-0001*Y-0001*G37*

Will not render because all of the coordinate values need to be followed by a D01 operation, like this:

G36*G01X-0001Y-0001D02*X1076D01*Y0226D01*X-0001D01*Y-0001D01*G37*

gerberplot's People

Contributors

wholder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.