GGBoundBox.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by Bier on December 28, 1986 2:21:08 pm PST
Contents: Procedures for creating and combining bounding boxes for refresh efficiency.
Pier, July 29, 1986 11:33:03 am PDT
Kurlander August 23, 1986 5:08:14 pm PDT
DIRECTORY
GGBasicTypes, GGModelTypes, GGSegmentTypes, Imager, ImagerTransformation;
GGBoundBox: CEDAR DEFINITIONS =
BEGIN
BoundBox: TYPE = GGModelTypes.BoundBox;
Circle: TYPE = GGBasicTypes.Circle;
Line: TYPE = GGBasicTypes.Line;
Outline: TYPE = GGModelTypes.Outline;
Point: TYPE = GGBasicTypes.Point;
Scene: TYPE = GGModelTypes.Scene;
Segment: TYPE = GGSegmentTypes.Segment;
Sequence: TYPE = GGModelTypes.Sequence;
Slice: TYPE = GGModelTypes.Slice;
Traj: TYPE = GGModelTypes.Traj;
Vector: TYPE = GGBasicTypes.Vector;
emptyBoundBox: BoundBox; -- [loX, loY: LargestNumber, hiX, hiY: SmallestNormalizedNumber]
Routines which create a new boundBox.
CreateBoundBox: PROC [loX, loY, hiX, hiY: REAL, null: BOOLFALSE, infinite: BOOLFALSE] RETURNS [bBox: BoundBox];
NullBoundBox: PROC [] RETURNS [bBox: BoundBox];
CopyBoundBox: PROC [bBox: BoundBox] RETURNS [copy: BoundBox];
BoundBoxOfBoxes: PROC [list: LIST OF BoundBox] RETURNS [bigBox: BoundBox];
BoundBoxOfBoundBox: PROC [box: BoundBox, transform: ImagerTransformation.Transformation] RETURNS [newBox: BoundBox];
BoundBoxFromRectangle: PROC [rect: Imager.Rectangle] RETURNS [bBox: BoundBox];
RectangleFromBoundBox: PROC [bBox: BoundBox] RETURNS [rect: Imager.Rectangle];
BoundBoxOfPixelArray: PROC [pa: Imager.PixelArray] RETURNS [bBox: BoundBox];
Computes a bounding box in units of screen dots for the given pixel array. The lower left corner will be [0,0].
BoundBoxOfBitMap: PROC [base: LONG POINTER, wordsPerLine: NAT,
sMin, fMin, sSize, fSize: NAT, tx, ty: INTEGER ← 0] RETURNS [bBox: BoundBox];
Computes a bounding box in units of screen dots for the given bit map. The lower left corner will be [0,0].
Routines which modify an existing boundBox.
AllowForJoints: PROC [box: BoundBox];
EnlargeByBox: PROC [bBox: BoundBox, by: BoundBox];
EnlargeByPoint: PROC [bBox: BoundBox, point: Point];
EnlargeByVector: PROC [bBox: BoundBox, vector: Vector];
Update bBox to be the bounding box of itself and itself offset by vector. Useful to take drop shadows into account, for instance.
EnlargeByOffset: PROC [bBox: BoundBox, offset: REAL];
Enlarges bBox to include a border of width offset around bBox. Useful to allow for stroke width of a segment, for instance.
UpdateBoundBox: PROC [bBox: BoundBox, loX, loY, hiX, hiY: REAL];
UpdateBoundBoxOfBoundBox: PROC [bBox: BoundBox, localBox: BoundBox, transform: ImagerTransformation.Transformation];
UpdateCopyBoundBox: PROC [bBox: BoundBox, from: BoundBox];
Modifies the numerical fields of bBox.
Routines which operate on BoundBoxObj (which is presumably allocated on the execution stack).
PointIsInBox: PROC [test: Point, box: GGBasicTypes.BoundBoxObj] RETURNS [BOOL];
Routines which require knowledge of Gargoyle data structures.
Used by GGAlign to compute hit testing boxes before invoking gravity.
BoundBoxOfSelected: PROC [scene: Scene, selectClass: GGSegmentTypes.SelectionClass ← normal] RETURNS [bigBox: BoundBox];
BoundBoxOfMoving: PROC [scene: Scene, selectClass: GGSegmentTypes.SelectionClass ← normal] RETURNS [bigBox: BoundBox];
Drawing BoundBoxes.
DrawBoundBox: PROC [dc: Imager.Context, bBox: BoundBox];
EraseWithinBoundBox: PROC [dc: Imager.Context, bBox: BoundBox];
Clip: PROC [dc: Imager.Context, bBox: BoundBox];
Hit Testing BoundBoxes.
MaskArray: TYPE = ARRAY[0..4) OF BOOL;
NearestPoint: PROC [bBox: BoundBox, testPoint: Point, tolerance: REAL ← 1E6, mask: MaskArray ← ALL[TRUE]] RETURNS [bestDist: REAL, bestJoint: NAT, bestPoint: Point, success: BOOL];
NearestSegment: PROC [bBox: BoundBox, testPoint: Point, tolerance: REAL ← 1E6, mask: MaskArray ← ALL[TRUE]] RETURNS [bestDist: REAL, bestSeg: NAT, bestPoint: Point, success: BOOL];
LineMeetsBoundBox: PROC [bBox: BoundBox, line: Line] RETURNS [points: LIST OF Point, pointCount: NAT];
Find the intersections of the given line with bBox. pointCount will be at most 2.
CircleMeetsBoundBox: PROC [bBox: BoundBox, circle: Circle] RETURNS [points: LIST OF Point, pointCount: NAT];
Find the intersections of the given circle with bBox. pointCount will be at most 8.
END.