5 # author: frank.zirkelbach@physik.uni-augsburg.de
10 cat >> temp.pov <<-EOF
12 <$1, $3, $2>, <$4, $6, $5>, 0.05
13 pigment { color White }
18 cat >> temp.pov <<-EOF
20 <$1, $3, $2>, <$4, $6, $5>, $7
22 color rgbf <0, 0, 1.0, 0.8>
23 finish { phong 1 metallic }
32 directory="doesnt_exist____for_sure"
36 x0="-0.6"; y0="-0.6"; z0="-0.6";
37 x1="0.6"; y1="0.6"; z1="0.6";
39 lx="0"; ly="-100"; lz="100";
41 bx0=""; by0=""; bz0="";
42 bx1=""; by1=""; bz1="";
44 clx="0"; cly="0"; clz="0";
58 -d) directory=$2; shift 2;;
59 -w) width=$2; shift 2;;
60 -h) height=$2; shift 2;;
61 -r) radius=$2; shift 2;;
62 -nll) x0=$2; y0=$3; z0=$4; shift 4;;
63 -fur) x1=$2; y1=$3; z1=$4; shift 4;;
64 -c) cx=$2; cy=$3; cz=$4; shift 4;;
65 -L) clx=$2; cly=$3; clz=$4; shift 4;;
66 -l) lx=$2; ly=$3; lz=$4; shift 4;;
67 -o) ortographic=1; shift 1;;
68 -b) bx0=$2; by0=$3; bz0=$4;
69 bx1=$5; by1=$6; bz1=$7; shift 7;;
72 -e) extra=1; shift 1;;
73 -D) displace=$2; shift 2;;
74 -m) mx1=$2; mx2=$3; mx3=$4;
75 my1=$5; my2=$6; my3=$7;
76 mz1=$8; mz2=$9; mz3=${10};
80 while [ $cnt -le $ab ]; do
81 anr[$cnt]=$1; shift 1;
89 echo "directory to progress:"
90 echo " -d <directory> (mandatory)"
96 echo " -B <bond cylinder radius>"
98 echo " -C <lattice constant>"
99 echo " -m <dimX> <dimY> <dimZ> (mirror atoms)"
100 echo "visualization volume:"
101 echo " -nll <x> <y> <z> (near lower left)"
102 echo " -fur <x> <y> <z> (far upper right)"
103 echo " -o (ortographic)"
105 echo " -b <x0> <y0> <z0> <x1> <y1> <z1>"
107 echo " -c <x> <y> <z> (camera position)"
108 echo " -L <x> <y> <z> (camera look)"
109 echo " -l <x> <y> <z> (light source)"
111 echo " -ab <atom number> <cutoff> (auto bonds)"
114 echo " 1: sym by <1 -1 0> at 1/4 <1 1 0>"
119 # calculation from lattic eunits to angstroms
121 [ "$lc" = "sic" ] && lc=4.359
122 [ "$lc" = "si" ] && lc=5.480
123 [ "$lc" = "c" ] && lc=3.566
125 #offset=`echo 0.125 \* $lc | bc`
128 x0=`echo $x0 \* $lc + $offset | bc`
129 y0=`echo $y0 \* $lc + $offset | bc`
130 z0=`echo $z0 \* $lc + $offset | bc`
131 x1=`echo $x1 \* $lc + $offset | bc`
132 y1=`echo $y1 \* $lc + $offset | bc`
133 z1=`echo $z1 \* $lc + $offset | bc`
135 mx1=`echo $mx1 \* $lc + $offset | bc`
136 my1=`echo $my1 \* $lc + $offset | bc`
137 mz1=`echo $mz1 \* $lc + $offset | bc`
138 mx2=`echo $mx2 \* $lc + $offset | bc`
139 my2=`echo $my2 \* $lc + $offset | bc`
140 mz2=`echo $mz2 \* $lc + $offset | bc`
141 mx3=`echo $mx3 \* $lc + $offset | bc`
142 my3=`echo $my3 \* $lc + $offset | bc`
143 mz3=`echo $mz3 \* $lc + $offset | bc`
145 clx=`echo $clx \* $lc + $offset | bc`
146 cly=`echo $cly \* $lc + $offset | bc`
147 clz=`echo $clz \* $lc + $offset | bc`
149 if [ -n "$cx" -a -n "$cy" -a -n "$cz" ]; then
150 cx=`echo $cx \* $lc + $offset | bc`
151 cy=`echo $cy \* $lc + $offset | bc`
152 cz=`echo $cz \* $lc + $offset | bc`
155 if [ -n "$bx0" ]; then
156 bx0=`echo $bx0 \* $lc + $offset | bc`
157 by0=`echo $by0 \* $lc + $offset | bc`
158 bz0=`echo $bz0 \* $lc + $offset | bc`
159 bx1=`echo $bx1 \* $lc + $offset | bc`
160 by1=`echo $by1 \* $lc + $offset | bc`
161 bz1=`echo $bz1 \* $lc + $offset | bc`
165 POVRAY="povray -W${width} -H${height} -d"
168 [ -n "$cx" -a -n "$cy" -a -n "$cz" ] && camloc="<$cx,$cz,$cy>"
171 COPTS="-font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
172 COPTS="$COPTS -depth 8 -fill white -stroke blue -pointsize 24"
176 if [ -d $directory ]; then
177 filesource=$directory/CONTCAR*
180 if [ -f $directory ]; then
181 filesource=$directory
184 for file in $filesource; do
186 echo "working on $file ..."
188 cat > temp.pov <<-EOF
189 #include "colors.inc"
190 #include "textures.inc"
191 #include "shapes.inc"
193 #include "metals.inc"
195 #include "stones.inc"
199 scale=`sed -n 2p $file | awk '{ print $1 }'`
200 line="`sed -n 3p $file`"
201 X1=`echo $line | awk '{ print $1 }'`
202 X2=`echo $line | awk '{ print $2 }'`
203 X3=`echo $line | awk '{ print $3 }'`
204 line="`sed -n 4p $file`"
205 Y1=`echo $line | awk '{ print $1 }'`
206 Y2=`echo $line | awk '{ print $2 }'`
207 Y3=`echo $line | awk '{ print $3 }'`
208 line="`sed -n 5p $file`"
209 Z1=`echo $line | awk '{ print $1 }'`
210 Z2=`echo $line | awk '{ print $2 }'`
211 Z3=`echo $line | awk '{ print $3 }'`
212 line="`sed -n 6p $file`"
213 nsi=`echo $line | awk '{ print $1 }'`
214 nc=`echo $line | awk '{ print $2 }'`
220 echo "cutoff: $cutoff"
227 export x0 y0 z0 x1 y1 z1 radius
233 checktsd=`sed -n 7p $file | awk '{ print $1 }'`
234 if [ "$checktsd" = "Transformed" ]; then
236 echo "tsd: yes, offset = $offset"
238 checkmore=`sed -n 8p $file | awk '{ print $1 }'`
239 if [ "$checkmore" = "Direct" ]; then
241 echo "tsd: yes, but anyways using offset $offset"
245 echo "tsd: no, offset = $offset"
249 [ $count -gt $ntot ] && break
251 if [ $count -le $nsi ]; then
259 line="`sed -n ${gl}p $file`"
260 x=`echo $line | awk '{ print $1 }'`
261 y=`echo $line | awk '{ print $2 }'`
262 z=`echo $line | awk '{ print $3 }'`
264 echo $x $y $z $count | awk '\
266 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
267 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
268 X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"];
269 Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"];
270 Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"];
271 radius=ENVIRON["radius"]; scale=ENVIRON["scale"];
272 color=ENVIRON["color"]
283 nx=$1+i; ny=$2+j; nz=$3+k;
294 xt=nx*X1+ny*Y1+nz*Z1;
295 yt=nx*X2+ny*Y2+nz*Z2;
296 zt=nx*X3+ny*Y3+nz*Z3;
302 if((xt>=x0)&&(yt>=y0)&&(zt>=z0)&&\
303 (xt<=x1)&&(yt<=y1)&&(zt<=z1)) {
305 print "sphere { <"xt","zt","yt">, "radius" ";
306 print "texture { pigment { color " color " } ";
307 print "finish { phong 1 metallic } } }";
315 # see, whether there are bonds to draw
316 if [ "$ab" = "0" ]; then
323 while [ $cnt -le $ab ]; do
325 if [ $anr -eq $count ]; then
331 if [ "$ab" = "-1" ]; then
332 if [ -n "`grep \/\/\ atom\ $count temp.pov`" ]; then
336 if [ "$dobond" = "no" ]; then
346 [ $ic -gt $count ] && break
348 if [ $ic -eq $count ]; then
354 line="`sed -n ${il}p $file`"
355 xb=`echo $line | awk '{ print $1 }'`
356 yb=`echo $line | awk '{ print $2 }'`
357 zb=`echo $line | awk '{ print $3 }'`
359 echo $x $y $z $xb $yb $zb $cutoff | awk '\
361 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
362 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
363 X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"];
364 Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"];
365 Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"];
366 bcr=ENVIRON["bcr"]; scale=ENVIRON["scale"];
374 for(ii=-1;ii<=1;ii++) {
375 for(ij=-1;ij<=1;ij++) {
376 for(ik=-1;ik<=1;ik++) {
378 nx=$1+i; ny=$2+j; nz=$3+k;
389 xt=nx*X1+ny*Y1+nz*Z1;
390 yt=nx*X2+ny*Y2+nz*Z2;
391 zt=nx*X3+ny*Y3+nz*Z3;
396 if((xt>=x0)&&(yt>=y0)&&(zt>=z0)&&\
397 (xt<=x1)&&(yt<=y1)&&(zt<=z1)) {
399 inx=$4+ii; iny=$5+ij; inz=$6+ik;
410 ixt=inx*X1+iny*Y1+inz*Z1;
411 iyt=inx*X2+iny*Y2+inz*Z2;
412 izt=inx*X3+iny*Y3+inz*Z3;
417 dist=sqrt((xt-ixt)^2+(yt-iyt)^2+(zt-izt)^2);
419 if((ixt>=x0)&&(iyt>=y0)&&(izt>=z0)&&\
420 (ixt<=x1)&&(iyt<=y1)&&(izt<=z1)) {
422 #if((xt>=x0)&&(yt>=y0)&&(zt>=z0)&&\
423 # (xt<=x1)&&(yt<=y1)&&(zt<=z1)) {
426 print "<"xt","zt","yt">,";
427 print "<"ixt","izt","iyt">,0.1";
428 print "pigment { color Blue }";
446 [ $ic -gt $ntot ] && break;
452 [ $count -gt $ntot ] && break;
458 # manually drawing the 3x4 boundaries specified by argv ...
459 if [ -n "$bx0" ]; then
460 draw_cyl $bx0 $by0 $bz0 $bx1 $by0 $bz0
461 draw_cyl $bx0 $by0 $bz0 $bx0 $by1 $bz0
462 draw_cyl $bx1 $by1 $bz0 $bx1 $by0 $bz0
463 draw_cyl $bx0 $by1 $bz0 $bx1 $by1 $bz0
465 draw_cyl $bx0 $by0 $bz1 $bx1 $by0 $bz1
466 draw_cyl $bx0 $by0 $bz1 $bx0 $by1 $bz1
467 draw_cyl $bx1 $by1 $bz1 $bx1 $by0 $bz1
468 draw_cyl $bx0 $by1 $bz1 $bx1 $by1 $bz1
470 draw_cyl $bx0 $by0 $bz1 $bx0 $by0 $bz0
471 draw_cyl $bx0 $by1 $bz1 $bx0 $by1 $bz0
472 draw_cyl $bx1 $by0 $bz1 $bx1 $by0 $bz0
473 draw_cyl $bx1 $by1 $bz1 $bx1 $by1 $bz0
476 # add camera and light source
477 cat >> temp.pov <<-EOF
480 if [ -n "$ortographic" ]; then cat >> temp.pov <<-EOF
484 cat >> temp.pov <<-EOF
486 look_at <$clx,$clz,$clz>
488 light_source { <0,100,-100> color White shadowless }
492 $POVRAY temp.pov > /dev/null 2>&1
493 mv temp.png `dirname $file`/