#! /bin/csh -fe
# Last edited on 2001-05-13 16:25:11 by stolfi

set usage = "$0 TPNAME TAG"

if ( $#argv != 2 ) then
  echo "usage: ${usage}"; exit 1
endif

set tpname = "$1"; shift;
set tag = "$1"; shift;

set stname = "${tpname}-${tag}"

set pkg = ../../..

echo "${tpname}.tp, ${stname}.st -> ${stname}.st3"

echo "projectTo3D"
nice ${pkg}/ProjectTo3D/${M3PLATFORM}/ProjectTo3D \
  -inFileTp "${tpname}" \
  -inFileSt "${stname}" \
  -outFile  "${stname}" \
  -projection Parallel -oblique 0 \
  -adjustCenter -adjustScale \
  -statistics

echo "${tpname}.tp, ${stname}.st3 -> ${stname}.ppm"

echo "TriangToPov"
nice ${pkg}/TriangToPov/${M3PLATFORM}/TriangToPov @M3stackdump \
  -inFileTp  ${tpname} \
  -inFileSt3 ${stname} \
  -outFile   ${stname} \
  -all \
  \
  -style of faces \
    if silhouette                then  color = 0.5 1.0 0.7  transmit = 0.7 \
    if from map faces            then  invisible \
    if from map cells            then  invisible \
  -style of edges \
    if border  from map edges    then  color = 0.0 0.0 1.0  transmit = 0.0 radius = 0.004 \
    if border  from map faces    then  color = 0.4 0.7 0.1  transmit = 0.0 radius = 0.002 \
    if miswound                  then  color = 1.0 0.2 0.0  transmit = 0.0 radius = 0.020 \
    if from map edges            then  color = 0.0 0.0 1.0  transmit = 0.0 radius = 0.004 \
    if from map faces            then  color = 0.6 0.8 0.1  transmit = 0.0 radius = 0.002 \
    if from map cells            then  color = 1.0 0.8 0.1  transmit = 0.0 radius = 0.001 \
  -style of vertices \
    if border  from map vertices then  color = 1.0 0.0 0.0  transmit = 0.0 radius = 0.008 \
    if border  from map edges    then  color = 0.0 0.0 1.0  transmit = 0.0 radius = 0.004 \
    if border  from map faces    then  color = 0.4 0.7 0.1  transmit = 0.0 radius = 0.002 \
    if miswound                  then  color = 1.0 0.2 0.0  transmit = 0.0 radius = 0.020 \
    if from map vertices         then  color = 1.0 0.0 0.0  transmit = 0.0 radius = 0.008 \
    if from map edges            then  color = 0.0 0.0 1.0  transmit = 0.0 radius = 0.004 \
    if from map faces            then  color = 0.6 0.8 0.1  transmit = 0.0 radius = 0.002 \
    if from map cells            then  color = 1.0 0.8 0.1  transmit = 0.0 radius = 0.001

${pkg}/scripts/RunPOV ${stname} 400 400 1 AOFF

# -faces 3,4,5,6,7,10,12,13,15,20,21,23,24,27 \
#
# Cell 0 faces:  0,1,3,6,8,11,14,16,18,19,20,22,23,26
# Cell 1 faces:  0,2,4,7,9,11,13,14,15,17,19,22,25,27
# Cell 2 faces:  1,2,5,8,9,10,12,16,17,18,21,24,25,26
# Cell 3 faces:  3,4,5,6,7,10,12,13,15,20,21,23,24,27
