diff options
author | Karl Berry <karl@freefriends.org> | 2019-12-08 22:49:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-12-08 22:49:10 +0000 |
commit | 7dd3149094da5810ffd95fbaa67bc44a0f4967a9 (patch) | |
tree | 457502beb2a99b4e2d89d2a8f94eb6a252a2516e /Master/texmf-dist/metapost | |
parent | 43e7967ca666f134ba02d13e77365b9581cbd825 (diff) |
mcf2graph (8dec19)
git-svn-id: svn://tug.org/texlive/trunk@53062 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 493 |
1 files changed, 214 insertions, 279 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 8de584bebee..e514b439868 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.45 Copyright (c) 2013-2019 Akira Yamaji +% mcf2graph ver 4.46 Copyright (c) 2013-2019 Akira Yamaji % % Permission is hereby granted, free of charge, to any person obtaining a copy of this software % and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -38,11 +38,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; %------------------------------------------------------------------------------------------------- -newinternal char_num,str_cnt,sub_usr,sub_int,tbl_cnt,sharp_char; +newinternal com,par,nA,nB,nC,nD,nE,nF,nP,char_num,str_cnt,sub_usr,sub_int,tbl_cnt,sharp_char; numeric save_num[],comD[][],parD[][],cntD[],tbl_atom[],tbl_subst[][], tbl_atom_wt[],tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],andA[],and_rot[],chargeA[]; -string save_str[],tbl_atom_str[],strD[],var[],tag[],out_file_name,out_file_aux,out_file_rep, - aux_delimiter,atomfont,save_atomfont,save_defaultfont; +string save_str[],tbl_atom_str[],strD[],var[],tag[],out_file_name,out_file_aux, + out_file_rep,out_file_mcl,aux_delimiter,atomfont,save_atomfont,save_defaultfont; pair save_pair[],msize,mposition,fsize,fmargin,save_mposition; picture mol_stru[],save_picture,temp_picture; path arrow_path,arrow_head; @@ -63,6 +63,7 @@ if (known green)and(known ahlength): %----------------------------------------------------------------------------------------- atomfont:=defaultfont:=""; out_file_aux:=jobname&"-info.aux"; + out_file_mcl:=jobname&"-mcl.txt"; out_file_rep:=jobname&"-report.txt"; def out_file_mol= jobname&"-"&fit_zero(char_num)&"-"&inf_EN&".mol" enddef; %--default ahangle=45--------------------------------------------------------------------- @@ -76,15 +77,16 @@ if (known green)and(known ahlength): elseif ahangle=13: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi) fi %--default ahlength=4--------------------------------------------------------------------- - if ahlength=1: sw_aux_out:=1; bboxmargin:=0; % output aux file - elseif ahlength=2: sw_aux_out:=2; bboxmargin:=0; % output aux file(fixed mode) - elseif ahlength=3: sw_rep_out:=1; bboxmargin:=0; % output report - elseif ahlength=5: sw_mol_out:=1; bboxmargin:=0; % output MOL(V2000) - elseif ahlength=6: sw_mol_out:=2; bboxmargin:=0; % output MOL(V3000) + if ahlength=1: sw_aux_out:=1; bboxmargin:=0; % output aux file + elseif ahlength=2: sw_aux_out:=2; bboxmargin:=0; % output aux file(fixed mode) + elseif ahlength=3: sw_rep_out:=1; bboxmargin:=0; % output report + elseif ahlength=5: sw_mol_out:=1; bboxmargin:=0; % output MOL(V2000) + elseif ahlength=6: sw_mol_out:=2; bboxmargin:=0; % output MOL(V3000) fi %-- default bboxmargin=2------------------------------------------------------------------ - if bboxmargin=0: def shipit = enddef; % No image file - elseif bboxmargin=1: proc_end:=1; % output first font only + if bboxmargin=0: def shipit = enddef; % No image file + elseif bboxmargin=1: proc_end:=1; % output first font only + elseif bboxmargin=3: def shipit = enddef;proc_end:=1; % No image file ,first font only fi %--default labeloffset=3------------------------------------------------------------------ if labeloffset=1: sw_arrow:=1; defaultfont:="uhvr8r"; % plain.mp label @@ -122,10 +124,11 @@ fi clearit; %-------------------------------------------------------------------------------------------------- message "---------------------------------------------"; -message "This is mcf2graph ver 4.45 2019.10"; +message "This is mcf2graph ver 4.46 2019.12"; if f_MP=1: if bboxmargin=0: message "output no image file"; elseif bboxmargin=1: message "output first font only"; + elseif bboxmargin=3: message "no image,first only"; fi message "jobname="&jobname; message "numbersystem="&numbersystem; @@ -156,7 +159,7 @@ def ext(text TXT)= sw_ext_all:=1; def EXT_ALL = TXT enddef; enddef; def ext_clear= sw_ext_all:=0; def EXT_ALL = enddef; enddef; %-------------------------------------------------------------------------------------------------- ?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1; -ratio_chain_ring:= 0.66; ratio_atom_bond:=0.36; +ratio_chain_ring:= 0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015; ratio_thickness_char:=0.1; ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15; ratio_zebragap_bond:=0.12; ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.040; @@ -181,26 +184,24 @@ sub_usr_start:=2500; % 2500 => 2999 for user sub structure (max 500) sub_int_start:=3000; % 3000 => 4000 for internal sub structure (max 1000) %-------------------------------------------------------------------------------------------------- def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; endfor enddef; -def_com(-4000)(_term,_jp_atom,_jp_atom_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_chg_line, - _dl,_mb,_N,_O,_S,_tmp_line,_chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env, - _tmp_env,_set_colorA,_set_colorB,_substA,_substB,_substC,_substD,_substE,_substF,_substG,_substH, - _set_clr,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse,_push,_pop, - _size_a,_numeric,_jump_at,_connect_at,_set_and,_chg_charge,_nop); -def_com(1)(si,dl,dr,db,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,si_,wf_,wb_,bd_); +def_com(-4090)(_com,_jp_atom,_jp_A_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_dl,_tmp_line, + _chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env,_tmp_env,_set_colorA,_set_colorB, + _substA,_substB,_substC,_substD,_substE,_substF,_substG,_substH, + _set_clr,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse, + _size_atom,_numeric,_jump_at,_connect_at,_set_and,_chg_charge,_nop, + si,dl,dr,db,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,si_,wf_,wb_,bd_); %-------------------------------------------------------------------------------------------------- def parameter_list= sw_rep_out,sw_numberA,sw_numberB,sw_mframe,sw_aux_out,sw_expand,sw_mol_out,sw_calc,sw_single, sw_ext_all,sw_aframe,sw_fframe,sw_subst_off,sw_trimming,sw_arrow,sw_label_emu, - ratio_atom_bond,ratio_thickness_bond,ratio_char_bond, - ratio_chain_ring,ratio_bondgap_bond,ratio_zebra_black,ratio_zebragap_bond,ratio_thickness_char, - ratio_wedge_bond,ratio_atomgap_atom,lonepairdiam,lonepairspace, - blength,offset_atom,offset_wedge,max_blength,offset_zebra_gap,offset_bond_gap, - thickness_fframe,thickness_mframe,thickness_aframe,offset_thickness, - numberA_start,numberA_end,numberB_start,numberB_end, - defaultsize,defaultscale,labeloffset,mangle, + ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,ratio_chain_ring,ratio_bondgap_bond, + ratio_zebra_black,ratio_zebragap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom, + lonepairdiam,lonepairspace,blength,offset_atom,offset_wedge,max_blength,offset_zebra_gap, + offset_bond_gap,thickness_fframe,thickness_mframe,thickness_aframe,offset_thickness, + numberA_start,numberA_end,numberB_start,numberB_end,defaultsize,defaultscale,labeloffset,mangle, + fsize,fmargin,msize,mposition,defaultfont,atomfont, Me,Et,Pr,Bu,iPr,tBu,CH3,CF3,CCl3,CBr3,NH,NH2,NO2,OH,CHO,COOH,CN,SH,OMe,OEt,SMe,SEt, - !CH3,!NH2,!OH,!CHO,!COOH,!CN,!SH,!NO2, - fsize,fmargin,msize,mposition,defaultfont,atomfont + !CH3,!NH2,!OH,!CHO,!COOH,!CN,!SH,!NO2 enddef; %-------------------------------------------------------------------------------------------------- def ]]]=] ] ] enddef; @@ -209,7 +210,7 @@ vardef pic_c(expr i,s)= substring(i,i+1) of s enddef; vardef sfB(expr a,b,c)= a shifted ((b,0) rotated c) enddef; %-------------------------------------------------------------------------------------------------- def init_par(text t)= -nA:=nB:=nC:=0; + nA:=nB:=nC:=0; for list=t: if numeric list: nA:=nA+1; save_num[nA]:=list; elseif pair list: nB:=nB+1; save_pair[nB]:=list; @@ -311,8 +312,8 @@ def endfont= enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def set_def_MC= - save /,//,/*,*/,**,*/*,~,^,`,<,>,>>,&,:,=,\,\\,*\,\*,*\*,@,$,{,},#, - |,||,|<,>|,|<=,|=,=|,|:,:|,_,d,w,z,inside_def_MC; + save /,//,/*,*/,**,*/*,~,^,`,<,>,>>,&,:,=,\,\\,*\,\*,*\*,@,$,{,},#,|,||,|||,|=,=|,|<,>|,|:,:|, + _,d,w,z,inside_def_MC; inside_def_MC:=1; _:=Me; d:=db; w:=wf; z:=zf; tertiarydef a=b == if (known a)and(known b):: change_bond(a,b) else:: _nop fi enddef; @@ -328,21 +329,14 @@ def set_def_MC= tertiarydef a`b == if known b:: (_tmp_len,b),a else:: _nop,a fi enddef; tertiarydef a~b == if known b:: (_tmp_line,b),a else:: _nop,a fi enddef; tertiarydef a>b == if known b:: (_tmp_env,b),a else:: _nop,a fi enddef; - def # == _connect_at enddef; - def @ == _jump_at enddef; - def \ == @,0 enddef; - def \\ == \~dm enddef; - def *\ == \~wf enddef; - def \* == \~zf enddef; + def # == _connect_at enddef; def @ == _jump_at enddef; + def \ == @,0 enddef; def \\ == \~dm enddef; + def *\ == \~wf enddef; def \* == \~zf enddef; def *\* == \~wv enddef; - def |: == (_push,0) enddef; - def :| == (_pop,0) enddef; - def |< == (_push,1) enddef; - def >| == (_pop,1) enddef; - def |=primary n == (_push,0),``n enddef; - def =| == (_pop,0) enddef; - def | == (_push,2) enddef; - def || == (_pop,2) enddef; + def | == (_com,1) enddef; def || == (_com,2) enddef; def ||| == (_com,3) enddef; + def |< == (_com,5) enddef; def >| == (_com,6) enddef; + def |: == (_com,7) enddef; def :| == (_com,8) enddef; + def |=primary n == |<,(_chg_len,n) enddef; def =| == >| enddef; def /secondary n == if known n:: (_substA,n) else:: _nop fi enddef; def //secondary n == if known n:: (_substB,n) else:: _nop fi enddef; def */secondary n == if known n:: (_substC,n) else:: _nop fi enddef; @@ -353,38 +347,33 @@ enddef; %================================================================================================= vardef '(text TXT)= read_command(incr sub_usr)(TXT); sub_usr enddef; %------------------------------------------------------------------------------------------------- -def read_command(expr ADR)(text TXT)= +def read_command(expr n)(text TXT)= begingroup save list_cnt; if unknown inside_def_MC:: set_def_MC fi - cntD[ADR]:=list_cnt:=0; + cntD[n]:=list_cnt:=0; for list==TXT:: - list_cnt:=list_cnt+1; if known list:: + list_cnt:=list_cnt+1; if pair list:: - cntD[ADR]:=cntD[ADR]+1; - comD[ADR][cntD[ADR]]:=xpart(list); - parD[ADR][cntD[ADR]]:=ypart(list); + cntD[n]:=cntD[n]+1; + comD[n][cntD[n]]:=xpart(list); parD[n][cntD[n]]:=ypart(list); elseif numeric list:: if list==_nop:: message "unknown command in "AND decimal(list_cnt); elseif list>=sub_emb_start:: for i==1 upto cntD[list]:: - cntD[ADR]:=cntD[ADR]+1; - comD[ADR][cntD[ADR]]:=comD[list][i]; - parD[ADR][cntD[ADR]]:=parD[list][i]; + cntD[n]:=cntD[n]+1; + comD[n][cntD[n]]:=comD[list][i]; parD[n][cntD[n]]:=parD[list][i]; endfor else:: - cntD[ADR]:=cntD[ADR]+1; - comD[ADR][cntD[ADR]]:=_mk_bond; - parD[ADR][cntD[ADR]]:=list; + cntD[n]:=cntD[n]+1; + comD[n][cntD[n]]:=_mk_bond; parD[n][cntD[n]]:=list; fi elseif string list:: - str_cnt:=str_cnt+1; - strD[str_cnt]:=list; - cntD[ADR]:=cntD[ADR]+1; - comD[ADR][cntD[ADR]]:=_set_atom; - parD[ADR][cntD[ADR]]:=str_cnt; + str_cnt:=str_cnt+1; strD[str_cnt]:=list; + cntD[n]:=cntD[n]+1; + comD[n][cntD[n]]:=_set_atom; parD[n][cntD[n]]:=str_cnt; fi else:: message "unknown command in "AND decimal(list_cnt); @@ -399,17 +388,14 @@ vardef read_number(text TXT)= for list==TXT:: if known list:: if numeric list:: - if list==_nop:: - message "unknown command in "AND decimal(sub_int); + if list==_nop:: message "unknown command in "AND decimal(sub_int); else:: cntD[sub_int]:=cntD[sub_int]+1; - comD[sub_int][cntD[sub_int]]:=_numeric; - parD[sub_int][cntD[sub_int]]:=list; + comD[sub_int][cntD[sub_int]]:=_numeric; parD[sub_int][cntD[sub_int]]:=list; fi elseif pair list:: cntD[sub_int]:=cntD[sub_int]+1; - comD[sub_int][cntD[sub_int]]:=xpart(list); - parD[sub_int][cntD[sub_int]]:=ypart(list); + comD[sub_int][cntD[sub_int]]:=xpart(list); parD[sub_int][cntD[sub_int]]:=ypart(list); fi else:: message "unknown command in "AND decimal(sub_int); @@ -419,79 +405,76 @@ vardef read_number(text TXT)= enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def fuse_ring(expr a,b) = - PA(_jp_bond,a) PA(_rot_ang,180) PA(_get_len,a) PA(_push,0) - PA(_chg_len,_ring_len) for i==1 upto b-2:: PA(_mk_bond,360 DIV b) endfor PA(_pop,0) - if a>=1:: PA(_cyc_eB,0) elseif a>=-999:: PA(_cyc_eB,a-b+2) else:: PA(_cyc_eB,a) fi + CP(_jp_bond,a) CP(_rot_ang,180) CP(_get_len,a) CP(_com,5) + CP(_chg_len,_ring_len) for i==1 upto b-2:: CP(_mk_bond,360 DIV b) endfor + CP(_com,6) if a<=0:: CP(_cyc_eB,a-b+2) else:: CP(_cyc_eB,a) fi enddef; %------------------------------------------------------------------------------------------------- def fuse_ring_bonds(expr a,b,c) = - PA(_jp_bond,xpart(a)) PA(_rot_ang,180) PA(_push,0) - if b==6:: PA(_chg_len,0) for i==1 upto c-1:: PA(_mk_bond,60) endfor - elseif b==5:: if c==2:: PA(_chg_len,1.25) PA(_mk_bond,80) - elseif c==3:: PA(_chg_len,1.1) PA(_mk_bond,78) PA(_mk_bond,72) fi - elseif b==4:: PA(_chg_len,1.225) PA(_mk_bond,105) fi - PA(_pop,0) if ypart(a)<=0:: PA(_cyc_eB,ypart(a)-c+1) else:: PA(_cyc_eB,ypart(a)) fi + CP(_jp_bond,xpart(a)) CP(_rot_ang,180) CP(_com,5) + if b==6:: CP(_chg_len,0) for i==1 upto c-1:: CP(_mk_bond,60) endfor + elseif b==5:: if c==2:: CP(_chg_len,1.25) CP(_mk_bond,80) + elseif c==3:: CP(_chg_len,1.1) CP(_mk_bond,78) CP(_mk_bond,72) fi + elseif b==4:: CP(_chg_len,1.225) CP(_mk_bond,105) fi + CP(_com,6) if ypart(a)<=0:: CP(_cyc_eB,ypart(a)-c+1) else:: CP(_cyc_eB,ypart(a)) fi enddef; %------------------------------------------------------------------------------------------------- def fuse_ring_rate(expr a,b,c) = - PA(_jp_bond,a) PA(_rot_ang,180) PA(_push,0) PA(_chg_len,c DIV 10) - if b==5:: PA(_mk_bond,72-((c-9) MUL 1.5)) PA(_mk_bond,72+(c-9)) PA(_mk_bond,72+(c-9)) - elseif b==6:: PA(_mk_bond,60-(c-8)) for i==1 upto 3:: PA(_mk_bond,60+((c-8) DIV 2)) endfor - elseif b==7:: PA(_mk_bond,360 DIV 7-(c-8)) - for i==1 upto 4:: PA(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) endfor - elseif b==8:: PA(_mk_bond,45-(c-8)) for i==1 upto 5:: PA(_mk_bond,45+((c-8) DIV 3)) endfor - fi - PA(_pop,0) if a>=1:: PA(_cyc_eB,0) else:: PA(_cyc_eB,list) fi + CP(_jp_bond,a) CP(_rot_ang,180) CP(_com,5) CP(_chg_len,c DIV 10) + if b==5:: CP(_mk_bond,72-((c-9) MUL 1.5)) CP(_mk_bond,72+(c-9)) CP(_mk_bond,72+(c-9)) + elseif b==6:: CP(_mk_bond,60-(c-8)) for i==1 upto 3:: CP(_mk_bond,60+((c-8) DIV 2)) endfor + elseif b==7:: CP(_mk_bond,360 DIV 7-(c-8)) + for i==1 upto 4:: CP(_mk_bond,360 DIV 7+((c-8) DIV 2.5)) endfor + elseif b==8:: CP(_mk_bond,45-(c-8)) for i==1 upto 5:: CP(_mk_bond,45+((c-8) DIV 3)) endfor fi + CP(_com,6) if a<=0:: CP(_cyc_eB,a-b+2) else:: CP(_cyc_eB,a) fi enddef; %================================================================================================== vardef change_bond(expr a,b) = - sub_int:=sub_int+1; - cntD[sub_int]:=0; - if known b:: if numeric b:: - if (b>=si)and(b<=bd_):: if b==dl:: PP(a,_dl) else:: PX(a)(_set_line,b) fi + if known b:: + sub_int:=sub_int+1; cntD[sub_int]:=0; + if numeric b:: + if (b>=si)and(b<=bd_):: CPe(a)(_set_line,b) elseif (b>=?3)and(b<=?20):: if a>=sub_int_start:: for i==1 upto cntD[a]:: fuse_ring(parD[a][i],b-?3+3) endfor else:: fuse_ring(a,b-?3+3) fi - elseif b==Ph1:: fuse_ring(a,6) PA(_dl,-2) PA(_dl,-4) - elseif b==Ph2:: fuse_ring(a,6) PA(_dl,-1) PA(_dl,-3) PA(_dl,-5) - elseif b==_jump_at:: PA(_jp_bond,a) - elseif b==_connect_at:: PA(_cyc_sB,a) + elseif b==Ph1:: fuse_ring(a,6) CP(_dl,-2) CP(_dl,-4) + elseif b==Ph2:: fuse_ring(a,6) CP(_dl,-1) CP(_dl,-3) CP(_dl,-5) + elseif b==_jump_at:: CP(_jp_bond,a) + elseif b==_connect_at:: CP(_cyc_sB,a) elseif comD[b][1]==_fuse:: if comD[b][2]<=6:: fuse_ring_bonds(a,parD[b][1],comD[b][2]) elseif (comD[b][2]>=11)and(comD[b][2]<=15):: fuse_ring_rate(a,parD[b][1],comD[b][2]) fi fi - elseif color b:: color_list[incr cntC]:=b; PX(a)(_set_colorB,cntC) - fi fi + elseif color b:: color_list[incr cntC]:=b; CPe(a)(_set_colorB,cntC) + fi sub_int %------- Retern value ------- + fi enddef; %------------------------------------------------------------------------------------------------- vardef change_atom(expr a,b)= - sub_int:=sub_int+1; - cntD[sub_int]:=0; - if known b:: if numeric b:: - if (b>=H)and(b<=U):: if b==N:: PP(a,_N) elseif b==O:: PP(a,_O) elseif b==S:: PP(a,_S) - else:: PX(a)(_chg_atom,b) - fi - ef b==NH:: PA(_set_clr,1) PP(a,_N) PX(a)(_substH,H) PA(_set_clr,0) - ef b==_jump_at:: PA(_jp_atom,a) - ef b==_connect_at:: PA(_cyc,a) + if known b:: + sub_int:=sub_int+1; cntD[sub_int]:=0; + if numeric b:: + if (b>=H)and(b<=U):: CPe(a)(_chg_atom,b) + ef b==NH:: CPe(a)(_chg_atom,N) CP(_set_clr,1) CPx(a)(_substH,H) CP(_set_clr,0) + ef b==_jump_at:: CP(_jp_atom,a) + ef b==_connect_at:: CP(_cyc,a) fi ef pair b:: - if xpart(b)==_set_and:: - PA(_set_and,ypart(b)) PA(_chg_charge,a) - else:: - PA(_set_clr,1) PX(a)(xpart(b),ypart(b)) PA(_set_clr,0) + if xpart(b)==_set_and:: CP(_set_and,ypart(b)) CP(_chg_charge,a) + else:: CP(_set_clr,1) CPx(a)(xpart(b),ypart(b)) CP(_set_clr,0) fi - ef color b:: color_list[incr cntC]:=b; PX(a)(_set_colorA,cntC) - fi fi + ef color b:: color_list[incr cntC]:=b; CPe(a)(_set_colorA,cntC) + fi sub_int %------- Retern value ------- + fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def puts(expr POS)(expr STR)= begingroup - save pA,sA,bA,nB,nC; + save pA,sA,bA; pair pA; string sA; picture bA; @@ -546,7 +529,7 @@ def add_mole(text TXT)= begingroup save w,h,n,l,p,am,aw,A,B,plus,minus,lonepair,**,<<,/*; numeric A[]dir,B[]up,A[]ang,B[]ang; - pair p[],A[],B[],B[]s,B[]e,B[]m,A[]up,A[]left,A[]right,A[]down, + pair p[],A[],B[]s,B[]e,B[]m,A[]up,A[]left,A[]right,A[]down, B[]up,B[]left,B[]right,B[]down; path B[]; ext_setup; @@ -733,29 +716,25 @@ enddef; arrow_head:=(0,0)--(ahlength,-(sind 0.5ahangle)*ahlength)-- (ahlength, (sind 0.5ahangle)*ahlength)--cycle; %------------------------------------------------------------------------------------------------- -def ahead_angle(expr p) = - angle direction .5ahlength/length(point 1 of p - point 0 of p) of p +def ahead_angle(expr p)= + angle direction .5ahlength/length(point 1 of p - point 0 of p) of p enddef; %================================================================================================= -def sub_add(expr a,b)= - cntD[sub_int]:=cntD[sub_int]+1; comD[sub_int][cntD[sub_int]]:=a; parD[sub_int][cntD[sub_int]]:=b; +def com_par(expr a,b)= + cntD[sub_int]:=cntD[sub_int]+1; comD[sub_int][cntD[sub_int]]:=a; parD[sub_int][cntD[sub_int]]:=b; enddef; %------------------------------------------------------------------------------------------------- -def sub_add_op(expr a,b)= +def com_par_op(expr a,b)= op_cnt[cntS]:=op_cnt[cntS]+1; op_com[cntS][op_cnt[cntS]]:=a; op_par[cntS][op_cnt[cntS]]:=b; enddef; %------------------------------------------------------------------------------------------------- -def sub_pro(expr a,b)= - if a>=sub_int_start:: for i==1 upto cntD[a]:: sub_add(b,parD[a][i]) endfor else:: sub_add(b,a) fi -enddef; -%------------------------------------------------------------------------------------------------- -def sub_ext(expr c)(expr a,b)= +def com_par_ext(expr f)(expr c)(expr a,b)= if c>=sub_int_start:: for i==1 upto cntD[c]:: - if comD[c][i]==_numeric:: sub_add(_set_adr,parD[c][i]) sub_add(a,b) - else:: sub_add(comD[c][i],parD[c][i]) fi + if comD[c][i]==_numeric:: com_par(_set_adr,parD[c][i]) com_par(a,b) + ef f==1:: com_par(comD[c][i],parD[c][i]) fi endfor - else:: sub_add(_set_adr,c) sub_add(a,b) + else:: com_par(_set_adr,c) com_par(a,b) fi enddef; %================================================================================================= @@ -768,18 +747,17 @@ enddef; %------------------------------------------------------------------------------------------------- def MC(text TXT)= begingroup - save com,par,adrA,adrB,f_bra,envT,envB,lenT,lineT,strAT,stkA,stkB,stkL,stkM,cntS,bondL,temp_len, - temp_cntB,f_end,f_term,rotT,adrS,f_at,f_lineT,f_rotT,f_lenT,f_envT,angT,tempB,tempA, + save markA,markB,f_bra,envT,envB,lenT,lineT,strAT,cntS,bondL,temp_lenE,temp_lenF, + temp_cntB,f_end,f_term,rotT,adrS,f_at,f_lineT,f_rotT,f_lenT,f_envT,angT, maxX,maxY,f_char,ps_adr,ps_com,sA,sC,sD,pA,pB,factor,m_wd,m_ht, - op_com,op_par,op_cnt,crR,colorA,colorB,PA,PO,PP,PX,defaultsize,defaultscale; + op_com,op_par,op_cnt,crR,colorA,colorB,CP,CPo,CPe,CPx,defaultsize,defaultscale; %----------------------------------------------------------------------------------------------- - def PA= sub_add enddef; - def PO= sub_add_op enddef; - def PP= sub_pro enddef; - def PX= sub_ext enddef; + def CP= com_par enddef; + def CPo= com_par_op enddef; + def CPe= com_par_ext(0) enddef; + def CPx= com_par_ext(1) enddef; %----------------------------------------------------------------------------------------------- - numeric stkB[],stkA[],stkL[],stkM[],f_char[],ps_adr[],ps_com[],colorA[],colorB[], - op_com[][],op_par[][],op_cnt[]; + numeric f_char[],ps_adr[],ps_com[],colorA[],colorB[],op_com[][],op_par[][],op_cnt[]; string sA,sC,sD; pair pA,pB; %----------------------------------------------------------------------------------------------- @@ -794,7 +772,7 @@ def MC(text TXT)= margin_lr:=xpart(fmargin); margin_tb:=ypart(fmargin); %=============================================================================================== - read_command(0)(TXT,(_term,0)); + read_command(0)(TXT,|||); %----------------------------------------------------------------------------------------------- proc_bond_atom(1); %----------------------------------------------------------------------------------------------- @@ -905,31 +883,28 @@ def MC(text TXT)= enddef; %------------------------------------------------------------------------------------------------- def subst_put= - begingroup - save nA; - if f_at=1: nA:=getA(adrT); check_adrA(nA); else: nA:=cntA+1; fi - cntS:=cntS+1; ps_adr[cntS]:=nA; ps_com[cntS]:=par; op_cnt[cntS]:=0; - if lineT<>0: PO(_tmp_line,lineT) fi - if rotT<>0: PO(_rot_ang,rotT) fi - if lenT<>crR: PO(_chg_len,lenT) fi - if envT<>hz: PO(_chg_env,envT) fi - if lineT=nl: PO(_chg_len,_size_a) PO(_adj_ang,0) fi - if lineT<>0: PO(_mk_bond,0) fi + if f_at=1: nE:=getA(adrT); check_adrA(nE); else: nE:=cntA+1; fi + cntS:=cntS+1; ps_adr[cntS]:=nE; ps_com[cntS]:=par; op_cnt[cntS]:=0; + if lineT<>0: CPo(_tmp_line,lineT) fi + if rotT<>0: CPo(_rot_ang,rotT) fi + if lenT<>crR: CPo(_chg_len,lenT) fi + if envT<>hz: CPo(_chg_env,envT) fi + if lineT=nl: CPo(_chg_len,_size_atom) CPo(_adj_ang,0) fi + if lineT<>0: CPo(_mk_bond,0) fi if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=crR; fi if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi - endgroup enddef; %------------------------------------------------------------------------------------------------- def subst_get(expr n)= sub_int:=0; nA:=cntS; nB:=cntD[0]; for i=n upto cntS: - PA(_jp_atom_abs,ps_adr[i]) PA(_push,1) - for j=1 upto op_cnt[i]: PA(op_com[i][j],op_par[i][j]) endfor - for j=1 upto cntD[ps_com[i]]: PA(comD[ps_com[i]][j],parD[ps_com[i]][j]) endfor - PA(_pop,1) PA(_term,0) + CP(_jp_A_abs,ps_adr[i]) CP(_com,5) + for j=1 upto op_cnt[i]: CP(op_com[i][j],op_par[i][j]) endfor + for j=1 upto cntD[ps_com[i]]: CP(comD[ps_com[i]][j],parD[ps_com[i]][j]) endfor + CP(_com,6) CP(_com,3) endfor proc_bond_atom(nB+1); if cntS>nA: subst_get(nA+1); fi enddef; @@ -939,10 +914,8 @@ def draw_frame(expr PS,LX,LY,PN)= enddef; %------------------------------------------------------------------------------------------------- def proc_size_setup= - if (blen*ratio_atom_bond+offset_atom)<.8blen: - atom_wd:=blen*ratio_atom_bond+offset_atom; - else: - atom_wd:=.8blen; ratio_chain_ring:= .5; + if (blen*ratio_atom_bond+offset_atom)<.8blen: atom_wd:=blen*ratio_atom_bond+offset_atom; + else: atom_wd:=.8blen; ratio_chain_ring:= .5; fi wedge_wd:= blen*ratio_wedge_bond+offset_wedge; zebra_gap:= blen*ratio_zebragap_bond+offset_zebra_gap; @@ -995,73 +968,60 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def proc_bond_atom(expr n)= f_bra:=f_end:=f_term:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=envB:=strAT:=f_at:=0; - stkL[0]:=bondL:=crR; lenT:=crR; sB[0]:=0; eB[0]:=1; lineT:=si; andAT:=0; - for i=0 upto 5: stkA[i]:=stkB[i]:=0; endfor + bondL:=crR; lenT:=crR; sB[0]:=0; eB[0]:=1; lineT:=si; + andAT:=markA:=markB:=0; %----------------------------------------------------------------------------------------------- for i=n upto cntD[0]: - nC:=comD[0][i]; par:=parD[0][i]; - if nC=_push: - if par=1: stkL[adrS]:=bondL; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB; - elseif par=0: temp_len:=bondL; - elseif par=2: stkA[adrS+1]:=cntA; stkB[adrS+1]:=cntB; - fi - ef nC=_pop: if par=1: adrS:=adrS-1; adrA:=stkA[adrS]; adrB:=stkB[adrS]; bondL:=stkL[adrS]; - ef par=0: bondL:=temp_len; - ef par=2: stkA[adrS+1]:=0; - fi - ef nC=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom; - ef nC=_set_adr: adrT:=par; - ef nC=_set_atom: strAT:=par; - ef nC=_substA: subst_put; - ef nC=_substB: lineT:=dm; subst_put; - ef nC=_substC: lineT:=wf; subst_put; - ef nC=_substD: lineT:=zf; subst_put; - ef nC=_substE: lineT:=nl; subst_put; - ef nC=_substF: lineT:=0; subst_put; - ef nC=_substG: lineT:=wv; subst_put; - ef nC=_substH: lineT:=nl; lenT:=_size_a; subst_put; - ef nC=_jp_bond: termA; tempB:=getB(par); check_adrB(tempB); sB[cntB+1]:=sB[tempB]; f_bra:=1; - ef nC=_jp_atom: termA; tempA:=getA(par); check_adrA(tempA); sB[cntB+1]:=tempA; f_bra:=1; - ef nC=_jp_atom_abs: sB[cntB+1]:=par; f_bra:=1; temp_cntB:=cntB; - ef nC=_chg_atom: numS[getA(adrT)]:=parD[par][1]; - ef nC=_N: numS[getA(par)]:=parD[N][1]; - ef nC=_O: numS[getA(par)]:=parD[O][1]; - ef nC=_S: numS[getA(par)]:=parD[S][1]; - ef nC=_chg_len: if par=_ring_len: bondL:=ringL; - ef par=0: if lenT<>crR: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi - else: bondL:=par; fi - ef nC=_get_len: if par=0: if bondL=crR: bondL:=lenT; fi else: ringL:=lenB[getB(par)]; fi - ef nC=_tmp_len: lenT:=par; - ef nC=_set_line: lineB[getB(adrT)]:=par; - ef nC=_dl: lineB[getB(par)]:=dl; - ef nC=_mb: lineB[getB(-1)]:=par; - ef (nC=_chg_line)or(nC=_tmp_line): lineT:=par; - ef nC=_tmp_rot: rotT:=par; - ef nC=_cyc: f_end:=getA(par); check_adrA(f_end); add_atom; - ef nC=_cyc_eB: f_end:=eB[getB(par)]; add_atom; - ef nC=_cyc_sB: f_end:=sB[getB(par)]; add_atom; - ef nC=_chg_env: envB:=par; - ef nC=_tmp_env: envT:=par; - ef nC=_set_clr: + com:=comD[0][i]; par:=parD[0][i]; + if com=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom; + ef com=_set_adr: adrT:=par; + ef com=_com: if par=1: markA:=cntA; markB:=cntB; elseif par=2: markA:=markB:=0; + elseif par=3: termA; + elseif par=5: temp_lenE:=bondL; elseif par=6: bondL:=temp_lenE; + elseif par=7: temp_lenF:=bondL; elseif par=8: bondL:=temp_lenF; fi + ef com=_set_clr: f_at:=par; - if par=1: if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi + if par=1: if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi if lenT<>crR: f_lenT:=1; fi if envT<>hz: f_envT:=1; fi - ef par=0: f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0; lineT:=si; lenT:=crR; - fi - ef nC=_term: termA; - ef nC=_set_colorA: colorA[getA(adrT)]:=par; - ef nC=_set_colorB: colorB[getB(adrT)]:=par; - ef nC=_set_and: andAT:=par; - ef nC=_chg_charge: andA[getA(par)]:=andAT; andAT:=0; if rotT<>0: and_rot[getA(par)]:=rotT; fi + ef par=0: f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0; lineT:=si; lenT:=crR; fi + ef com=_set_atom: strAT:=par; + ef com=_substA: subst_put; + ef com=_substB: lineT:=dm; subst_put; + ef com=_substC: lineT:=wf; subst_put; + ef com=_substD: lineT:=zf; subst_put; + ef com=_substE: lineT:=nl; subst_put; + ef com=_substF: lineT:=0; subst_put; + ef com=_substG: lineT:=wv; subst_put; + ef com=_substH: lineT:=nl; lenT:=_size_atom; subst_put; + ef com=_jp_bond: termA; nA:=getB(par); check_adrB(nA); sB[cntB+1]:=sB[nA]; f_bra:=1; + ef com=_jp_atom: termA; nA:=getA(par); check_adrA(nA); sB[cntB+1]:=nA; f_bra:=1; + ef com=_jp_A_abs: sB[cntB+1]:=par; f_bra:=1; temp_cntB:=cntB; + ef com=_chg_atom: numS[getA(adrT)]:=parD[par][1]; + ef com=_chg_len: if par=_ring_len: bondL:=ringL; else: bondL:=par; fi + ef com=_get_len: if par=_tmp_len: if bondL=crR: bondL:=lenT; fi + ef par=_ring_len: if lenT<>crR: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi + else: ringL:=lenB[getB(par)]; fi + ef com=_tmp_len: lenT:=par; + ef com=_set_line: lineB[getB(adrT)]:=par; + ef com=_dl: lineB[getB(par)]:=dl; + ef com=_tmp_line: lineT:=par; + ef com=_tmp_rot: rotT:=par; + ef com=_cyc: f_end:=getA(par); check_adrA(f_end); add_atom; + ef com=_cyc_eB: f_end:=eB[getB(par)]; add_atom; + ef com=_cyc_sB: f_end:=sB[getB(par)]; add_atom; + ef com=_chg_env: envB:=par; + ef com=_tmp_env: envT:=par; + ef com=_set_colorA: colorA[getA(adrT)]:=par; + ef com=_set_colorB: colorB[getB(adrT)]:=par; + ef com=_set_and: andAT:=par; + ef com=_chg_charge: andA[getA(par)]:=andAT; andAT:=0; if rotT<>0: and_rot[getA(par)]:=rotT; fi else: fi endfor enddef; %------------------------------------------------------------------------------------------------- def add_atom= - cntB:=cntB+1; - lineB[cntB]:=lineT; - lineT:=si; + cntB:=cntB+1; lineB[cntB]:=lineT; lineT:=si; if lenT=crR: lenB[cntB]:=bondL; else: lenB[cntB]:=lenT; lenT:=crR; fi if f_bra=0: cntA:=cntA+1; sB[cntB]:=cntA; numS[cntA]:=strAT; andA[cntA]:=andAT; andAT:=strAT:=and_rot[cntA]:=0; @@ -1071,48 +1031,38 @@ def add_atom= enddef; %-------------------------------------------------------------------------------------------------- def check_adrA(expr n)= - if (n>iif(f_term=0,cntA+1,cntA))or(n<=0): errmessage("adrA=[ "&decimal(n)&" ]"); fi enddef; -def check_adrB(expr n)= if (n>cntB)or(n<=0): errmessage("adrB=[ "&decimal(n)&" ]"); fi enddef; + if (n>iif(f_term=0,cntA+1,cntA))or(n<=0): errmessage("cntA=[ "&decimal(n)&" ]"); fi +enddef; +def check_adrB(expr n)= if (n>cntB)or(n<=0): errmessage("cntB=[ "&decimal(n)&" ]"); fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def proc_skeleton= begingroup - save posBs,posBe,nC; + save posBs,posBe; pair posBs,posBe; - adrA:=adrB:=cntA:=cntB:=adrS:=f_end:=f_bra:=rotT:=f_term:=f_at:=0; - envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=stkM[0]:=0; lineT:=si; angT:=mangle; + markA:=markB:=cntA:=cntB:=adrS:=f_end:=f_bra:=rotT:=f_term:=f_at:=0; + envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0; lineT:=si; angT:=mangle; angA[0]:=angB[0]:=angX[0]:=0; posA[0]:=posBs:=posBe:=(0,0); - for i=0 upto 5: stkA[i]:=stkB[i]:=0; endfor %----------------------------------------------------------------------------------------------- for i=1 upto cntD[0]: - nC:=comD[0][i]; par:=parD[0][i]; - if nC=_push: if par=1: stkM[adrS]:=envB; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; - stkB[adrS]:=adrB:=cntB; - ef par=0: temp_len:=bondL; - ef par=2: stkA[adrS+1]:=cntA; stkB[adrS+1]:=cntB; - fi - ef nC=_pop: if par=1: adrS:=adrS-1; adrA:=stkA[adrS]; adrB:=stkB[adrS]; envB:=stkM[adrS]; - ef par=0: temp_len:=bondL; - ef par=2: stkA[adrS+1]:=0; - fi - ef nC=_jp_bond: termB; tempB:=getB(par); posBs:=posA[sB[tempB]]; - angT:=angB[tempB]; f_bra:=1; rotT:=0; - ef nC=_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; - angT:=angX[adrT]; f_bra:=1; rotT:=0; - ef nC=_jp_atom_abs: adrT:=par; posBs:=posA[adrT]; + com:=comD[0][i]; par:=parD[0][i]; + if com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par); + ef com=_com: if par=1: markA:=cntA; markB:=cntB; elseif par=2: markA:=markB:=0; + elseif par=3: termB; fi + ef com=_jp_bond: termB; nA:=getB(par); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0; + ef com=_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0; + ef com=_jp_A_abs: adrT:=par; posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB; - ef nC=_adj_ang: if (angT<40)or(angT>320): angT:=0; + ef com=_adj_ang: if (angT<40)or(angT>320): angT:=0; ef angT<140: angT:=90; ef angT<220: angT:=180; else: angT:=270; fi - ef nC=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par); - ef nC=_rot_ang: angT:=(angT+par) mod 360; - ef nC=_tmp_rot: rotT:=par; - ef (nC>=_substA)and(nC<=_substH): rotT:=0; - ef nC=_chg_env: envB:=par; - ef nC=_tmp_env: envT:=par; - ef nC=_set_clr: f_at:=par; if par=0: lineT:=si; lenT:=crR; rotT:=envT:=0; fi - ef nC=_cyc: f_end:=1; proc_cyc(getA(par)); - ef nC=_cyc_sB: f_end:=1; proc_cyc(sB[getB(par)]); - ef nC=_cyc_eB: f_end:=1; proc_cyc(eB[getB(par)]); - ef nC=_term: termB; + ef com=_rot_ang: angT:=(angT+par) mod 360; + ef com=_tmp_rot: rotT:=par; + ef (com>=_substA)and(com<=_substH): rotT:=0; + ef com=_chg_env: envB:=par; + ef com=_tmp_env: envT:=par; + ef com=_set_clr: f_at:=par; if par=0: lineT:=si; lenT:=crR; rotT:=envT:=0; fi + ef com=_cyc: f_end:=1; proc_cyc(getA(par)); + ef com=_cyc_sB: f_end:=1; proc_cyc(sB[getB(par)]); + ef com=_cyc_eB: f_end:=1; proc_cyc(eB[getB(par)]); else: fi endfor @@ -1120,8 +1070,6 @@ def proc_skeleton= enddef; %------------------------------------------------------------------------------------------------- def add_bond(expr ROT)= - begingroup - save nA,nB; if ROT=_arg_ang: nA:=proc_env(angT,envB); else: nA:=ROT; fi if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posBs; angA[cntA]:=angT; @@ -1130,7 +1078,7 @@ def add_bond(expr ROT)= fi angB[cntB+1]:=angT:=(angT+nA) mod 360; if f_end=0: - if lenB[cntB+1]=_size_a: posBe:=sfB(posBs,atom_wd,angT); + if lenB[cntB+1]=_size_atom: posBe:=sfB(posBs,atom_wd,angT); else: nA:=lenB[cntB+1]; if nA<0: nB:=glu_atom(adrT)+glu_atom(cntA+1); nA:=abs(nA); @@ -1143,16 +1091,10 @@ def add_bond(expr ROT)= f_end:=0; f_term:=1; fi cntB:=cntB+1; posBs:=posBe; - endgroup enddef; %================================================================================================== -vardef getA(expr ADR)= - if ADR>=0: stkA[adrS+1]+ADR ef ADR>=-999: cntA+ADR+1 else: stkA[adrS]+ADR+4095 fi -enddef; -%-------------------------------------------------------------------------------------------------- -vardef getB(expr ADR)= - if ADR>=1: stkB[adrS+1]+ADR ef ADR=0: tempB ef ADR>=-999: cntB+ADR+1 else: stkB[adrS]+ADR+4095 fi -enddef; +vardef getA(expr n)= if n>=0: markA+n ef n>=-999: cntA+n+1 else: n+4095 fi enddef; +vardef getB(expr n)= if n>=0: markB+n ef n>=-999: cntB+n+1 else: n+4095 fi enddef; %-------------------------------------------------------------------------------------------------- def termA= if f_term=0: @@ -1173,26 +1115,24 @@ def termB= fi enddef; %-------------------------------------------------------------------------------------------------- -def proc_cyc(expr ADR)= add_bond(angle(posA[ADR]-posBs)-angT); enddef; +def proc_cyc(expr n)= add_bond(angle(posA[n]-posBs)-angT); enddef; %-------------------------------------------------------------------------------------------------- vardef glu_atom(expr NUM)= - save nB,nC; if numS[NUM]<>0: - nB:=angT mod 90; nC:=0.5atom_wd; - (iif(nB<45,sind(nB),cosd(nB))*nC)++nC - else: 0 + nE:=angT mod 90; nF:=0.5atom_wd; (iif(nE<45,sind(nE),cosd(nE))*nF)++nF + else: 0 fi enddef; %-------------------------------------------------------------------------------------------------- vardef proc_env(expr ANG,ENV)= - save nA,nCW,nCC; + save nANG,nCW,nCC; nCC:=60; nCW:=-nCC; - nA:=(ANG mod 360); + nANG:=(ANG mod 360); if ENV>=sub_emb_start: parD[ENV][cntB-temp_cntB] else: - if ENV=hz: if nA=0:nCC ef nA<=90:nCW ef nA<=180:nCC ef nA<270:nCW else:nCC fi - ef ENV=vt: if nA=0:nCW ef nA<90:nCC ef nA<=180:nCW ef nA<=270:nCC else:nCW fi + if ENV=hz: if nANG=0:nCC ef nANG<=90:nCW ef nANG<=180:nCC ef nANG<270:nCW else:nCC fi + ef ENV=vt: if nANG=0:nCW ef nANG<90:nCC ef nANG<=180:nCW ef nANG<=270:nCC else:nCW fi ef (ENV>=-180)and(ENV<=180): ENV fi fi @@ -1200,7 +1140,7 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_atom(expr NUM)= begingroup - save slen,f_wd,f_ht,r_ff,pA,pB,bA,sA,sB,dx,nA,nB,nC,nD; + save slen,f_wd,f_ht,r_ff,pA,pB,bA,sA,sB,dx; string sA,sB; pair pA,pB; picture bA; @@ -1248,7 +1188,7 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_bond(expr NUM)= begingroup - save ww,ap,am,ang,col,len,Ls,Le,nA,nB,nC,nD,nL,nS,nE,pA,zA,zL,wpcs; + save ww,ap,am,ang,col,len,Ls,Le,nL,nS,nE,pA,zA,zL,wpcs; pair pA,Ls,Le; path zA,zL; def wpcs expr n= withpen pencircle scaled n enddef; @@ -1320,16 +1260,15 @@ vardef frame_str(expr NUM)= (posA[NUM]-(.5nA+iif((dxA[NUM]=-1)and(wdA[NUM]>atom_wd),nB-nA,0),.5nA)) enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def ring expr n= <((-180 DIV n)-90),(_chg_len,0), - for i==2 upto n:: ,(360 DIV n) endfor,(_cyc_sB,1-n) enddef; -%------------------------------------------------------------------------------------------------- sub_usr:=sub_emb_start; %------------------------------------------------------------------------------------------------- lr:='(60 for i==1 upto 10:: ,-60,60 endfor); rl:='(-60,lr); -for i=3 upto 20: ?[i]:='(|:,ring i,:|); endfor +for i=3 upto 20: ?[i]:='(|:,(_get_len,_ring_len),<((-180 DIV i)-90) + for j==2 upto i:: ,(360 DIV i) endfor,(_cyc_sB,1-i),:|); endfor Ph:=Ph1:='(?6,(_dl,-2),(_dl,-4),(_dl,-6)); Ph2:='(?6,(_dl,-1),(_dl,-3),(_dl,-5)); -!:=!1:='((_mk_bond,_arg_ang)); !!:='(!,(_mb,db)); !!!:='(!,(_mb,tm)); !0:='(<180,180); -for i=2 upto 20: ![i]:='(|:,(_get_len,0),! for j==2 upto i::,! endfor,:|); endfor +!:=!1:='((_mk_bond,_arg_ang)); !!:='(!,(_set_adr,-1),(_set_line,db)); +!!!:='(!,,(_set_adr,-1),(_set_line,tm)); !0:='(<180,180); +for i=2 upto 20: ![i]:='(|:,(_get_len,_tmp_len),! for j==2 upto i::,! endfor ,:|); endfor Me:='(); Et:='(!); Pr:=!x2:='(!,!); Bu:=!x3:='(!,!,!); for i=4,5,6: for j=2 upto i-2: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor @@ -1373,9 +1312,7 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def char_size_set(expr WD)(expr HT)(expr STR)= for j=0 upto length(STR)-1: - nA:=ASCII(pic_c(j,STR)); - tbl_char_wd[nA]:=WD; - tbl_char_ht[nA]:=HT; + nA:=ASCII(pic_c(j,STR)); tbl_char_wd[nA]:=WD; tbl_char_ht[nA]:=HT; endfor enddef; %------------------------------------------------------------------------------------------------- @@ -1707,7 +1644,7 @@ def proc_report_out= printf "------------------------------------------------------------------"; printf "< NO. >< bond (sdt)><angle + ( +- )><length ( pt )>"; for i=1 upto cntB: - nC:=lenB[i]; if nC=_size_a: nC:=ratio_atom_bond; elseif nC<0: nC:=-nC; fi + nC:=lenB[i]; if nC=_size_atom: nC:=ratio_atom_bond; elseif nC<0: nC:=-nC; fi if lineB[i]<>0: nB:=angB[i]; if nB>180: nB:=nB-360; fi printf " B"&fdl(4)(i)&fdr(3)(sB[i])&" -> "&fdr(3)(eB[i])& @@ -1750,9 +1687,7 @@ def proc_mol_out= out_file_name:=out_file_mol; if sw_mol_out<=2: out_file_name:=out_file_mol; - if sw_mol_out=1: proc_vdk; - elseif sw_mol_out=2: proc_vtk; - fi + if sw_mol_out=1: proc_vdk; elseif sw_mol_out=2: proc_vtk; fi fi endgroup enddef; |