DIRECTORY CDOrient, IP, IPBasicOps; IPBasicOpsImpl: CEDAR PROGRAM IMPORTS CDOrient, IPBasicOps EXPORTS IPBasicOps = BEGIN OPEN IPBasicOps; ETCombineFailed: PUBLIC ERROR = CODE; CTOrient: PUBLIC PROC[ct: CornerTypes, operation: IP.Orientation] RETURNS [CornerTypes] ={ ct _ CTRotate[ct, operation/2]; IF CDOrient.IncludesMirrorX[operation] THEN RETURN [CTMirror[ct, ver]] ELSE RETURN [ct] }; --CTOrient CTMirror: PUBLIC PROC[ct: CornerTypes, mirrorOrient: OrientationTypes] RETURNS [CornerTypes] ={ SELECT mirrorOrient FROM hor => RETURN [(SELECT ct FROM sw => nw, se => ne, ne => se, nw => sw, ENDCASE => ERROR)]; ver => RETURN [(SELECT ct FROM sw => se, se => sw, ne => nw, nw => ne, ENDCASE => ERROR)]; ENDCASE => ERROR; }; --CTMirror CTRotate: PUBLIC PROC[ct: CornerTypes, cnt: INT _ 1] RETURNS[CornerTypes] ={ cnt _ cnt MOD 4; SELECT ct FROM sw => RETURN [(SELECT cnt FROM 0 => sw, 1, -3 => se, -1, 3 => nw, 2, -2 => ne, ENDCASE => ERROR)]; se => RETURN [(SELECT cnt FROM 0 => se, 1, -3 => ne, -1, 3 => sw, 2, -2 => nw, ENDCASE => ERROR)]; ne => RETURN [(SELECT cnt FROM 0 => ne, 1, -3 => nw, -1, 3 => se, 2, -2 => sw, ENDCASE => ERROR)]; nw => RETURN [(SELECT cnt FROM 0 => nw, 1, -3 => sw, -1, 3 => ne, 2, -2 => se, ENDCASE => ERROR)]; ENDCASE => ERROR;}; --CTRotate-- CTFindRotDirectn: PUBLIC PROC[ct: CornerTypes, ot: OrientationTypes] RETURNS [PolarityTypes] ={ SELECT ct FROM sw, ne => RETURN [IF ot = hor THEN neg ELSE pos]; se, nw => RETURN [IF ot = hor THEN pos ELSE neg]; ENDCASE => ERROR; }; --CTFindRotDirectn-- CTResolve: PUBLIC PROC[ct: CornerTypes] RETURNS [hor, ver: EdgeTypes]= { SELECT ct FROM sw => {hor _ south; ver _ west}; se => {hor _ south; ver _ east}; ne => {hor _ north; ver _ east}; nw => {hor _ north; ver _ west}; ENDCASE => ERROR}; --CTResolve-- CTResolveFor: PUBLIC PROC[ct: CornerTypes, ot: OrientationTypes] RETURNS [EdgeTypes] = {RETURN [IF ot = hor THEN CTResolve[ct].hor ELSE CTResolve[ct].ver]}; CTDirectn: PUBLIC PROC[ct: CornerTypes] RETURNS [hor, ver: PolarityTypes]= { SELECT ct FROM sw => {hor _ neg; ver _ neg}; se => {hor _ pos; ver _ neg}; ne => {hor _ pos; ver _ pos}; nw => {hor _ neg; ver _ pos}; ENDCASE => ERROR}; --CTDirectn-- CTDirectnFor: PUBLIC PROC[ct: CornerTypes, ot: OrientationTypes] RETURNS [PolarityTypes] = {RETURN [IF ot = hor THEN CTDirectn[ct].hor ELSE CTDirectn[ct].ver]}; CTFromPTs: PUBLIC PROC[hor, ver: PolarityTypes] RETURNS [CornerTypes] = { SELECT ver FROM neg => RETURN [IF hor = neg THEN sw ELSE se]; pos => RETURN [IF hor = neg THEN nw ELSE ne]; ENDCASE => ERROR; }; --CTFromPTs-- ETRotate: PUBLIC PROC[et: EdgeTypes, cnt: INT _ 1] RETURNS[EdgeTypes]= { cnt _ cnt MOD 4; SELECT et FROM south => RETURN [(SELECT cnt FROM 0 => south, 1, -3 => east, -1, 3 => west, 2, -2 => north, ENDCASE => ERROR)]; east => RETURN [(SELECT cnt FROM 0 => east, 1, -3 => north, -1, 3 => south, 2, -2 => west, ENDCASE => ERROR)]; north => RETURN [(SELECT cnt FROM 0 => north, 1, -3 => west, -1, 3 => east, 2, -2 => south, ENDCASE => ERROR)]; west => RETURN [(SELECT cnt FROM 0 => west, 1, -3 => south, -1, 3 => north, 2, -2 => east, ENDCASE => ERROR)]; ENDCASE => ERROR; }; --ETRotate-- ETOrient: PUBLIC PROC[et: EdgeTypes] RETURNS [OrientationTypes] ={ SELECT et FROM south, north => RETURN [hor]; east, west => RETURN [ver]; ENDCASE => ERROR;}; --ETOrient-- ETCombine: PUBLIC PROC[et1, et2: EdgeTypes] RETURNS [CornerTypes]= { SELECT et1 FROM south => RETURN [(SELECT et2 FROM east => se, west => sw, ENDCASE => ERROR ETCombineFailed)]; east => RETURN [(SELECT et2 FROM south => se, north => ne, ENDCASE => ERROR ETCombineFailed)]; north => RETURN [(SELECT et2 FROM east => ne, west => nw, ENDCASE => ERROR ETCombineFailed)]; west => RETURN [(SELECT et2 FROM south => sw, north => nw, ENDCASE => ERROR ETCombineFailed)]; ENDCASE => ERROR; }; --ETCombine-- ETDirectn: PUBLIC PROC[et: EdgeTypes] RETURNS [PolarityTypes] = { SELECT et FROM south, west => RETURN [neg]; east, north => RETURN [pos]; ENDCASE => ERROR;}; --ETDirectn-- Copy1Shape: PUBLIC PROC[oShape: REF IP.ShapeRep] RETURNS [REF IP.ShapeRep] = { IF oShape = NIL THEN RETURN [NIL]; RETURN [NEW[IP.ShapeRep _ [oShape.dim, oShape.cornerSpaces]]]; }; --Copy1Shape Copy2Shape: PUBLIC PROC[oShape: REF IP.ShapeRep] RETURNS [REF IP.ShapeRep] = { dim, sw, se, ne, nw: REF IP.NatVector; IF oShape = NIL THEN RETURN [NIL]; BEGIN OPEN oCS: oShape.cornerSpaces; IF oShape.dim # NIL THEN dim _ NuNatVector[oShape.dim.x, oShape.dim.y]; IF oCS.sw # NIL THEN sw _ NuNatVector[oCS.sw.x, oCS.sw.y]; IF oCS.se # NIL THEN se _ NuNatVector[oCS.se.x, oCS.se.y]; IF oCS.ne # NIL THEN ne _ NuNatVector[oCS.ne.x, oCS.ne.y]; IF oCS.nw # NIL THEN nw _ NuNatVector[oCS.nw.x, oCS.nw.y]; END; RETURN [NEW[IP.ShapeRep _[dim, [sw, se, ne, nw]]]] }; --Copy2Shape END.  -- File: IPBasicOpsImpl.mesa -- Last Edited by: CSChow, January 5, 1985 8:28:13 am PST --Documentation will come later after consolidating the design -- ΚI˜Jšœ™Jšœ9™9J™J™AJ˜šΟk ˜ J˜ Jšœ˜Jšœ ˜ J˜—šœœ˜Jšœ˜Jšœœœ ˜+J˜Icodešœœœœ˜%K˜š Οnœœœœœ˜ZKšœ˜šœ%˜'Kšœœ˜Kšœœ˜—KšœΟc ˜ —K˜šžœ œ2œ˜_šœ˜Kš œœœœ)œœ˜ZKš œœœœ)œœ˜ZKšœœ˜—KšœŸ ˜ —K˜š žœœœœœ˜LKšœ œ˜šœ˜Kš œœœœ1œœ˜bKš œœœœ1œœ˜bKš œœœœ1œœ˜bKš œœœœ1œœ˜bKšœœŸ ˜ ——K˜šžœœœ(œ˜_šœ˜Kš œ œœ œœ˜1Kš œ œœ œœ˜1Kšœœ˜—KšœŸœ˜—K˜šž œœœœ˜Hšœ˜K˜ K˜ K˜ K˜ KšœœŸ ˜ ——K˜Kšž œœœ(œœœ œœ˜œK˜šž œœœœ˜Lšœ˜K˜K˜K˜K˜KšœœŸ ˜ ——K˜Kšž œœœ(œœœ œœ˜ K˜šž œœœœ˜Išœ˜Kš œœœ œœ˜-Kš œœœ œœ˜-Kšœœ˜—KšœŸ œ˜—š žœœœœœ˜HKšœ œ˜šœ˜Kš œ œœœ;œœ˜oKš œœœœ;œœ˜nKš œ œœœ;œœ˜oKš œœœœ;œœ˜nKšœœ˜—KšœŸ ˜—šžœœœœ˜Bšœ˜Kšœœ˜Kšœœ˜KšœœŸ ˜ ——J˜šž œœœœ˜Dšœ˜Kš œ œœœœœ˜]Kš œœœœœœ˜^Kš œ œœœœœ˜]Kš œœœœœœ˜^Kšœœ˜—KšœŸ ˜—J˜J˜– "Cedar" stylešž œœœœ˜A– "Cedar" stylešœ˜Kšœœ˜Kšœœ˜KšœœŸ ˜!——K– "Cedar" style˜– "Cedar" stylešž œœœ œœ œœœ˜NK– "Cedar" styleš œ œœœœ˜"K– "Cedar" stylešœœœ0˜>K– "Cedar" stylešœŸ ˜—K– "Cedar" style˜– "Cedar" stylešž œœœ œœ œœœ˜NK– "Cedar" stylešœœœ ˜&K– "Cedar" styleš œ œœœœ˜"– "Cedar" stylešœœ˜$K– "Cedar" stylešœœœ/˜GK– "Cedar" stylešœ œœ&˜:K– "Cedar" stylešœ œœ&˜:K– "Cedar" stylešœ œœ&˜:K– "Cedar" stylešœ œœ&˜:K– "Cedar" stylešœ˜—K– "Cedar" stylešœœœ$˜2K– "Cedar" stylešœŸ ˜—K– "Cedar" style˜K– "Cedar" style˜K– "Cedar" stylešœ˜——…—¬•