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
|
* gp2rml.c - Convert from gnuplot to RML
|
||||||
*
|
*
|
||||||
* Written 2010-2012 by Werner Almesberger
|
* Written 2010-2013 by Werner Almesberger
|
||||||
* Copyright 2010-2012 Werner Almesberger
|
* Copyright 2010-2013 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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 path *paths = NULL, *curr_path;
|
||||||
static struct segment **next_seg;
|
static struct segment **next_seg;
|
||||||
static double z_max = -1e6; /* -1 km :) */
|
static double z_max = -1e6; /* -1 km :) */
|
||||||
|
static double z_scale = 1; /* < 1: compress; > 1: stretch */
|
||||||
|
|
||||||
|
|
||||||
#define units(mm) ((int) round((mm)*40.0))
|
#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;
|
seg = seg->next;
|
||||||
while (seg) {
|
while (seg) {
|
||||||
printf("!ZZ%d,%d,%d\n", units(seg->x), units(seg->y),
|
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);
|
d = hypot(x-seg->x, y-seg->y);
|
||||||
txy = d/xy_speed;
|
txy = d/xy_speed;
|
||||||
tz = fabs(z-seg->z)/z_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)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s z_clear[mm] xy_speed z_speed [file]\n\n"
|
"usage: %s [-s z_scale] z_clear[mm] xy_speed z_speed [file]\n\n"
|
||||||
" z_clear clearance above the highest peak, in mm (must be > 0)\n"
|
" -s z_scale scale Z axis by z_scale (default: 1.0)\n"
|
||||||
" Unit (\"mm\") can optionally be specified\n"
|
" z_clear clearance above the highest peak, in mm (must be > 0)\n"
|
||||||
" xy_speed cutting speed, in mm/s\n"
|
" Unit (\"mm\") can optionally be specified\n"
|
||||||
" z_speed vertical speed when lowering the pen, in mm/s\n"
|
" xy_speed cutting speed, in mm/s\n"
|
||||||
|
" z_speed vertical speed when lowering the pen, in mm/s\n"
|
||||||
, name);
|
, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -197,11 +199,24 @@ static void usage(const char *name)
|
|||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
|
const char *name;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *end;
|
char *end;
|
||||||
int i;
|
int i;
|
||||||
double p[3];
|
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) {
|
switch (argc) {
|
||||||
case 4:
|
case 4:
|
||||||
file = stdin;
|
file = stdin;
|
||||||
@ -214,7 +229,7 @@ int main(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(name);
|
||||||
}
|
}
|
||||||
for (i = 0; i != 3; i++) {
|
for (i = 0; i != 3; i++) {
|
||||||
p[i] = strtod(argv[i+1], &end);
|
p[i] = strtod(argv[i+1], &end);
|
||||||
@ -225,7 +240,7 @@ int main(int argc, const char **argv)
|
|||||||
if (!i && *end && !strcmp(end, "mm"))
|
if (!i && *end && !strcmp(end, "mm"))
|
||||||
continue;
|
continue;
|
||||||
if (*end || p[i] <= 0)
|
if (*end || p[i] <= 0)
|
||||||
usage(*argv);
|
usage(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
process_file(file);
|
process_file(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user