alternate.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-- Copyright (C) 1996 Kouji KODAMA
--
-- 1996/12/15 K.Kodama
-- "Alternate" set crossings as alternate diagram.
class ALTERNATE
class ALTERNATE is
shared tStart:CARD;
shared up,dn:VERTEXC;
const nc:=0;
const setc:=1;
const set:=2;
mark(inout Knot:KNOT, pt:CARD, inout Up:BOOL) is
pt1:INT;
if VERTEXC::crossing.in(Knot[pt].sep) then
pt1:=Knot.cmpOf(pt.int);
if (pt1.is_pos)and(pt1<tStart.int)then
if (setc=Knot[pt].work)or(set=Knot[pt].work) then
if Up/=(VERTEXC::over.in(Knot[pt].sep)) then
-- May be a component is not closed.
end;
else -- nc
if Up then Knot[pt].sep:=up.clone; Knot[pt1].sep:=dn.clone;
else Knot[pt].sep:=dn.clone; Knot[pt1].sep:=up.clone;
end;
Knot[pt1].work:=setc;
end;
Up:=~ Up;
end;
end;
Knot[pt].work:=set;
end;
AltCompo(inout Knot:KNOT, i0:CARD) is
Up0,Up:BOOL; -- true if over
stp,enp,pt:CARD;
-- Alternate the component
loop
while!( VERTEXC::crossing.in(Knot[i0].sep).not
and
VERTEXC::ke.in(Knot[i0].sep).not );
i0:=i0+1;
end;
Up0:=(Knot[i0].work=nc)or(VERTEXC::over.in(Knot[i0].sep));
stp:=Knot.endOfString(i0.int,-1).card;
enp:=Knot.endOfString(i0.int,1.int).card;
Up:=Up0;
loop pt:=i0.upto!(enp); mark(inout Knot,pt,inout Up); end;
Up:=Up0;
loop pt:=i0.stepto!(stp,-1); mark(inout Knot,pt,inout Up); end;
end;
Alternate(inout Knot:KNOT) is
up:=VERTEXC::cross_over;
dn:=VERTEXC::cross_under;
if ~Knot.is_proper then return; end;
if Knot.CrossSet then ; end;
tStart:=Knot.length;
loop i::=Knot.length.downto!(0);
if VERTEXC::ts.in(Knot[i].sep) then tStart:=i; end;
Knot[i].work:=nc;
end;
loop
i::=0;
loop while!((i<tStart)and(nc/=Knot[i].work)); i:=i+1; end;
if i<tStart then
AltCompo(inout Knot, i);
loop
j::=0;
loop j:=j+1;
until!((Knot.length<=j)or(setc=Knot[j].work));
end;
if j<Knot.length then
AltCompo(inout Knot,j);
else break!;
end;
end;
else break!;
end;
end;
loop Knot[Knot.k.ind!].work:=nc; end;
end;
end; -- class ALTERNATE.