1 #!/bin/bash
  2 # --verbose  print as lines are read
  3 
  4 # $Revision: 1.8 $  $Author: schwehr $  $Date: 2004/11/05 02:50:08 $
  5 
  6 ##############################################################################
  7 #     Copyright (C) 2004  Kurt Schwehr
  8 #
  9 #     This library is free software; you can redistribute it and/or
 10 #     modify it under the terms of the GNU Lesser General Public
 11 #     License as published by the Free Software Foundation; either
 12 #     version 2.1 of the License, or (at your option) any later version.
 13 #
 14 #     This library is distributed in the hope that it will be useful,
 15 #     but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 #     Lesser General Public License for more details.
 18 #
 19 #     You should have received a copy of the GNU Lesser General Public
 20 #     License along with this library; if not, write to the Free Software
 21 #     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 22 ###############################################################################
 23 
 24 # The goal of this script is to take 1st the ardath data sets and test
 25 # out the bootstrapping blobby density function and create a
 26 # visualization of it.  Hopefully later, I will get to processing the
 27 # Owens Lake data.
 28 
 29 
 30 
 31 ######################################################################
 32 # Debugging
 33 ######################################################################
 34 
 35 . debug.bash
 36 
 37 ######################################################################
 38 # Local tuning
 39 ######################################################################
 40 
 41 FailIfNotThere()
 42 {
 43     declare -ir line=$1
 44     declare -r filename="$2"
 45     
 46     if [ ! -e $filename ]; then
 47 	echo "makemovie2.bash:($line): ERROR $filename does not exist.  Goodbye."
 48 	exit $EXIT_FAILURE
 49     fi
 50 }
 51 
 52 #
 53 # Make sure we have a sane environment
 54 #
 55 FailIfNotThere $LINENO sample.wpt
 56 FailIfNotThere $LINENO g1-fluidized-all.iv
 57 
 58 # 0..99 frames
 59 declare -ir maxFrames=100
 60 #declare -ir maxFrames=5
 61 
 62 
 63 #
 64 # Make all the frames
 65 #
 66 declare -ir size=200
 67 declare -r render_args="axes.iv     -p 0.05  -w sample.wpt -L -W $size -H $size -v $debugLevel"
 68 #declare -r render_args="axes.iv     -p 0.5  -w sample.wpt -L -W $size -H $size -v $debugLevel"
 69 
 70 
 71 declare -ar ol_groups=( g1-fluidized g2-undeformed g3-sheared g4-little-def g5-intermediate )
 72 #declare -ar ol_groups=( g2-undeformed )
 73 
 74 echo ${ol_groups[@]}
 75 
 76 if [ 1 == 1 ]; then 
 77     for group in "${ol_groups[@]}"; do
 78 	DebugEcho $TERSE $LINENO "Rendering group $group"
 79 
 80 	FailIfNotThere $LINENO ${group}-all.iv
 81 	render -b ${group}-all- ${group}-all.iv $render_args || die $LINENO
 82 
 83 	FailIfNotThere $LINENO ${group}-vmax-8.iv
 84         render -b ${group}-vmax- ${group}-vmax-8.iv $render_args $group-vmax.xyz.iv || die $LINENO
 85 
 86 	FailIfNotThere $LINENO ${group}-vint-8.iv
 87         render -b ${group}-vint- ${group}-vint-8.iv $render_args $group-vint.xyz.iv || die $LINENO
 88 
 89 	FailIfNotThere $LINENO ${group}-vmin-8.iv
 90         render -b ${group}-vmin- ${group}-vmin-8.iv $render_args $group-vmin.xyz.iv || die $LINENO
 91     done
 92 fi
 93 
 94 if [ 1 == 1 ]; then 
 95     DebugEcho $TERSE $LINENO "Brightening all images"
 96     for file in g[1-5]-*.png; do
 97 	convert -modulate 210 $file tmp-$file || die $LINENO
 98 	/bin/mv -f tmp-$file $file
 99     done
100 fi
101 
102 #
103 # Label the all 3 component images using ImageMagic
104 # http://www-106.ibm.com/developerworks/library/l-graf/?ca=dnt-428
105 #
106 if [ 1 == 1 ]; then 
107     if [ 1 == 1 ]; then 
108 	DebugEcho $TERSE $LINENO "Label the 'all' images"
109 	for group in "${ol_groups[@]}"; do
110 	    DebugEcho $TERSE $LINENO "  Group: $group"
111 	    for file in $group-all-*.png; do
112 		convert -font helvetica -fill white -pointsize 12 -draw "text 10,15 $group" $file tmp-$file
113 		/bin/mv -f tmp-$file $file
114 	    done
115 	done
116     fi
117     DebugEcho $TERSE $LINENO "Labeling the component images - vmin"
118     for file in g?-*-vmin-*.png; do
119 	convert -font helvetica -fill white -pointsize 12 -draw "text 10,15 Vmin" $file tmp-$file
120 	/bin/mv -f tmp-$file $file
121     done
122     DebugEcho $TERSE $LINENO "Labeling the component images - vint"
123     for file in g?-*-vint-*.png; do
124 	convert -font helvetica -fill white -pointsize 12 -draw "text 10,15 Vint" $file tmp-$file
125 	/bin/mv -f tmp-$file $file
126     done
127     DebugEcho $TERSE $LINENO "Labeling the component images - vmax"
128     for file in g?-*-vmax-*.png; do
129 	convert -font helvetica -fill white -pointsize 12 -draw "text 10,15 Vmax" $file tmp-$file
130 	/bin/mv -f tmp-$file $file
131     done
132 fi
133 
134 #
135 # Group all rendered frames for one step into one big movie frame
136 # 
137 
138 if [ 1 == 1 ]; then 
139     for group in "${ol_groups[@]}"; do
140 	declare -i fileNum=0
141 	DebugEcho $TERSE $LINENO "Assemble frames for group: $group"
142 	while [ $maxFrames != $fileNum ]; do
143 	    f=`printf "%04d" $fileNum`
144 	    echo $f
145 	    pngtopnm ${group}-all-${f}.png > all.pnm
146 	    pngtopnm ${group}-vmax-${f}.png > vmax.pnm
147 	    pngtopnm ${group}-vint-${f}.png > vint.pnm
148 	    pngtopnm ${group}-vmin-${f}.png > vmin.pnm
149 
150 	    pnmcat -lr  all.pnm vmax.pnm > l
151 	    pnmcat -lr vint.pnm vmin.pnm > r
152 	    pnmcat -lr l r | pnmtopng > ${group}-$f.png
153 
154 	    fileNum=$[fileNum+1]
155 	    rm -f all.pnm vmax.pnm vint.pnm vmin.pnm l r
156 	done
157     done
158 fi
159 
160 
161 if [ 1 == 1 ]; then 
162     declare -i fileNum=0
163     while [ $maxFrames != $fileNum ]; do
164 	f=`printf "%04d" $fileNum`
165 	DebugEcho $TERSE $LINENO "Assemble composites to a superframe for $f"
166 	for group in "${ol_groups[@]}"; do
167 	    pngtopnm ${group}-${f}.png > ${group}.pnm  || die $LINENO
168 	done
169 	pnmcat -tb g1-fluidized.pnm g2-undeformed.pnm > t1  || die $LINENO
170 	pnmcat -tb g3-sheared.pnm   g4-little-def.pnm > t2  || die $LINENO
171 	pnmcat -tb t1 t2 > t3 || die $LINENO
172 	pnmcat -tb t3 g5-intermediate.pnm | pnmtopng > ol-$f.png || die $LINENO
173 	rm -f t{1,2,3}  g1-fluidized.pnm g2-undeformed.pnm g3-sheared.pnm  g4-little-def.pnm g5-intermediate.pnm
174 	fileNum=$[fileNum+1]
175     done
176 fi


syntax highlighted by Code2HTML, v. 0.9.1