<> <<>> <> <> <> DIRECTORY Rope, HerculesStorage, HerculesAlgebra USING[Frame, Matrix]; HerculesImage: DEFINITIONS = BEGIN OPEN HerculesStorage, Alg: HerculesAlgebra; <<- - - - THE CURRENT IMAGE >> image: Image; -- The current image AddPoint: PROC [p: PointPtr]; -- Adds the given point to the image, in proper x-order SortPoints: PROC; -- Sorts list of points points by increasing x-coordinate. -- Useful after moves and constraint solving. AddConstr: PROC [c: ConstrPtr]; -- Adds the given constraint to the image. AddAction: PROC [a: ActionPtr]; -- Adds the given action to the image (in chronological order). <<- - - - IMAGE SAVE AND RESTORE >> PushImage: PROC; -- saves current image (i.e., its points, constraints, and actions) and makes it empty PopImage: PROC; -- restores last saved image PurgeImage: PROC; -- makes current image to be empty <<- - - - IMAGE ELEMENT ENUMERATION >> <> <> <> PointOp: TYPE = PROC [p, pAnt: PointPtr]; EnumeratePoints: PROC [Op: PointOp]; ConstrOp: TYPE = PROC [c, cAnt: ConstrPtr]; EnumerateConstrs: PROC [Op: ConstrOp]; ActionOp: TYPE = PROC [a, aAnt: ActionPtr]; EnumerateActions: PROC [Op: ActionOp]; <<- - - - POINT LOCATION >> FindPoint: PROC [x, y: REAL, wound: BOOL _ FALSE] RETURNS [champ: PointPtr]; -- This procedure finds the point closest to x, y in the current image. -- If wound=TRUE then considers only points with non-zero winding number. <<- - - - BALOON SELECTION >> NextPointProc: TYPE = PROC RETURNS [x, y: INTEGER, lastPoint: BOOL]; BaloonSelect: PROC [xS, yS: INTEGER, NextPoint: NextPointProc]; -- The effect of BaloonSelect is to collect the vertices of a polygon -- (starting with xS, yS and continuing as specified by the NextPoint procedure), -- and set the wn (winding number) -- field for all image points contained in the polygon. -- The NextPoint procedure should return lastPoint = TRUE if x, y is the last point. -- (BaloonSelect will close the polygon automatically) AnyWoundPoints: PROC RETURNS [BOOL]; -- Returns TRUE if there are any points in the image with nonzero winding number. <<- - - - OPERATIONS ON BALOON-SELECTED ITEMS >> ConstrIsWound: PROC [c: ConstrPtr] RETURNS [wound: BOOL]; -- Returns TRUE if all points entering into the constraint c have wn # 0. ActionIsWound: PROC [a: ActionPtr] RETURNS [wound: BOOL]; -- Returns TRUE if all points athat are arguments to the action a have wn # 0. UnwindAllPoints: PROC; -- Sets p.wn=0 for all points p in the image. DeleteWoundItems: PROC; -- Deletes all points with wn # 0 (unless connected by actions/constraints to unwound points). -- Deletes also all actions and constraints involving only wound points. -- After the call all points have wn=0. TransformWoundPoints: PROC[mat: REF Alg.Matrix]; -- Applies the given transformation to all points p with p.wn#0. MoveWoundPoints: PROC [source, dest: Alg.Frame] RETURNS [singular: BOOL]; -- This procedure assumes source and dest are frames with same number of points. It -- (a) computes a transform that takes the source frame to the destination frame, -- (b) applies the transform to all points with wn#0, and -- (c) identifies the source points with the dest points (i.e. replaces the former by the latter -- in all constraints and actions of the current image). -- This procedure assumes all copy links are NIL on entry, all points in the source frame -- have wn#0, and all points in the dest frame have wn=0. -- It returns singular = TRUE if the source frame is degenerate. CopyWoundItems: PROC; -- Creates a new copy of every point p with p.wn#0. -- Also creates a new copy of any constraint all of whose arguments have been copied. -- After the call every copied point has p.copy pointing to its copy, p.wn set to zero, and -- p.copy.wn set to the original p.wn. IdentifyPoints: PROC; -- For every point p such that p.copy#NIL, replaces p by p.copy -- in all constraints and actions. Then sets -- Also sets p.copy _ NIL for all points p in the image END. <<>> <> <> <> <> <<>> <> <>