DIRECTORY JunoStorage USING [Point, Coords, Item, IntCoords], JunoOldSolver USING [Outcome]; JunoImage: DEFINITIONS = BEGIN OPEN Stor: JunoStorage, Solv: JunoOldSolver; Point: TYPE = Stor.Point; Coords: TYPE = Stor.Coords; IntCoords: TYPE = Stor.IntCoords; Item: TYPE = Stor.Item; PurgeImage: PROC; AddPoint: PROC [p: Point]; RemovePoint: PROC [p: Point]; SortPoints: PUBLIC PROC; AddItem: PROC [item: Item]; EnumPoints: PROC [Proc: PointVisitProc]; PointVisitProc: TYPE = PROC [p: Point]; ReplacePoints: PROC [Proc: PointReplaceProc]; PointReplaceProc: TYPE = PROC [p: Point] RETURNS [new: Point]; EnumItems: PROC [Proc: ItemVisitProc]; ItemVisitProc: TYPE = PROC [item: Item]; EnumItemPoints: PROC [item: Item, Proc: PointVisitProc]; ReplaceItemPoints: PROC [item: Item, 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]; ItemIsWound: PROC [item: Item] RETURNS [wound: BOOL]; UnwindAllPoints: PROC; DeleteWoundItems: PROC; DuplicateWoundItems: PROC; IdentifyPoints: PROC; SolveImage: PROC [eps: REAL] RETURNS [outcome: Solv.Outcome]; END.  JunoImage.mesa Last Hacked by: Jorge Stolfi June 13, 1984 9:00:35 am 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. - - - - ITEMS (ACTIONS AND CONSTRAINTS) Adds the given item to the current image. - - - - 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/action arguments. Calls Proc for each constraint/action on the image. Proc should not insert or delete constraints/actions. CAlls Proc[p] for each point in arguments of the item. Proc should not change the constraint/action arguments. Replaces p by Proc[p] for each point in arguments of the item. Proc should not return NIL. Proc should not change the other constraint/action arguments. - - - - 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 item 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 constraints/actions to unwound points). Deletes also all actions and constraints involving only wound points (except graphics state-pushing actions such as set font, set color, etc). 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/action all of whose arguments have been copied, and appends those constraints and actions at the end of the respective lists. All graphics state-pushing actions are copied, too. 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. ÊÓ˜šœ™Jšœ=™=Jšœ?™?šœÏk ˜ Jšœ œ1œ ˜S——JšœÏb œ ˜Jšœ˜šœ˜šœ˜Jšœ(˜(——™Jšœœ˜Jšœ œ˜Jšœ œ˜"Jšœœ ˜—™Jšœz™zšœÏn œœ˜JšœO™O——™šœŸœœ ˜Jšœ™—šœŸ œœ ˜™2J™6——šœŸ œœœ˜™$J™±———™(šœŸœœ˜Jšœ)™)——™šœŸ œœ˜)šœ&™&J™)—JšœŸœœœ ˜(—šœŸ œœ˜.šœ.™.Jšœ-™-J™>—Jš œŸœœœ œ˜?—šœŸ œœ˜'šœ3™3J™6—JšœŸ œœœ˜)—šœŸœœ$˜9šœ6™6J™8——šœŸœœ&˜>šœ>™>J™J™>———™š Ÿ œœœœœ˜OšœD™DJšœE™E———™šœŸ œœ.˜AšÏcœ  bÐcr  Ïr F™æJš  ¡  œ   œ ¡  &™‡—Jš œŸ œ œœ œ˜I—š œŸœœœœ˜%JšœN™N—šÐbn œœœ œ˜7Jš -¡ ¡ ™?—šŸœœ˜Jš ¡ ¡ ™+——™/šŸœœ˜š ¡ A™[Jš Ž™ŽJš ¡ œ™(——šŸœœ˜š "¡ ¡ «™ØJš 3™3Jš  &¡ ¡ ¡  ¡ ™}———™šŸœœ˜š ¡ ¡ ¡  ™\Jš  œ ¡  ™5———™š œŸ œœœœ˜>šœK™KJšœ8™8J™*———Jšœœ˜—…—