Skip to content

Commit c511518

Browse files
committed
Initial commit
0 parents  commit c511518

5 files changed

Lines changed: 101 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
snapz
2+
*.stl

COPYING

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
Version 2, December 2004
3+
4+
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5+
6+
Everyone is permitted to copy and distribute verbatim or modified
7+
copies of this license document, and changing it is allowed as long
8+
as the name is changed.
9+
10+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12+
13+
0. You just DO WHAT THE FUCK YOU WANT TO

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CC?=gcc
2+
CFLAGS?=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong -pedantic
3+
LIBS=-ladmesh
4+
5+
snapz: snapz.c
6+
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
7+
8+
clean:
9+
rm -f snapz
10+
11+
.PHONY: clean

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
snapz - Snaps STL files to zero Z coordinate
2+
============================================
3+
4+
STL files sliced with Skeinforge are not snapped to zero Z coordinate automatically.
5+
This could lead to various errors while printing and you have to be sure to snap the STL object to Z = 0.
6+
While there are GUI tools that can do that, snapz aims for command line utility.
7+
8+
Compile
9+
-------
10+
11+
To compile snapz, you'll need the [admesh library](https://github.com/hroncok/admesh), gcc and make. Then just type `make` to compile it.
12+
13+
Install
14+
-------
15+
16+
You don't need to install snapz, you can invoke it from where it is with `./snapz`. However, to make things easier, it is recommended to put it somewhere in your `$PATH` (e.g. `/usr/local/bin`).
17+
18+
Run
19+
---
20+
21+
To snap an STL file to Z = 0, run:
22+
23+
snapz file.stl
24+
25+
If you want to keep the input and save the snapped STL to a different file, you can do it this way:
26+
27+
snapz input.stl output.stl
28+
29+
If `output.stl` exists, it will be overwritten without questions, cause you know, what are you doing, right?
30+
31+
License
32+
-------
33+
34+
This app and it's docs are released under the terms of WTFPL. That means you just do what the fuck you want to.

snapz.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <admesh/stl.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
5+
#define NAME "snapz"
6+
#define VERSION "1"
7+
#define INFO NAME " " VERSION "\n"
8+
#define COPYRIGHT "Created by Miro Hrončok <miro@hroncok.cz>, WTFPL\n"
9+
#define USAGE "Usage: " NAME " file.stl [output.stl]\n"
10+
11+
int main(int argc, char** argv) {
12+
int out;
13+
stl_file* s;
14+
15+
if (argc == 2) {
16+
if (!strcmp(argv[1],"--help")) {
17+
printf(INFO COPYRIGHT USAGE);
18+
return EXIT_SUCCESS;
19+
}
20+
if (!strcmp(argv[1],"--version")) {
21+
printf(INFO);
22+
return EXIT_SUCCESS;
23+
}
24+
out = 1;
25+
} else if (argc == 3) {
26+
out = 2;
27+
} else {
28+
printf(USAGE);
29+
return EXIT_FAILURE;
30+
}
31+
32+
s = (stl_file*)malloc(sizeof(stl_file));
33+
memset(s,0,sizeof(stl_file));
34+
stl_open(s,argv[1]);
35+
stl_translate(s, s->stats.min.x, s->stats.min.y, 0.0);
36+
stl_write_binary(s, argv[out], "snapzed");
37+
stl_close(s);
38+
free(s);
39+
return EXIT_SUCCESS;
40+
}
41+

0 commit comments

Comments
 (0)