<> <> <> DIRECTORY FS, IO, Real, Rope; PartXForm: CEDAR PROGRAM IMPORTS FS, IO, Real, Rope ~ BEGIN Degrees: TYPE = [0..360); ROPE: TYPE = Rope.ROPE; Transformation: TYPE = RECORD[m11, m12, m21, m22: REAL]; rot45: Transformation _ [.7071, .7071, -.7071, .7071]; <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <<>> Apply: PROC [t: Transformation, x1, y1: INT] RETURNS [x2, y2: INT] ~ { x2 _ Real.Round[(x1*t.m11) + (y1*t.m21)]; y2 _ Real.Round[(x1*t.m12) + (y1*t.m22)]; }; Transform: PROC [fName: ROPE, t: Transformation] ~ { in: IO.STREAM _ FS.StreamOpen[Rope.Concat[fName, ".part"]]; out: IO.STREAM _ FS.StreamOpen[Rope.Concat[fName, "R.part"], $create]; x, y: INT; name: ROPE; swap, dia, site, type, pad: INT; out.PutF["%g ", IO.int[in.GetInt[]]]; -- part number out.PutF["%g ", IO.int[in.GetInt[]]]; -- shape number FOR i: NAT IN [0..3) DO x _ in.GetInt[]; y _ in.GetInt[]; [x, y] _ Apply[t, x, y]; out.PutF["%g %g ", IO.int[x], IO.int[y]]; ENDLOOP; FOR i: NAT IN [0..3) DO out.PutF["%g ", IO.rope[in.GetTokenRope[IO.IDProc].token]]; ENDLOOP; out.PutF["\n"]; DO x _ in.GetInt[! IO.EndOfStream => GOTO finished]; y _ in.GetInt[]; name _ in.GetTokenRope[IO.IDProc].token; swap _ in.GetInt[]; dia _ in.GetInt[]; site _ in.GetInt[]; type _ in.GetInt[]; pad _ in.GetInt[]; [x, y] _ Apply[t, x, y]; out.PutFL["%4g %4g %8g %3g %3g %3g %3g %3g\n", LIST[IO.int[x], IO.int[y], IO.rope[name], IO.int[swap], IO.int[dia], IO.int[site], IO.int[type], IO.int[pad]]]; REPEAT finished => NULL; ENDLOOP; IO.Close[in]; IO.Close[out]; }; END.