-- ChipOrient.mesa
-- last edited by E. McCreight, December 15, 1982 6:16 PM
-- written by E. McCreight, February 22, 1982 10:00 AM
DIRECTORY
InlineDefs,
ppdefs;
ChipOrient: DEFINITIONS IMPORTS InlineDefs =
BEGIN OPEN ppdefs;
MapRect: PROC [itemInCell: Rect, cellSize: Point,
cellInstOrient: orientationIndex, cellInstPos: Point ← [0,0]]
RETURNS [itemInWorld: Rect];
-- Given an item in a prototype cell, and the
-- size of the prototype cell, both in "cell" co-ordinates, and
-- the position and orientation index of an instance of that cell in "world"
-- co-ordinates, this procedure returns the world
-- co-ordinates of the instance of the item.
DeMapRect: PROC [itemInWorld: Rect, cellSize: Point,
cellInstOrient: orientationIndex, cellInstPos: Point ← [0,0]]
RETURNS [itemInCell: Rect];
-- Given an item in world co-ordinates, and the
-- size of a prototype cell, both in "cell" co-ordinates, and
-- the position and orientation index of an instance of that cell in "world"
-- co-ordinates, this procedure returns the cell prototype
-- co-ordinates of that item.
ComposeOrient: PROC [
itemOrientInCell, cellOrientInWorld: orientationIndex]
RETURNS [itemOrientInWorld: orientationIndex];
-- This procedure produces the composite orientation
-- obtained by first doing itemInCell and then
-- doing cellInWorld.
InverseOrient: PROC [orient: orientationIndex]
RETURNS [inverse: orientationIndex];
-- For all orientationIndexes o1, ComposeOrient[o1, InverseOrient[o1]] = 0.
DecomposeOrient: PROCEDURE[
itemOrientInWorld, cellOrientInWorld: orientationIndex]
RETURNS [itemOrientInCell: orientationIndex];
-- For all orientationIndexes o1 and o2,
-- DecomposeOrient[cellOrientInWorld: o1, itemOrientInWorld:
-- ComposeOrient[cellOrientInWorld: o1, itemOrientInCell: o2]] = o2.
RefPt: PROC [r: Rect] RETURNS [Point];
-- This procedure returns a lambda-grid point near the
-- center of the rectangle.
NormalizeList: PROC [lp: listPtr, origin: Point ← [0,0]]
RETURNS [size, offset: Point];
-- This procedure normalizes the list so that some element
-- starts at x=origin.x and some element starts at y=origin.y.
-- new ← old+offset.
BoundingRect: PROC [lp: listPtr] RETURNS [r: Rect];
Rot90: PROC [orient: ppdefs.orientationIndex] RETURNS [[0..1]] = INLINE
{RETURN[IF InlineDefs.BITAND[orient, 4]=0 THEN 0 ELSE 1]};
Size: PROC [size: ppdefs.Point, orient: ppdefs.orientationIndex]
RETURNS [ppdefs.Point] = INLINE
{RETURN[IF InlineDefs.BITAND[orient, 4]=0 THEN size ELSE
[x: size.y, y: size.x]]};
DecomposeRect: PROC [r, test: ppdefs.Rect, rInsideTest,
rOutsideTest: PROC[ppdefs.Rect]];
-- calls rInsideTest and rOutsideTest on a set of up to 5 rectangles
-- that are mutually exclusive and exhaust r.
END. -- of ChipOrient