GGUtility.mesa
Copyright Ó 1986, 1988, 1989 by Xerox Corporation. All rights reserved.
Pier, September 18, 1990 4:52 pm PDT
Bier, June 3, 1991 6:24 pm PDT
Doug Wyatt, December 5, 1989 6:03:48 pm PST
Contents: General Purpose routines for use by Gargoyle.
DIRECTORY
Basics, FeedbackTypes, GGBasicTypes, GGCoreTypes, GGHistoryTypes, GGInterfaceTypes, GGModelTypes, GGUserInput, Imager, ImagerTransformation, Interpress, IO, RefTab, Rope;
GGUtility: CEDAR DEFINITIONS = BEGIN
Color: TYPE = Imager.Color;
version: REAL; -- e.g. 8708.21
versionRope: Rope.ROPE; -- e.g. "8708.21"
BitVector: TYPE = GGBasicTypes.BitVector;
FeatureData: TYPE = GGModelTypes.FeatureData;
MsgRouter: TYPE = FeedbackTypes.MsgRouter;
GGData: TYPE = GGInterfaceTypes.GGData;
HistoryEvent: TYPE = GGHistoryTypes.HistoryEvent;
Scene: TYPE = GGModelTypes.Scene;
Slice: TYPE = GGModelTypes.Slice;
SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor;
Sequence: TYPE = GGModelTypes.Sequence;
SequenceOfReal: TYPE = GGCoreTypes.SequenceOfReal;
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];
CopyFeatureDataList: PROC [l: LIST OF FeatureData] RETURNS [copyList: LIST OF FeatureData];
FeatureDataNconc: PROC [l1, l2: LIST OF FeatureData] RETURNS [bigList: 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];
AppendSequenceList: PROC [list1, list2: LIST OF Sequence] RETURNS [result: LIST OF Sequence];
DeleteSequenceFromList: PROC [seq: Sequence, seqList: LIST OF Sequence] RETURNS [smallerList: LIST OF Sequence];
SequenceSubst: PROC [new, old: Sequence, expr: LIST OF Sequence] RETURNS [head: LIST OF Sequence ← NIL];
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];
AppendSliceDescriptorList: PROC [list1, list2: LIST OF SliceDescriptor] RETURNS [result: LIST OF SliceDescriptor];
DeleteSliceDescriptorFromList: PROC [sliceD: SliceDescriptor, sliceDList: LIST OF SliceDescriptor] RETURNS [smallerList: LIST OF SliceDescriptor];
CopySliceDescriptorList: PROC [list: LIST OF SliceDescriptor] RETURNS [copy: LIST OF SliceDescriptor];
Operations on LIST OF Slice
StartSliceList: PROC [] RETURNS [entityList, ptr: LIST OF Slice];
AddSlice: PROC [entity: Slice, entityList, ptr: LIST OF Slice] RETURNS [newList, newPtr: LIST OF Slice];
AppendSliceList: PROC [list1, list2: LIST OF Slice] RETURNS [result: LIST OF Slice];
DeleteSliceFromList: PROC [slice: Slice, sliceList: LIST OF Slice] RETURNS [smallerList: LIST OF Slice];
FindSliceAndNeighbors: PROC [slice: Slice, sliceList: LIST OF Slice] RETURNS [beforeEnt, ent, afterEnt: LIST OF Slice, found: BOOLFALSE];
CopySliceList: PROC [sliceList: LIST OF Slice] RETURNS [copyList: LIST OF Slice];
Comparison: TYPE = Basics.Comparison;
SliceCompareProc: TYPE = PROC [ref1: Slice, ref2: Slice] RETURNS [Comparison];
SortSliceList: PROC [list: LIST OF Slice, compareProc: SliceCompareProc] RETURNS [LIST OF Slice];
SortSliceListByPriority: PROC [list: LIST OF Slice] RETURNS [LIST OF Slice];
Sorts back to front.
OverlapOrder: TYPE = {incr, decr};
OrderedSelectionList: PROC [ggData: GGData, order: OverlapOrder, andSelectEntire: BOOLFALSE] RETURNS [list: LIST OF Slice];
CopySceneClean: PROC [scene: Scene, copyAll: BOOLFALSE] RETURNS [virginList: LIST OF Slice, virginMap: RefTab.Ref];
traverse the scene entities from beginning (back) to end (front), making a clean copy of the scene list from unselected slices AND copies of selected slices. Also, return a RefTab that maps the copies onto their originals.
RestoreSceneClean: PROC [scene: Scene, virginList: LIST OF Slice, virginMap: RefTab.Ref];
restores ggData.scene.entities to its original state as specified by the virginList and virginMap
UnlinkCapturedScene: PROC [historyEvent: HistoryEvent];
unlinks a captured clean scene which is no longer needed. Trying to help the garbage collector here. Caller must guarantee that the historyEvent isn't used elsewhere.
Operations on LIST OF Traj
StartTrajList: PROC [] RETURNS [entityList, ptr: LIST OF Traj];
AddTraj: PROC [entity: Traj, entityList, ptr: LIST OF Traj] RETURNS [newList, newPtr: LIST OF Traj];
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;
Colors and Dash Patterns
In GGUtilityImplA.mesa
GetSpecialColor moved to GGPort
ChangeHue: PROC [startColor: Color, hueFrom: Color] RETURNS [newColor: Color];
CopyPattern: PROC [pattern: SequenceOfReal] RETURNS [new: SequenceOfReal];
EquivalentPatterns: PROC [p1, p2: SequenceOfReal] RETURNS [BOOLFALSE];
Text Descriptions of Simple Data Types
DescribeTraj: PROC [traj: Traj] RETURNS [text: Rope.ROPE];
DescribeColor: PROC [color: Imager.Color] RETURNS [rope: Rope.ROPE];
DescribeSequence: PROC [seq: Sequence] RETURNS [text: Rope.ROPE];
DescribeControlPoint: PROC [traj: Traj, segNum: NAT, cpNum: NAT] RETURNS [text: Rope.ROPE];
DescribeJoint: PROC [traj: Traj, jointNum: NAT] RETURNS [text: Rope.ROPE];
DescribeSegment: PROC [traj: Traj, segNum: NAT] RETURNS [text: Rope.ROPE];
DescribeInterior: PROC [traj: Traj] RETURNS [text: Rope.ROPE];
Transforms the color (does nothing if color is not a sampled color or sampled black).
END.