]> hackdaworld.org Git - physik/posic.git/commitdiff
changes to visualization, not finished by now!
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 25 Jul 2007 16:51:51 +0000 (18:51 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 25 Jul 2007 16:51:51 +0000 (18:51 +0200)
ppm2avi
run
sic.c
visual/visual.c
visualize [new file with mode: 0755]

diff --git a/ppm2avi b/ppm2avi
index fec403e3f70f308c38a2ea8595385a9ff79fdd86..6987317414dcb383a7d51e5e602a5f58b543a169 100755 (executable)
--- a/ppm2avi
+++ b/ppm2avi
@@ -1,5 +1,5 @@
-for i in $1/*.ppm; do
-       convert $i $1/$(basename $i ppm)png
-done
+#for i in $1/*.ppm; do
+#      convert $i $1/$(basename $i ppm)png
+#done
 
 mencoder mf://$1/*.png -ovc copy -o $1/md.avi >/dev/null 2>&1
diff --git a/run b/run
index 5a20df0b0acb4ce0266fe158db475901f163aa3f..6e120d781b42e1e3d721d3b0c2a3b64df4729853 100755 (executable)
--- a/run
+++ b/run
@@ -4,7 +4,8 @@
 if [ "$?" == "0" ]; then
        #./perms
        if [ "$1" ] ; then
-               rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1
+               ./visualize $1
+               #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1
                ./ppm2avi $1
        fi
 fi
diff --git a/sic.c b/sic.c
index fa2a396acd7fd1437a26c6c19b97ce30bf484235..1f9bbbe7b0932a7a20ee7881ef2ef005d8114395 100644 (file)
--- a/sic.c
+++ b/sic.c
@@ -25,7 +25,7 @@
 #define NR_ATOMS       1
 #define R_C            1.0
 #define T_C            10.0
-#define LCNT           5
+#define LCNT           3
 
 typedef struct s_hp {
        int a_count;    /* atom count */
index 573ac4fd68be8be1beecb10a3a452331bc4a2724..3a8f7f8e2fcaeaab51f7dc03deeb2c1da88119f0 100644 (file)
@@ -78,7 +78,8 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        dim.y=v->dim.y;
        dim.z=v->dim.z;
 
-       sprintf(file,"%s/visualize_%07.f.xyz",v->fb,time);
+       //sprintf(file,"%s/visualize_%07.f.xyz",v->fb,time);
+       sprintf(file,"%s/povray_%07.f.in",v->fb,time);
        fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
        if(fd<0) {
                perror("open visual save file fd");
@@ -99,23 +100,56 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) {
        dprintf(v->fd,"zap\n");
 
        /* write the actual data file */
-       dprintf(fd,"%d\n",(dim.x==0)?n:n+8);
-       dprintf(fd,"atoms at time %07.f\n",time);
+       //dprintf(fd,"%d\n",(dim.x==0)?n:n+8);
+       dprintf(fd,"# [C] %d\n",n);
+       dprintf(fd,"# [T] %07.f\n",time);
+       dprintf(fd,"# [L] <%f,%f,%f>\n",-1.0*dim.x/4.0,
+                                       1.5*dim.y,1.5*dim.z);
        for(i=0;i<n;i++)
-               dprintf(fd,"%s %f %f %f\n",pse[atom[i].element],
-                                          atom[i].r.x,
-                                          atom[i].r.y,
-                                          atom[i].r.z);
+               dprintf(fd,"0.5 %f %f %f\n",atom[i].r.x,
+                                           atom[i].r.y,
+                                           atom[i].r.z);
        if(dim.x) {
-               dprintf(fd,"%s %f %f %f\n",pse[0],dim.x/2,dim.y/2,dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],-dim.x/2,dim.y/2,dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],dim.x/2,-dim.y/2,dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],dim.x/2,dim.y/2,-dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],-dim.x/2,-dim.y/2,dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],dim.x/2,-dim.y/2,-dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],-dim.x/2,dim.y/2,-dim.z/2);
-               dprintf(fd,"%s %f %f %f\n",pse[0],-dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,-dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,-dim.z/2,
+                       -dim.x/2,dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,-dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,-dim.z/2,
+                       dim.x/2,dim.y/2,-dim.z/2);
+
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       -dim.x/2,dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,dim.y/2,dim.z/2);
+
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,-dim.y/2,dim.z/2,
+                       -dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       -dim.x/2,dim.y/2,dim.z/2,
+                       -dim.x/2,dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,-dim.y/2,dim.z/2,
+                       dim.x/2,-dim.y/2,-dim.z/2);
+               dprintf(fd,"# [D] %f %f %f %f %f %f\n",
+                       dim.x/2,dim.y/2,dim.z/2,
+                       dim.x/2,dim.y/2,-dim.z/2);
        }
+
        close(fd);
 
        return 0;
diff --git a/visualize b/visualize
new file mode 100755 (executable)
index 0000000..b85b839
--- /dev/null
+++ b/visualize
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+if [ ! -d $1 ] ; then
+       echo "no such directory -> $1"
+       exit
+fi
+
+POVRAY="povray -W1024 -H768 -d" 
+
+echo "processing $1 ..."
+
+for file in $1/povray_*.in ; do
+       cat > temp.pov <<-EOF
+#include "colors.inc"
+#include "textures.inc"
+#include "shapes.inc"
+#include "glass.inc"
+#include "metals.inc"
+#include "woods.inc"
+#include "stones.inc"
+EOF
+
+       # meta info
+       count=`grep '# \[C\]' $file | awk '{ print $3 }'`
+       time=`grep '# \[T\]' $file | awk '{ print $3 }'`
+       camloc=`grep '# \[L\]' $file | awk '{ print $3 }'`
+
+       # atoms
+       cat $file | grep -v '#' | while read radius x y z ; do #temp dis; do
+               cat >> temp.pov <<-EOF
+sphere {
+       <$x, $z, $y>, $radius
+       texture {
+               pigment { color Yellow }
+               finish {
+                       phong 1
+                       metallic
+                }
+       }
+}
+EOF
+       done
+
+       # boundaries
+       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
+       done
+
+       # add camera and light source
+       cat >> temp.pov <<-EOF
+camera {
+//     orthographic
+       location $camloc
+       look_at <0,0,0>
+}
+light_source { <0,10000,0> color White shadowless }
+EOF
+
+       # mv png
+       $POVRAY temp.pov > /dev/null 2>&1
+       mv temp.png `echo $file | sed 's/\.in/\.png/'`
+
+done
+
+echo "done"