2# Build the GitHub Pages site: download the first STEP chunk of the ABC
3# dataset, extract the first N models, gzip each file, and write an index.
4#
5# Env:
6# CHUNK_ARCHIVE path to an already-downloaded abc_0000_step_v00.7z
7# (skips the ~1.6 GB download)
8# WORK working directory (default: ./build)
9# N number of models to host (default: 1000)
10set -euo pipefail
12REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
13WORK=${WORK:-"$REPO_ROOT/build"}
14N=${N:-1000}
16mkdir -p "$WORK"
17cd "$WORK"
19if [ -z "${CHUNK_ARCHIVE:-}" ]; then
20 wget -q https://deep-geometry.github.io/abc-dataset/data/step_v00.txt
21 CHUNK_URL=$(sed '1q;d' step_v00.txt | awk '{print $1}')
22 CHUNK_NAME=$(sed '1q;d' step_v00.txt | awk '{print $2}')
23 echo "Downloading $CHUNK_NAME from $CHUNK_URL ..."
24 wget -q --no-check-certificate "$CHUNK_URL" -O "$CHUNK_NAME"
25 CHUNK_ARCHIVE="$WORK/$CHUNK_NAME"
26fi
27CHUNK_NAME=$(basename "$CHUNK_ARCHIVE")
29# Extract only the first N model directories; the full chunk holds 10000
30# models (~15 GB uncompressed), far more than we need or than CI disk allows.
31echo "Extracting first $N model directories from $CHUNK_NAME ..."
32seq -f '%08g/*' 0 $((N - 1)) > include.txt
33rm -rf extracted
347z x -y "$CHUNK_ARCHIVE" -i@include.txt -oextracted > /dev/null
36rm -rf site
37mkdir -p site/step
38find extracted -name '*.step' | sort | head -n "$N" > files.txt
39echo "Compressing $(wc -l < files.txt) STEP files ..."
40xargs -a files.txt -P "$(nproc)" -I{} \
41 sh -c 'gzip -9 -c "$1" > "site/step/$(basename "$1").gz"' _ {}
43python3 "$REPO_ROOT/scripts/make_index.py" files.txt site "$CHUNK_NAME"
44cp "$REPO_ROOT/site/index.html" site/
46echo "Done. Site size:"
47du -sh site