CDBasicsImpl.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 3, 1983 4:26 pm
Last Edited by Christian Jacobi, September 19, 1985 4:31:49 am PDT
DecomposeRect:
PUBLIC
PROC [r, test:
CD.Rect, inside, outside:
PROC[
CD.Rect]←Skip] =
BEGIN
IF r.x1<test.x1
THEN {
outside[[x1: r.x1, y1: r.y1, x2: MIN[r.x2, test.x1], y2: r.y2]];
IF r.x2<test.x1 THEN RETURN;
};
IF r.y1<test.y1
THEN {
outside[[x1: MAX[test.x1, r.x1], y1: r.y1, x2: r.x2, y2: MIN[r.y2, test.y1]]];
IF r.y2<test.y1 THEN RETURN;
};
IF test.y2<r.y2
THEN {
outside[[x1:
MAX[test.x1, r.x1], y1:
MAX[test.y2, r.y1], x2: r.x2,
y2: r.y2]];
IF test.y2<r.y1 THEN RETURN;
};
IF test.x2<r.x2
THEN {
outside[[x1:
MAX[test.x2, r.x1], y1:
MAX[test.y1, r.y1], x2: r.x2,
y2: MIN[r.y2, test.y2]]];
IF test.x2<r.x1 THEN RETURN;
};
inside[[x1: MAX[test.x1, r.x1], y1: MAX[test.y1, r.y1], x2: MIN[test.x2, r.x2], y2: MIN[test.y2, r.y2]]];
END;