mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 03:59:00 +02:00
62 lines
1021 B
C
62 lines
1021 B
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] [file.stl]\n", name);
|
|
exit(1);
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
float box = 0;
|
|
int c;
|
|
|
|
slice_init();
|
|
|
|
while ((c = getopt(argc, argv, "b:")) != EOF)
|
|
switch (c) {
|
|
case 'b':
|
|
box = atof(optarg);
|
|
if (!box)
|
|
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);
|
|
}
|
|
|
|
slice_dump(box);
|
|
|
|
return 0;
|
|
}
|