From: hackbard Date: Wed, 23 Sep 2009 16:31:45 +0000 (+0200) Subject: auto bond feature added X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a5c13f7bf7756f538292a79edee97ce518a5395;p=physik%2Fposic.git auto bond feature added --- diff --git a/vasp_tools/visualize b/vasp_tools/visualize index 8d1e98f..793e72e 100755 --- a/vasp_tools/visualize +++ b/vasp_tools/visualize @@ -37,7 +37,7 @@ lx="0"; ly="-100"; lz="100"; ortographic="" bx0=""; by0=""; bz0=""; bx1=""; by1=""; bz1=""; -bcr=""; +bcr="0.1"; clx="0"; cly="0"; clz="0"; extra=0 displace="" @@ -45,6 +45,7 @@ mirror=0 mx1=0; mx2=0; mx3=0; my1=0; my2=0; my3=0; mz1=0; mz2=0; mz3=0; +ab=0 # parse argv @@ -70,7 +71,8 @@ while [ "$1" ]; do my1=$5; my2=$6; my3=$7; mz1=$8; mz2=$9; mz3=${10}; mirror=1; shift 10;; - + -A) ab=1; + anr=$2; cutoff=$3; shift 3;; *) echo "options:" echo "########" @@ -95,6 +97,8 @@ while [ "$1" ]; do echo " -c (camera position)" echo " -L (camera look)" echo " -l (light source)" + echo "bonds:" + echo " -ab (auto bonds)" exit 1;; esac done @@ -344,7 +348,68 @@ EOF }' >> temp.pov fi - fi + fi + + # auto bonds + if [ "$ab" = "1" ]; then + ((tmp=anr+1)) + line="`sed -n ${tmp}p $file`" + aX=`echo $line | awk '{ print $2 }'` + aY=`echo $line | awk '{ print $3 }'` + aZ=`echo $line | awk '{ print $4 }'` + export aX aY aZ cutoff mirror + cat $file | grep -v '#' | awk '\ + BEGIN { + x=ENVIRON["aX"]; y=ENVIRON["aY"]; z=ENVIRON["aZ"]; + co=ENVIRON["cutoff"]; dist=0; bcr=ENVIRON["bcr"]; + mx1=ENVIRON["mx1"]; my1=ENVIRON["my1"]; + mz1=ENVIRON["mz1"]; mx2=ENVIRON["mx2"]; + my2=ENVIRON["my2"]; mz2=ENVIRON["mz2"]; + mx3=ENVIRON["mx3"]; my3=ENVIRON["my3"]; + mz3=ENVIRON["mz3"]; mirror=ENVIRON["mirror"]; + } + { + dist=sqrt((x-$2)^2+(y-$3)^2+(z-$4)^2); + if((dist<=co)&&(dist>0.01)) { + print "cylinder {"; + print "<"x","z","y">,"; + print "<"$2","$4","$3">, "bcr; + print "pigment { color Blue }"; + print "}"; + } + + if(mirror) { + nx=$2-mx1; ny=$3-mx2; nz=$4-mx3; + dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2) + if((dist<=co)&&(dist>0.01)) { + print "cylinder {"; + print "<"x","z","y">,"; + print "<"nx","nz","ny">, "bcr; + print "pigment { color Blue }"; + print "}"; + } + nx=$2-my1; ny=$3-my2; nz=$4-my3; + dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2) + if((dist<=co)&&(dist>0.01)) { + print "cylinder {"; + print "<"x","z","y">,"; + print "<"nx","nz","ny">, "bcr; + print "pigment { color Blue }"; + print "}"; + } + nx=$2-mz1; ny=$3-mz2; nz=$4-mz3; + dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2) + if((dist<=co)&&(dist>0.01)) { + print "cylinder {"; + print "<"x","z","y">,"; + print "<"nx","nz","ny">, "bcr; + print "pigment { color Blue }"; + print "}"; + } + } + + }' >> temp.pov + fi # add camera and light source cat >> temp.pov <<-EOF