GGUtility.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on April 9, 1987 11:26:37 pm PDT.
Contents: General Purpose routines for use by Gargoyle.
Pier, May 12, 1987 3:44:34 pm PDT
DIRECTORY
AtomButtonsTypes, GGBasicTypes, GGModelTypes, Imager, Interpress, ImagerTransformation, IO, Rope, ViewerClasses;
GGUtility: CEDAR DEFINITIONS = BEGIN
BitVector: TYPE = GGBasicTypes.BitVector;
FeatureData: TYPE = GGModelTypes.FeatureData;
FeedbackData: TYPE = AtomButtonsTypes.FeedbackData;
Outline: TYPE = GGModelTypes.Outline;
OutlineDescriptor: TYPE = GGModelTypes.OutlineDescriptor;
Sequence: TYPE = GGModelTypes.Sequence;
SequenceOfReal: TYPE = GGBasicTypes.SequenceOfReal;
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
StartSequenceList: PROC [] RETURNS [entityList, ptr: LIST OF Sequence];
AddSequence: PROC [entity: Sequence, entityList, ptr: LIST OF Sequence] RETURNS [newList, newPtr: 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];
Operations on LIST OF SliceDescriptor
StartSliceDescriptorList: PROC [] RETURNS [entityList, ptr: LIST OF SliceDescriptor];
AddSliceDescriptor: PROC [entity: SliceDescriptor, entityList, ptr: LIST OF SliceDescriptor] RETURNS [newList, newPtr: LIST OF SliceDescriptor];
DeleteSliceDescriptorFromList: PROC [sliceD: SliceDescriptor, sliceDList: LIST OF SliceDescriptor] RETURNS [smallerList: LIST OF SliceDescriptor];
AppendSliceDescriptorList: PROC [list1, list2: LIST OF SliceDescriptor] RETURNS [result: LIST OF SliceDescriptor];
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
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
GetGargoyleFileName: PROC [ggName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: FeedbackData, emergency: BOOLFALSE] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE, versionSpecified: BOOLFALSE];
GetInterpressFileName: PROC [ipName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: FeedbackData] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE];
GetScriptFileName: PROC [scriptName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: FeedbackData] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE];
OpenInterpressOrComplain: PROC [feedback: FeedbackData, fullName: Rope.ROPE] RETURNS [ipMaster: Interpress.Master, success: BOOL];
Colors
ExtractRGB: PROC [color: Imager.Color] RETURNS [r,g,b: REAL];
GetSpecialColor: PROC RETURNS [color: Imager.Color];
EquivalentColors: PROC [color1, color2: Imager.Color] RETURNS [BOOL];
CopyPattern: PROC [pattern: SequenceOfReal] RETURNS [new: SequenceOfReal];
Conversions
BoolToRope: PROC [bool: BOOL] RETURNS [rope: Rope.ROPE];
Returns "T" or "F".
RopeToBool: PROC [rope: Rope.ROPE] RETURNS [bool: BOOL];
Takes "T" or "F". Raises an Error if rope is anything else.
END.