#!/bin/sh
#
#  NOTE:  all tests duplicated in q_test.bat
if ! which qconvex >/dev/null 2>&1; then
    if [ ! -d bin ]; then
	echo 'eg/q_test: Run eg/q_test from the Qhull directory with bin/qconvex, or add qconvex/etc. to $PATH'
        exit 1
    fi
    if [ ! -e bin/qconvex -a ! -e bin/qconvex.exe ]; then
        echo 'eg/q_test: Build qhull first.  qconvex is missing from bin/ directory and $PATH'
        exit 1
    fi
    echo 'eg/q_test: Temporarily add "$PWD/bin" to $PATH for access to qconvex,etc.'
    PATH=$PWD/bin:$PATH
    if ! which qconvex >/dev/null 2>&1; then
	echo 'eg/q_test: PATH=... failed.  Please execute "export PATH=$PWD/bin:$PATH" and repeat'
	exit 1
    fi
fi
if ! user_eg >/dev/null; then
    echo eg/q_test: user_eg failed to run.  It uses the shared qhull library 
    echo 'On Linux, export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH'
    echo 'On Windows with mingw, cp -p lib/libqhull_r.dll bin/'
fi

echo ==============================
echo ========= eg/q_test ==========
echo == Check qhull programs ======
echo ==============================
echo
echo "qhull => $(qhull -V)"
echo "qconvex => $(qconvex -V)"
echo "qvoronoi => $(qconvex -V)"
echo "qdelaunay => $(qdelaunay -V)"
echo "qhalf => $(qhalf -V)"
(ls -ld $(which qhull) \
      $(which qconvex) \
      $(which qvoronoi) \
      $(which qdelaunay) \
      $(which qhalf) \
      $(which user_eg) \
      $(which user_eg2) \
      $(which user_eg3)) 2>/dev/null
echo ==============================
echo == check user_eg, user_eg2, and user_eg3
echo == errors if 'user_eg' and 'user_eg2' not found
echo ==============================
set -v # echo commands to stdout
user_eg
user_eg  'QR1 p n Qt'  'v p'  'Fp'
user_eg2
user_eg2 'QR1 p'       'v p'  'Fp'
user_eg3
user_eg3 eg-100
user_eg3 eg-convex
user_eg3 eg-delaunay
user_eg3 eg-voronoi
user_eg3 eg-fifo
user_eg3 rbox qhull
user_eg3 rbox qhull T1
user_eg3 rbox qhull d
user_eg3 rbox y c
user_eg3 rbox D2 10 2 "s r 5"  qhull 's p' facets
user_eg3 rbox "10 D2" eg-convex
user_eg3 rbox '10 D2' qhull s eg-convex
user_eg3 rbox 10 eg-delaunay qhull 'd o'
user_eg3 rbox D5 c P2 qhull d eg-delaunay
user_eg3 rbox '10 D2' eg-voronoi
user_eg3 rbox "D5 c P2" qhull v eg-voronoi o
user_eg3 rbox '10 D2' eg-fifo
user_eg3 rbox D2 10 qhull v eg-fifo p Fi Fo

set +v
echo === check front ends and examples ${d:-`date`} ==================
set -v
qconvex -
qconvex .
qconvex -? # [mar'19] isatty does not work for Git for Windows
rbox c D3 | qconvex s n Qt 
rbox c D2 | qconvex s i 
rbox c D2 | qconvex s n
rbox c D2 | qconvex o
rbox 1000 s | qconvex s Tv FA
rbox c d D2 | qconvex s Qc Fx
rbox y 1000 W0 | qconvex Qc s n 
rbox y 1000 W0 | qconvex s QJ
rbox d G1 D12 | qconvex QR0 FA
rbox c D6 | qconvex s FA TF500
rbox c D7 | qconvex s FA TF1000
rbox d G1 D12 | qconvex QR0 FA Pp
rbox c P0 d D2 | qconvex p Fa Fc FP FI Fn FN FS Fv Fx 
rbox c d D2 | qconvex s i QV0
rbox c | qconvex Q0
qvoronoi -
qvoronoi .
qvoronoi -? # [mar'19] isatty does not work for Git for Windows
rbox c P0 D2 | qvoronoi s o
rbox c P0 D2 | qvoronoi Fi Tv
rbox c P0 D2 | qvoronoi Fo Tv
rbox c P0 D2 | qvoronoi Fv
rbox c P0 D2 | qvoronoi s Qu Fv
rbox c P0 D2 | qvoronoi s Qu Qt Fv
rbox c P0 D2 | qvoronoi Qu Fo
rbox c G1 d D2 | qvoronoi s p 
rbox c G1 d D2 | qvoronoi QJ p 
rbox c P-0.1 P+0.1 P+0.1 D2 | qvoronoi s Fc FP FQ Fn FN 
rbox P0 c D2 | qvoronoi s Fv QV0
qdelaunay -
qdelaunay .
qdelaunay -? # [mar'19] isatty does not work for Git for Windows
rbox c P0 D2 | qdelaunay s o
rbox c P0 D2 | qdelaunay i
rbox c P0 D2 | qdelaunay Fv
rbox c P0 D2 | qdelaunay s Qu Qt Fv
rbox c G1 d D2 | qdelaunay s i
rbox c G1 d D2 | qhull d Qbb Ft
rbox c G1 d D2 | qhull d Qbb QJ s Ft
rbox M3,4 z 100 D2 | qdelaunay s
rbox c P-0.1 P+0.1 P+0.1 D2 | qdelaunay s Fx Fa Fc FP FQ Fn FN
rbox P0 P0 c D2 | qdelaunay s FP QV0
qhalf -
qhalf .
qhalf -? # [mar'19] isatty does not work for Git for Windows
rbox d | qhull FQ n | qhalf s Qt H0,0,0 Fp
rbox c | qhull FQ FV n | qhalf s i
rbox c | qhull FQ FV n | qhalf o
rbox d D2 | qhull FQ n | qhalf s H0 Fc FP Fn FN FQ Fv Fx
# qhull - printed at end
qhull .
qhull -? # [mar'19] isatty does not work for Git for Windows
rbox 1000 s | qhull Tv s FA
rbox 10 D2 | qhull d QJ s i TO q_test.log.1
cat q_test.log.1
rbox 10 D2 | qhull v Qbb Qt p
rbox 10 D2 | qhull d Qu QJ m              
rbox 10 D2 | qhull v Qu QJ o
rbox c d D2 | qhull Qc s f Fx      
rbox c | qhull FV n | qhull H Fp
rbox d D12 | qhull QR0 FA                 
rbox c D7 | qhull FA TF1000
rbox y 1000 W0 | qhull Qc                 
rbox c | qhull n
rbox c | qhull TA1
rbox 10 s | qhull C1e-5 T1P-1f

set +v
echo === check quality of Qhull for ${d:-`hostname`} ${d:-`date`}
set -v
rbox 1000 W0 | qhull QR2 QJ s Fs Tv
rbox 1000 W0 | qhull QR2 s Fs Tv
rbox 1000 s | qhull C0.02 Qc Tv
rbox 500 s D4 | qhull C0.01 Qc Tv
rbox 1000 s | qhull C-0.02 Qc Tv
rbox 1000 s D4 | qhull C-0.01 Qc Tv
rbox 200 s D5 | qhull C-0.01 Qx Qc Tv 
rbox 100 s D6 | qhull C-0.001 Qx Qc Tv
rbox 1000 W1e-4 | qhull C-1e-6 Qc Tv
rbox 1000 W5e-4 D4 | qhull C-1e-5 Qc Tv
rbox 400 W1e-3 D5 | qhull C-1e-5 Qx Qc Tv

set +v
echo === check input format etc. ${d:-`date`}
set -v
qhull <<EOF
2 4 input comment
1 0 1 1 1 2  0 0
EOF
qhull <<EOF
2 4 input comment
1 0 1 1 1 2  0 0 0
EOF
qhull Qa <<EOF
2 4 input comment
1 0 1 1 1 2  0 0 0
EOF
qhull <<EOF
2 4 input comment
1 0 1 1 1 2  0
EOF
qhull Qa <<EOF
2 4 input comment
1 0 1 1 1 2  0
EOF
qhull <<EOF
2 
4 input comment
1 #another comment
0 1 1 1 2  0
EOF
qhull <<EOF
2 4  1 0  1 1  1 2  0 0
EOF
qhull d Qz <<EOF
2 5  1 0  1 1  0 1  0 0  0
EOF
qhull d Q8 Qz <<EOF
2 5  1 0  1 1  0 1  0 0  0
EOF
rbox d h | qhull Fd FV n FD Tcv | qhull Fd H Fp Tcv
rbox 10 h | qhull Fd FD p Tcv | qhull Fd d Tcv 

set +v
echo === check rbox ${d:-`date`}
set -v
rbox 3 n D2
rbox 3 D2
rbox 3 h D2
rbox 3 z D2
rbox 3 z h D2
rbox 3 B10 D2
rbox 3 B10 D2 C2,1E-13,1
rbox 3 z B10 D2
rbox 4 L2 r D2
rbox 8 L2 r D2
rbox 8 L2 D2 C1,1E-13,2
rbox 4 L4 r D3
rbox 4 L4 s D5 W1e-3 
rbox 4 L4 s D5 W1e-3 C1,1E-12
rbox y
rbox 10 M3,4 
rbox 10 M3,4 C1,1E-14
rbox 27 M1,0,1
rbox 10 L4 r D3 | qhull Tcv
rbox 10 L4 s D5 W1e-3 | qhull Tcv
rbox 10 L4 s D5 W1e-3 C1,1E-12 | qhull Tcv
rbox 10 L6 D3 | qhull Tcv
rbox 10 L1.1 s D4 | qhull Tcv
rbox y r 100 W0 O0.5 | qhull s p Tcv
rbox x r 100 W0 O0.5 | qhull s Tcv
rbox 12 D8 | qhull Tcv
rbox 12 D9 | qhull Tcv
rbox 1000 D4 | qhull s i A-0.97 C0.2 A0.7 Tcv
rbox 3 D2 | qhull Qb0B1:-2 p 
rbox 100 r D2 | qhull Pd0:0.7 PD0:0.8 Pg n Tcv
rbox 1000 s | qhull  C0.05 Tcv
rbox 1000 s t | qhull Qm C0.05 Tcv
rbox 500 D2 | qhull n A-0.95 C0.1 Tcv
rbox 500 s P1,1,1 | qhull QgG0 Pp Tcv
rbox d | qhull m
rbox d | qhull FM
rbox c D2 | qhull Tcv Q0
rbox d D2 | qhull Tcv
rbox c D3 | qhull Tcv Q0
rbox d D3 | qhull Tcv
rbox c D4 | qhull Tcv Q0
rbox d D4 | qhull Tcv
rbox c D5 | qhull Tcv Q0
rbox d D5 | qhull Tcv
rbox c D6 | qhull Tcv Q0
rbox d D6 | qhull Tcv
rbox d D7 | qhull Tcv
rbox c D2 | qhull Tcv C-0
rbox c D3 | qhull Tcv C-0
rbox c D4 | qhull Tcv C-0
rbox c D5 | qhull Tcv C-0
rbox c D6 | qhull Tcv C-0
rbox c D7 | qhull Tv C-0
rbox 20 l D3 | qhull Tcv
rbox 100 s D2 | qhull Tcv
rbox 100 s D3 | qhull Tcv
rbox 100 s D4 | qhull Tcv
rbox 100 s c D4 | qhull Tcv
rbox 100 s d G1.5 D4 | qhull Tcv
rbox 100 s W1e-2 | qhull Tcv
rbox 100 | qhull Tcv
rbox 100 W1e-3 | qhull Tcv
rbox 100 r D2 | qhull Tcv
rbox 100 r s Z1 | qhull Tcv
rbox 100 r s Z1 G0.1 | qhull Tcv C-0
rbox 100 s Z1 G0.1 | qhull Tcv 
rbox 100 s Z1e-5 G0.1 | qhull Tc Pp

set +v
echo === check qhull option errors ${d:-`date`}
set -v
rbox 10 | qhull d H0
rbox 10 | qhull Zza
rbox 10 | qhull Zza Qw
rbox 10 | qhull Q999
rbox 10 | qhull Q999 Qw
qhull TIxyzlkajdfhwh
rbox 10 >r.x
qhull TIr.x
qhull p TI    r.x TO x.x
cat x.x

set +v
echo === check qhull output formats ${d:-`date`}
set -v
rbox 5 r s D2 | qhull Tcv
rbox 5 r s D2 | qhull s 
rbox 5 r s D2 | qhull s o 
rbox 5 r s D2 | qhull f
rbox 5 r s D2 | qhull i 
rbox 5 r s D2 | qhull m 
rbox 5 r s D2 | qhull FM 
rbox 5 r s D2 | qhull n 
rbox 5 r s D2 | qhull p 
rbox 5 r s D2 | qhull o 
rbox 5 r s D2 | qhull Ft
rbox 5 r s D2 | qhull Fx
rbox 5 r s D2 | qhull p n i p p
rbox 10 D3 | qhull f Tcv
rbox 10 D3 | qhull i
rbox 10 D3 | qhull p 
rbox 10 D3 | qhull o 
rbox 10 D3 | qhull Fx
rbox 27 M1,0,1 | qhull Qc
rbox 50 D3 s | qhull C0.1 Qc Pd0d1d2 Pg s p Tcv
rbox 10 D2 P0 P1e-15 | qhull d Qc FP s Tcv
rbox 100 s | qhull C-0.003 Qc FP s
rbox 100 s D2 | qhull C0.1 i Fx Tcv
rbox 4 s D3 | qhull Qc Ghipv Tcv 
rbox 6 D4 | qhull f Tcv
rbox 6 D4 | qhull i
rbox 6 D4 | qhull p 
rbox 6 D4 | qhull o
rbox 1000 s D2 | qhull FA Tcv
rbox 1000 s | qhull FA Tcv
rbox c D4 | qhull FA Tcv
rbox c D5 | qhull FA Tcv
rbox c D5 | qhull FA Qt Tcv
rbox 10 D2 | qhull d FA Tcv
rbox 10 D2 | qhull d Qu FA Tcv
rbox 10 D2 | qhull FA Tcv
rbox 10 c D2 | qhull Fx Tcv
rbox 1000 s | qhull FS Tcv
rbox 10 W0 D2 | qhull p Qc FcC Tcv
rbox 4 z h s D2 | qhull Fd s n FD Tcv
rbox 6 s D3 | qhull C-0.1 Qc FF s FQ Fi n Fo FQ FI Fm Fn FN FO FO FQ Fs FS FV Fv Tcv
rbox P0.5,0.5 P0.5,0.5 W0 5 D2 | qhull d FN Qc
rbox 10 D3 | qhull Fa PA5
rbox 10 D3 | qhull Fa PF0.4

set +v
echo === test Qt ${d:-`date`}
set -v
rbox c | qhull Qt s o Tcv
rbox c | qhull Qt f i
rbox c | qhull Qt m FM n
rbox c | qhull Qt p o
rbox c | qhull Qt Fx
rbox c | qhull Qt FA s Fa
rbox 6 r s c G0.1 D2 | qhull Qt d FA Tcv
rbox 6 r s c G0.1 D2 | qhull d FA Tcv
rbox 6 r s c G0.1 D2 | qhull Qt v p Tcv
rbox c | qhull Qt C-0.1 Qc FF s FQ Fi n Fo FQ FI Fm Fn FN FO FO FQ Fs FS FV Fv Tcv
rbox 6 r s c G0.1 D2 P0.1,0.1 | qhull s FP d FO Qt
rbox 100 W0 | qhull Tv Q11 FO 

set +v
echo === test unbounded intersection ${d:-`date`}
set -v
rbox c | qhull PD0:0.5 n | qhull H0 Fp Tcv
rbox 1000 W1e-3 D3 | qhull PA8 Fa FS s n Tcv 
rbox 1000 W1e-3 D3 | qhull C-0.01 PM10 Fm n Tcv Qc
rbox 1000 W1e-3 D3 | qhull C-0.01 PA8 PG n Tcv Qc
rbox 10 | qhull FO Tz TO q_test.log.1
cat q_test.log.1

set +v
echo === check Delaunay/Voronoi ${d:-`date`}
set -v
rbox 10 D2 | qhull d Tcv
rbox 10 D2 | qhull d Qz Tcv
rbox 10 D3 | qhull d Tcv
rbox c | qhull d Qz Ft Tcv
rbox 10 s D2 c | qhull d Tcv 
rbox 10 s D2 | qhull d Tcv Qz Q8
rbox 10 D2 | qhull d Tcv p
rbox 10 D2 | qhull d Tcv i
rbox 10 D2 | qhull d Tcv o
rbox 10 D2 | qhull v Tcv o
rbox 10 D2 | qhull v Tcv p
rbox 10 D2 | qhull v Tcv G
rbox 10 D2 | qhull v Tcv Fv
rbox 10 D2 | qhull v Tcv Fi
rbox 10 D2 | qhull v Tcv Fo
rbox 10 D2 | qhull v Qu o Fv Fi Fo Tcv
rbox 10 D3 | qhull v Fv Tcv
rbox 10 D3 | qhull v Fi Tcv
rbox 10 D3 | qhull v Fo Tcv
rbox 10 D3 | qhull v Qu o Fv Fi Fo Tcv
rbox 5 D2 | qhull v f FnN o

set +v
echo === check Halfspace and Qhull identity pipeline, showing the input ${d:-`date`}
echo === the Qhull pipeline recreates 100 4-D cospherical points with the same area and volume
set -v
rbox 100 s D4 | qhull FA FV s n | head
rbox 100 s D4 | qhull FQ FA FV n s | qhull s H Fp | head
rbox 100 s D4 | qhull FQ FA FV n s Tcv | qhull FQ s H Fp Tcv | qhull FA Tcv
echo === the Qhull pipeline recreates a 3-D tetrahedron
rbox d D3 | qhull n FD
rbox d D3 | qhull s n FD Tcv | qhull s Fd H0.1,0.1 Fp Tcv
echo === the Qhull pipeline recreates a regular 2-D pentagon
rbox 5 r D2 | qhull FQ n
rbox 5 r D2 | qhull s FQ n Tcv | qhull s H0 Fp Tcv

set +v
echo === check qhull ${d:-`date`}
set -v
rbox 10 s D3 | qhull Tcv
rbox 10 s D3 | qhull f Pd0:0.5 Pd2 Pg Tcv
rbox 10 s D3 | qhull f Tcv PD2:-0.5 Pg 
rbox 10 s D3 | qhull QR-1
rbox 10 s D3 | qhull QR-40
rbox 1000 D3 | qhull Tcvs
# Test tracing 'Tn', combine stderr/stdout 'Tz', flush fprintf 'Tf'
rbox 100 D3 | qhull T1 Tz Tf TA1 TO q_test.log.1
tail -n -10 q_test.log.1
rm q_test.log.1
rbox 100 s D3 | qhull TcvA10
rbox 100 s D3 | qhull TcvV-2
rbox 100 s D3 | qhull TcvC2
rbox 100 s D3 | qhull TcvV2
rbox 100 s D3 | qhull T1cvV2P2
rbox 100 s D3 | qhull TcvF100
rbox 100 s D3 | qhull Qf Tcv
rbox 100 D3 | qhull Tcv
rbox 100 D3 | qhull Qs Tcv
rbox 100 D5 | qhull Qs Tcv
rbox 100 D3 | qhull Qr Tcv
rbox 100 D3 | qhull Qxv Tcv
rbox 100 D3 | qhull Qi f Pd0 Pd1 Pd2 Pg Tcv
rbox c d | qhull Qc f Tcv
rbox c d | qhull Qc p Tcv
rbox 100 D3 | qhull QbB FO Tcv
rbox 1000 D2 B1e6 | qhull d Qbb FO Tcv
rbox 10 D3 | qhull QbB p Tcv
rbox 10 D3 | qhull Qbb p Tcv
rbox 10 D3 | qhull Qb0:-10B2:20 p Tcv
rbox 10 D3 | qhull Qb0:-10B2:20 p Tcv | qhull QbB p Tcv
rbox 10 D3 | qhull Qb1:0B1:0 d Tcv Q8
rbox 10 D3 | qhull Qb1:0B1:0B2:0 d Tcv Q8
rbox 10 D3 | qhull Qb1:0 d Tcv 
rbox 10 D3 | qhull Qb1:0B1:0  Tcv
echo "== next command will error ${d:-`date`} =="
rbox 10 D2 | qhull Qb1:1B1:1 Tcv
rbox 200 L20 D2 t | qhull FO Tcv C-0
rbox 1000 L20 t | qhull FO Tcv C-0
rbox 200 L20 D4 t | qhull FO Tcv C-0
rbox 200 L20 D5 t | qhull FO Tcv Qx
rbox 1000 W1e-3 s D2 t | qhull d FO Tcv Qu Q0
rbox 1000 W1e-3 s D2 t | qhull d FO Tcv Qu C-0

set +v
echo === check joggle and TRn ${d:-`date`}
set -v
rbox 100 W0 | qhull QJ1e-14 Qc TR100 Tv
rbox 100 W0 | qhull QJ1e-13 Qc TR100 Tv
rbox 100 W0 | qhull QJ1e-12 Qc TR100 Tv
rbox 100 W0 | qhull QJ1e-11 Qc TR100 Tv
rbox 100 W0 | qhull QJ1e-10 Qc TR100 Tv
rbox 100 | qhull d QJ Qb0:1e4 QB0:1e5 Qb1:1e4 QB1:1e6 Qb2:1e5 QB2:1e7 FO Tv

set +v
echo === check precision options ${d:-`date`}
set -v
rbox 100 D3 s | qhull E0.01 Qx Tcv FO
rbox 100 D3 W1e-1 | qhull W1e-3 Tcv
rbox 100 D3 W1e-1 | qhull W1e-2 Tcv Q0
rbox 100 D3 W1e-1 | qhull W1e-2 Tcv 
rbox 100 D3 W1e-1 | qhull W1e-1 Tcv
rbox 15 D2 P0 P1e-14,1e-14 | qhull d Quc Tcv
rbox 15 D3 P0 P1e-12,1e-14,1e-14 | qhull d Qcu Tcv
rbox 1000 s D3 | qhull C-0.01 Tcv Qc
rbox 1000 s D3 | qhull C-0.01 V0 Qc Tcv
rbox 1000 s D3 | qhull C-0.01 U0 Qc Tcv
rbox 1000 s D3 | qhull C-0.01 V0 Qcm Tcv
rbox 1000 s D3 | qhull C-0.01 Qcm Tcv
rbox 1000 s D3 | qhull C-0.01 Q1 FO Tcv Qc
rbox 1000 s D3 | qhull C-0.01 Q2 FO Tcv Qc
rbox 1000 s D3 | qhull C-0.01 Q3 FO Tcv Qc
rbox 1000 s D3 | qhull C-0.01 Q4 FO Tcv Qc
echo === this may generate an error ${d:-`date`}
rbox 1000 s D3 | qhull C-0.01 Q5 FO Tcv 
echo === this should generate an error ${d:-`date`}
rbox 1000 s D3 | qhull C-0.01 Q6 FO Po Tcv Qc
rbox 1000 s D3 | qhull C-0.01 Q7 FO Tcv Qc
rbox 1000 s D3 | qhull C-0.01 Qx Tcv Qc
echo === this may generate an error e.g., t1263080158 ${d:-`date`}
rbox 100 s D3 t | qhull R1e-3 Tcv Qc
rbox 100 s D3 t | qhull R1e-2 Tcv Qc
rbox 500 s D3 t | qhull R0.05 A-1 Tcv Qc
rbox 100 W0 D3 t | qhull R1e-3 Tcv Qc
rbox 100 W0 D3 t | qhull R1e-3 Qx Tcv Qc
rbox 100 W0 D3 t | qhull R1e-2 Tcv Qc
rbox 100 W0 D3 t | qhull R1e-2 Qx Tcv Qc
rbox 500 W0 D3 t | qhull R0.05 A-1 Tcv Qc
rbox 500 W0 D3 t | qhull R0.05 Qx Tcv Qc
rbox 1000 W1e-20 t | qhull Tcv Qc
rbox 1000 W1e-20 D4 t | qhull Tcv Qc
rbox 500 W1e-20 D5 t | qhull Tv Qc
rbox 100 W1e-20 D6 t | qhull Tv Qc
rbox 50 W1e-20 D6 t | qhull Qv Tv Qc
rbox 10000 D4 t | qhull QR0 Qc C-0.01 A0.3 Tv
rbox 1000 D2 t | qhull d QR0 Qc C-1e-8 Qu Tv
rbox 300 D5 t |qhull A-0.999 Qx Qc Tcv
rbox 100 D6 t |qhull A-0.9999 Qx Qc Tcv
rbox 50 D7 t |qhull A-0.99999 Qx Qc Tcv W0.1

set +v
echo =======================================================
echo === The following commands may cause errors ${d:-`date`}
echo =======================================================
echo
echo === check bad cases for Qhull ${d:-`date`}
set -v
rbox 1000 L100000 s G1e-6 t | qhull Tv
rbox 1000 L100000 s G1e-6 t | qhull Tv Q10
rbox 1000 s Z1 G1e-13 t | qhull Tv
rbox 1000 s W1e-13 P0 t | qhull d Qbb Qc Q12 Tv
rbox 1000 s W1e-13 t | qhull d Q12 Tv
rbox 1000 s W1e-13 t D2 | qhull d Tv

set +v
echo === check Qhull without merging Q0 ${d:-`date`}
set -v
rbox c D7 | qhull Q0 Tcv
rbox 100 s D3 | qhull Q0 E1e-3 Tc Po
rbox 100 s D3 | qhull Q0 E1e-2 Tc Po
rbox 100 s D3 | qhull Q0 E1e-1 Tc Po
rbox 100 s D3 | qhull Q0 R1e-3 Tc Po
rbox 100 s D3 | qhull Q0 R1e-2 Tc Po
rbox 100 s D3 | qhull Q0 R0.05 Tc
rbox 100 s D3 | qhull Q0 R0.05 Tc Po
rbox 1000 W1e-7 | qhull Q0 Tc Po
rbox 50 s | qhull Q0 V0.05 W0.01 Tc Po
rbox 100 s D5 | qhull Q0 R1e-2 Tc Po

set +v
echo === check nearly incident points ${d:-`date`}
set -v
rbox L100 2000 D4 s C1,1e-13 t2 | qhull
rbox L100 2000 D4 s C1,1e-13 t2 | qhull Q12
rbox 50 C1,1E-13 t1447644703 | qhull d
rbox 50 C1,1E-13 t1447644703 | qhull d Q12
rbox 50 C1,1E-13 t1447644703 | qhull d Q14

set +v
echo =======================================================
echo === Testing done.  Print documentation
echo =======================================================
set -v

qhull -
rbox
cat html/qhull.txt html/rbox.txt

# end of q_test
