1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 04:13:20 +02:00

slicer/Makefile, slicer.c: forgot to commit these files :-(

This commit is contained in:
Werner Almesberger 2015-01-08 09:12:53 -03:00
parent 6b7cecaf5f
commit aa327c8e37
2 changed files with 86 additions and 0 deletions

25
slicer/Makefile Normal file
View File

@ -0,0 +1,25 @@
#
# slicer/Makefile - Build the mesh slicer
#
# Written 2015 by Werner Almesberger
# Copyright 2015 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.
#
NAME = slicer
OBJS = $(NAME).o slice.o stl.o
CFLAGS = -g -Wall -Wshadow -Wmissing-prototypes -Wmissing-declarations\
$(shell pkg-config --cflags glib-2.0)
LDLIBS = -lm $(shell pkg-config --libs glib-2.0)
$(NAME): $(OBJS)
clean:
rm -f $(OBJS)

61
slicer/slicer.c Normal file
View File

@ -0,0 +1,61 @@
/*
* 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;
}