pretzel.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 

class PRETZEL_CNV

class PRETZEL_CNV is Pretzel2Knot(s:STR, inout knot:KNOT):BOOL is j::=s.search("endcode"); if (0<j).not then return false; end; return Pretzel2Knot(#WORD(s.substring(0,j)).w, inout knot); end; Pretzel2Knot(a:ARRAY{INT}, inout knot:KNOT):BOOL is -- Pretzel P(a0,a1,...) knot:=KNOT::NoCompo0; d:INT:=16; d2:INT:=d*2.int; -- width r,l,t_footer:KNOT; r:=KNOT::trivial0.append(KNOT::trivial0); r.CodeIn(0.int,0.int,1); r.CodeIn(d,-d,VERTEXC::cross_under,2); r.CodeIn(d2,-d2,3); r.CodeIn(d2,0.int,6); r.CodeIn(d,-d,VERTEXC::cross_over,7); r.CodeIn(0.int,-d2,8); l:=r.clone; l.mirrorZ; t_footer:=KNOT::trivial0;; t_footer.CodeIn(0.int,0.int,1); t_footer.CodeIn(0.int,0.int,2); max_t:INT:=0; loop max_t:=max_t.max(a.elt!.abs); end; -- twist loop i::=a.ind!.int; t:INT:=a.elt!; c:KNOT; if t.is_pos then c:=r.clone; elsif t.is_neg then c:=l.clone; t:=-t; end; twist::=KNOT::NoCompo0; loop t.times!; twist:=twist.append(c.clone); c.Shift(0.int,-d*2.int); end; if t<max_t then t_footer[1]:=#(0.int,-d2*t); t_footer[2]:=#(0.int,-d2*max_t); twist:=twist.append(t_footer.clone); t_footer[1]:=#(d2,-d2*t); t_footer[2]:=#(d2,-d2*max_t); twist:=twist.append(t_footer.clone); end; twist.Shift(d*4.int*i,0.int); knot:=knot.append(twist); end; -- header/footer t_footer:=KNOT::trivial0;; t_footer.CodeIn(0.int,0.int,1); t_footer.CodeIn(0.int,d,2); t_footer.CodeIn(d2*(a.size.int*2.int-1.int),d,3); t_footer.CodeIn(d2*(a.size.int*2.int-1.int),0.int,4); knot:=knot.append(t_footer); -- t_footer:=KNOT::trivial0;; t_footer.CodeIn(0.int,-max_t*d2,1); t_footer.CodeIn(0.int,-max_t*d2-d,2); t_footer.CodeIn(d*(a.size.int*4.int-2.int),-max_t*d2-d,3); t_footer.CodeIn(d*(a.size.int*4.int-2.int),-max_t*d2,4); knot:=knot.append(t_footer); loop i:INT:=1.upto!(a.size-1).int; t_footer:=KNOT::trivial0; t_footer.CodeIn(d*(i*4.int-2.int),0.int,1); t_footer.CodeIn(d*i*4.int,0.int,2); knot:=knot.append(t_footer); end; loop i:INT:=1.upto!(a.size-1).int; t_footer:=KNOT::trivial0; t_footer.CodeIn(d*(i*4.int-2.int),-d2*max_t,1); t_footer.CodeIn(d*i*4.int,-d2*max_t,2); knot:=knot.append(t_footer); end; knot.concat; knot.edge_clean; knot.shiftToInside; return true; end; end;