From c1f74e23422d004f7b9d2493cc747871c7ebfbae Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 25 Jul 2007 18:51:51 +0200 Subject: [PATCH] changes to visualization, not finished by now! --- ppm2avi | 6 ++--- run | 3 ++- sic.c | 2 +- visual/visual.c | 64 +++++++++++++++++++++++++++++++++----------- visualize | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 20 deletions(-) create mode 100755 visualize diff --git a/ppm2avi b/ppm2avi index fec403e..6987317 100755 --- 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 5a20df0..6e120d7 100755 --- 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 fa2a396..1f9bbbe 100644 --- 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 */ diff --git a/visual/visual.c b/visual/visual.c index 573ac4f..3a8f7f8 100644 --- a/visual/visual.c +++ b/visual/visual.c @@ -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 $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" -- 2.20.1