diff options
Diffstat (limited to 'service/src')
| -rw-r--r-- | service/src/stlfile.c | 14 | ||||
| -rw-r--r-- | service/src/util.h | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/service/src/stlfile.c b/service/src/stlfile.c index 4dda8ee..88fc430 100644 --- a/service/src/stlfile.c +++ b/service/src/stlfile.c @@ -248,7 +248,7 @@ parse_file_bin(struct parseinfo *info, char *buf, size_t len) bp += 12; for (k = 0; k < 3; k++, bp += 12) { for (m = 0; m < 3; m++) { - v = le32toh(*(float *)(bp + 4 * m)); + v = fle32toh(*(float*)(bp + 4 * m)); info->bbmin[m] = MIN(info->bbmin[m], v); info->bbmax[m] = MAX(info->bbmax[m], v); } @@ -401,3 +401,15 @@ free_info(struct parseinfo *info) NULLFREE(info->solidname); info->valid = 0; } + +float fle32toh(float v) +{ + union { + uint32_t u; + float f; + } conv; + + conv.f = v; + conv.u = le32toh(conv.u); + return conv.f; +} diff --git a/service/src/util.h b/service/src/util.h index eaef14f..c0e9064 100644 --- a/service/src/util.h +++ b/service/src/util.h @@ -31,6 +31,8 @@ const char* ask(const char *fmtstr, ...); void dump(const char *filepath); int strpfcmp(const char *prefix, const char *str); +float fle32toh(float v); + extern int echo; #endif /* UTIL_H */ |
