From: hackbard Date: Wed, 28 Apr 2004 06:03:11 +0000 (+0000) Subject: implemented plot support for carbon concentration in amorphous, crystalline or both... X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=432c30bbaa659faf5103ca4c969285dade166df2;p=physik%2Fnlsop.git implemented plot support for carbon concentration in amorphous, crystalline or both volumes of depth --- diff --git a/dfbapi.c b/dfbapi.c index 8eadfc9..11c1128 100644 --- a/dfbapi.c +++ b/dfbapi.c @@ -340,7 +340,7 @@ int d3_event_init(d3_lattice *d3_l) return 1; } -int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp) +int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp,int *ac_distr) { DFBInputEvent ke; @@ -362,6 +362,9 @@ int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switch if(ke.key_id==DIKI_3) *bmp=3; if(ke.key_id==DIKI_4) *bmp=4; if(ke.key_id==DIKI_5) *bmp=5; + if(ke.key_id==DIKI_A) *ac_distr=1; + if(ke.key_id==DIKI_C) *ac_distr=2; + if(ke.key_id==DIKI_B) *ac_distr=3; } return 1; diff --git a/dfbapi.h b/dfbapi.h index c06be52..6d628d8 100644 --- a/dfbapi.h +++ b/dfbapi.h @@ -71,7 +71,7 @@ int d3_lattice_release(d3_lattice *d3_l); int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,unsigned char mode,int max_extra); int d2_event_init(d2_lattice *d2_l); int d3_event_init(d3_lattice *d3_l); -int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp); +int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc,int *switchmode,int *bmp,int *ac_distr); int dx_lattice_get_color(unsigned char *status,unsigned char *r,unsigned char *g,unsigned char *b,unsigned char mode); #endif /* DFBAPI_H */ diff --git a/nlsop.c b/nlsop.c index 9b9f803..5d44239 100644 --- a/nlsop.c +++ b/nlsop.c @@ -328,6 +328,43 @@ int calc_max_extra(d3_lattice *d3_l) return max; } +int write_ac_distr(d3_lattice *d3_l,int ac_distr) +{ + int fd,x,y,z; + int count=0,offset; + char file[16]; + + if(ac_distr==1) strcpy(file,"a.plot"); + if(ac_distr==2) strcpy(file,"c.plot"); + if(ac_distr==3) strcpy(file,"b.plot"); + + if((fd=open(file,O_WRONLY|O_CREAT))<0) + { + puts("cannot open plot file"); + return -1; + } + + for(z=0;zmax_z;z++) + { + for(x=0;xmax_x;x++) + { + for(y=0;ymax_y;y++) + { + offset=x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; + if(ac_distr==1) + if(*(d3_l->status+offset)&AMORPH) count+=*(d3_l->extra+offset); + if(ac_distr==2) + if(!(*(d3_l->status+offset)&AMORPH)) count+=*(d3_l->extra+offset); + if(ac_distr==3) count+=*(d3_l->extra+offset); + } + } + dprintf(fd,"%d %d\n",z,count); + } + close(fd); + + return 1; +} + int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) { int fd,i,j,size=0,foo=0,end=0; @@ -658,7 +695,7 @@ int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l) int main(int argc,char **argv) { u32 x,y,z,x_c,y_c,z_c; - int i,j,quit,escape,switchmode,nowait,bmp; + int i,j,quit,escape,switchmode,nowait,bmp,ac_distr; int refresh,resave; int c_step; char s_file[MAX_CHARS]; @@ -1002,9 +1039,10 @@ int main(int argc,char **argv) if(switchmode==2) strcpy(mode_txt,"view: a pressure mode"); d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra); bmp=0; - scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp); + ac_distr=0; + scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr); if(bmp) write_bmp(&d3_l,bmp,x,y,z); - + if(ac_distr) write_ac_distr(&d3_l,ac_distr); } d3_lattice_release(&d3_l);