1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 05:23:19 +02:00
cae-tools/slicer/slicer.c
2015-01-08 09:54:53 -03:00

76 lines
1.4 KiB
C

/*
* slicer.c - Generate slices
*
* Written 2015 by Werner Almesberger
* Copyright 2015 by 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "slice.h"
#include "stl.h"
static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-b distance] [-z distance] [file.stl]\n"
" -b distance draw a box at the specified distance around the object\n"
" (default: do not draw a box)\n"
" -z distance duplicate layers if distance to next lower is larger than\n"
" specified (default: do not insert intermediate layers\n"
, name);
exit(1);
}
int main(int argc, char **argv)
{
float box = 0;
float z_step = 0;
int c;
slice_init();
while ((c = getopt(argc, argv, "b:z:")) != EOF)
switch (c) {
case 'b':
box = atof(optarg);
if (!box)
usage(*argv);
break;
case 'z':
z_step = atof(optarg);
if (!z_step)
usage(*argv);
break;
default:
usage(*argv);
}
switch (argc-optind) {
case 0:
stl_load_file(stdin, slice);
break;
case 1:
stl_load(argv[optind], slice);
break;
default:
usage(*argv);
}
if (z_step)
slice_intermediate(z_step);
slice_dump(box);
return 0;
}