knot_str.sa


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

class KNOT_STR

class KNOT_STR is Knot2String(Knot:KNOT, out KStr:STR):BOOL is i,j:CARD; code:VERTEXC; str,str2:STR; b,endSw:BOOL; if Knot.length.is_zero then return false; end; KStr:=""; i:=0; j:=1;endSw:=false; loop -- #OUT+"Knot2String:"+i+"\n"; code:=Knot[i].sep; if VERTEXC::normal=code then KStr:=KStr+Knot[i].x.inti.decimal_str+" "+Knot[i].y.inti.decimal_str+", "; elsif VERTEXC::crossing.in(code) then KStr:=KStr+Knot[i].x.inti.decimal_str+" "+Knot[i].y.inti.decimal_str; if VERTEXC::over.in(code) then KStr:=KStr+" o, "; else KStr:=KStr+" u, "; end; elsif VERTEXC::graph_s=code then KStr := KStr+"gs, "; elsif VERTEXC::graph_e=code then KStr := KStr+"ge, "; endSw:=true; elsif VERTEXC::knot_s=code then KStr := KStr+"ks, "; elsif VERTEXC::knot_e=code then KStr := KStr+"ke, "; endSw:=true; elsif VERTEXC::band.in(code) then KStr:=KStr+Knot[i].x.inti.decimal_str+" "+Knot[i].y.inti.decimal_str+" b, "; elsif VERTEXC::ts.in(code) then KStr:=KStr+"ts, "; elsif VERTEXC::te.in(code) then KStr:=KStr+"te, "; endSw:=true; elsif VERTEXC::code_e=code then KStr:=KStr+"endcode"; break!; end; if endSw or (j>=5) then KStr:=KStr+"\n"; j:=1;endSw:=false; else j:=j+1; end; i:=i+1; end; return true; end; String2Knot(KnotStr:STR, out Knot:KNOT):BOOL is sc:STR_CURSOR; -- STR_CURSOR version of KnotStr str:STR; -- part of KnotStr code0:VERTEXC; x,y:INT; i:CARD; reply:BOOL; -- #OUT+"String2Knot:"+"\n"; sc:=KnotStr.cursor; Knot:=#; Knot.NoCompo0; code0:=VERTEXC::graph_e; loop -- read items for Knot[] str:=STRINGSK::splitStr(inout sc); i:=Knot.length; if str="gs" then if ~VERTEXC::ge.in(code0) then Knot.NoCompo0; return false; end; code0:=VERTEXC::graph_s; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="ge" then if VERTEXC::normal/=code0 then Knot.NoCompo0; return false; end; code0:=VERTEXC::graph_e; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="ks" then if ~(VERTEXC::ge.in(code0) or VERTEXC::ke.in(code0)) then Knot.NoCompo0; return false; end; code0:=VERTEXC::knot_s; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="ke" then if VERTEXC::normal/=code0 then Knot.NoCompo0; return false; end; code0:=VERTEXC::knot_e; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="ts" then if ~(VERTEXC::ge.in(code0) or VERTEXC::ke.in(code0) or VERTEXC::te.in(code0)) then Knot.NoCompo0; return false; end; code0:=VERTEXC::band_s; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="te" then if VERTEXC::normal/=code0 then Knot.NoCompo0; return false; end; code0:=VERTEXC::band_e; Knot.CodeIn(0.int,0.int,i); Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="endcode" then if ~(VERTEXC::ge.in(code0) or VERTEXC::ke.in(code0) or VERTEXC::te.in(code0)) then return false; end; return true; else -- normal/crossing/band if ~((str[0].is_digit) or (str[0]='-')) then Knot.NoCompo0; return false; end; x:=#INT(str); str:=STRINGSK::splitStr(inout sc); if ~(str[0].is_digit or (str[0]='-')) then Knot.NoCompo0; return false; end; y:=#INT(str); Knot.CodeIn(x,y,i); str:=STRINGSK::splitStr(inout sc); if str="," then if ~(VERTEXC::normal.in(code0) or VERTEXC::crossing.in(code0) or VERTEXC::ks.in(code0) or VERTEXC::ts.in(code0) or VERTEXC::gs.in(code0) ) then Knot.NoCompo0; return false; end; code0:=Knot[i].sep; -- normal elsif str="b" then -- band if ~(VERTEXC::normal.in(code0) or VERTEXC::crossing.in(code0)) then return false; end; code0:=VERTEXC::band_attach; Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="o" then -- crossing over if ~(VERTEXC::normal.in(code0) or VERTEXC::crossing.in(code0)) then return false; end; code0:=VERTEXC::cross_over; Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); elsif str="u" then -- crossing under if ~(VERTEXC::normal.in(code0) or VERTEXC::crossing.in(code0)) then return false; end; code0:=VERTEXC::cross_under; Knot[i].sep:=code0; str:=STRINGSK::splitStr(inout sc); else Knot.NoCompo0; return false; end; end; if str/="," then Knot.NoCompo0; return false; end; end; -- loop #ERR+" Cnaaot reach here. "+"(ReadKnotSKnot)"; Knot.NoCompo0; return false; end; end; -- class KNOT_STR