DIRECTORY AIS, IO, ReadAIS, Rope, SVError; ReadAISImpl: PROGRAM IMPORTS AIS, IO, Rope, SVError EXPORTS ReadAIS = BEGIN Raster: TYPE = AIS.Raster; FilenameMinusExtension: PUBLIC PROC [wholeName: Rope.ROPE] RETURNS [firstPart: Rope.ROPE] = { wholeStream: IO.STREAM _ IO.RIS[wholeName]; [firstPart, ----] _ IO.GetTokenRope[wholeStream, PeriodBreakProc]; }; PeriodBreakProc: SAFE PROC [char: CHAR] RETURNS [IO.CharClass] = TRUSTED { SELECT char FROM '. => RETURN[sepr]; ENDCASE => RETURN[other]; }; CreateFile: PUBLIC PROC [filename: Rope.ROPE, raster: Raster, comment: Rope.ROPE, overwrite: BOOLEAN _ FALSE, attributeLength: CARDINAL _ 0, resolution: REAL] RETURNS[f: AIS.FRef] = { f _ AIS.CreateFile[filename, raster]; AIS.WriteComment[f, comment]; }; OpenFile: PUBLIC PROC [name: Rope.ROPE, write: BOOLEAN _ FALSE] RETURNS [f: AIS.FRef, resolution: REAL] = { comment: Rope.ROPE; commentStream: IO.STREAM; f _ AIS.OpenFile[name, write]; comment _ AIS.ReadComment[f]; IF comment = NIL THEN { SVError.Append["72 dots/in assumed. AIS file has no res. comment.", TRUE]; SVError.Blink[]; resolution _ 72.0; RETURN}; commentStream _ IO.RIS[comment]; ReadRope[commentStream, "res: "]; resolution _ ReadReal[commentStream]; }; Resolution: PUBLIC PROC [filename: Rope.ROPE] RETURNS [resolution: REAL] = { f: AIS.FRef; comment: Rope.ROPE; commentStream: IO.STREAM; f _ AIS.OpenFile[filename, FALSE]; comment _ AIS.ReadComment[f]; IF comment = NIL THEN { resolution _ 72.0; AIS.CloseFile[f]; RETURN}; commentStream _ IO.RIS[comment]; ReadRope[commentStream, "res: "]; resolution _ ReadReal[commentStream]; AIS.CloseFile[f]; }; ReadRope: PUBLIC PROC [f: IO.STREAM, rope: Rope.ROPE] = { c: CHAR; FOR i: INT IN[1..Rope.Length[rope]] DO c _ IO.GetChar[f]; IF NOT c = Rope.Fetch[rope,i-1] THEN SIGNAL RopeNotOnTop [IO.GetIndex[f], Rope.FromChar[c], rope]; ENDLOOP; }; RopeNotOnTop: PUBLIC SIGNAL [position: NAT, wasThere: Rope.ROPE, notThere: Rope.ROPE] = CODE; ReadReal: PUBLIC PROC [f: IO.STREAM] RETURNS [r: REAL] = { realRope: Rope.ROPE; [realRope, ----] _ IO.GetTokenRope[f, RealBreakProc]; IF Rope.Find[realRope, ".", 0, FALSE] = -1 THEN realRope _ Rope.Concat[realRope, ".0"]; r _ IO.GetReal[IO.RIS[realRope]]; }; RealBreakProc: SAFE PROC [char: CHAR] RETURNS [IO.CharClass] = TRUSTED { SELECT char FROM '], ', => RETURN [break]; IO.CR =>RETURN [break]; IO.SP => RETURN [break]; ENDCASE => RETURN [other]; }; END. ÐFile: ReadAISImpl.mesa Author: Eric Bier on June 17, 1983 10:40 am Last edited by Bier on June 26, 1984 11:10:08 am PDT Removes the given rope from the top of the stream. Used to remove formatting words and phrases from 3d files. We are not interested in these strings but only in the data in between them. Signals RopeNotOnTop if some other rope is on top. Reads digits up to the next ], , or . Leaves these terminators on the stream. Ê„˜Ihead1™J™+J™5šÏk ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜—J˜šœ ˜Jšœœœ˜Jšœ ˜—šœ˜Jšœœœ˜J˜—š Ïnœœœœœœ˜]Jš œ œœœœ ˜+Jšœ Ïcœœ,˜BJšœ˜—šžœœœœœœœ˜Jšœ˜Jšœœ˜Jšœœ˜—Jšœ˜—J˜šž œœœœ œ œœœœœœ ˜·Jšœœ˜%Jšœ˜Jšœ˜J˜—šžœœœ œ œœœœœ˜kJšœœ˜Jšœœœ˜Jšœœ˜Jšœ œ˜šœ œœ˜JšœDœ˜JJšœ˜Jšœ˜Jšœ˜—J˜Jšœœœ ˜ Jšœ!˜!Jšœ%˜%J˜—J˜š ž œœœœœœ˜LJšœœ˜ Jšœœ˜Jšœœœ˜Jšœœœ˜#Jšœ œ˜šœ œœ˜Jšœ˜Jšœ˜Jšœ˜—J˜Jšœœœ ˜ Jšœ!˜!Jšœ%˜%Jšœ˜J˜—J˜š žœœœœœ œ˜9Jšœ»™»Jšœ2™2Jšœœ˜šœœœ˜&Jšœœ ˜šœœ˜$Jšœœ&˜=——Jšœ˜Jšœ˜—Jš œœœ œœœœ˜]šžœœœœœœœ˜:Jšœa™aJšœœ˜Jšœ Ÿœœ ˜5Jšœœœ(˜WJšœœ œœ ˜!Jšœ˜—šž œœœœœœœ˜Hšœ˜Jšœ œ ˜Jšœœœ ˜Jšœœœ ˜Jšœœ ˜Jšœ˜J˜——J˜Jšœ˜—…— xÌ