DEFINITION MODULE PolysysDS;

(*
    Title    :  Polysys Permanent Data Structures
    LastEdit :  Thu Feb 23 13:51:10 1984
    Author   :  LDS
    Acorn Computers VLSI Design Aids Group
*)

FROM SYSTEM     IMPORT ADDRESS;
FROM TwoDthings IMPORT Point;

EXPORT QUALIFIED BBox, pEdge, pSheet, SheetFlag, SheetFlags, opensheet,
                 CurPolygon, Debugging, push, pop, copysheet, copypolygon,
                 copytfmd, ScanDS;

CONST  pStackDepth = 50;

TYPE       BBox = RECORD
                    ll, ur : Point;
                  END;
                  
          pEdge = POINTER TO Edge;
         pSheet = POINTER TO Sheet;

           Edge = RECORD
                    tail : Point;
           intersections : ADDRESS;  (* points to various temp structures *)
                    head : pEdge;
                  END;

     (* N.B. Order Unoriented, CCW, CW is assumed later by Inverse[] *)
      SheetFlag = (Unoriented, CCW, CW,
                   Cut, Enclosed,
		   ReSort,
                   Unwanted, Wanted, Allwanted,
                   BigSheet, BigPolygon);
		   
     SheetFlags = SET OF SheetFlag;
     
          Sheet = RECORD
                    bb : BBox;
                 edges : pEdge;
             daughters : pSheet;
               brother : pSheet;
	         flags : SheetFlags;
                  END;
		  
VAR         Tos : INTEGER;		  
         pStack : ARRAY [0..pStackDepth] OF pSheet;
      opensheet : pSheet;
     CurPolygon : pSheet;
      Debugging : BOOLEAN;

PROCEDURE push(p : pSheet);
PROCEDURE pop(VAR p : pSheet);
PROCEDURE copysheet(s : pSheet) : pSheet;
PROCEDURE copypolygon(p : pSheet) : pSheet;
PROCEDURE ScanDS(A : ADDRESS;  type, offset : CARDINAL);
PROCEDURE copytfmd(p : pSheet;
                   swapXandY, negX, negY : BOOLEAN;  tx, ty : INTEGER);
END PolysysDS.
