-- TSGlueImpl.mesa -- Michael Plass, May 6, 1982 2:58 pm DIRECTORY TSTypes, TSGlue; TSGlueImpl: PROGRAM IMPORTS TSTypes EXPORTS TSGlue = BEGIN OPEN TSTypes, TSGlue; SetGlue: PUBLIC PROC [desired: Dimn, g: Glue] RETURNS [GlueSet] = BEGIN delta: Dimn ← SubDimn[desired, g.space]; fuzz: Dimn = IntDimn[1,mica]; shrinking: BOOLEAN ← delta<0; v: Dimn ← IF shrinking THEN g.shrink ELSE g.stretch; absDelta: Dimn ← AbsDimn[delta]; IF shrinking AND absDelta.texPts > v.texPts + fuzz.texPts THEN RETURN[overfullGlueSet]; v ← MaxDimn[fuzz, v]; RETURN[[DimnRatio[delta,v]]]; END; GlueBadness: PUBLIC PROC [set: GlueSet] RETURNS [Badness] = BEGIN b: Badness ← IF set.value IN (-1..2000] THEN ABS[100*set.value*set.value*set.value] ELSE infBadness; IF b>=infBadness THEN RETURN[infBadness] ELSE RETURN[b]; END; END.