more interstitial testing, added bond visualization
[physik/posic.git] / visualize
index b5d8f74..ab6e374 100755 (executable)
--- a/visualize
+++ b/visualize
@@ -14,6 +14,14 @@ pigment { color White }
 }
 EOF
 }
+draw_bond() {
+       cat >> temp.pov <<-EOF
+cylinder {
+<$1, $3, $2>, <$4, $6, $5>, $7
+pigment { color Blue }
+}
+EOF
+}
 
 directory="doesnt_exist____for_sure"
 width="640"
@@ -23,8 +31,10 @@ x0=""; y0=""; z0="";
 x1=""; y1=""; z1="";
 cx=""; cy=""; cz="";
 lx="0"; ly="-100"; lz="100";
+ortographic=""
 bx0=""; by0=""; bz0="";
 bx1=""; by1=""; bz1="";
+bcr="";
 
 while [ "$1" ]; do
        case "$1" in
@@ -39,6 +49,7 @@ while [ "$1" ]; do
                -o)             ortographic=1;          shift 1;;
                -b)             bx0=$2; by0=$3; bz0=$4;
                                bx1=$5; by1=$6; bz1=$7; shift 7;;
+               -B)             bcr=$2;                 shift 2;;
                *)
                                echo "options:"
                                echo "########"
@@ -49,6 +60,7 @@ while [ "$1" ]; do
                                echo "  -h <height>"
                                echo "atom size:"
                                echo "  -r <radius>"
+                               echo "  -B <bond cylinder radius>"
                                echo "visualization volume:"
                                echo "  -nll <x> <y> <z> (near lower left)"
                                echo "  -fur <x> <y> <z> (far upper right)"
@@ -125,14 +137,11 @@ EOF
        if [ -z "$bx0" ]; then
 
        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 }
-}
-EOF
+               draw_cyl $x1 $z1 $y1 $x2 $z2 $y2 0.05
        done
+
        else
                # manually drawing the 3x4 boundaries ...
                draw_cyl $x0 $y0 $z0 $x1 $y0 $z0
@@ -171,6 +180,38 @@ EOF
 
        fi      
 
+       # bonds
+       if [ -n "$bcr" ]; then
+
+               if [ -z "$x0" ]; then
+
+       cat $file | grep '# \[B\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do
+               draw_bond $x1 $z1 $y1 $x2 $z2 $y2 $bcr
+       done
+
+               else
+
+               export x0 y0 z0 x1 y1 z1 bcr
+               cat $file | grep '# \[B\]' | awk '\
+               BEGIN {
+                       x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
+                       x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
+                       bcr=ENVIRON["bcr"];
+               }
+               {
+                       if(($3>=x0)&&($4>=y0)&&($5>=z0)&&\
+                          ($3<=x1)&&($4<=y1)&&($5<=z1)) {
+                               print "cylinder {";
+                               print "<"$3","$5","$4">,";
+                               print "<"$6","$8","$7">, "bcr;
+                               print "pigment { color Blue }";
+                               print "}";
+                       }
+               }' >> temp.pov
+
+               fi
+       fi      
+
        # add camera and light source
        cat >> temp.pov <<-EOF
 camera {