TestPipal.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Bertrand Serlet March 7, 1988 3:58:31 pm PST
DIRECTORY Imager, Pipal, PipalInt, PipalMask, PipalPaint, PipalReal;
TestPipal:
CEDAR
PROGRAM
IMPORTS Imager, PipalInt, PipalMask, PipalPaint, PipalReal =
IntOperations:
PROC ~ {
OPEN PipalInt;
v1: Vector = [3, -5];
v2: Vector = [7, 13];
i1: Interval = [3, -5];
i2: Interval = [7, 13];
r1: Rectangle = [v1, v2];
r2: Rectangle = [[2, 3], [4, 7]];
t1: Transformation = [v1, rotate270X];
t2: Transformation = [v2, rotate180X];
IF Add[Sub[Add[v1, v2], v1], Neg[v2]] # zeroVector THEN ERROR;
IF Min[v1, Max[v1, v2]] # v1 THEN ERROR;
IF NOT IsEmptySize[zeroVector] THEN ERROR;
IF IsEmptySize[v2] THEN ERROR;
IF DoIntervalsIntersect[i1, i2] THEN ERROR;
IF IsInsideInterval[i2, i1] THEN ERROR;
IF NOT IsInsideInterval[i2, [8, -1]] THEN ERROR;
IF NOT IsInsideInterval[i1, i1] THEN ERROR;
IF IsInsideInterval[[infinity/2, -infinity], i1] THEN ERROR;
IF NOT IsInsideInterval[[-infinity/2, infinity], i1] THEN ERROR;
IF NOT IsInsideIntervalNumber[i2, 12] THEN ERROR;
IF NOT IsInsideIntervalNumber[i2, 20] THEN ERROR;
IF IsInsideIntervalNumber[i2, 21] THEN ERROR;
IF IsInsideIntervalNumber[[infinity/2, -infinity], 21] THEN ERROR;
IF NOT IsInsideIntervalNumber[[-infinity/2, infinity], 12] THEN ERROR;
IF Extend[Translate[r1, v2], 3]#Translate[Extend[r1, 3], v2] THEN ERROR;
IF IntersectBox[r1, r1]#r1 THEN ERROR;
IF BoundingBox[r1, r1]#r1 THEN ERROR;
IF IsEmptyRectangle[r1] THEN ERROR;
IF NOT IsEmptyRectangle[Extend[r1, -14]] THEN ERROR;
IF NOT DoRectanglesIntersect[r1, r1] THEN ERROR;
IF NOT IsInsideRectangle[r1, r1] THEN ERROR;
IF NOT IsInsideRectangle[r1, IntersectBox[r1, r2]] THEN ERROR;
IF NOT IsInsideRectangle[BoundingBox[r1, r2], r1] THEN ERROR;
IF NOT IsInsidePoint[r1, r1.base] THEN ERROR;
IF NOT IsInsidePoint[r1, Extremity[r1]] THEN ERROR;
[] ← DecomposeRect[r1, r2];
IF NOT IsInsidePoint[r1, Center[r1]] THEN ERROR;
IF IntersectBox[r1, fullRectangle]#r1 THEN ERROR;
IF BoundingBox[r1, emptyRectangle]#r1 THEN ERROR;
IF DoRectanglesIntersect[r1, emptyRectangle] THEN ERROR;
IF NOT DoRectanglesIntersect[r1, fullRectangle] THEN ERROR;
IF TransformVector[Compose[t1, t2], v1]#TransformVector[t1, TransformVector[t2, v1]] THEN ERROR;
IF TransformRectangle[t1, [zeroVector, v1]]#TransformBBox[t1, v1] THEN ERROR;
IF TransformRectangle[Compose[t1, t2], r1]#TransformRectangle[t1, TransformRectangle[t2, r1]] THEN ERROR;
};
RealOperations:
PROC ~ {
OPEN PipalReal;
v1: Vector = [3, -5];
v2: Vector = [7, 13];
i1: Interval = [3, -5];
i2: Interval = [7, 13];
r1: Rectangle = [v1, v2];
r2: Rectangle = [[2, 3], [4, 7]];
t1: Transformation = IntToRealTransformation[[[3, -5], rotate270X]];
t2: Transformation = IntToRealTransformation[[[7, 13], rotate180X]];
IF Add[Sub[Add[v1, v2], v1], Neg[v2]] # zeroVector THEN ERROR;
IF Min[v1, Max[v1, v2]] # v1 THEN ERROR;
IF NOT IsEmptySize[zeroVector] THEN ERROR;
IF IsEmptySize[v2] THEN ERROR;
IF DoIntervalsIntersect[i1, i2] THEN ERROR;
IF IsInsideInterval[i2, i1] THEN ERROR;
IF NOT IsInsideInterval[i2, [8, -1]] THEN ERROR;
IF NOT IsInsideInterval[i1, i1] THEN ERROR;
IF IsInsideInterval[[infinity/2, -infinity], i1] THEN ERROR;
IF NOT IsInsideInterval[[-infinity/2, infinity], i1] THEN ERROR;
IF NOT IsInsideIntervalNumber[i2, 12] THEN ERROR;
IF NOT IsInsideIntervalNumber[i2, 20] THEN ERROR;
IF IsInsideIntervalNumber[i2, 21] THEN ERROR;
IF NOT IsInsideIntervalNumber[[-infinity/2, infinity], 12] THEN ERROR;
IF Extend[Translate[r1, v2], 3]#Translate[Extend[r1, 3], v2] THEN ERROR;
IF IntersectBox[r1, r1]#r1 THEN ERROR;
IF BoundingBox[r1, r1]#r1 THEN ERROR;
IF IsEmptyRectangle[r1] THEN ERROR;
IF NOT IsEmptyRectangle[Extend[r1, -14]] THEN ERROR;
IF NOT DoRectanglesIntersect[r1, r1] THEN ERROR;
IF NOT IsInsideRectangle[r1, r1] THEN ERROR;
IF NOT IsInsideRectangle[r1, IntersectBox[r1, r2]] THEN ERROR;
IF NOT IsInsideRectangle[BoundingBox[r1, r2], r1] THEN ERROR;
IF NOT IsInsidePoint[r1, r1.base] THEN ERROR;
IF NOT IsInsidePoint[r1, Extremity[r1]] THEN ERROR;
[] ← DecomposeRect[r1, r2];
IF NOT IsInsidePoint[r1, Center[r1]] THEN ERROR;
IF IntersectBox[r1, fullRectangle]#r1 THEN ERROR;
IF BoundingBox[r1, emptyRectangle]#r1 THEN ERROR;
IF DoRectanglesIntersect[r1, emptyRectangle] THEN ERROR;
IF NOT DoRectanglesIntersect[r1, fullRectangle] THEN ERROR;
IF TransformVector[Compose[t1, t2], v1]#TransformVector[t1, TransformVector[t2, v1]] THEN ERROR;
IF TransformRectangle[t1, [zeroVector, v1]]#TransformBBox[t1, v1] THEN ERROR;
IF TransformRectangle[Compose[t1, t2], r1]#TransformRectangle[t1, TransformRectangle[t2, r1]] THEN ERROR;
};
AreaOperations:
PROC ~ {
OPEN PipalPaint;
Signature:
PROC [area: Area]
RETURNS [sig:
REAL ← 0] = {
transformation: PipalReal.Transformation ← PipalReal.CreateTransformation[];
SigRect: PipalReal.RectangleProc = {
sig ← sig + (rect.size.x+1)*(rect.size.y+1);
};
[] ← EnumerateArea[area, SigRect, transformation];
PipalReal.DestroyTransformation[transformation];
};
obj: Pipal.Object ← PipalMask.CreateBrick[[30, 50], Imager.MakeGray[0.5]];
bbox: PipalReal.Rectangle ← PipalReal.BBox[obj];
area: Area;
area1: Area ← ChildArea[obj, bboxChild];
area2: Area ← ChildArea[obj, edgesChild];
IF NOT IsEmptyArea[emptyArea] THEN ERROR;
IF IsEmptyArea[fullArea] THEN ERROR;
IF IsEmptyArea[area1] THEN ERROR;
IF Signature[IntersectArea[area1, area1]]#Signature[area1] THEN ERROR;
IF NOT IsEmptyArea[SubArea[area1, area1]] THEN ERROR;
IF NOT IsEmptyArea[SubArea[area1, fullArea]] THEN ERROR;
IF Signature[IntersectArea[fullArea, area1]]#Signature[area1] THEN ERROR;
IF NOT IsEmptyArea[IntersectArea[emptyArea, area1]] THEN ERROR;
IF Signature[SubArea[area1, emptyArea]]#Signature[area1] THEN ERROR;
IF NOT IsEmptyArea[IntersectArea[emptyArea, emptyArea]] THEN ERROR;
IF IsEmptyArea[area2] THEN ERROR;
IF NOT IsEmptyArea[SubArea[area2, area2]] THEN ERROR;
IF NOT IsEmptyArea[SubArea[area2, fullArea]] THEN ERROR;
IF Signature[IntersectArea[fullArea, area2]]#Signature[area2] THEN ERROR;
IF NOT IsEmptyArea[IntersectArea[emptyArea, area2]] THEN ERROR;
IF Signature[SubArea[area2, emptyArea]]#Signature[area2] THEN ERROR;
IF NOT IsEmptyArea[IntersectArea[emptyArea, emptyArea]] THEN ERROR;
area ← SubArea[area2, area2];
IF NOT IsEmptyArea[area] THEN ERROR;
area ← SubArea[area, area1];
IF NOT IsEmptyArea[area] THEN ERROR;
area ← SubArea[area, area1];
IF NOT IsEmptyArea[area] THEN ERROR;
};
END.