From ddf5c236446767b60718b7254a4e4d3c5e4c941c Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Sun, 23 May 2021 19:00:18 +0200 Subject: added test command for upload custom file, various smaller changes, fixed float little-endian loading --- service/src/stlfile.c | 14 +++++++++++++- service/src/util.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'service/src') 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 */ -- cgit v1.2.3-71-gd317