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";
57 -d) directory=$2; shift 2;;
58 -w) width=$2; shift 2;;
59 -h) height=$2; shift 2;;
60 -r) radius=$2; shift 2;;
61 -nll) x0=$2; y0=$3; z0=$4; shift 4;;
62 -fur) x1=$2; y1=$3; z1=$4; shift 4;;
63 -c) cx=$2; cy=$3; cz=$4; shift 4;;
64 -L) clx=$2; cly=$3; clz=$4; shift 4;;
65 -l) lx=$2; ly=$3; lz=$4; shift 4;;
66 -o) ortographic=1; shift 1;;
67 -b) bx0=$2; by0=$3; bz0=$4;
68 bx1=$5; by1=$6; bz1=$7; shift 7;;
71 -e) extra=1; shift 1;;
72 -D) displace=$2; shift 2;;
73 -m) mx1=$2; mx2=$3; mx3=$4;
74 my1=$5; my2=$6; my3=$7;
75 mz1=$8; mz2=$9; mz3=${10};
79 while [ $cnt -le $ab ]; do
80 anr[$cnt]=$1; shift 1;
87 echo "directory to progress:"
88 echo " -d <directory> (mandatory)"
94 echo " -B <bond cylinder radius>"
96 echo " -C <lattice constant>"
97 echo " -m <dimX> <dimY> <dimZ> (mirror atoms)"
98 echo "visualization volume:"
99 echo " -nll <x> <y> <z> (near lower left)"
100 echo " -fur <x> <y> <z> (far upper right)"
101 echo " -o (ortographic)"
103 echo " -b <x0> <y0> <z0> <x1> <y1> <z1>"
105 echo " -c <x> <y> <z> (camera position)"
106 echo " -L <x> <y> <z> (camera look)"
107 echo " -l <x> <y> <z> (light source)"
109 echo " -ab <atom number> <cutoff> (auto bonds)"
114 # calculation from lattic eunits to angstroms
116 [ "$lc" = "sic" ] && lc=4.359
117 [ "$lc" = "si" ] && lc=5.480
118 [ "$lc" = "c" ] && lc=3.566
120 #offset=`echo 0.125 \* $lc | bc`
123 x0=`echo $x0 \* $lc + $offset | bc`
124 y0=`echo $y0 \* $lc + $offset | bc`
125 z0=`echo $z0 \* $lc + $offset | bc`
126 x1=`echo $x1 \* $lc + $offset | bc`
127 y1=`echo $y1 \* $lc + $offset | bc`
128 z1=`echo $z1 \* $lc + $offset | bc`
130 mx1=`echo $mx1 \* $lc + $offset | bc`
131 my1=`echo $my1 \* $lc + $offset | bc`
132 mz1=`echo $mz1 \* $lc + $offset | bc`
133 mx2=`echo $mx2 \* $lc + $offset | bc`
134 my2=`echo $my2 \* $lc + $offset | bc`
135 mz2=`echo $mz2 \* $lc + $offset | bc`
136 mx3=`echo $mx3 \* $lc + $offset | bc`
137 my3=`echo $my3 \* $lc + $offset | bc`
138 mz3=`echo $mz3 \* $lc + $offset | bc`
140 clx=`echo $clx \* $lc + $offset | bc`
141 cly=`echo $cly \* $lc + $offset | bc`
142 clz=`echo $clz \* $lc + $offset | bc`
144 if [ -n "$cx" -a -n "$cy" -a -n "$cz" ]; then
145 cx=`echo $cx \* $lc + $offset | bc`
146 cy=`echo $cy \* $lc + $offset | bc`
147 cz=`echo $cz \* $lc + $offset | bc`
150 if [ -n "$bx0" ]; then
151 bx0=`echo $bx0 \* $lc + $offset | bc`
152 by0=`echo $by0 \* $lc + $offset | bc`
153 bz0=`echo $bz0 \* $lc + $offset | bc`
154 bx1=`echo $bx1 \* $lc + $offset | bc`
155 by1=`echo $by1 \* $lc + $offset | bc`
156 bz1=`echo $bz1 \* $lc + $offset | bc`
160 POVRAY="povray -W${width} -H${height} -d"
163 [ -n "$cx" -a -n "$cy" -a -n "$cz" ] && camloc="<$cx,$cz,$cy>"
166 COPTS="-font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
167 COPTS="$COPTS -depth 8 -fill white -stroke blue -pointsize 24"
171 if [ -d $directory ]; then
172 filesource=$directory/CONTCAR*
175 if [ -f $directory ]; then
176 filesource=$directory
179 for file in $filesource; do
181 echo "working on $file ..."
183 cat > temp.pov <<-EOF
184 #include "colors.inc"
185 #include "textures.inc"
186 #include "shapes.inc"
188 #include "metals.inc"
190 #include "stones.inc"
194 scale=`sed -n 2p $file | awk '{ print $1 }'`
195 line="`sed -n 3p $file`"
196 X1=`echo $line | awk '{ print $1 }'`
197 X2=`echo $line | awk '{ print $2 }'`
198 X3=`echo $line | awk '{ print $3 }'`
199 line="`sed -n 4p $file`"
200 Y1=`echo $line | awk '{ print $1 }'`
201 Y2=`echo $line | awk '{ print $2 }'`
202 Y3=`echo $line | awk '{ print $3 }'`
203 line="`sed -n 5p $file`"
204 Z1=`echo $line | awk '{ print $1 }'`
205 Z2=`echo $line | awk '{ print $2 }'`
206 Z3=`echo $line | awk '{ print $3 }'`
207 line="`sed -n 6p $file`"
208 nsi=`echo $line | awk '{ print $1 }'`
209 nc=`echo $line | awk '{ print $2 }'`
215 echo "cutoff: $cutoff"
222 export x0 y0 z0 x1 y1 z1 radius
226 checktsd=`sed -n 7p $file | awk '{ print $1 }'`
227 if [ "$checktsd" = "Transformed" ]; then
229 echo "tsd: yes, offset = $offset"
232 echo "tsd: no, offset = $offset"
238 if [ $count -le $nsi ]; then
246 line="`sed -n ${gl}p $file`"
247 x=`echo $line | awk '{ print $1 }'`
248 y=`echo $line | awk '{ print $2 }'`
249 z=`echo $line | awk '{ print $3 }'`
251 echo $x $y $z | awk '\
253 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
254 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
255 X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"];
256 Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"];
257 Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"];
258 radius=ENVIRON["radius"]; scale=ENVIRON["scale"];
259 color=ENVIRON["color"]
269 nx=$1+i; ny=$2+j; nz=$3+k;
271 xt=nx*X1+ny*Y1+nz*Z1;
272 yt=nx*X2+ny*Y2+nz*Z2;
273 zt=nx*X3+ny*Y3+nz*Z3;
279 if((xt>=x0)&&(yt>=y0)&&(zt>=z0)&&\
280 (xt<=x1)&&(yt<=y1)&&(zt<=z1)) {
281 print "sphere { <"xt","zt","yt">, "radius" ";
282 print "texture { pigment { color " color " } ";
283 print "finish { phong 1 metallic } } }";
291 # see, whether there are bonds to draw
292 if [ "$ab" = "0" ]; then
298 while [ $cnt -le $ab ]; do
300 if [ $anr -eq $count ]; then
306 if [ "$ab" = "-1" ]; then
309 if [ "$dobond" = "no" ]; then
318 [ $ic -gt $count ] && break
320 if [ $ic -eq $count ]; then
326 line="`sed -n ${il}p $file`"
327 xb=`echo $line | awk '{ print $1 }'`
328 yb=`echo $line | awk '{ print $2 }'`
329 zb=`echo $line | awk '{ print $3 }'`
331 echo $x $y $z $xb $yb $zb $cutoff | awk '\
333 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
334 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
335 X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"];
336 Y1=ENVIRON["Y1"]; Y2=ENVIRON["Y2"]; Y3=ENVIRON["Y3"];
337 Z1=ENVIRON["Z1"]; Z2=ENVIRON["Z2"]; Z3=ENVIRON["Z3"];
338 bcr=ENVIRON["bcr"]; scale=ENVIRON["scale"];
345 for(ii=-1;ii<=1;ii++) {
346 for(ij=-1;ij<=1;ij++) {
347 for(ik=-1;ik<=1;ik++) {
349 nx=$1+i; ny=$2+j; nz=$3+k;
350 xt=nx*X1+ny*Y1+nz*Z1;
351 yt=nx*X2+ny*Y2+nz*Z2;
352 zt=nx*X3+ny*Y3+nz*Z3;
357 inx=$4+ii; iny=$5+ij; inz=$6+ik;
358 ixt=inx*X1+iny*Y1+inz*Z1;
359 iyt=inx*X2+iny*Y2+inz*Z2;
360 izt=inx*X3+iny*Y3+inz*Z3;
365 dist=sqrt((xt-ixt)^2+(yt-iyt)^2+(zt-izt)^2);
367 if((xt>=x0)&&(yt>=y0)&&(zt>=z0)&&\
368 (xt<=x1)&&(yt<=y1)&&(zt<=z1)) {
371 print "<"xt","zt","yt">,";
372 print "<"ixt","izt","iyt">,0.1";
373 print "pigment { color Blue }";
387 [ $ic -gt $ntot ] && break;
392 [ $count -gt $ntot ] && break;
398 # manually drawing the 3x4 boundaries specified by argv ...
399 draw_cyl $bx0 $by0 $bz0 $bx1 $by0 $bz0
400 draw_cyl $bx0 $by0 $bz0 $bx0 $by1 $bz0
401 draw_cyl $bx1 $by1 $bz0 $bx1 $by0 $bz0
402 draw_cyl $bx0 $by1 $bz0 $bx1 $by1 $bz0
404 draw_cyl $bx0 $by0 $bz1 $bx1 $by0 $bz1
405 draw_cyl $bx0 $by0 $bz1 $bx0 $by1 $bz1
406 draw_cyl $bx1 $by1 $bz1 $bx1 $by0 $bz1
407 draw_cyl $bx0 $by1 $bz1 $bx1 $by1 $bz1
409 draw_cyl $bx0 $by0 $bz1 $bx0 $by0 $bz0
410 draw_cyl $bx0 $by1 $bz1 $bx0 $by1 $bz0
411 draw_cyl $bx1 $by0 $bz1 $bx1 $by0 $bz0
412 draw_cyl $bx1 $by1 $bz1 $bx1 $by1 $bz0
414 # add camera and light source
415 cat >> temp.pov <<-EOF
418 if [ -n "$ortographic" ]; then cat >> temp.pov <<-EOF
422 cat >> temp.pov <<-EOF
424 look_at <$clx,$clz,$clz>
426 light_source { <0,100,-100> color White shadowless }
430 $POVRAY temp.pov > /dev/null 2>&1
431 mv temp.png `dirname $file`/