GGUtility.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on January 30, 1987 8:34:13 pm PST.
Contents: General Purpose routines for use by Gargoyle.
Pier, February 3, 1987 12:19:27 pm PST
DIRECTORY
GGBasicTypes, GGModelTypes, Interpress, ImagerTransformation, IO, Rope, ViewerClasses;
GGUtility: CEDAR DEFINITIONS = BEGIN
BitVector: TYPE = GGBasicTypes.BitVector;
FeatureData: TYPE = GGModelTypes.FeatureData;
Outline: TYPE = GGModelTypes.Outline;
OutlineDescriptor: TYPE = GGModelTypes.OutlineDescriptor;
Sequence: TYPE = GGModelTypes.Sequence;
Slice: TYPE = GGModelTypes.Slice;
SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor;
Traj: TYPE = GGModelTypes.Traj;
Viewer: TYPE = ViewerClasses.Viewer;
Operations on LIST OF FeatureData
StartFeatureDataList: PROC [] RETURNS [entityList, ptr: LIST OF FeatureData];
AddFeatureData: PROC [entity: FeatureData, entityList, ptr: LIST OF FeatureData] RETURNS [newList, newPtr: LIST OF FeatureData];
Operations on LIST OF Sequence
DeleteSequenceFromList: PROC [seq: Sequence, seqList: LIST OF Sequence] RETURNS [smallerList: LIST OF Sequence];
AppendSequenceList: PROC [list1, list2: LIST OF Sequence] RETURNS [result: LIST OF Sequence];
StartSequenceList: PROC [] RETURNS [entityList, ptr: LIST OF Sequence];
AddSequence: PROC [entity: Sequence, entityList, ptr: LIST OF Sequence] RETURNS [newList, newPtr: LIST OF Sequence];
Operations on LIST OF REF ANY
Two Finger List Constructor
StartList: PROC [] RETURNS [entityList, ptr: LIST OF REF ANY];
AddEntity: PROC [entity: REF ANY, entityList, ptr: LIST OF REF ANY] RETURNS [newList, newPtr: LIST OF REF ANY];
Operations on a Set of REF ANY
SetOfRefAny: TYPE = REF SetOfRefAnyObj;
SetOfRefAnyObj: TYPE = RECORD [
count: NAT,
sorted: BOOLFALSE,
refs: SEQUENCE maxCount: NAT OF REF ANY
];
EmptySet: PROC [] RETURNS [set: SetOfRefAny];
AddToSet: PROC [entity: REF ANY, set: SetOfRefAny];
SizeOfSet: PROC [set: SetOfRefAny] RETURNS [count: NAT];
FetchSetElement: PROC [set: SetOfRefAny, index: NAT] RETURNS [entity: REF ANY];
DeleteFromSet: PROC [index: NAT, set: SetOfRefAny];
SortSet: PROC [set: SetOfRefAny, orderProc: OrderProc];
OrderProc: TYPE = PROC [e1, e2: REF ANY] RETURNS [e1GoesBeforeE2: BOOL];
Operations on Assorted LIST Types
AppendNATs: PROC [list1, list2: LIST OF NAT] RETURNS [result: LIST OF NAT];
StartNATList: PROC [] RETURNS [entityList, ptr: LIST OF NAT];
StartTrajList: PROC [] RETURNS [entityList, ptr: LIST OF Traj];
StartSDList: PROC [] RETURNS [entityList, ptr: LIST OF SliceDescriptor];
StartOutlineList: PROC [] RETURNS [entityList, ptr: LIST OF Outline];
StartSliceList: PROC [] RETURNS [entityList, ptr: LIST OF Slice];
AddNAT: PROC [entity: NAT, entityList, ptr: LIST OF NAT] RETURNS [newList, newPtr: LIST OF NAT];
AddTraj: PROC [entity: Traj, entityList, ptr: LIST OF Traj] RETURNS [newList, newPtr: LIST OF Traj];
AddSD: PROC [entity: SliceDescriptor, entityList, ptr: LIST OF SliceDescriptor] RETURNS [newList, newPtr: LIST OF SliceDescriptor];
AddOutline: PROC [entity: Outline, entityList, ptr: LIST OF Outline] RETURNS [newList, newPtr: LIST OF Outline];
AddSlice: PROC [entity: Slice, entityList, ptr: LIST OF Slice] RETURNS [newList, newPtr: LIST OF Slice];
Modular Arithmetic
BreakIntervalMOD: PROC [start, end, mod: NAT] RETURNS [s1, e1, s2, e2: INT];
Given an interval of a circular buffer whose elements are numbered 0 .. mod -1, we break up the interval into one or two pieces, neither of which crosses the mod-1 to 0 boundary.
Examples: BreakIntervalMOD[6, 2, 7] => [6, 6, 0, 2];
BreakIntervalMOD[2, 6, 7] => [2, 6, -1, -1];
BreakIntervalMODLen: PROC [start, len, mod: NAT] RETURNS [s1, len1, s2, len2: INT];
Lile BreakIntervalMOD except that both the original interval and the results are expressed in the form (start of interval, length of interval) instead of [start..end].
InMODRegion: PROC [test: NAT, start, end, mod: NAT] RETURNS [BOOL];
Non-destructive (copies the first list).
Operations on Bit Vectors
Operations on Bit Vectors
AllFalse: PROC [bitvec: BitVector] RETURNS [BOOL];
AllTrue: PROC [bitvec: BitVector] RETURNS [BOOL];
Operations on REAL
For algorithms that need a variable initialized to an impossibly large number. Unfortunately, Real.PlusInfinity can't be compared with anything. These sizes were chosen so that they can be scaled by 1000 and squared once without causing overflow. (Many geometric algorithms work with distance squared to keep from doing square roots)
plusInfinity: REAL = 1E16;
minusInfinity: REAL = -1E16;
Gargoyle guarantees accuracy to within 0.001 inches, or 0.072 screen dots. Allowing two orders of magnitude leeway gives 10-5 inches or 7.2 * 10-4 screen dots.
epsilonInPoints: REAL = 7.2E-4;
epsilonInInches: REAL = 1.0E-5;
FileNames
GetInterpressFileName: PROC [ipName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: Viewer] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE];
OpenInterpressOrComplain: PROC [feedback: Viewer, fullName: Rope.ROPE] RETURNS [ipMaster: Interpress.Master, success: BOOL];
GetGargoyleFileName: PROC [ggName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: Viewer, emergency: BOOLFALSE] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE, versionSpecified: BOOLFALSE];
Font Parsing
ParseFontData: PROC [inStream: IO.STREAM, prefixP, familyP, faceP, transformP, sizeP: BOOLFALSE] RETURNS [fail: BOOL, prefix, family, face: Rope.ROPE, transform: ImagerTransformation.Transformation, size: REAL ← 0.0];
ParseLiteralFontData: PROC [inStream: IO.STREAM, nameP, transformP, sizeP: BOOLFALSE] RETURNS [fail: BOOL, fontName: Rope.ROPE, transform: ImagerTransformation.Transformation, size: REAL ← 0.0];
FontDataFromUserData: PROC [prefix, family, face: Rope.ROPE, size: REAL, preferredSize: REAL] RETURNS [fontName: Rope.ROPE, fontSize: REAL, fontPreferredSize: REAL, problem: Rope.ROPE];
UserDataFromFontData: PROC [fontName: Rope.ROPE, fontSize: REAL, fontPreferredSize: REAL] RETURNS [prefix, family, face: Rope.ROPE, size: REAL, preferredSize: REAL, problem: Rope.ROPE];
END.