-- File CIFDrcNewList.mesa
-- Written by Dan Fitzpatrick and Martin Newell, September 1980
-- Last updated: March 24, 1981 2:55 PM
-- CIF Drc List Routines
DIRECTORY
CIFDrcNewListDefs: FROM "CIFDrcNewListDefs",
CIFDrcUtilsDefs: FROM "CIFDrcUtilsDefs" USING [FreeTrap,Trapezoid],
IntervalsDefs: FROM "IntervalsDefs" USING [InitIntervals,Insert,FreeIntervals, GetFirst,GetNext,GetHandleRecord,Node];
CIFDrcNewList: PROGRAM
IMPORTS CIFDrcUtilsDefs, IntervalsDefs
EXPORTS CIFDrcNewListDefs =
BEGIN OPEN CIFDrcNewListDefs, IntervalsDefs, CIFDrcUtilsDefs;
InitList: PUBLIC PROCEDURE[left,right: LONG INTEGER] =
BEGIN
xmin ← left;
xmax ← right;
FOR layer:CARDINAL IN [MinLayer..MaxLayer] DO
FOR swath:SwathType IN [bottom..top] DO
Swath[layer][swath] ← InitIntervals[xmin,xmax];
ENDLOOP;
ENDLOOP;
END;
InsertTrap:PUBLIC PROCEDURE [trap:Trapezoid,layer:CARDINAL,swath:SwathType] =
BEGIN
Insert[Swath[layer][swath],trap.minx,trap.maxx,trap];
END;
EmptyList:PUBLIC PROCEDURE [layer:CARDINAL] =
BEGIN
-- no-op ?
END;
StepSwaths:PUBLIC PROCEDURE [] =
BEGIN
FOR layer:CARDINAL IN [MinLayer..MaxLayer] DO
FreeIntervals[Swath[layer][bottom],FreeTrap];
Swath[layer][bottom] ← Swath[layer][middle];
Swath[layer][middle] ← Swath[layer][top];
Swath[layer][top] ← InitIntervals[xmin,xmax];
ENDLOOP;
END;
GenSwath: PUBLIC PROCEDURE [layer:CARDINAL, swath:SwathType,list:POINTER TO ListDescriptor] RETURNS[trap:Trapezoid] =
BEGIN
list.swath ← swath;
RETURN[GetFirst[Swath[layer][swath],xmin,xmax,@list.handle]];
END;
GetSwath: PUBLIC PROCEDURE [list:POINTER TO ListDescriptor] RETURNS[trap:Trapezoid] =
BEGIN
RETURN[GetNext[@(list.handle)]];
END;
GenLocal: PUBLIC PROCEDURE [minx,maxx:LONG INTEGER, layer:CARDINAL, list:POINTER TO ListDescriptor] RETURNS[trap:Trapezoid] =
BEGIN
list.swath ← bottom;
list.min ← minx;
list.max ← maxx;
list.layer ← layer;
trap ← GetFirst[Swath[layer][bottom],minx,maxx,@(list.handle)];
IF trap = NIL THEN {
trap ← GetFirst[Swath[list.layer][middle],list.min,list.max, @(list.handle)];
list.swath ← middle;
};
IF trap = NIL THEN {
trap ← GetFirst[Swath[list.layer][top],list.min,list.max, @(list.handle)];
list.swath ← top;
}
END;
GetLocal: PUBLIC PROCEDURE [list:POINTER TO ListDescriptor] RETURNS[trap:Trapezoid] =
BEGIN
trap ← GetNext[@(list.handle)];
IF trap = NIL AND list.swath = bottom THEN {
trap ← GetFirst[Swath[list.layer][middle],list.min,list.max, @(list.handle)];
list.swath ← middle;
};
IF trap = NIL AND list.swath = middle THEN {
trap ← GetFirst[Swath[list.layer][top],list.min,list.max, @(list.handle)];
list.swath ← top;
}
END;
MinLayer:CARDINAL = 0;
MaxLayer:CARDINAL = 7;
xmin,xmax: LONG INTEGER;
Swath: ARRAY [MinLayer..MaxLayer] OF ARRAY SwathType OF Node;
END.