stlfile.h (944B)
1#ifndef STLFILE_H 2#define STLFILE_H 3 4#include <stdlib.h> 5#include <string.h> 6#include <stdint.h> 7#include <endian.h> 8#include <math.h> 9 10#include "util.h" 11 12#define FMT_ERR(...) fprintf(stderr, "FORMAT ERR: " __VA_ARGS__) 13 14enum { 15 KW_INVALID = -1, 16 KW_UNKNOWN, 17 KW_SOLID_BEGIN, 18 KW_SOLID_END, 19 KW_FACET_BEGIN, 20 KW_FACET_END, 21 KW_LOOP_BEGIN, 22 KW_LOOP_END, 23 KW_VERTEX 24}; 25 26enum { 27 STATE_SOLID, 28 STATE_FACET, 29 STATE_LOOP 30}; 31 32enum { 33 TYPE_ASCII, 34 TYPE_BIN 35}; 36 37struct stack { 38 int *data; 39 size_t count, cap; 40}; 41 42struct parseinfo { 43 char header[80], *hash, *modelname, *solidname; 44 uint32_t loopcount; 45 unsigned filesize; 46 float bbmin[3], bbmax[3]; 47 int type, valid; 48}; 49 50int parse_file(struct parseinfo *info, char *buf, size_t len, char **modelname); 51int save_info(struct parseinfo *info, FILE *f); 52int load_info(struct parseinfo *info, FILE *f); 53void print_info(struct parseinfo *info); 54void free_info(struct parseinfo *info); 55 56#endif /* STLFILE_H */