X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=visualize;h=f24e7b76490b011ef4766078ab190eaf586f316c;hb=863fae26146496ac4bc3bc6c95cbffff7bb6eca2;hp=b85b83939134cfd6a54ecf9e08f85feabe29539b;hpb=c1f74e23422d004f7b9d2493cc747871c7ebfbae;p=physik%2Fposic.git diff --git a/visualize b/visualize index b85b839..f24e7b7 100755 --- a/visualize +++ b/visualize @@ -1,15 +1,60 @@ #!/bin/sh -if [ ! -d $1 ] ; then - echo "no such directory -> $1" - exit +# +# visualization script +# author: frank.zirkelbach@physik.uni-augsburg.de +# + +directory="doesnt_exist____for_sure" +width="1024" +height="768" +radius="1.0" +x0=""; y0=""; z0=""; +x1=""; y1=""; z1=""; +cx=""; cy=""; cz=""; +lx="0"; ly="-100"; lz="100"; + +while [ "$1" ]; do + case "$1" in + -d) directory=$2; shift 2;; + -w) width=$2; shift 2;; + -h) height=$2; shift 2;; + -r) radius=$2; shift 2;; + -nll) x0=$2; y0=$3; z0=$4; shift 4;; + -fur) x1=$2; y1=$3; z1=$4; shift 4;; + -c) cx=$2; cy=$3; cz=$4; shift 4;; + -l) lx=$2; ly=$3; lz=$4; shift 4;; + -o) ortographic=1; shift 1;; + *) + echo "options:" + echo "########" + echo "directory to progress:" + echo " -d (mandatory)" + echo "png dim:" + echo " -w " + echo " -h " + echo "atom size:" + echo " -r " + echo "visualization volume:" + echo " -nll (near lower left)" + echo " -fur (far upper right)" + echo " -o (ortographic)" + echo "povray:" + echo " -c (camera position)" + echo " -l (light source)" + exit 1;; + esac +done + +if [ ! -d $directory ] ; then + echo "no valid directory" + exit 1 fi -POVRAY="povray -W1024 -H768 -d" +POVRAY="povray -W${width} -H${height} -d" -echo "processing $1 ..." +for file in $directory/atomic_conf_*.xyz; do -for file in $1/povray_*.in ; do cat > temp.pov <<-EOF #include "colors.inc" #include "textures.inc" @@ -21,49 +66,75 @@ for file in $1/povray_*.in ; do EOF # meta info - count=`grep '# \[C\]' $file | awk '{ print $3 }'` - time=`grep '# \[T\]' $file | awk '{ print $3 }'` - camloc=`grep '# \[L\]' $file | awk '{ print $3 }'` + count=`grep '# \[P\]' $file | awk '{ print $3 }'` + time=`grep '# \[P\]' $file | awk '{ print $4 }'` + camloc=`grep '# \[P\]' $file | awk '{ print $5 }'` + [ -n "$cx" -a -n "$cy" -a -n "$cz" ] && camloc="<$cx,$cz,$cy>" # atoms - cat $file | grep -v '#' | while read radius x y z ; do #temp dis; do - cat >> temp.pov <<-EOF + if [ -n "$x0" ]; then + export x0 y0 z0 x1 y1 z1 radius + cat $file | grep -v '#' | awk '\ + BEGIN { + x0=ENVIRON["x0"]; y0==ENVIRON["y0"]; z0==ENVIRON["z0"]; + x1=ENVIRON["x1"]; y0==ENVIRON["y1"]; z0==ENVIRON["z1"]; + radius=ENVIRON["radius"]; + } + { + if(($2>=x0)&&($3>=y0)&&($4>=z0)&&\ + ($2<=x1)&&($3<=y1)&&($4<=z1)) { + print "sphere { <"$2","$4","$3">, "radius" "; + print "texture { pigment { color "$5" } "; + print "finish { phong 1, metallic } } }"; + } + }' >> temp.pov + else + cat $file | grep -v '#' | while read name x y z color temp; do + cat >> temp.pov <<-EOF sphere { - <$x, $z, $y>, $radius - texture { - pigment { color Yellow } - finish { - phong 1 - metallic - } - } +<$x, $z, $y>, $radius +texture { +pigment { color $color } +finish { +phong 1 +metallic +} +} } EOF - done + done + fi # boundaries + if [ -z "$x0" ]; then cat $file | grep '# \[D\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do cat >> temp.pov <<-EOF cylinder { - <$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05 - pigment { color White } +<$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05 +pigment { color White } } EOF done + fi # add camera and light source cat >> temp.pov <<-EOF camera { -// orthographic - location $camloc - look_at <0,0,0> +EOF + if [ -n "$ortographic" ]; then cat >> temp.pov <<-EOF +orthographic +EOF + fi + cat >> temp.pov <<-EOF +location $camloc +look_at <0,0,0> } -light_source { <0,10000,0> color White shadowless } +light_source { <0,100,-100> color White shadowless } EOF # mv png $POVRAY temp.pov > /dev/null 2>&1 - mv temp.png `echo $file | sed 's/\.in/\.png/'` + mv temp.png `echo $file | sed 's/\.xyz/\.png/'` done