ImagerScanConverter.mesa
Copyright Ó 1984, 1985, 1986, 1989, 1991 by Xerox Corporation. All rights reserved.
Michael Plass, August 16, 1991 5:15 pm PDT
Doug Wyatt, March 7, 1986 2:06:19 pm PST
DIRECTORY
ImagerPath USING [LineToProc, MoveToProc, PathProc],
ImagerSample USING [EdgeAction],
ImagerTransformation USING [Transformation],
SF USING [Box, BoxAction, BoxGenerator, maxBox];
ImagerScanConverter: CEDAR DEFINITIONS
~ BEGIN
PathProc: TYPE ~ ImagerPath.PathProc;
Transformation: TYPE ~ ImagerTransformation.Transformation;
Box: TYPE ~ SF.Box;
maxBox: Box ~ SF.maxBox;
BoxAction: TYPE ~ SF.BoxAction;
DevicePath: TYPE ~ REF DevicePathRep;
DevicePathRep: TYPE;
The DevicePath structure holds the (private) representation of the outline.
Create/Destroy
Create: PROC RETURNS [DevicePath];
Destroy: PROC [devicePath: DevicePath];
Asserts devicePath won't be used anymore.
Loading the outline
SetTolerance: PROC [devicePath: DevicePath, tolerance: REAL];
sets the tolerance field in the devicepath. This controls the accuracy of the scan conversion when calling SetPath with this DevicePath, and should be positive.
SetPath: PROC [devicePath: DevicePath, path: PathProc, transformation: Transformation ¬ NIL, clipBox: Box ¬ maxBox];
Loads an outline (described by the PathProc) into devicePath.
CreatePath: PROC [path: PathProc,
transformation: Transformation ¬ NIL,
clipBox: Box ¬ maxBox
] RETURNS [DevicePath];
Short for Create + SetPath
Loading the outline (continued)
Lower-level access to the workings of SetPath
Pair: TYPE ~ RECORD [s, f: REAL];
SetBounds: PROC [devicePath: DevicePath, box: SF.Box]; -- resets to null region
MoveTo: PROC [devicePath: DevicePath, pt: Pair];
LineTo: PROC [devicePath: DevicePath, pt: Pair];
ParTo: PROC [devicePath: DevicePath, p1, p2: Pair]; -- parabola
CurveTo: PROC [devicePath: DevicePath, p1, p2, p3: Pair]; -- cubic Bezier
ConicTo: PROC [devicePath: DevicePath, p1, p2: Pair, r: REAL]; -- conic section
Getting the scan-converted results
BoundingBox: PROC [devicePath: DevicePath, clipBox: Box ¬ maxBox] RETURNS [Box];
A tight bounding box, clipped to clipBox.
NumberOfBoxes: PROC [devicePath: DevicePath] RETURNS [INT];
Guaranteed to be an upper bound, should be close to the actual.
ConvertToBoxes: PROC [devicePath: DevicePath, oddWrap: BOOL ¬ FALSE,
clipBox: Box ¬ maxBox, boxAction: BoxAction];
This is the normal output mechanism; boxAction is called for each box of the region.
ConvertToManhattanPolygon: PROC [devicePath: DevicePath, oddWrap: BOOL ¬ FALSE, clipBox: Box ¬ maxBox] RETURNS [LIST OF Box];
Satisfies assertion for an ImagerManhattan.Polygon.
Monotone: PROC [devicePath: DevicePath] RETURNS [BOOL];
Says whether the area is a monotone region, and hence subject to rapid scan conversion.
GenerateEdges: PROC [devicePath: DevicePath, edgeAction: ImagerSample.EdgeAction];
Enumerates the edges, sorted by increasing sMin. Really useful just for monotone regions.
ObjectsFromPath: PROC [path: PathProc, clipBox: Box, objectProc: PROC [Box, SF.BoxGenerator], devicePath: DevicePath];
Makes a separate call to objectProc for each trajectory of the path. The Box passed to objectProc is a bounding box for the trajectory, and the BoxGenerator generates the individual boxes.
PathToLines: PROC [moveTo: ImagerPath.MoveToProc, lineTo: ImagerPath.LineToProc,
path: ImagerPath.PathProc, transformation: ImagerTransformation.Transformation ¬ NIL, tolerance: REAL];
approximates the supplied path by line segments, and maps out using the supplied moveTo and lineTo procs. If transformation is NIL, path coordinates will not be transformed. the tolerance parameter controls the accuracy of the approximation - it should be positive.
END.