DIRECTORY JunoStorage USING [Point, Coords, Action, Constr, IntCoords], JunoOldSolver USING [Outcome]; JunoImage: DEFINITIONS = BEGIN OPEN Stor: JunoStorage, Solv: JunoOldSolver; Point: TYPE = Stor.Point; Coords: TYPE = Stor.Coords; IntCoords: TYPE = Stor.IntCoords; Action: TYPE = Stor.Action; Constr: TYPE = Stor.Constr; PurgeImage: PROC; AddPoint: PROC [p: Point]; RemovePoint: PROC [p: Point]; SortPoints: PUBLIC PROC; AddConstr: PROC [c: Constr]; AddAction: PROC [a: Action]; EnumPoints: PROC [Proc: PointVisitProc]; PointVisitProc: TYPE = PROC [p: Point]; ReplacePoints: PROC [Proc: PointReplaceProc]; PointReplaceProc: TYPE = PROC [p: Point] RETURNS [pNew: Point]; EnumConstrs: PROC [Proc: ConstrVisitProc]; ConstrVisitProc: TYPE = PROC [c: Constr]; EnumConstrPoints: PROC [c: Constr, Proc: PointVisitProc]; ReplaceConstrPoints: PROC [c: Constr, Proc: PointReplaceProc]; EnumActions: PROC [Proc: ActionVisitProc]; ActionVisitProc: TYPE = PROC [a: Action]; EnumActionPoints: PROC [a: Action, Proc: PointVisitProc]; ReplaceActionPoints: PROC [a: Action, Proc: PointReplaceProc]; FindPoint: PROC [coords: Coords, wound: BOOL _ FALSE] RETURNS [champ: Point]; BaloonSelect: PROC [start: IntCoords, NextPoint: NextPointProc]; NextPointProc: TYPE = PROC RETURNS [coords: IntCoords, lastPoint: BOOL]; AnyWoundPoints: PROC RETURNS [BOOL]; ConstrIsWound: PROC [c: Constr] RETURNS [wound: BOOL]; ActionIsWound: PROC [a: Action] RETURNS [wound: BOOL]; UnwindAllPoints: PROC; DeleteWoundItems: PROC; DuplicateWoundItems: PROC; IdentifyPoints: PROC; SolveImage: PROC [eps: REAL] RETURNS [outcome: Solv.Outcome]; END. AddNewVer: PROC [i,j: Point]; AddNewPara: PROC [i,j,k,l: Point]; AddNewPerp: PROC [i,j,k,l: Point]; AddNewCong: PROC [i,j,k,l: Point]; AddNewAt: PROC [p: Point, x, y: REAL]; AddNewCcw: PROC [i,j,k: Point]; ConstrPtr: TYPE = REF ConstrRec; -- to some kind of constraint record ConstrList: TYPE = REF ConstrPtr; -- linked by link field. NewHor: PROC [i,j: Point] RETURNS [ap: ApplPtr]; NewVer: PROC [i,j: Point] RETURNS [ap: ApplPtr]; NewPara: PROC [i,j,k,l: Point] RETURNS [ap: ApplPtr]; NewPerp: PROC [i,j,k,l: Point] RETURNS [ap: ApplPtr]; NewCong: PROC [i,j,k,l: Point] RETURNS [ap: ApplPtr]; NewAt: PROC [p: Point, x, y: REAL] RETURNS [ap: ApplPtr]; NewCcw: PROC [i,j,k: Point] RETURNS [ap: ApplPtr]; DeleteConstr: PROC [c, cAnt: ConstrPtr, list: ConstrList] RETURNS [newList: ConstrList]; InsertConstr: PROC [c, cAnt: ConstrPtr, list: ConstrList] RETURNS [newList: ConstrList]; GcConstr: PROC[pf, pl: ConstrList]; ActionPtr: TYPE = REF ActionRec; -- to some kind of action record ActionList: TYPE = RECORD [first, last: ActionPtr]; -- linked by link field in chronological (painting) order.; ActionRec: TYPE = RECORD [link: ActionPtr, op: ATOM, -- operation (usually atom, the function name) larg, rarg: Alg.Value _ NIL -- left- and right-arguments ]; NewAction: PROC [op: Alg.Se, arg: Alg.Value] RETURNS [ap: ActionPtr]; DeleteAction: PROC [a, aAnt: ActionPtr, list: ActionList] RETURNS [newList: ActionList]; InsertAction: PROC [a, aAnt: ActionPtr, list: ActionList] RETURNS [newList: ActionList]; GcAction: PROC[af, al: ActionPtr]; ` JunoImage.mesa Last Hacked by: Jorge Stolfi June 4, 1984 11:57:29 pm PDT Procedures to manipulate and traverse the current Juno image. - - - - IMPORTED TYPES - - - - THE CURRENT IMAGE The current image consists of a list of points, and a list of constraints and a list of actions involving those points. Discards and reclaims all points, actions and constraints in the current image - - - - IMAGE POINTS Adds p to the current image. Removes the point from the image and reclaims it. Assumes it does not occur in any constraint or action. Sorts the points from left to right. Is automatically called by SolveImage, and is not necessary after inserting a new point, but must be called explicitly after other changes to the coordinates of existing points. - - - - CONSTRAINTS Adds the given constraint to the curren image. - - - - ACTIONS Allocates new action and appends it to the image actions. If doIt=TRUE, also executes the action. - - - - ELEMENT ENUMERATION Calls Proc for all point on the image. Proc should not insert or delete points. Replaces p by Proc[p] for each point in image. If Proc[p] = NIL, deletes and reclaims point. Proc should not change the other constraint arguments. Calls Proc for each constraint on the image. Proc should not insert or delete constraints. CAlls Proc[p] for each point in arguments of the c. Proc should not change the constraint arguments. Replaces p by Proc[p] for each point in arguments of the c. Proc should not return NIL. Proc should not change the other constraint arguments. Calls Proc for each action on the image. Proc should not insert or delete actions. Calls PointVisitProc for each point in the arguments of the action. Proc should not insert affect any arguments of a. Replaces p by Proc[p] for each point in the arguments of the action. Proc should not return NIL. Proc should not affect any other arguments of a. - - - - POINT LOCATION 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 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 coords is the last point. (BaloonSelect will close the polygon automatically) Returns TRUE if there are any points in the image with nonzero winding number. Returns TRUE if all points entering into the constraint c have wn # 0. Returns TRUE if all points athat are arguments to the action a have wn # 0. Sets p.wn=0 for all points p in the image. - - - - OPERATIONS ON BALOON-SELECTED POINTS 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. 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. - - - - POINT IDENTIFICATION For every point p such that p.copy#NIL, replaces p by p.copy in all constraints and actions. Also sets p.copy _ NIL for all points p in the image - - - - CONSTRAINT SOLVING Solves the image constraints for all image points that have p.fixed=FALSE. Reorders the points according to their new coordinates. Does NOT refresh the image on the screen. - - - - JUNK Deletes the constraint c from the list. If cAnt is not NIL, it should be the previous constraint in list. Inserts the constraint c into the list, just after cAnt (if cAnt=NIL inserts at beginning) Garbage-collects all elements in the list starting with pf and ending with pl. Deletes the action a from the list. If aAnt is not NIL, it should be the previous action in list. Inserts the action a into the list, just after aAnt (if aAnt=NIL inserts at beginning) Garbage-collects all elements in the list starting with a and ending with al. ʘšœ™Jšœ=™=Jšœ?™?šœÏk ˜ Jšœ œ;œ ˜]——JšœÏb œ ˜Jšœ˜šœ˜šœ˜Jšœ,˜,——™Jšœœ˜Jšœ œ˜Jšœ œ˜"Jšœ œ˜Jšœ œ˜—™Jšœz™zšœÏn œœ˜JšœO™O——™šœŸœœ ˜Jšœ™—šœŸ œœ ˜™2J™6——šœŸ œœœ˜™$J™±———™šœŸ œœ ˜Jšœ.™.——™šœŸ œœ ˜šœ9™9Jšœ'™'———™šœŸ œœ˜)šœ&™&J™)—JšœŸœœœ ˜(—šœŸ œœ˜.šœ.™.Jšœ-™-J™7—Jš œŸœœœ œ˜@—šœŸ œœ˜+šœ,™,J™.—JšœŸœœœ ˜*—šœŸœœ#˜:šœ3™3J™1——šœŸœœ%˜?šœ;™;J™J™7——šœŸ œœ˜+šœ(™(J™*—JšœŸœœœ ˜*—šœŸœœ#˜:šœC™CJ™2——šœŸœœ%˜?šœD™DJ™J™1———™š Ÿ œœœœœ˜OšœD™DJšœE™E———™šœŸ œœ.˜AšÏcœ  bÐcr  Ïr F™æJš  ¡  œ   œ ¡  &™‡—Jš œŸ œ œœ œ˜I—š œŸœœœœ˜%JšœN™N—šÐbnœœ œ œ˜8Jš 8¡ ¡ ™G—š£œœ œ œ˜7Jš =¡ ¡ ™K—šŸœœ˜Jš ¡ ¡ ™+——™/šŸœœ˜š ¡ A™[Jš E™EJš ¡ œ™(——šŸœœ˜š "¡ ¡ V™ƒJš &¡ ¡ ™XJš¡  ¡ ™$———™šŸœœ˜š ¡ ¡ ¡  ™\Jš  œ ¡  ™5———™š œŸ œœœœ˜>šœK™KJšœ8™8J™*———Jšœœ˜™JšœŸ œœ˜JšœŸ œœ˜#JšœŸ œœ˜#JšœŸ œœ˜#JšœŸœœœ˜'JšœŸ œœ˜ Jšœ œœ  $˜FJšœ œœ   ¡ ˜;JšœŸœœœ˜1JšœŸœœ œ˜1JšœŸœœœ˜6JšœŸœœœ˜6JšœŸœœœ˜6Jš œŸœœœœ˜:JšœŸœœœ˜3š ž œœ(œ˜YJšœi™i—š Ÿ œœ(œ˜YJšœZ™Z—šœŸœœ˜$J™N—Jšœ œœ   ˜BJš œ œœ  ¡ )œ˜rJš œ œœœ /œœ œ˜§JšœŸ œœœ˜Fš Ÿ œœ(œ˜YJš a™a—š Ÿ œœ(œ˜YJš 3œ "™V—šœŸœœ˜#J™M——J˜—…— ¦#“