-- CGReducer.mesa -- Last changed by Doug Wyatt, August 23, 1982 3:32 pm DIRECTORY CGArea USING [Ref], GraphicsBasic USING [Vec]; CGReducer: CEDAR DEFINITIONS = { Vec: TYPE = GraphicsBasic.Vec; Ref: TYPE = REF Rep; Rep: TYPE = RECORD [ size: NAT, -- number of available edges edges: Edges, -- array of edges queue: Queue, -- priority queue for edges qsize: NAT, -- priority queue size save: Vec, -- previous vertex first: Vec, -- first vertex of current boundary closed: BOOLEAN, -- if TRUE, boundary has been closed free: EdgeIndex -- head of list of free edges ]; EdgeIndex: TYPE = NAT; nil: EdgeIndex = 0; Tag: TYPE = [0..3]; Edge: TYPE = REF EdgeRep; EdgeRep: TYPE = RECORD [ this: EdgeIndex, -- index of this edge next: EdgeIndex, -- index of next edge in list up: BOOLEAN, -- if TRUE, edge was defined with increasing y vert: BOOLEAN, -- if TRUE, xbot = xtop AND slope = 0 line: BOOLEAN _ FALSE, -- if TRUE, this edge is a degenerate line lastR: BOOLEAN _ FALSE, -- if TRUE, right side was inside on previous pass tag: Tag, -- identifies figure associated with this edge xbot,ybot: REAL, -- lower endpoint xtop,ytop: REAL, -- upper endpoint a,b,c: REAL, -- line equation coefficients slope: REAL, -- dx/dy yemit: REAL _ 0 -- bottom of visible portion to emit ]; Edges: TYPE = REF EdgesRep; EdgesRep: TYPE = RECORD[SEQUENCE space: EdgeIndex OF Edge]; Queue: TYPE = REF QueueRep; QueueRep: TYPE = RECORD[SEQUENCE space: NAT OF EdgeIndex]; Error: ERROR[type: ErrorType]; ErrorType: TYPE = {bug}; New: PROC[size: NAT _ 0] RETURNS[Ref]; -- create a new reducer object with given initial size Clip: PROC[self: Ref, edgeL,edgeR: Edge]; -- enter a pair of clipping edges Vertex: PROC[self: Ref, v: Vec]; -- enter a vertex of the figure Close: PROC[self: Ref]; -- close a boundary of the figure Rectangle: PROC[self: Ref, q: Vec]; -- form a closed rectangular boundary, -- with previous vertex and q as corners Generate: PROC[self: Ref, area: CGArea.Ref, exclude: BOOLEAN _ FALSE, oddwrap: BOOLEAN _ FALSE]; -- generate the intersection of the clipper and the current figure }.