DIRECTORY Imager, RatNums, EuclideanGraphs, ConvexEuclideanGraphs, ConvexCombiner, CombinePoly; CombinePolyImpl: CEDAR PROGRAM IMPORTS EuclideanGraphs, ConvexEuclideanGraphs, ConvexCombiner EXPORTS CombinePoly = BEGIN OPEN RN: RatNums, EG: EuclideanGraphs, CEG: ConvexEuclideanGraphs, CC: ConvexCombiner, CombinePoly; PointList: TYPE = LIST OF Point; -- Used to reverse order of points on Imager.Trajectory, and omit last (repeats first) point. PointGeneratorObj: PUBLIC TYPE = RECORD [ points: PointList ]; RegionGeneratorObj: PUBLIC TYPE = RECORD [ regions: CEG.RegionList ]; CreateDatabase: PUBLIC PROC [] RETURNS [dbid: DBID] ~ { EG.vertexIndex _ 1; dbid _ NIL; }; CreatePolygon: PUBLIC PROC [point1, point2: Point, clientData: REF] RETURNS [polyID: PolyID] ~ { ratPoint1: EG.Point _ EG.MakePointFromReals[point1.x, point1.y]; ratPoint2: EG.Point _ EG.MakePointFromReals[point2.x, point2.y]; entryPrior, entryNext: EG.Vertex _ NIL; [entryPrior, entryNext] _ CEG.AddVertexToPolygon [entryPrior, entryNext, ratPoint1, clientData]; [entryPrior, entryNext] _ CEG.AddVertexToPolygon [entryPrior, entryNext, ratPoint2, clientData]; RETURN[entryNext]; }; AddPointToPolygon: PUBLIC PROC [point: Point, polyid: PolyID] ~ { ratPoint: EG.Point _ EG.MakePointFromReals[point.x, point.y]; entryNext: EG.Vertex _ polyid; entryPrior: EG.Vertex _ CEG.SpecialPreviousOutlineVertex[entryNext]; thisToNext, nextToThis: EG.Adjacency; exitPrior: EG.Vertex; clientData: REF; IF polyid=NIL OR polyid.adjacentVertices=NIL THEN ERROR; -- AddPointToPolygon can only be called on a polygon that already has at least two vertices; [thisToNext, nextToThis] _ EG.FindAdjacency[entryPrior, entryNext]; clientData _ CEG.GetEdgeClientData[thisToNext]; [exitPrior, entryNext] _ CEG.AddVertexToPolygon[entryPrior, entryNext, ratPoint, clientData]; RETURN; }; PolygonIntoDatabase: PUBLIC PROC [polyID: PolyID, dbid: DBID, overlapHandler: RegionOverlapProc, glueHandler: RegionGlueProc] RETURNS[newDbid: DBID] ~ { startToEnd, endToStart: EG.Adjacency; inputClientData: REF; previous: EG.Vertex _ CEG.SpecialPreviousOutlineVertex[polyID]; [startToEnd, endToStart] _ EG.FindAdjacency[previous, polyID]; inputClientData _ CEG.GetEdgeClientData[startToEnd]; newDbid _ CC.Combiner[dbid, polyID, inputClientData, overlapHandler]; }; MaximalRegions: PUBLIC PROC [dbid: DBID, isA: IsAProc] RETURNS [regionGen: RegionGenerator] ~ { regionGen _ NEW[RegionGeneratorObj _ [regions: CEG.MaximalRegions[dbid, isA] ] ]; RETURN[regionGen]; }; TrajectoryToPointList: PROC [traj: Imager.Trajectory] RETURNS [list: PointList _ NIL] ~ { point: Point; WHILE traj.prev#NIL DO -- omit last point point.x _ traj.lp.x; point.y _ traj.lp.y; list _ CONS[point, list]; traj _ traj.prev; ENDLOOP; }; NextPoint: PUBLIC PROC [pointGen: PointGenerator] RETURNS [pointAndDone: PointAndDone] ~ { WHILE pointGen.points#NIL DO nextPoint: Point _ pointGen.points.first; pointGen.points _ pointGen.points.rest; RETURN[NEW[PointAndDoneRec _ [ point: nextPoint, done: FALSE ] ] ]; ENDLOOP; RETURN[NEW[PointAndDoneRec _ [ point: [0., 0.], done: TRUE ] ] ]; }; NextRegion: PUBLIC PROC [regionGen: RegionGenerator] RETURNS [outlineHolesDataAndDone: OutlineHolesDataAndDone] ~ { WHILE regionGen.regions#NIL DO nextRegion: CEG.Region _ regionGen.regions.first; regionGen.regions _ regionGen.regions.rest; RETURN[NEW[OutlineHolesDataAndDoneRec _ [ outline: NEW[PointGeneratorObj _ [points: TrajectoryToPointList[nextRegion.outline] ] ], holes: (IF nextRegion.holes=NIL THEN NIL ELSE NEW[RegionGeneratorObj _ [regions: nextRegion.holes] ] ), data: nextRegion.clientData, done: FALSE ] ] ]; ENDLOOP; RETURN[NEW[OutlineHolesDataAndDoneRec _ [ outline: NIL, holes: NIL, data: NIL, done: TRUE ] ] ]; }; END. τCombinePolyImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Arnon on February 14, 1986 12:07:11 pm PST Pier, June 2, 1986 2:45:44 pm PDT CC.SimpleCleaner[newDbid, glueHandler]; -- currently disabled Κ°˜Jšœ™Icodešœ Οmœ1™<šœ9™9K™!—K™šΟk ˜ K˜Kšœ˜Jšœ˜Jšœ˜Jšœ˜Kšœ ˜ —K˜head2šœžœž˜Jšžœ7˜>Jšžœ ˜J˜—Kš œžœžœžœ žœžœžœ˜kK˜Kšœ žœžœžœΟc^˜K˜šœžœžœžœ˜)Kšœ˜K˜K˜—šœžœžœžœ˜*Kšœ žœ ˜K˜K˜—š Οnœžœžœžœžœ˜7Kšžœ˜Kšœžœ˜ K˜—K˜š  œž œ%žœžœ˜`Kšœ žœ žœ(˜@Kšœ žœ žœ(˜@Kšœžœ žœ˜'Jšœžœ0˜`Jšœžœ0˜`Jšžœ ˜J˜K˜—š œžœžœ#˜AKšœ žœ žœ&˜=Kšœ žœ˜Kšœ žœ žœ)˜DKšœžœ ˜%Kšœ žœ˜Kšœ žœ˜Kš žœžœžœžœžœžœŸ\˜•Kšœžœ&˜CKšœ žœ˜/Kšœžœ.˜]Kšžœ˜K˜K˜K˜—š  œž œžœBžœ žœ˜˜Jšœžœ ˜%Jšœžœ˜Jšœ žœ žœ&˜?Jšœžœ!˜>Jšœžœ˜4Jšœ žœ:˜FJšžœ<™>J˜K˜—š  œžœžœžœžœ!˜_Kšœ žœ žœ˜QJšžœ ˜J˜K˜—š œžœžœžœ˜YK˜ šžœ žœžœŸ˜)K˜*Kšœžœ!˜,Kšžœ˜—K˜K˜—š  œžœžœžœ!˜Zšžœž˜Kšœ)˜)Kšœ'˜'šžœžœ˜Kšœ˜Kšœž˜ K˜—Kšžœ˜—šžœžœ˜Kšœ˜Kšœž˜ K˜—K˜—K˜š  œžœžœžœ7˜sšžœž˜Kšœ žœ"˜1Kšœ+˜+šžœžœ˜)Kšœ žœL˜XKš œžœžœžœžœžœžœ6˜gKšœ˜Kšœž˜ K˜—Jšžœ˜—šžœžœ˜)Kšœ žœ˜ Kšœžœ˜ Kšœžœ˜ Kšœž˜ K˜—˜K˜——Kšžœ˜J˜—…—’F