mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-01-03 20:00:14 +02:00
gp2rml/gp2rml.c: new option -s to set Z scale factor
Sounds weird, but the mill seems to be off by some 10%.
This commit is contained in:
parent
033d55c8ad
commit
d64a34045f
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gp2rml.c - Convert from gnuplot to RML
|
||||
*
|
||||
* Written 2010-2012 by Werner Almesberger
|
||||
* Copyright 2010-2012 Werner Almesberger
|
||||
* Written 2010-2013 by Werner Almesberger
|
||||
* Copyright 2010-2013 Werner Almesberger
|
||||
*
|
||||
* 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
|
||||
@ -56,6 +56,7 @@ struct path {
|
||||
static struct path *paths = NULL, *curr_path;
|
||||
static struct segment **next_seg;
|
||||
static double z_max = -1e6; /* -1 km :) */
|
||||
static double z_scale = 1; /* < 1: compress; > 1: stretch */
|
||||
|
||||
|
||||
#define units(mm) ((int) round((mm)*40.0))
|
||||
@ -155,7 +156,7 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
|
||||
seg = seg->next;
|
||||
while (seg) {
|
||||
printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y),
|
||||
units(seg->z-z_max));
|
||||
units((seg->z-z_max)*z_scale));
|
||||
d = hypot(x-seg->x, y-seg->y);
|
||||
txy = d/xy_speed;
|
||||
tz = fabs(z-seg->z)/z_speed;
|
||||
@ -185,11 +186,12 @@ static void output_paths(double z_clear, double xy_speed, double z_speed)
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s z_clear[mm] xy_speed z_speed [file]\n\n"
|
||||
" z_clear clearance above the highest peak, in mm (must be > 0)\n"
|
||||
" Unit (\"mm\") can optionally be specified\n"
|
||||
" xy_speed cutting speed, in mm/s\n"
|
||||
" z_speed vertical speed when lowering the pen, in mm/s\n"
|
||||
"usage: %s [-s z_scale] z_clear[mm] xy_speed z_speed [file]\n\n"
|
||||
" -s z_scale scale Z axis by z_scale (default: 1.0)\n"
|
||||
" z_clear clearance above the highest peak, in mm (must be > 0)\n"
|
||||
" Unit (\"mm\") can optionally be specified\n"
|
||||
" xy_speed cutting speed, in mm/s\n"
|
||||
" z_speed vertical speed when lowering the pen, in mm/s\n"
|
||||
, name);
|
||||
exit(1);
|
||||
}
|
||||
@ -197,11 +199,24 @@ static void usage(const char *name)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
const char *name;
|
||||
FILE *file;
|
||||
char *end;
|
||||
int i;
|
||||
double p[3];
|
||||
|
||||
name = *argv;
|
||||
|
||||
if (argc > 2 && !strcmp(argv[1], "-s")) {
|
||||
if (argc < 3)
|
||||
usage(name);
|
||||
z_scale = strtod(argv[2], &end);
|
||||
if (*end)
|
||||
usage(name);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
|
||||
switch (argc) {
|
||||
case 4:
|
||||
file = stdin;
|
||||
@ -214,7 +229,7 @@ int main(int argc, const char **argv)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
usage(name);
|
||||
}
|
||||
for (i = 0; i != 3; i++) {
|
||||
p[i] = strtod(argv[i+1], &end);
|
||||
@ -225,7 +240,7 @@ int main(int argc, const char **argv)
|
||||
if (!i && *end && !strcmp(end, "mm"))
|
||||
continue;
|
||||
if (*end || p[i] <= 0)
|
||||
usage(*argv);
|
||||
usage(name);
|
||||
}
|
||||
|
||||
process_file(file);
|
||||
|
Loading…
Reference in New Issue
Block a user