Build script now runs deps.sh before building to prevent running commands that aren't available.
Script now compiles csg files. TODO: fix the csg2step.py script by using latest FreeCAD logic. Script allows for input of a size (50ft/100ft) or an part (from FILES) to render fewer files. Migrate bulk of the loop into a render_part() function that can be re-used.
This commit is contained in:
parent
97737b0ba6
commit
fa5726a6a8
|
@ -8,5 +8,4 @@ else
|
||||||
CPU=-1
|
CPU=-1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo $CPU
|
echo $CPU
|
178
scripts/v3.sh
178
scripts/v3.sh
|
@ -3,89 +3,153 @@ V="v3"
|
||||||
|
|
||||||
echo "Rendering GNAL ${V}"
|
echo "Rendering GNAL ${V}"
|
||||||
|
|
||||||
sh ./scripts/license.sh
|
bash ./scripts/deps.sh
|
||||||
|
bash ./scripts/license.sh
|
||||||
|
|
||||||
VERSION=`bash ./scripts/version.sh`
|
VERSION=`bash ./scripts/version.sh`
|
||||||
CPU=`bash ./scripts/cpu.sh`
|
CPU=`bash ./scripts/cpu.sh`
|
||||||
DIST=./stl
|
DIST=./stl
|
||||||
|
CSG=./csg
|
||||||
IMG=./img
|
IMG=./img
|
||||||
NOTES=./notes/${V}.csv
|
NOTES=./notes/${V}.csv
|
||||||
|
STEP=true
|
||||||
|
LOGGING=true
|
||||||
|
|
||||||
#"quarter_a" "quarter_b" "quarter_c" "quarter_d"
|
#"quarter_a" "quarter_b" "quarter_c" "quarter_d"
|
||||||
#quarter pieces not rendering properly
|
#quarter pieces not rendering properly
|
||||||
|
|
||||||
FILES=( "spindle_bottom" "spindle_top" "spindle_single" "spacer" "top" "spiral" "insert_s8" "insert_16" "spacer_16" "insert_single" )
|
FILES=(
|
||||||
|
"spindle_bottom"
|
||||||
|
"spindle_top"
|
||||||
|
"spindle_single"
|
||||||
|
"insert_s8"
|
||||||
|
"insert_16"
|
||||||
|
"spacer_16"
|
||||||
|
"insert_single"
|
||||||
|
"top"
|
||||||
|
"spiral"
|
||||||
|
)
|
||||||
SIZES=( "50ft" "100ft" )
|
SIZES=( "50ft" "100ft" )
|
||||||
|
|
||||||
mkdir -p $DIST
|
mkdir -p $DIST
|
||||||
|
if [ $STEP = true ]; then
|
||||||
|
mkdir -p $CSG
|
||||||
|
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
|
||||||
|
openscad --csglimit=2000000 -o "$stl" -D "PART=\"${FILE}\"" -D "FN=800" "${scad}"
|
||||||
|
else
|
||||||
|
openscad --csglimit=1000000 -o "$stl" -D "PART=\"${FILE}\"" -D "FN=600" "${scad}"
|
||||||
|
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`
|
||||||
|
admesh -c -b "$stl" "$tmpBinary"
|
||||||
|
newSize=`wc -c < "$tmpBinary"`
|
||||||
|
newSize=`echo $newSize | xargs`
|
||||||
|
|
||||||
|
if [ $newSize -lt $fileSize ]; then
|
||||||
|
cp "$tmpBinary" "$stl"
|
||||||
|
percent=`echo "scale=1;($newSize/$fileSize)*100" | bc`
|
||||||
|
fileSize="${newSize}"
|
||||||
|
echo "Binary conversion created STL file ${percent}% of original"
|
||||||
|
else
|
||||||
|
echo "Binary STL is larger than ASCII original, skipping conversion..."
|
||||||
|
fi
|
||||||
|
rm "$tmpBinary"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
hash=`sha256sum "$stl" | awk '{ print $1 }'`
|
||||||
|
|
||||||
|
if [ ${LOGGING} = true ]; then
|
||||||
|
line="${VERSION},${CPU},$stl,$hash,$fileSize,$srchash,$srcsize,$facets,$volume,$runtime"
|
||||||
|
echo "$line" >> $NOTES
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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 "Rendering image of ${stl}..."
|
||||||
|
|
||||||
|
if [[ "${FILE}" == "spiral" ]]; then
|
||||||
|
tmp=`mktemp`
|
||||||
|
fullPath=`realpath "${stl}"`
|
||||||
|
data="import(\"${fullPath}\");"
|
||||||
|
echo data > "${tmp}.scad"
|
||||||
|
openscad -o "$png" --imgsize=2048,2048 --colorscheme=DeepOcean "${tmp}.scad"
|
||||||
|
else
|
||||||
|
openscad -o "$png" --imgsize=2048,2048 --colorscheme=DeepOcean -D "PART=\"${FILE}\"" "${scad}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${1}" != "" ]]; then
|
||||||
|
LOGGING=false
|
||||||
|
SIZE="${1}"
|
||||||
|
scad="./scad/${SIZE}_${V}/gnal_${SIZE}.scad"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
echo "version,cpu,file,file_hash,file_size,source_hash,source_size,facets,volume,render_time" > $NOTES
|
echo "version,cpu,file,file_hash,file_size,source_hash,source_size,facets,volume,render_time" > $NOTES
|
||||||
|
|
||||||
for SIZE in "${SIZES[@]}"
|
for SIZE in "${SIZES[@]}"
|
||||||
do
|
do
|
||||||
:
|
:
|
||||||
mkdir -p "${DIST}/${SIZE}_${V}"
|
|
||||||
scad="./scad/${SIZE}_${V}/gnal_${SIZE}.scad"
|
scad="./scad/${SIZE}_${V}/gnal_${SIZE}.scad"
|
||||||
srchash=`sha256sum "${scad}" | awk '{ print $1 }'`
|
srchash=`sha256sum "${scad}" | awk '{ print $1 }'`
|
||||||
srcsize=`wc -c < "${scad}"`
|
srcsize=`wc -c < "${scad}"`
|
||||||
srcsize=`echo $srcsize | xargs`
|
srcsize=`echo $srcsize | xargs`
|
||||||
|
|
||||||
for FILE in "${FILES[@]}"
|
mkdir -p "${DIST}/${SIZE}_${V}"
|
||||||
do
|
|
||||||
:
|
|
||||||
stl="${DIST}/${SIZE}_${V}/gnal_${SIZE}_${FILE}.stl"
|
|
||||||
png="${IMG}/gnal_${SIZE}_${V}_${FILE}.png"
|
|
||||||
echo "${scad} - ${FILE}"
|
|
||||||
start=`date +%s`
|
|
||||||
if [[ "${SIZE}" == "100ft" ]]; then
|
|
||||||
openscad -o "$stl" -D "PART=\"${FILE}\"" -D "FN=800" "${scad}"
|
|
||||||
else
|
|
||||||
openscad -o "$stl" -D "PART=\"${FILE}\"" -D "FN=600" "${scad}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
end=`date +%s`
|
for FILE in "${FILES[@]}"; do
|
||||||
runtime=$((end-start))
|
render_part "${scad}" "${SIZE}" "${FILE}"
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
hash=`sha256sum "$stl" | awk '{ print $1 }'`
|
|
||||||
|
|
||||||
line="${VERSION},${CPU},$stl,$hash,$fileSize,$srchash,$srcsize,$facets,$volume,$runtime"
|
|
||||||
echo "$line" >> $NOTES
|
|
||||||
echo "$line"
|
|
||||||
|
|
||||||
echo "Rendering image of ${stl}..."
|
|
||||||
|
|
||||||
if [[ "${FILE}" == "spiral" ]]; then
|
|
||||||
tmp=`mktemp`
|
|
||||||
fullPath=`realpath "${stl}"`
|
|
||||||
data="import(\"${fullPath}\");"
|
|
||||||
echo data > "${tmp}.scad"
|
|
||||||
openscad -o "$png" --imgsize=1920,1080 --colorscheme=DeepOcean "${tmp}.scad"
|
|
||||||
else
|
|
||||||
openscad -o "$png" --imgsize=1920,1080 --colorscheme=DeepOcean -D "PART=\"${FILE}\"" "${scad}"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# add license to directories for zip
|
# add license to directories for zip
|
||||||
cp ./LICENSE.txt "./stl/${SIZE}_v3/"
|
cp ./LICENSE.txt "./stl/${SIZE}_v3/"
|
||||||
# zip all
|
# zip all
|
||||||
|
|
Loading…
Reference in New Issue