37 #include <glib/gstdio.h>
45 #define round(x) floor(x + 0.5)
52 GArray* apertureTable = g_array_new(FALSE, FALSE,
sizeof(
int));
56 setlocale(LC_NUMERIC,
"C");
58 if ((fd = g_fopen(filename,
"w")) == NULL) {
59 GERB_COMPILE_ERROR(_(
"Can't open file for writing: %s"), filename);
72 "; Please change this parameters to your needs\r\n"
73 "; Don't forget to change the drill depth to\r\n"
74 "; your PCB thickness\r\n"
76 "; The normal movement velocity in 1/1000 mm/s\r\n"
79 "; The fast movement velocity in 1/1000 mm/s\r\n"
81 "; The safety height in mm over the PCB for movement\r\n"
85 "; Drill velocity of downwards movement in 1/1000 mm/s\r\n"
89 "; The drill depth in 1/1000 mm\r\n"
91 "DRILLDEF D1800 ; 1.5mm material + 0.3mm break through\r\n"
93 "; DO NOT CHANGE THESE PARAMETERS!!\r\n"
100 gerbv_aperture_t* currentAperture;
104 for (
int i = APERTURE_MIN; i < APERTURE_MAX; i++) {
105 currentAperture = image->
aperture[i];
107 if (!currentAperture)
110 switch (currentAperture->type) {
113 fprintf(fd,
"; TOOL %d - Diameter %1.3f mm\r\n", i + 1, COORD2MMS(currentAperture->parameter[0]));
114 g_array_append_val(apertureTable, i);
123 for (guint i = 0; i < apertureTable->len; i++) {
124 int currentAperture = g_array_index(apertureTable,
int, i);
127 fprintf(fd,
"GETTOOL %d\r\n", currentAperture + 1);
130 for (currentNet = image->
netlist; currentNet; currentNet = currentNet->
next) {
132 if (currentNet->
aperture != currentAperture)
140 xVal = (long)round(COORD2MMS(currentNet->
stop_x) * 1e3);
141 yVal = (long)round(COORD2MMS(currentNet->
stop_y) * 1e3);
142 fprintf(fd,
"DRILL X%06ld Y%06ld\r\n", xVal, yVal);
146 GERB_COMPILE_WARNING(
147 _(
"Skipped to export of unsupported state %d "
148 "interpolation \"%s\""),
154 g_array_free(apertureTable, TRUE);
156 fprintf(fd,
"PROGEND\r\n");
161 setlocale(LC_NUMERIC,
"");
gboolean gerbv_export_isel_drill_file_from_image(const gchar *filename, gerbv_image_t *inputImage, gerbv_user_transformation_t *transform)
Export an image to a new file in ISEL NCP drill format.
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
gerbv_image_t * gerbv_image_duplicate_image(gerbv_image_t *sourceImage, gerbv_user_transformation_t *transform)
Duplicate an existing image and return the new copy.
const char * gerbv_interpolation_name(gerbv_interpolation_t interp)
Return string name of gerbv_interpolation_t interpolation.
The main header file for the libgerbv library.
@ GERBV_APERTURE_STATE_FLASH
gerbv_aperture_t * aperture[APERTURE_MAX]
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation