2020-05-28 16:16:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
V="v3"
|
|
|
|
|
2021-10-15 16:13:08 +00:00
|
|
|
# Commit changes before running this build script
|
|
|
|
|
2020-05-28 16:16:45 +00:00
|
|
|
echo "Rendering GNAL ${V}"
|
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
bash ./scripts/deps.sh
|
|
|
|
bash ./scripts/license.sh
|
2021-02-18 02:57:55 +00:00
|
|
|
|
2020-05-28 16:16:45 +00:00
|
|
|
VERSION=`bash ./scripts/version.sh`
|
|
|
|
CPU=`bash ./scripts/cpu.sh`
|
|
|
|
DIST=./stl
|
2021-10-15 15:20:11 +00:00
|
|
|
CSG=./csg
|
2020-05-28 16:16:45 +00:00
|
|
|
IMG=./img
|
|
|
|
NOTES=./notes/${V}.csv
|
2021-11-03 21:20:03 +00:00
|
|
|
STEP=false
|
2021-10-15 15:20:11 +00:00
|
|
|
LOGGING=true
|
2020-09-12 14:57:01 +00:00
|
|
|
|
2020-08-19 12:41:26 +00:00
|
|
|
#"quarter_a" "quarter_b" "quarter_c" "quarter_d"
|
|
|
|
#quarter pieces not rendering properly
|
2020-09-12 14:57:01 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
FILES=(
|
|
|
|
"spindle_bottom"
|
|
|
|
"spindle_top"
|
2021-11-03 21:20:03 +00:00
|
|
|
"spindle_single"
|
|
|
|
"spindle_stacking"
|
2021-10-15 15:20:11 +00:00
|
|
|
"insert_s8"
|
|
|
|
"insert_16"
|
2021-10-15 16:32:31 +00:00
|
|
|
"spacer"
|
2021-10-15 15:20:11 +00:00
|
|
|
"spacer_16"
|
|
|
|
"insert_single"
|
|
|
|
"top"
|
|
|
|
"spiral"
|
|
|
|
)
|
2020-05-28 16:16:45 +00:00
|
|
|
SIZES=( "50ft" "100ft" )
|
|
|
|
|
2021-10-15 15:39:18 +00:00
|
|
|
mkdir -p "${DIST}"
|
2021-10-18 18:15:01 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
if [ $STEP = true ]; then
|
2021-10-15 15:39:18 +00:00
|
|
|
mkdir -p "${CSG}"
|
2021-10-15 15:20:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
render_part () {
|
|
|
|
scad="${1}"
|
|
|
|
SIZE="${2}"
|
|
|
|
FILE="${3}"
|
|
|
|
stl="${DIST}/${SIZE}_${V}/gnal_${SIZE}_${FILE}.stl"
|
|
|
|
csg="${CSG}/${SIZE}_${V}/gnal_${SIZE}_${FILE}.csg"
|
|
|
|
png="${IMG}/gnal_${SIZE}_${V}_${FILE}.png"
|
|
|
|
|
|
|
|
echo "${scad} - ${FILE}"
|
|
|
|
|
|
|
|
start=`date +%s`
|
|
|
|
if [[ "${SIZE}" == "100ft" ]]; then
|
2021-10-18 17:07:19 +00:00
|
|
|
openscad --csglimit=2000000 -o "$stl" -D "PART=\"${FILE}\"" -D "FN=800" -D "DEBUG=false" "${scad}"
|
2021-10-15 15:20:11 +00:00
|
|
|
else
|
2021-10-18 17:07:19 +00:00
|
|
|
openscad --csglimit=1000000 -o "$stl" -D "PART=\"${FILE}\"" -D "FN=600" -D "DEBUG=false" "${scad}"
|
2021-10-15 15:20:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
end=`date +%s`
|
|
|
|
runtime=$((end-start))
|
|
|
|
|
|
|
|
fileSize=`wc -c < "$stl"`
|
|
|
|
fileSize=`echo $fileSize | xargs`
|
|
|
|
|
|
|
|
if ! [ -x "$(command -v admesh)" ]; then
|
|
|
|
facets="N/A"
|
|
|
|
volume="N/A"
|
|
|
|
else
|
|
|
|
firstline=`head -n 1 "$stl"`
|
|
|
|
if [[ $firstline == solid* ]]; then
|
|
|
|
#convert from ascii to binary
|
|
|
|
tmpBinary=`mktemp`
|
2021-10-15 15:39:18 +00:00
|
|
|
admesh -c -b "$tmpBinary" "$stl"
|
2021-10-15 15:20:11 +00:00
|
|
|
newSize=`wc -c < "$tmpBinary"`
|
|
|
|
newSize=`echo $newSize | xargs`
|
|
|
|
|
|
|
|
if [ $newSize -lt $fileSize ]; then
|
|
|
|
cp "$tmpBinary" "$stl"
|
2020-08-19 05:14:04 +00:00
|
|
|
percent=`echo "scale=1;($newSize/$fileSize)*100" | bc`
|
2020-08-19 12:41:26 +00:00
|
|
|
fileSize="${newSize}"
|
2020-08-19 05:14:04 +00:00
|
|
|
echo "Binary conversion created STL file ${percent}% of original"
|
2021-10-15 15:20:11 +00:00
|
|
|
else
|
|
|
|
echo "Binary STL is larger than ASCII original, skipping conversion..."
|
2020-08-19 05:14:04 +00:00
|
|
|
fi
|
2021-10-15 15:20:11 +00:00
|
|
|
rm "$tmpBinary"
|
2020-06-04 13:46:13 +00:00
|
|
|
fi
|
2021-10-15 15:20:11 +00:00
|
|
|
ao=`admesh -c "$stl"`
|
|
|
|
facets=`echo "$ao" | grep "Number of facets" | awk '{print $5}'`
|
|
|
|
volume=`echo "$ao" | grep "Number of parts" | awk '{print $8}'`
|
|
|
|
fi
|
2020-05-31 01:53:57 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
hash=`sha256sum "$stl" | awk '{ print $1 }'`
|
2020-08-19 12:41:26 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
if [ ${LOGGING} = true ]; then
|
2020-05-28 16:16:45 +00:00
|
|
|
line="${VERSION},${CPU},$stl,$hash,$fileSize,$srchash,$srcsize,$facets,$volume,$runtime"
|
|
|
|
echo "$line" >> $NOTES
|
|
|
|
echo "$line"
|
2021-10-15 15:20:11 +00:00
|
|
|
fi
|
|
|
|
|
2021-10-15 16:13:08 +00:00
|
|
|
if [ ${STEP} = true ] && [[ "${FILE}" == "spiral" ]]; then
|
2021-10-18 18:15:01 +00:00
|
|
|
mkdir -p "${CSG}/${SIZE}_${V}/"
|
2021-10-15 16:13:08 +00:00
|
|
|
start=`date +%s`
|
|
|
|
if [[ "${SIZE}" == "100ft" ]]; then
|
|
|
|
openscad --csglimit=20000000 -o "$csg" -D "PART=\"${FILE}\"" -D "FN=800" "${scad}"
|
|
|
|
else
|
|
|
|
openscad --csglimit=10000000 -o "$csg" -D "PART=\"${FILE}\"" -D "FN=600" "${scad}"
|
|
|
|
fi
|
|
|
|
end=`date +%s`
|
|
|
|
runtime=$((end-start))
|
|
|
|
echo "Compiling CSG took ${runtime}sec"
|
2021-10-15 15:20:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Rendering image of ${stl}..."
|
|
|
|
|
|
|
|
if [[ "${FILE}" == "spiral" ]]; then
|
|
|
|
tmp=`mktemp`
|
|
|
|
fullPath=`realpath "${stl}"`
|
|
|
|
data="import(\"${fullPath}\");"
|
|
|
|
echo data > "${tmp}.scad"
|
2021-11-03 21:20:03 +00:00
|
|
|
openscad -o "$png" --csglimit=2000000 --imgsize=2048,2048 --colorscheme=DeepOcean "${tmp}.scad"
|
2021-10-15 15:20:11 +00:00
|
|
|
else
|
2021-11-03 21:20:03 +00:00
|
|
|
openscad -o "$png" --csglimit=1000000 --imgsize=2048,2048 --colorscheme=DeepOcean -D "PART=\"${FILE}\"" "${scad}"
|
2021-10-15 15:20:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "${1}" != "" ]]; then
|
|
|
|
LOGGING=false
|
|
|
|
SIZE="${1}"
|
|
|
|
scad="./scad/${SIZE}_${V}/gnal_${SIZE}.scad"
|
2020-05-28 16:16:45 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
mkdir -p "${DIST}/${SIZE}_${V}"
|
|
|
|
if [[ "${2}" != "" ]]; then
|
|
|
|
FILE="${2}"
|
|
|
|
render_part "${scad}" "${SIZE}" "${FILE}"
|
|
|
|
else
|
|
|
|
for FILE in "${FILES[@]}"; do
|
|
|
|
render_part "${scad}" "${SIZE}" "${FILE}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-05-28 16:16:45 +00:00
|
|
|
|
2021-10-15 15:20:11 +00:00
|
|
|
echo "version,cpu,file,file_hash,file_size,source_hash,source_size,facets,volume,render_time" > $NOTES
|
|
|
|
|
|
|
|
for SIZE in "${SIZES[@]}"
|
|
|
|
do
|
|
|
|
:
|
|
|
|
scad="./scad/${SIZE}_${V}/gnal_${SIZE}.scad"
|
|
|
|
srchash=`sha256sum "${scad}" | awk '{ print $1 }'`
|
|
|
|
srcsize=`wc -c < "${scad}"`
|
|
|
|
srcsize=`echo $srcsize | xargs`
|
|
|
|
|
|
|
|
mkdir -p "${DIST}/${SIZE}_${V}"
|
|
|
|
|
|
|
|
for FILE in "${FILES[@]}"; do
|
|
|
|
render_part "${scad}" "${SIZE}" "${FILE}"
|
2020-05-28 16:16:45 +00:00
|
|
|
done
|
2021-10-15 15:20:11 +00:00
|
|
|
|
2021-02-18 02:57:55 +00:00
|
|
|
# add license to directories for zip
|
|
|
|
cp ./LICENSE.txt "./stl/${SIZE}_v3/"
|
2020-08-19 16:46:19 +00:00
|
|
|
# zip all
|
2020-08-19 17:13:30 +00:00
|
|
|
zip -x ".*" -r "./releases/gnal_${SIZE}_v3.zip" "./stl/${SIZE}_v3/"
|
|
|
|
# tar all
|
|
|
|
tar --exclude=".*" -czvf "./releases/gnal_${SIZE}_v3.tar.gz" "./stl/${SIZE}_v3/"
|
2021-02-18 02:57:55 +00:00
|
|
|
done
|
|
|
|
|