CombinePoly.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on February 6, 1986 1:55:17 pm PST
Contents: Client interface for the Arnon and Greene Combiners.
Pier, June 2, 1986 2:42:35 pm PDT
DIRECTORY
Imager,
ConvexCombiner;
CombinePoly: CEDAR DEFINITIONS
= BEGIN
DBID: TYPE = ConvexCombiner.Vertex;
PolyID: TYPE = ConvexCombiner.Vertex;
Point: TYPE = Imager.VEC;
PointGenerator: TYPE = REF PointGeneratorObj;
PointGeneratorObj: TYPE;
RegionGenerator: TYPE = REF RegionGeneratorObj;
RegionGeneratorObj: TYPE;
RegionOverlapProc: TYPE = ConvexCombiner.ClientDataCombiner;
ConvexCombiner.ClientDataCombiner: TYPE = PROC[currentClientdata, inputClientdata: REF] RETURNS [resultClientData: REF];
This procedure is called whenever a new polygon overlaps a region already in the database. resultData becomes the client data for intersection region.
The order of arguments is important: currentRegionData is the client data for the region already in the database, newRegionData is the data for the new region coming in.
If either arg is NIL, then return the other unchanged.
RegionGlueProc: TYPE = ConvexCombiner.ClientDataEqual;
This procedure is called whenever the combiner would like to glue two adjacent regions together to form a single region (either for garbage collection regions or in order to handle a client request for maximally sized regions). If gluing is not allowed, the proc should return NIL.
IsAProc: TYPE = ConvexCombiner.IsAProc;
The client must provide one such procedure for each query of the database. For instance, if the client wants maximally sized regions which are blue, the client should pass in an IsAProc which returns TRUE if clientData belongs to a blue region and FALSE otherwise.
CreateDatabase: PROC [] RETURNS [dbid: DBID];
CreatePolygon: PROC [point1, point2: Point, clientData: REF] RETURNS [polyID: PolyID];
[point1, point2] is the initial edge of a polygon whose interior lies to the left of vector [point1, point2], and has associated clientData.
AddPointToPolygon: PROC [point: Point, polyid: PolyID];
Currently it is assumed that the points added to a polygon are the counterclockwise-ordered vertices of a convex polygon
PolygonIntoDatabase: PROC [polyID: PolyID, dbid: DBID, overlapHandler: RegionOverlapProc, glueHandler: RegionGlueProc] RETURNS[newDbid: DBID];
Called by the client when all the points have been added to the polygon which are going to be added. The polygon pointed to by polyID must have at least three vertices. It is added to the database pointed to by dbid.
Currently polygons must be closed (i.e. represent a finite area); open polygons (representing a path of edges) are not allowed.
Self-intersecting polygons currently not allowed.
MaximalRegions: PROC [dbid: DBID, isA: IsAProc] RETURNS [regionGen: RegionGenerator];
PointAndDone: TYPE = REF PointAndDoneRec;
PointAndDoneRec: TYPE = RECORD [
point: Point,
done: BOOL
];
NextPoint: PROC [pointGen: PointGenerator] RETURNS [pointAndDone: PointAndDone];
Returns points on a region outline in counterclockwise order with respect to region interior.
OutlineHolesDataAndDone: TYPE = REF OutlineHolesDataAndDoneRec;
OutlineHolesDataAndDoneRec: TYPE = RECORD [
outline: PointGenerator,
holes: RegionGenerator,
data: REF,
done: BOOL
];
NextRegion: PROC [regionGen: RegionGenerator] RETURNS [outlineHolesDataAndDone: OutlineHolesDataAndDone];
Regions returned in no particular order.
END.