DIRECTORY Imager, Pipal, PipalInt, Real; PipalReal: CEDAR DEFINITIONS = BEGIN Number: TYPE = REAL; infinity: Number = Real.LargestNumber/16; Vector: TYPE = Imager.VEC; Position: TYPE = Vector; -- alias when a Vector expresses a position Size: TYPE = Vector; -- alias when a Vector expresses a size zeroVector: Vector = Imager.zeroVEC; 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]; Transformation: TYPE = Imager.Transformation; VectorToRope: PROC [v: Vector] RETURNS [Pipal.ROPE]; RectangleToRope: PROC [r: Rectangle] 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]; Apply: PROC [t1, t2: Transformation]; CreateTransformation: PROC RETURNS [Transformation]; CopyTransformation: PROC [t: Transformation] RETURNS [Transformation]; DestroyTransformation: PROC [t: Transformation]; EqualTransformation: PROC [t1, t2: Transformation] RETURNS [BOOL]; 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; UseIntSize: SizeProc; 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]; TransformObject: PROC [transformation: Transformation, child: Pipal.Object] RETURNS [Pipal.Object]; IntToRealVector: PROC [v: PipalInt.Vector] RETURNS [Vector]; IntToRealRectangle: PROC [r: PipalInt.Rectangle] RETURNS [Rectangle]; IntToRealTransformation: PROC [t: PipalInt.Transformation] RETURNS [Transformation]; ApplyRealInt: PROC [t1: Transformation, t2: PipalInt.Transformation]; END. ΚPipalReal.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Louis Monier January 14, 1988 12:56:05 pm PST Bertrand Serlet May 17, 1988 2:19:30 pm PDT Barth, January 26, 1988 11:40:48 am PST Theory Type definitions and basic operations for Pipal real data types. Real types are used for layout and schematics painting, or for capture of device independent data. Refer to Imager documentation for more information on the geometrical data structures. 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. 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]] Expensive: a new Transformation is created. Equivalent to t1^ _ Compose[t1, IntToRealTransformation[t2]]^. Careful: t1 is modified in place. Creation, Destruction and Equality Creates an identity transformation. Returns a copy of t. Asserts the Transformation is available for re-use. Returns TRUE if t1 and t2 are close. Enumeration Method transformation should not be modified at exit. Enumerates all children of an object. There is an implicit overlay to compose all children. In order to be efficient, it is OK to modify transformation in place. However, at exit, transformation should be the same as at entry, even if quit. Applies the enumerate method. No enumerate method => all children are enumerated using PipalInt.Enumerate. 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. nthTrans is a new transformation. 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. Calls PipalInt.ObjectSize. Geometrical Classes General Transform Creates the densest object possible. Might even return child itself if the transformation is the identity. Coercion from PipalInt Types Equivalent to t1^ _ Compose[t1, IntToRealTransformation[t2]]^. Careful: t1 is modified in place. ΚΎ˜– "Cedar" stylešœ™Jšœ<™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—šœ+™+K™——šžœœ˜%Kšœ>™>Kšœ!™!——™"šžœœœ˜4J™#J˜—šžœœœ˜FK™J™—šžœœ˜0Jšœ3™3J™—šžœœœœ˜BJšœœ™$———™K˜š œœœ7œœœ˜nKšœ.™.—š œœœMœœœ˜„J™%J™5KšœPΟbœ1  œ™•—Kšž œœœœ˜9šž œ˜K™KšœL™LKšœP™P—š žœœ>œœ5œ˜–K™OKšœ!™!—šž œœœ œ˜@K™7——™ K˜Kšœ˜Kšœ œœœ˜Bšœ œœ8œ˜gK˜—šž œ ˜K™'™(J™IK™&J™——šžœ ˜Jšœ( œ™E—šžœ ˜"Jšœ7™7—šžœ ˜"Jšœ7™7—šž œ ˜Jšœ™——™šœ™Kšœ˜Kšœ œœ˜#šœœœ˜Kšœ ˜ Kšœ˜K˜—šžœœ7œ˜kK˜—šžœœ7œ˜cKšœ&™&KšœE™E———™šžœœœ ˜™>Kšœ!™!K™——Jšœ˜J˜—…—'¦