DIRECTORY Pipal; PipalInt: CEDAR DEFINITIONS = BEGIN Number: TYPE = INT32; infinity: Number = LAST [Number]/2; Vector: TYPE = RECORD [ x: Number, -- horizontal dimension, going right y: Number]; -- vertical dimension, going down Position: TYPE = Vector; -- alias when a vector expresses a position Size: TYPE = Vector; -- alias when a vector expresses a size zeroVector: Vector = [0, 0]; emptySize: Size = [-infinity, -infinity]; Interval: TYPE = RECORD [ base: Number, size: Number]; Rectangle: TYPE = RECORD [ base: Vector, size: Size]; emptyRectangle: Rectangle = [[infinity/2, infinity/2], emptySize]; fullRectangle: Rectangle = [[-infinity/2, -infinity/2], [infinity, infinity]]; RectangleProc: TYPE = PROC [rect: Rectangle] RETURNS [quit: BOOL _ FALSE]; Orientation: TYPE = MACHINE DEPENDENT {identity(0), mirrorX(1), rotate90(2), rotate90X(3), rotate180(4), rotate180X(5), rotate270(6), rotate270X(7)}; Transformation: TYPE = RECORD [translation: Vector _ zeroVector, orientation: Orientation _ identity]; VectorToRope: PROC [v: Vector] RETURNS [Pipal.ROPE]; RectangleToRope: PROC [r: Rectangle] RETURNS [Pipal.ROPE]; OrientationToRope: PROC [o: Orientation] RETURNS [Pipal.ROPE]; TransformationToRope: PROC [t: Transformation] RETURNS [Pipal.ROPE]; Add: PROC [v1, v2: Vector] RETURNS [Vector]; Sub: PROC [v1, v2: Vector] RETURNS [Vector]; Min: PROC [v1, v2: Vector] RETURNS [Vector]; Max: PROC [v1, v2: Vector] RETURNS [Vector]; Neg: PROC [v: Vector] RETURNS [Vector]; IsDegeneratedSize: PROC [s: Size] RETURNS [BOOL]; IsEmptySize: PROC [s: Size] RETURNS [BOOL]; IntersectionIntervals: PROC [i1, i2: Interval] RETURNS [Interval]; UnionIntervals: PROC [i1, i2: Interval] RETURNS [Interval]; DoIntervalsIntersect: PROC [i1, i2: Interval] RETURNS [BOOL]; IsInsideInterval: PROC [container, candidate: Interval] RETURNS [BOOL]; IsInsideIntervalNumber: PROC [container: Interval, candidate: Number] RETURNS [BOOL]; Translate: PROC [r: Rectangle, v: Vector] RETURNS [Rectangle]; Extend: PROC [r: Rectangle, n: Number] RETURNS [Rectangle]; IntersectBox: PROC [r1, r2: Rectangle] RETURNS [Rectangle]; BoundingBox: PROC [r1, r2: Rectangle] RETURNS [Rectangle]; BoundingRectangle: PROC [p1, p2: Position] RETURNS [Rectangle]; IsDegeneratedRectangle: PROC [r: Rectangle] RETURNS [BOOL]; IsEmptyRectangle: PROC [r: Rectangle] RETURNS [BOOL]; DoRectanglesIntersect: PROC [r1, r2: Rectangle] RETURNS [BOOL]; IsInsideRectangle: PROC [container, candidate: Rectangle] RETURNS [BOOL]; IsInsidePoint: PROC [container: Rectangle, candidate: Position] RETURNS [BOOL]; AlwaysQuit: RectangleProc; Extremity: PROC [r: Rectangle] RETURNS [Position]; DecomposeRect: PROC [r, clip: Rectangle, inside, outside: RectangleProc _ NIL] RETURNS [quit: BOOL _ FALSE]; Center: PROC [r: Rectangle] RETURNS [Position]; TransformVector: PROC [t: Transformation, v: Vector] RETURNS [Vector]; TransformBBox: PROC [t: Transformation, s: Size] RETURNS [Rectangle]; TransformRectangle: PROC [t: Transformation, r: Rectangle] RETURNS [Rectangle]; Compose: PROC [t1, t2: Transformation] RETURNS [Transformation]; enumerateMethod: Pipal.Method; EachChildProc: TYPE = PROC [transformation: Transformation, child: Pipal.Object] RETURNS [quit: BOOL _ FALSE]; EnumerateProc: TYPE = PROC [object: Pipal.Object, each: EachChildProc, transformation: Transformation _ []] RETURNS [quit: BOOL _ FALSE]; HasEnumerate: PROC [object: Pipal.Object] RETURNS [BOOL]; Enumerate: EnumerateProc; NthChild: PROC [object: Pipal.Object, transformation: Transformation _ [], rank: NAT _ 0] RETURNS [nthTrans: Transformation, nthChild: Pipal.Object _ NIL]; CountChildren: PROC [object: Pipal.Object] RETURNS [count: NAT]; sizeMethod: Pipal.Method; bboxMethod: Pipal.Method; SizeProc: TYPE = PROC [object: Pipal.Object] RETURNS [size: Size]; BBoxProc: TYPE = PROC [object: Pipal.Object, transformation: Transformation] RETURNS [bbox: Rectangle]; ObjectSize: SizeProc; BBox: BBoxProc; CachedSizeFromEnumerate: SizeProc; CachedBBoxFromEnumerate: BBoxProc; abutBoxMethod: Pipal.Method; AbutBoxProc: TYPE = PROC [object: Pipal.Object] RETURNS [abutBox: Rectangle]; AbutBox: AbutBoxProc; AbutBoxFromSize: AbutBoxProc; CachedAbutBoxFromEnumerate: AbutBoxProc; transformClass: Pipal.Class; Transform: TYPE = REF TransformRec; TransformRec: TYPE = RECORD [ transformation: Transformation, child: Pipal.Object]; CreateTransform: PROC [transformation: Transformation, child: Pipal.Object] RETURNS [transform: Transform]; translationClass: Pipal.Class; Translation: TYPE = REF TranslationRec; TranslationRec: TYPE = RECORD [ vector: Vector, child: Pipal.Object]; CreateTranslation: PROC [vector: Vector, child: Pipal.Object] RETURNS [translation: Translation]; orientClass: Pipal.Class; Orient: TYPE = REF OrientRec; OrientRec: TYPE = RECORD [ orientation: Orientation, child: Pipal.Object]; CreateOrient: PROC [orientation: Orientation, child: Pipal.Object] RETURNS [orient: Orient]; TransformObject: PROC [transformation: Transformation, child: Pipal.Object] RETURNS [Pipal.Object]; abutBoxProp: ATOM; CreateAbutBoxAnnotation: PROC [child: Pipal.Object, rectangle: Rectangle] RETURNS [annotation: Pipal.Annotation]; abutClass: Pipal.Class; Abut: TYPE = REF AbutRec; AbutRec: TYPE = RECORD [ inX: BOOL, children: SEQUENCE size: NAT OF Pipal.Object ]; CreateAbut: PROC [inX: BOOL, children: Pipal.Objects] RETURNS [abut: Abut]; HashByEnumeration: Pipal.HashProc; CachedHashByEnumeration: Pipal.HashProc; HashObjectSize: Pipal.HashProc; HashVector: PROC [vector: Vector] RETURNS [hash: CARD]; HashRectangle: PROC [rectangle: Rectangle] RETURNS [hash: CARD]; HashTransformation: PROC [transformation: Transformation] RETURNS [hash: CARD]; EqualByEnumeration: Pipal.EqualProc; AtEdge: PROC [abutBox: Rectangle, trans: Transformation, object: Pipal.Object] RETURNS [BOOL]; END. PipalInt.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Louis Monier January 15, 1988 11:24:39 pm PST Bertrand Serlet May 19, 1988 0:34:15 am PDT Barth, January 26, 1988 11:30:32 am PST Theory Type definitions and basic operations for Pipal integer data structures. Integers are used for layout and schematic capture. Types size<=0 <=> empty interval. All empty intervals are legal. Intervals are closed at the base and open at the extremity. If anyone can tell us why this should be so please do. size.x<=0 or size.y<=0 <=> empty rectangle. All empty rectangles are legal Standard types for enumerations of rectangles. An orientation represents an anticlockwise rotation maybe followed by a reflection in x. [Reflection in x means: modify x coordinates, leave y coordinates] A transformation represents an orientation followed by a translation. Printing Utilities Vector Operations Transformations Sum, v1+v2. Difference, v1-v2. Negative, -v. Predicates Returns TRUE iff s.x<0 OR s.y<0. Returns TRUE iff s.x<=0 OR s.y<=0. Interval Operations Returns TRUE iff candidate is inside of container. Returns TRUE iff candidate is inside of container. Extremity is included. Rectangle Operations Transformations fullRectangle is a neutral element for this operation. emptyRectangle is a neutral element for this operation. no neutral element for this operation. Predicates Returns TRUE iff r1 and r2 have some common points or border; TRUE if rects touch on a single point. Others Calls inside [part of r inside of clip] and outside [parts of r outside of clip]. Border points might be part of both calls. NIL call backs means discard. Returns center of rect r Transformation Operations Application Same as TransformRectangle[t, [zeroVector, s]]; Composition For each position p, the following equality holds: TransformVector [Compose [t1, t2], p] = TransformVector [t1, TransformVector [t2, p]] Enumeration Method Enumerates all children of an object. There is an implicit overlay to compose all children. Short cut for applying the enumerate method. No enumerate method => crash and burn. Successive invocations with the same object should apply each in the same order. Returns the Nth child, 0 being of course the first child, NIL if no such child. Returns the number of children obtained by enumeration. Size Method Short cut for applying the size method. Default when no size method is found is: Compute the size by computing the size of the bounding box of children. No enumerate method => crash and burn. No child => emptySize Computes the bounding box of an object, in the context of an overlay. Computes the size by enumeration and caches its result. Computes the bbox by enumeration and caches its result. AbutBox Method Short cut for applying the abutBox method. Default when no abutBox method is found is: Computes the abutBox by computing the bounding box of children. No enumerate method => crash and burn. No child => emptyRectangle Returns [[0, 0], ObjectSize[object]]. For use by atomic classes which do not fiddle the abutBox. Computes the abutbox by enumeration and caches its result. Geometrical Classes General Transform Translation Orient Compacted creation of objects Creates the densest object possible. Might even return child itself if the transformation is the identity. Abut-related Annotations and Classes Abut Box Annotation Annotation for specifying an Abut Box for an object. Key of the annotation is abutBoxProp and value is a REF Rectangle. Abut Abut children are guaranteed to be enumerated in increasing order (left to right and bottom to top). Abuts differ from overlay by the fact they contain an ordered list of children abutted one next to the other. The order of children is important and the leftmost (resp. bottommost) is the first one. Abutted cells are checked for compatible sizes. Miscellaneous Uses Enumerate on children to compute hash. Same as previous, but caches its result. Uses Enumerate on children to decide whether equal. Returns TRUE iff transformed object touches or extends beyond abutBox. Κ :˜– "Cedar" stylešœ™Jšœ<™Kšžœœœœ˜D—™™šžœœœ ˜,K™ —šžœœœ ˜,K™—Kšžœœœ ˜,Kšžœœœ ˜,šžœœ œ ˜'K™ ——™ šžœœ œœ˜1Kšœœ™ —šž œœ œœ˜+Kšœœ™"———™Kšžœœœ ˜Bšžœœœ ˜;K˜—Kšžœœœœ˜=šžœœ"œœ˜GKšœœ&™2—šžœœ*œœ˜UKšœœ&™2K™——™™šž œœœ ˜>K˜—šžœœœ ˜;K˜—šž œœœ ˜;Kšœ6™6K˜—šž œœœ ˜:Kšœ7™7K˜—šžœœœ ˜?Kšœ&™&K˜——™ Kšžœœœœ˜;Kšžœœœœ˜5šžœœœœ˜?Jšœœ2œ"™d—Jšžœœ#œœ˜IJšž œœ-œœ˜O—™Jšž œ˜šž œœœ ˜2J˜—š ž œœ7œœœœ˜lJšœQ™QJšœ*™*Jšœ™J˜—šžœœœ ˜/Jšœ™———™™ šžœœ œ ˜FK˜—šž œœœ ˜EKšœ/™/K˜—šžœœ#œ ˜OK˜——™ šžœœœ˜@šœ2™2KšœU™U—J˜———™K˜Kš œœœ7œœœ˜nš œœœRœ œ˜‰J™%J™5—Kšž œœœœ˜9šž œ˜K™.K™&KšœP™P—š žœœCœœ5œ˜›K™O—šž œœœ œ˜@K™7——™ K˜Kšœ˜Kšœ œœœ˜Bšœ œœ8œ˜gK˜—šž œ ˜K™'™(J™IK™&J™——šžœ ˜Jšœ(Οbœ™E—šžœ ˜"Jšœ7™7—šžœ ˜"Jšœ7™7——™K˜Kšœ œœœ˜Mšžœ˜K™*™+JšœA™AK™&J™——šžœ˜Kšœ&™&Kšœ;™;—šžœ˜(Jšœ:™:——™šœ™Kšœ˜Kšœ œœ˜#šœœœ˜Kšœ ˜ Kšœ˜—Kšžœœ7œ˜k—™ Kšœ˜Kšœ œœ˜'šœœœ˜Kšœ˜Kšœ˜—Kšžœœ'œ˜a—™Kšœ˜Kšœœœ ˜šœ œœ˜Kšœ˜Kšœ˜—Kšž œœ1œ˜\—™šžœœ7œ˜cKšœ&™&KšœE™EK™———™$™šœx™xM™—šœ œ˜K˜—Kšžœœ-œ ˜q—™Kšœ˜Kšœœœ ˜šœ œœ˜Kšœœ˜ Jšœ œœœ ˜,Jšœ˜Jšœd™dJ™—šž œœœœ˜KJšœΙ™ΙJšœ/™/J™———™ šžœ˜"K™+K™—šžœ˜(K™(K™—šžœ˜K˜—šž œœœœ˜7K˜—šž œœœœ˜@K˜—šžœœ"œœ˜OK˜—šžœ˜$K™3K™—šžœœCœœ˜^Kšœœ:™FK™——Jšœ˜K™—…—Ζ0