# Last edited on 2024-09-19 11:13:44 by stolfi

SHELL := /bin/bash

.PHONY: \
  make-all-models show-all-models make-all-images \
  make-nnn-models show-nnn-models make-nnn-images

PROG := slicing_box_example

# all: make-all-models show-all-models
# all: make-all-models make-all-images
# all: make-all-models
all: make-all-images

TAG := box

# ${NI} values for {make-all-models}:
NIS := 512 1024 2048 4096 8192

# Should {make-nnn-images} display each image and wait?
SHOW := NO

make-all-models:
	for Ni in ${NIS} ; do \
          ${MAKE} NI=$${Ni} make-nnn-models ; \
        done
        
make-all-images:
	${MAKE} NI=2 make-nnn-models make-nnn-images

########################################################################
# Section for one ${NI}:

ifneq "/${NI}" "/"

NI8 := ${shell printf "%08d" ${NI}}

OUT_PREF := out/${TAG}_${NI8}

make-nnn-models: ${PROG}.py ${wildcard *.py}
	mkdir -p out
	rm -fv ${OUT_PREF}_*.{obj,inc,pgm}
	${PROG}.py ${TAG} ${NI} || ( rm -fv ${OUT_PREF}_*.{obj,inc,pgm} ; exit 1 )
	tar -cvzf ${OUT_PREF}.tgz ${OUT_PREF}_*.obj

show-nnn-models:
	for subd in triang convex mono orig; do \
          ofile="${OUT_PREF}_$${subd}.obj" ; \
	  if [[ -s $${ofile} ]]; then \
            ls -l $${ofile} ; \
            f3d -n $${ofile} ; \
          fi ; \
        done

make-nnn-images: slicing_box_run_povray.sh
	for subd in triang convex mono orig; do \
	  ifile="${OUT_PREF}_$${subd}.inc" ; \
	  if [[ -s $${ifile} ]]; then \
            slicing_box_run_povray.sh ${TAG} ${NI} $${subd} ${SHOW} ; \
          fi ; \
        done

endif
