From 28c7ef1bb4e19bd1372988768df106c370a3c2d8 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Wed, 19 Aug 2020 15:12:02 -0400 Subject: [PATCH] Script to convert existing models to binary. Found a curious thing: taking one very complex file from ascii to binary increased the file size dramatically (9460%). Need to investigate if this was a specific case and whether or not this is something to investigate in other projects. The model in question is gnal_100ft_spiral_top.stl produced by current code. --- scripts/binary_convert.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/binary_convert.sh diff --git a/scripts/binary_convert.sh b/scripts/binary_convert.sh new file mode 100644 index 0000000..f92f413 --- /dev/null +++ b/scripts/binary_convert.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# "v1" not working as expected +VERSIONS=( "v2" "v3" ) +SIZES=( "50ft" "100ft" ) + + +for VERSION in "${VERSIONS[@]}" +do + : + + for SIZE in "${SIZES[@]}" + do + : + echo "./stl/${SIZE}_${VERSION}" + FILES=./stl/${SIZE}_${VERSION}/*.stl + for stl in $FILES + do + fileSize=`wc -c < "$stl"` + fileSize=`echo $newSize | xargs` + + firstline=`head -n 1 "$stl"` + if [[ $firstline == solid* ]]; then + echo "Converting $stl to binary..." + #convert from ascii to binary + admesh -c -b "$stl" "$stl" + newSize=`wc -c < "$stl"` + newSize=`echo $newSize | xargs` + percent=`echo "scale=1;($newSize/$fileSize)*100" | bc` + #fileSize="${newSize}" + echo "Binary conversion created STL file ${percent}% of original" + fi + done + + done +done \ No newline at end of file