FitState.mesa
Maureen Stone June 25, 1984 7:53:01 pm PDT
Michael Plass August 13, 1982 9:50 am
DIRECTORY
Cubic USING [Bezier],
Complex USING [Vec],
Seq USING [ComplexSequence,NatSequence],
FitBasic USING [Handle];
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
Closed: PROC [handle: Handle, closed: BOOLEANTRUE] RETURNS [was: BOOLEAN];
MinDist: PROC [handle: Handle, minDist: REAL ← 0] RETURNS [was: REAL];
contours is samples plus links. nodes and cusps are subsets of samples
DataType: TYPE = {samples, links, nodes, cusps, contour};
ResetData: PROC[handle: Handle, type: DataType, all: BOOLEANFALSE];
ScaleData: PROC[handle: Handle, scale: REAL, type: DataType, all: BOOLEANFALSE];
TranslateData: PROC[handle: Handle, trans: Complex.Vec, type: DataType, all: BOOLEANFALSE];
StartSamples: PROC[handle: Handle, x,y: REAL]; --starts a new sList, resets current one
AddSample: PROC[handle: Handle, x,y: REAL]; --adds to the end of the current list
RemoveSample: PROC[handle: Handle]; --unlinks the selected sample
InsertBeforeSample: PROC[handle: Handle, x,y: REAL]; --inserts before the selected sample
Links are not edited (yet) so only AddLink and Reset are necessary
AddLink: PROC[handle: Handle, b: Cubic.Bezier];
these set flags. No allocation necessary
AddNode: PROC[handle: Handle, index: NAT, tan: Complex.Vec ← [0,0]];
DeleteNode: PROC[handle: Handle, index: NAT];
AddCusp: PROC[handle: Handle, index: NAT, tanIn,tanOut: Complex.Vec ← [0,0]];
DeleteCusp: PROC[handle: Handle, index: NAT];
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 interface to fitting routines
CurrentNodes: PROC[handle: Handle] RETURNS[nodes: Seq.NatSequence, tangents: Seq.ComplexSequence];
CurrentSamples: PROC[handle: Handle] RETURNS[Seq.ComplexSequence];
CurrentCusps: PROC[handle: Handle] RETURNS[cusps: Seq.NatSequence, tangents: Seq.ComplexSequence];
points and links independent of structures
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.