#!/bin/csh
#
# Intent:	Script for creating icon database for all studies in common area
# $Revision: 1.1 $

echo This is the top level script for creating the files needed for the
echo print_mgr application.  It invokes a separate script for each study
echo that we wish to include in the print demonstration.  The parent
echo directory for the source files is variable.  Each study directory
echo is hard-coded.

set SRC = /flash_c/image_storage/rsna-cases-acc
set DST = /flash_c/print

echo ""
echo The default root directory for source images is
echo "                    " $SRC
echo ""
echo You can change this default at this point by entering a new
echo directory name.  You can use the default by hitting return.
echo ""
echo Please enter new default directory for source images or RTN.

set a = $<
if ($a != "") then
set SRC = $a
endif

echo ""
echo Checking for our known set of source images
echo ""

set PASS = TRUE
foreach i (acuson-1 acuson-2 acuson-3 ali-4 ali-5 atl-6 atl-7 atl-8)
if (!(-e $SRC/$i)) then
echo Missing $SRC/$i
set PASS = FALSE
endif
end
foreach i (cemax-20 cemax-21 isg-22 isg-23)
if (!(-e $SRC/$i)) then
echo Missing $SRC/$i
set PASS = FALSE
endif
end

foreach i (ge-10 ge-11 ge-9 picker-12 picker-13)
if (!(-e $SRC/$i)) then
echo Missing $SRC/$i
set PASS = FALSE
endif
end
foreach i (siemens-14 siemens-15 siemens-16 siemens-17 siemens-18 siemens-19)
if (!(-e $SRC/$i)) then
echo Missing $SRC/$i
set PASS = FALSE
endif
end

if ($PASS != "TRUE") then
echo One or more source directories were not found.  Please check your
echo directory structure or list of source directories and rerun this script.
exit
endif

echo ""
echo The default target directory for the print demonstration is
echo "                    " $DST
echo You can change this default at this point by entering a new
echo directory name.  You can use the default by hitting return.
echo ""
echo Please enter new default directory for target images or RTN.

set a = $<
if ($a != "") then
set DST = $a
endif

set PASS = TRUE
foreach i (config db images)
if (!(-e $DST/$i)) then
echo missing $DST/$i
set PASS = FALSE
endif
end
if ($PASS != "TRUE") then
echo One or more target directories were not found.  Please check your
echo directory structure or list of source directories and rerun this script.
exit
endif

if (-e $DST/db/print.db) then
echo It is suspicious that you have an existing print database in
echo "              " $DST/db/print.db
echo Continuing with this script may cause existing print files to be
echo deleted.  Do you wish to continue "(y/n)?"
set a = $<
if (($a != "y") && ($a != "Y")) then
exit
endif
endif

echo The script will now create all of the print files and icon files
echo needed for the print demonstration.  On a Sparc 10, this takes
echo 90-110 minutes.
echo Please his RTN when you are ready to proceed.
set a = $<

foreach i (acuson-1 acuson-2 acuson-3 ali-4 ali-5 atl-6 atl-7 atl-8)
echo Working on source directory $SRC/$i
set file_list = `ls $SRC/$i`
icon_script $SRC $DST/images $i $DST/db/print.db $DST/db/icon.index \
$DST/db/icon.file $file_list
if ($status != 0) then
echo icon_script failed
exit
endif
end

foreach i (cemax-20 cemax-21 isg-22 isg-23)
echo Working on source directory $SRC/$i
set file_list = `ls $SRC/$i`
icon_script $SRC $DST/images $i $DST/db/print.db $DST/db/icon.index \
$DST/db/icon.file $file_list
if ($status != 0) then
echo icon_script failed
exit
endif
end

foreach i (ge-10 ge-11 ge-9 picker-12 picker-13)
echo Working on source directory $SRC/$i
set file_list = `ls $SRC/$i`
icon_script $SRC $DST/images $i $DST/db/print.db $DST/db/icon.index \
$DST/db/icon.file $file_list
if ($status != 0) then
echo icon_script failed
exit
endif
end

foreach i (siemens-14 siemens-15 siemens-16 siemens-17 siemens-18 siemens-19)
echo Working on source directory $SRC/$i
set file_list = `ls $SRC/$i`
icon_script $SRC $DST/images $i $DST/db/print.db $DST/db/icon.index \
$DST/db/icon.file $file_list
if ($status != 0) then
echo icon_script failed
exit
endif
end
