GGSequence.mesa
Copyright Ó 1986, 1987, 1992 by Xerox Corporation. All rights reserved.
Last edited by Bier on July 16, 1987 1:42:44 pm PDT
Contents: Sequences are a way to describe some part of a trajectory without actually pulling the trajectory apart. The new definition of sequence is that it is ANY subset of the parts of a trajectory (joints and/or segments). Procedures are provided which make sequences, perform boolean operations on them, and step through them.
Pier, December 16, 1987 12:08:37 pm PST
Eisenman, October 2, 1987 6:26:21 pm PDT
Bier, November 4, 1988 11:05:32 pm PST
DIRECTORY
GGBasicTypes, GGCoreTypes, GGModelTypes, GGSegmentTypes, Imager, Rope;
GGSequence:
CEDAR
DEFINITIONS =
BEGIN
BezierDragRecord: TYPE = GGModelTypes.BezierDragRecord;
BoundBox: TYPE = GGCoreTypes.BoundBox;
ControlPointGenerator: TYPE = GGModelTypes.ControlPointGenerator;
EditConstraints: TYPE = GGModelTypes.EditConstraints;
Joint: TYPE = GGModelTypes.Joint;
JointGenerator: TYPE = GGModelTypes.JointGenerator;
Point: TYPE = GGBasicTypes.Point;
PointAndDone: TYPE = GGModelTypes.PointAndDone;
PointWalkProc: TYPE = GGModelTypes.PointWalkProc;
SegAndIndex: TYPE = RECORD [seg: Segment, index: NAT];
Segment: TYPE = GGSegmentTypes.Segment;
SegmentGenerator: TYPE = GGModelTypes.SegmentGenerator;
SelectionClass: TYPE = GGSegmentTypes.SelectionClass;
SequenceOfReal: TYPE = GGCoreTypes.SequenceOfReal;
Slice: TYPE = GGModelTypes.Slice;
SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor;
SliceParts: TYPE = GGModelTypes.SliceParts;
StrokeEnd: TYPE = Imager.StrokeEnd;
StrokeJoint: TYPE = Imager.StrokeJoint;
Traj: TYPE = GGModelTypes.Traj;
TrajData: TYPE = GGModelTypes.TrajData;
TrajEnd: TYPE = GGModelTypes.TrajEnd; -- {lo, hi};
TrajParts: TYPE = GGModelTypes.TrajParts;
TrajPartType: TYPE = GGModelTypes.TrajPartType; -- {none, joint, controlPoint, segment};
SequenceGenerator: TYPE = REF SequenceGeneratorObj;
SequenceGeneratorObj:
TYPE =
RECORD [
list: LIST OF TrajParts
];
CreateFromSegments:
PROC [traj: TrajData, startSeg, endSeg:
NAT]
RETURNS [seq: TrajParts];
The sequence created will include all of the segments from startSeg to endSeg inclusive, and all of the joints which they touch. startSeg and endSeg must be legal TrajParts numbers for this trajectory. If the trajectory is closed, then startSeg > endSeg is allowed, in which case the segment sequence wraps around.
If startSeg = endSeg, then one segment is added.
If startSeg = endSeg + 1 (modulo the number of segments in traj), then the whole trajectory is selected.
Returns a sequences with only one contiguous part [start...end].
CreateJointToJoint:
PROC [traj: TrajData, startJoint, endJoint:
NAT]
RETURNS [seq: TrajParts];
IF the traj is open, then include all segments in the interval [startJoint..endJoint]. If the traj is closed, there are three cases: 1) IF startJoint = endJoint then select a single joint. 2) IF startJoint < endJoint then proceed as for an open traj (but there is no way to include the whole trajectory. 3) IF endJoint < startJoint, wrap around, selecting all segments above startJoint, all segments below endJoint, all joints above startJoint including startJoint, all joints below endJoint, including endJoint.
CreateEmpty:
PROC [traj: TrajData]
RETURNS [seq: TrajParts];
Returns a sequence belonging to traj, which refers to none of its parts.
CreateComplete: PROC [traj: TrajData] RETURNS [seq: TrajParts];
CreateFromJoint:
PROC [traj: TrajData, jointNum:
NAT]
RETURNS [seq: TrajParts];
Returns a sequence belonging to traj, which refers to a single joint.
CreateFromSegment: PROC [traj: TrajData, segNum: NAT] RETURNS [seq: TrajParts];
CreateSimpleFromSegment: PROC [traj: TrajData, segNum: NAT] RETURNS [seq: TrajParts];
CreateFromControlPoint:
PROC [traj: TrajData, segNum:
NAT, controlPointNum:
NAT]
RETURNS [seq: TrajParts];
Returns a sequence belonging to traj, which refers to a single segment (and the joints at its endpoints).
Copy: PROC [seq: TrajParts] RETURNS [copy: TrajParts];
Procedures which mutate Segments (use with caution)
CopyInto:
PROC [to: TrajParts, from: TrajParts];
Returns a sequence belonging to traj, which refers to all of its parts.
FillInJoints:
PROC [seq: TrajParts];
Ensures that, for each segment A in seq, both endjoints of A are in seq as well.
FillInControlPoints:
PROC [seq: TrajParts];
Ensures that, for each segment A in seq, all control points of A are in seq as well.
TrimSelectedParts:
PROC [trimDescriptor: SliceDescriptor,
selectedList:
LIST
OF SliceDescriptor];
Modifies, mutes, and munges seq, so that it no longer includes any parts mentioned in selectedList. Used by GGAlign.RemoveMoving.
TrimSelectedJointSegments:
PROC [trimDescriptor: SliceDescriptor,
selectedList:
LIST
OF SliceDescriptor];
Modifies, mutes, and munges seq, so that it no longer includes any segments whose joints are mentioned in selectedList. Used by GGAlign.RemoveMoving.
TrimSelectedControlPointSegments:
PROC [trimDescriptor: SliceDescriptor,
selectedList:
LIST
OF SliceDescriptor];
Modifies, mutes, and munges seq, so that it no longer includes any segments whose control points are mentioned in selectedList. Used by GGAlign.RemoveMoving.
DDifference:
PROC [mutable, negative: SliceDescriptor];
This is a destructive form of the Difference operation. mutable ← mutable - negative.
Union: PROC [a, b: SliceDescriptor] RETURNS [union: SliceDescriptor];
Difference: PROC [a, b: SliceDescriptor] RETURNS [aMinusB: SliceDescriptor];
Intersection: PROC [a, b: SliceDescriptor] RETURNS [intersection: SliceDescriptor];
TrajMovingParts: PROC [slice: Slice, parts: SliceParts, editConstraints: EditConstraints, bezierDrag: BezierDragRecord] RETURNS [background, overlay, rubber, drag: TrajParts];
Augment: PROC [descriptor: SliceDescriptor, trajEnd: TrajEnd, extend: BOOL] RETURNS [bigger: TrajParts];
IsObsolete: PROC [seq: TrajParts] RETURNS [BOOL];
TRUE if trajectory has changed size (number of joints, segments, or control points) since seq was made.
IsEmpty:
PROC [seq: TrajParts]
RETURNS [
BOOL];
TRUE if the seq represents none of the joints, segments, and control points of its trajectory.
IsComplete:
PROC [seq: TrajParts]
RETURNS [
BOOL];
TRUE if the seq represents all of the joints, segments, and control points of its trajectory.
IsConstrained:
PUBLIC PROC [descriptor: SliceDescriptor, segNum, cPNum:
NAT, editConstraints: EditConstraints]
RETURNS [
BOOL];
Tells if a joint is constrained.
Overlap:
PROC [descriptor1, descriptor2: SliceDescriptor]
RETURNS [
BOOL];
RETURNS TRUE iff descriptor1 and descriptor2 share some joints or segments.
ContainsJoint: PROC [seq: TrajParts, jointNum: NAT] RETURNS [BOOL];
ContainsSegment: PROC [seq: TrajParts, segNum: NAT] RETURNS [BOOL];
ContainsSomeSegment:
PROC [seq: TrajParts]
RETURNS [
BOOL];
Returns TRUE if the sequence contains the segment itself.
ContainsSegmentParts:
PROC [seq: TrajParts, segNum:
NAT]
RETURNS [
BOOL];
Returns TRUE if the sequence contains any part of a segment, including its end joints, its control points, or the segment proper.
LastSegAndJoint: PROC [traj: TrajData, trajEnd: TrajEnd] RETURNS [segAndJoint: TrajParts];
UnpackOnePointSequence:
PROC [seq: TrajParts]
RETURNS [isACP:
BOOL, segNum, cpNum, jointNum:
NAT];
seq is asserted to be either a single joint or a single control point. Return the [segNum, cpNum] pair or the jointNum as appropriate.
UnpackOneSegmentSequence:
PROC [seq: TrajParts]
RETURNS [segNum:
NAT];
seq is asserted to be a single segment. Return the segNum.
UnpackSimpleSequence: PROC [slice: Slice, parts: SliceParts] RETURNS [success: BOOL, partType: TrajPartType ¬ none, traj: TrajData, joint: Joint ¬ NIL, jointNum: NAT ¬ 999, cp: Point ¬ [0,0], cpNum: NAT ¬ 999, seg: Segment ¬ NIL, segNum: NAT ¬ 999];
RunsInSequence:
PROC [seq: TrajParts]
RETURNS [seqGen: SequenceGenerator, runCount:
NAT];
A run is a sequence with only one contiguous piece. In other words, each joint in the run touches at least one segment in the run (unless the run is a single joint), and each segment in the run touches at least one joint in the run (unless the run is a single segment). The run whose lowest joint has the lowest index will be returned first by NextSequence. The other runs will follow in ascending order.
NextSequence: PROC [seqGen: SequenceGenerator] RETURNS [seq: TrajParts];
FirstRun: PROC [seq: TrajParts] RETURNS [runParts: TrajParts];
SegmentWalkProc: TYPE = PROC [traj: TrajData, seg: Segment, index: NAT] RETURNS [done: BOOL ¬ FALSE];
SegmentsInTraj:
PROC [traj: TrajData]
RETURNS [segGen: SegmentGenerator];
Returns a generator for all segment in traj, beginning with segment 0.
WalkSegmentsInTraj:
PROC [traj: TrajData, walkProc: SegmentWalkProc]
RETURNS [aborted:
BOOL ¬
FALSE];
Calls walkProc for each segment in traj, until walkProc returns done=TRUE.
SegmentsInSequence:
PROC [traj: TrajData, seq: TrajParts]
RETURNS [segGen: SegmentGenerator];
Returns a generator for all segments in seq, beginning with the lowest numbered one (contrast this with OrderedSegmentsInSequence below).
WalkSegmentsInSequence: PROC [traj: TrajData, seq: TrajParts, walkProc: SegmentWalkProc] RETURNS [aborted: BOOL ¬ FALSE];
CountSegmentsInSequence:
PROC [traj: TrajData, seq: TrajParts]
RETURNS [count:
NAT];
Calls walkProc for each segment mentioned in seq, until walkProc returns done=TRUE.
OrderedSegmentsInSequence:
PROC [traj: TrajData, seq: TrajParts]
RETURNS [segGen: SegmentGenerator];
Returns a generator for all segment in seq, beginning with the lowest numbered one (in the case of open trajectories), or the first segment that follows a segment that is not in seq (for closed trajectories). If seq.traj is complete and closed, then behaves like SegmentsInSequence.
NextSegment:
PROC [segGen: SegmentGenerator]
RETURNS [next: Segment];
Returns the next segment from segGen. segGen may have been produced by SegmentsInTraj, SegmentsInSequence or OrderedSegmentsInSequence.
NextSegmentAndIndex: PROC [segGen: SegmentGenerator] RETURNS [next: SegAndIndex];
ControlPointsInSequence: PROC [traj: TrajData, seq: TrajParts] RETURNS [cpGen: ControlPointGenerator];
WalkControlPointsInSequence: PROC [traj: TrajData, seq: TrajParts, walkProc: PointWalkProc];
NextControlPoint: PROC [cpGen: ControlPointGenerator] RETURNS [next: PointAndDone];
NextSegNumAndCPNum: PROC [cpGen: ControlPointGenerator] RETURNS [segNum, cpNum: NAT, done: BOOL];
NextSegmentAndControlPointNum: PROC [cpGen: ControlPointGenerator] RETURNS [segAndCPNum: SegAndIndex];
JointsInSequence: PROC [seq: TrajParts] RETURNS [jointGen: JointGenerator];
WalkJointsInSequence: PROC [traj: TrajData, seq: TrajParts, walkProc: PointWalkProc];
JointWalkProc: TYPE = PROC [traj: TrajData, jointPos: Point, index: NAT] RETURNS [done: BOOL ¬ FALSE];
WalkJointPositionsInSequence:
PROC [traj: TrajData, seq: TrajParts, walkProc: JointWalkProc];
Calls walkProc on each joint position in seq until walkProc returns done=TRUE.
JointsInTraj: PROC [traj: TrajData] RETURNS [jointGen: JointGenerator];
FirstJointNum:
PROC [run: TrajParts]
RETURNS [
INT];
run had better be a run (a single non-empty contiguous sequence). Returns -1 if there are no joints in the run.
LastJointNum: PROC [run: TrajParts, firstJointNum: INT] RETURNS [lastNum: INT];
FirstSegNum:
PROC [run: TrajParts]
RETURNS [
INT];
run had better be a run (a single non-empty contiguous sequence).
LastSegNum:
PROC [run: TrajParts, firstSegNum:
INT]
RETURNS [lastNum:
INT];
run had better be a run (a single non-empty contiguous sequence). Returns -1 if there are no joints in the run. Note that FirstJointNum[run] and LastJointNum[run] can be the same.
NextJoint: PROC [jointGen: JointGenerator] RETURNS [next: INT];
END.