-- Area.mesa
-- Last changed by Doug Wyatt, September 12, 1980 5:22 PM

DIRECTORY
Vector USING [Vec];

Area: DEFINITIONS = {

Rec: TYPE = RECORD[ll,ur: Vector.Vec];

Outside: PROC[a,b: Rec] RETURNS[BOOLEAN] = INLINE {
RETURN[a.ur.x<=b.ll.x OR a.ur.y<=b.ll.y
OR a.ll.x>=b.ur.x OR a.ll.y>=b.ur.y]
};

Inside: PROC[a,b: Rec] RETURNS[BOOLEAN] = INLINE {
RETURN[a.ll.x>=b.ll.x AND a.ll.y>=b.ll.y
AND a.ur.x<=b.ur.x AND a.ur.y<=b.ur.y]
};

Handle: TYPE = LONG POINTER TO Object;

Vertices: PROC[self: Handle, Proc: PROC[Vector.Vec]] = INLINE {
self.procs.Vertices[self,Proc]
};
Rectangle: PROC[self: Handle] RETURNS[Rec] = INLINE {
RETURN[self.procs.Rectangle[self]]
};
Rectangular: PROC[self: Handle] RETURNS[BOOLEAN] = INLINE {
RETURN[self.rect]
};
Free: PROC[selfPtr: LONG POINTER TO Handle] = INLINE {
self: Handle=selfPtr↑; selfPtr↑←NIL; self.procs.Free[self]
};

Object: PRIVATE TYPE = RECORD [
procs: LONG POINTER TO READONLY Procs,
data: LONG POINTER TO Data,
rect: BOOLEAN
];
Procs: PRIVATE TYPE = RECORD [
Vertices: PROC[self: Handle, Proc: PROC[Vector.Vec]],
Rectangle: PROC[self: Handle] RETURNS[Rec],
Free: PROC[self: Handle]
];
Data: PRIVATE TYPE;

}.