-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcode.cc
65 lines (60 loc) · 2.46 KB
/
gcode.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This is a component of stippler, an image processing tool
// Copyright 2004, 2005 Jeff Epler <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <cstdio>
struct point { double x, y; };
extern int cols, rows;
void output(char *name, bool reverse_video, bool variable_size, double maxden,
double *den, int ndots, struct point *G) {
printf("(generated by stippler from %s with %d dots %dx%d)\n",
name, ndots, cols, rows);
printf("#1=[1/72] (Scaling factor)\n"
"#2=-0.002 (Minimum depth of cut for dots)\n"
"#12=-0.006 (Maximum depth of cut for dots)\n"
"#3=0.000 (Dwell time)\n"
"#4=0.015 (Safety height)\n"
"#5=25 (Feed rate for dots)\n"
"\n"
"#10=-1 (1 = normal X, -1 = mirror X)\n"
"#11=1 (1 = normal Y, -1 = mirror Y)\n"
"\n"
"#9=1.5 (Toolchange height)\n"
);
printf("G0 Z#4\n"
"G61\n"
"G17 G20 G40 G49\n"
"G54 G80 G90 G94\n"
"G64\n"
"S1000 M3\n"
"G4 P3\n");
printf("(Begin block of reorderable sections)\n");
for(int i=0; i<ndots; i++) {
printf("(Begin section %f %f)\n", G[i].x, G[i].y);
if(variable_size) {
double depth = variable_size ? den[i] / maxden : .5;
printf("G82 X[%f*#1*#10] Y[%f*#1*#11] Z[#2+%f*[#12-#2]] "
"P#3 R#4 F#5\n",
G[i].x, G[i].y, depth);
} else {
printf("G82 X[%f*#1*#10] Y[%f*#1*#11] Z#2 P#3 R#4 F#5\n",
G[i].x, G[i].y);
}
printf("(End section)\n");
}
printf("(End block of reorderable sections)\n");
printf("G0 Z#9\n");
printf("M2\n");
}