FitState.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Maureen Stone November 27, 1984 2:42:38 pm PST
Michael Plass August 13, 1982 9:50 am
Doug Wyatt, September 5, 1985 1:54:13 pm PDT
DIRECTORY
Cubic USING [Bezier],
Complex USING [VEC],
Seq USING [ComplexSequence,JointSequence],
FitBasic USING [Handle, JointType];
FitState: CEDAR DEFINITIONS =
BEGIN
Handle: TYPE = FitBasic.Handle;
A contour is a list of samples and a list of cubic links. The cubic links are usually the result of the last fitting operation. The handle keeps a list of contours with one marked as "current". Operations that apply to one contour act on the current contour.
The current sample list keeps a reference to a selected sample. Operations that take a sample use the current sample. The selected is initialized to the list head. InsertBefore the list head adds the sample to the end of the list. AddSample and InsertBeforeSample change the selected sample to be the last sample added.
Create: PROC RETURNS [handle: Handle];
Undo: PROC[handle: Handle]; --reverses the last operation
SetClosed: PROC [handle: Handle, closed: BOOLEAN] = INLINE {handle.closed ← closed};
GetClosed: PROC [handle: Handle] RETURNS [BOOLEAN] = INLINE {RETURN[handle.closed]};
SetMinDist: PROC [handle: Handle, minDist: REAL ← 0]= INLINE {handle.minDist ← minDist};
GetMinDist: PROC [handle: Handle] RETURNS [REAL] = INLINE {RETURN[handle.minDist]};
contours = samples plus links. Joints is a subset of samples. The all flag defines whether the operation is applied only to the current contour or to all contours in the handle.
DataType: TYPE = {samples, links, joints, contours};
ResetData: PROC[handle: Handle, type: DataType, all: BOOLEAN ← FALSE];
ScaleData: PROC[handle: Handle, scale: REAL, type: DataType, all: BOOLEAN ← FALSE];
TranslateData: PROC[handle: Handle, trans: Complex.VEC, type: DataType, all: BOOLEAN ← FALSE];
JointType: TYPE = {none, potential, forced};
AddSample: PROC[handle: Handle, x,y: REAL, joint: FitBasic.JointType ← none, tanIn,tanOut: Complex.VEC ← [0,0]]; --adds to the end of the current list
RemoveSample: PROC[handle: Handle]; --unlinks the selected sample
InsertBeforeSample: PROC[handle: Handle, x,y: REAL, joint: FitBasic.JointType ← none, tanIn,tanOut: Complex.VEC ← [0,0]]; --inserts before the selected sample
Links are not edited (yet) so only AddLink and Reset are necessary
AddLink: PROC[handle: Handle, b: Cubic.Bezier];
This sets a flag. No allocation necessary. tanIn=tanOut for smooth joint
SetJoint: PROC[handle: Handle, index: NAT, joint: FitBasic.JointType ← potential, tanIn,tanOut: Complex.VEC ← [0,0]];
Change the definition of current contour
NewContour: PROC[handle: Handle]; -- Makes an empty contour and selects it
NextContour: PROC[handle: Handle]; -- Moves to the next contour.
For the interface PiecewiseFit
Samples are a sequence of points. Closed indicates a closed shape (don't double endpoints)
The joints indicate the possible locations for joints in the curve and are a sequence of the record [index: NAT, forced: BOOLEAN]. The index is an index into the sample sequence so, for example, samples[joints[0].index] is the sample value for the first possible joint in the curve. If forced=TRUE a joint will always occure at that point.
CurrentJoints: PROC[handle: Handle] RETURNS[joints: Seq.JointSequence, tangents: Seq.ComplexSequence];
CurrentSamples: PROC[handle: Handle] RETURNS[Seq.ComplexSequence];
points and links independent of structures. See FitStateUtils for other enumerators
EnumerateLinks: PROC[handle: Handle, newContour: PROC[x,y: REAL], newCubic: PROC[c: Cubic.Bezier]];
EnumerateSamples: PROC[handle: Handle, newContour: PROC[x,y: REAL], newSample: PROC[x,y: REAL]];
CountContours: PROC[handle: Handle] RETURNS [INT];
END.