Back to home page

EIC code displayed by LXR

 
 

    


Warning, /epic/scripts/view15/generate_eps is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env bash
0002 
0003 #trignometry
0004 sin ()
0005 {
0006     echo "scale=5;s($1)" | bc -l
0007 }
0008 
0009 add ()
0010 {
0011     echo "scale=5;$1 + $2" | bc -l
0012 }
0013 
0014 cos ()
0015 {
0016     echo "scale=5;c($1)" | bc -l
0017 }
0018 
0019 tan ()
0020 {
0021     echo "scale=5;s($1)/c($1)" | bc -l
0022 }
0023 
0024 
0025 function print_the_help {
0026   echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
0027   echo "  OPTIONS: "
0028   echo "            -t,--tag           filename tag (default: view1)"
0029   exit
0030 }
0031 
0032 FILE_TAG="view15"
0033 INPUT_FILE="../../g4_0000.prim"
0034 
0035 
0036 POSITIONAL=()
0037 while [[ $# -gt 0 ]]
0038 do
0039   key="$1"
0040 
0041   case $key in
0042     -h|--help)
0043       shift # past argument
0044       print_the_help
0045       ;;
0046     -t|--tag)
0047       FILE_TAG="$2"
0048       shift # past argument
0049       shift # past value
0050       ;;
0051     -i|--input)
0052       INPUT_FILE="$2"
0053       shift # past argument
0054       shift # past value
0055       ;;
0056     -[a-zA-Z]*) # unknown option
0057       POSITIONAL+=("$1") # save it in an array for later
0058       echo "unknown option $1"
0059       print_the_help
0060       shift # past argument
0061       ;;
0062     *)     # positional options
0063       POSITIONAL+=("$1") # save it in an array for later
0064       shift # past argument
0065       ;;
0066   esac
0067 done
0068 set -- "${POSITIONAL[@]}" # restore positional parameters
0069 
0070 # units are mm
0071 
0072 echo "view15 produces a series of slightly rotated XY slices a different z locations. Along beamline"
0073 
0074 # slice at z = 2m
0075 # note the offset has to change with sign of the direction to cut in the opposite direction.
0076 #dawncut 0  0  1  10005 ${INPUT_FILE} ${FILE_TAG}b_temp0.prim
0077 #dawncut 0  0 -1 -1000 ${FILE_TAG}b_temp0.prim  ${FILE_TAG}b.prim
0078 #dawn  ${FILE_TAG}b.prim
0079 #ps2pdf ${FILE_TAG}b.eps ${FILE_TAG}b_full.pdf
0080 #gs -o ${FILE_TAG}b.pdf -sDEVICE=pdfwrite \
0081 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0082 #  -f ${FILE_TAG}b_full.pdf
0083 #pdftoppm ${FILE_TAG}b.pdf ${FILE_TAG}b -png -singlefile -cropbox
0084 
0085 echo "done ..."
0086 
0087 
0088 original_file_tag="${FILE_TAG}"
0089 
0090 make_slice(){
0091   local zpos="$1"
0092   local tagnum=$(printf "%04d" ${zpos})
0093   local FILE_TAG="${original_file_tag}a${tagnum}"
0094   local z1=$(( ${zpos} + 100 ))
0095   local z2=$(( ${zpos} - 100 ))
0096   #dawncut 0 0 1 $(( 10 * ${z1} + 1 )) ${INPUT_FILE} ${FILE_TAG}_temp0.prim
0097   #dawncut 0 0 -1 $(( -10 * ${z2} )) ${FILE_TAG}_temp0.prim  ${FILE_TAG}.prim
0098   ../../bin/dawn_tweak -z ${zpos}0 --draw 5
0099   #cp ${INPUT_FILE} ${FILE_TAG}.prim
0100   dawncut -1 0 0 0 ${INPUT_FILE} ${FILE_TAG}.prim
0101   dawn -d ${FILE_TAG}.prim
0102   ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_full.pdf
0103   gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
0104     -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0105     -f ${FILE_TAG}_full.pdf
0106       pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox
0107   rm "${FILE_TAG}_temp0.prim"
0108   rm "${FILE_TAG}.prim"
0109 }
0110 
0111 for zzz in $@ ;
0112 do
0113   make_slice ${zzz}
0114 done
0115 
0116 wait
0117 
0118 
0119 
0120 #dawncut 0  1 0 10 ${INPUT_FILE} ${FILE_TAG}c_temp0.prim
0121 #dawncut 0 -1 0 0 ${FILE_TAG}c_temp0.prim  ${FILE_TAG}c.prim
0122 #dawn -d ${FILE_TAG}c.prim
0123 #ps2pdf ${FILE_TAG}c.eps ${FILE_TAG}c_full.pdf
0124 #gs -o ${FILE_TAG}c.pdf -sDEVICE=pdfwrite \
0125 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0126 #  -f ${FILE_TAG}c_full.pdf
0127 #pdftoppm ${FILE_TAG}c.pdf ${FILE_TAG}c -png -singlefile -cropbox
0128 #
0129 ## slice at z = -1m
0130 #dawncut 0 0 1 -1000 ${INPUT_FILE} ${FILE_TAG}d_temp0.prim
0131 #dawncut 0 0 -1 1001 ${FILE_TAG}d_temp0.prim  ${FILE_TAG}d.prim
0132 #dawn -d ${FILE_TAG}d.prim
0133 #ps2pdf ${FILE_TAG}d.eps ${FILE_TAG}d_full.pdf
0134 #gs -o ${FILE_TAG}d.pdf -sDEVICE=pdfwrite \
0135 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0136 #  -f ${FILE_TAG}d_full.pdf
0137 #pdftoppm ${FILE_TAG}d.pdf ${FILE_TAG}d -png -singlefile -cropbox
0138 #
0139 ## slice at z = -2m
0140 #dawncut 0 0 1 -2000 ${INPUT_FILE} ${FILE_TAG}e_temp0.prim
0141 #dawncut 0 0 -1 2001 ${FILE_TAG}e_temp0.prim  ${FILE_TAG}e.prim
0142 #dawn -d ${FILE_TAG}e.prim
0143 #ps2pdf ${FILE_TAG}e.eps ${FILE_TAG}e_full.pdf
0144 #gs -o ${FILE_TAG}e.pdf -sDEVICE=pdfwrite \
0145 #  -c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
0146 #  -f ${FILE_TAG}e_full.pdf
0147 #pdftoppm ${FILE_TAG}e.pdf ${FILE_TAG}e -png -singlefile -cropbox
0148 
0149 
0150 #https://geant4.kek.jp/~tanaka/DAWN/About_DAWNCUT.html
0151 # % dawncut a b c d input-file [output-file]
0152 #
0153 #       input-file : Source DAWN-format file describing a 3D scene.
0154 #
0155 #       output-file: Output DAWN-format file describing a plane-clipped
0156 #                    3D scene.  The default output stream is stdout.
0157 #
0158 #       a, b, c, d : Parameters  a, b, c, and d  are double values to
0159 #                    define a clipping plane described with the following
0160 #                    equation:
0161 #
0162 #                       ax + by + cz + d = 0.
0163 #
0164 #                    Vector (a,b,c) defines the normal vector of
0165 #                    the clipping plane.
0166 #                    3D scene data in the half space at the front side
0167 #                    of the clipping plane are clipped out and erased.
0168 #                    The normal vector (a,b,c) needs not be a unit vector.
0169 #                    If it is a unit vector, parameter "d" gives distance
0170 #                    between the clipping plane and origin (0,0,0).