DIRECTORY Atom, AtomButtonsTypes, Convert, FS, GGBasicTypes, Feedback, GGEvent, GGFileIn, GGInterfaceTypes, GGModelTypes, GGScene, GGParseIn, GGSegmentTypes, GGSlice, GGUtility, Imager, ImagerColor, IO, Rope, ViewerClasses; GGFileInImpl: CEDAR PROGRAM IMPORTS Atom, Convert, Feedback, GGEvent, GGScene, GGParseIn, GGSlice, GGUtility, IO, Rope EXPORTS GGFileIn = BEGIN Viewer: TYPE = ViewerClasses.Viewer; Color: TYPE = Imager.Color; FeedbackData: TYPE = AtomButtonsTypes.FeedbackData; GGData: TYPE = GGInterfaceTypes.GGData; Outline: TYPE = GGModelTypes.Outline; Point: TYPE = GGBasicTypes.Point; Scene: TYPE = GGModelTypes.Scene; Segment: TYPE = GGSegmentTypes.Segment; SegmentClass: TYPE = GGSegmentTypes.SegmentClass; Slice: TYPE = GGModelTypes.Slice; SliceClass: TYPE = GGModelTypes.SliceClass; StrokeEnd: TYPE = Imager.StrokeEnd; Traj: TYPE = GGModelTypes.Traj; Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = Feedback.Problem; FileinSceneAndOptions: PUBLIC PROC [f: IO.STREAM, ggData: GGData] = { sceneName: Rope.ROPE; scene: Scene _ ggData.scene; version: REAL; count: NAT; entity: Slice; finger, newEntities: LIST OF Slice; GGParseIn.ReadBlankAndRope[f, "Gargoyle file for scene:"]; sceneName _ GGParseIn.ReadBlankAndWord[f]; GGParseIn.ReadBlankAndRope[f, "Produced by version"]; version _ GGParseIn.ReadBlankAndReal[f]; IF version >= 8607.17 THEN ReadOptions[f, version, ggData]; GGParseIn.ReadBlankAndRope[f, "Entities:"]; GGParseIn.ReadBlankAndRope[f, "["]; count _ GGParseIn.ReadBlankAndNAT[f]; GGParseIn.ReadBlankAndRope[f, "]:"]; GGParseIn.ReadWhiteSpace[f]; [newEntities, finger] _ GGUtility.StartSliceList[]; FOR i: NAT IN[1..count] DO entity _ FileinEntity[f, version, ggData.feedback]; IF entity#NIL THEN [newEntities, finger] _ GGUtility.AddSlice[entity, newEntities, finger]; ENDLOOP; GGScene.AddSlices[scene, newEntities]; f.Close[]; }; ReadOptions: PROC [f: IO.STREAM, version: REAL, ggData: GGData] = { keyWord, option: Rope.ROPE; good: BOOL; nextChar: CHAR; twoCRsFound: BOOL _ FALSE; UNTIL twoCRsFound DO [keyWord, good] _ GGParseIn.ReadKeyWord[f]; IF NOT good THEN { nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; LOOP}; good _ GGParseIn.ReadHorizontalBlank[f]; IF NOT good THEN { nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; LOOP}; option _ GGParseIn.ReadLine[f]; ProcessOption[keyWord, option, version, ggData]; nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; ENDLOOP; }; ProcessOption: PROC[keyWord, option: Rope.ROPE, version: REAL, ggData: GGData] = { optionStream: IO.STREAM _ IO.RIS[option]; optionList: LIST OF Rope.ROPE; value: REAL; SELECT TRUE FROM Rope.Equal[keyWord, "Slope", FALSE] => { optionList _ GGParseIn.ReadListOfRope[optionStream]; FOR list: LIST OF Rope.ROPE _ optionList, list.rest UNTIL list = NIL DO value _ Convert.RealFromRope[list.first]; GGEvent.AddSlopeInternal[ggData, value]; ENDLOOP; }; Rope.Equal[keyWord, "Angle", FALSE] => { optionList _ GGParseIn.ReadListOfRope[optionStream]; FOR list: LIST OF Rope.ROPE _ optionList, list.rest UNTIL list = NIL DO value _ Convert.RealFromRope[list.first]; GGEvent.AddAngleInternal[ggData, value]; ENDLOOP; }; Rope.Equal[keyWord, "Radius", FALSE] => { optionList _ GGParseIn.ReadListOfRope[optionStream]; FOR list: LIST OF Rope.ROPE _ optionList, list.rest UNTIL list = NIL DO value _ Convert.RealFromRope[list.first]; GGEvent.AddRadiusInternal[ggData, value]; ENDLOOP; }; Rope.Equal[keyWord, "LineDistance", FALSE] => { optionList _ GGParseIn.ReadListOfRope[optionStream]; FOR list: LIST OF Rope.ROPE _ optionList, list.rest UNTIL list = NIL DO value _ Convert.RealFromRope[list.first]; GGEvent.AddDistanceInternal[ggData, value]; ENDLOOP; }; Rope.Equal[keyWord, "Midpoints", FALSE] => { on, good: BOOL; [on, good] _ GGParseIn.ReadBOOL[optionStream, version]; GGEvent.SetMidpointsInternal[ggData, on AND good]; }; ENDCASE => SIGNAL Problem[msg: "Unknown keyword in gargoyle file."]; }; -- end ProcessOption FileinSceneOnly: PUBLIC PROC [f: IO.STREAM, scene: Scene] = { sceneName: Rope.ROPE; version: REAL; count: NAT; entity: Slice; finger, newEntities: LIST OF Slice; GGParseIn.ReadBlankAndRope[f, "Gargoyle file for scene:"]; sceneName _ GGParseIn.ReadBlankAndWord[f]; GGParseIn.ReadBlankAndRope[f, "Produced by version"]; version _ GGParseIn.ReadBlankAndReal[f]; IF version >= 8607.17 THEN SkipOptions[f]; GGParseIn.ReadBlankAndRope[f, "Entities:"]; GGParseIn.ReadBlankAndRope[f, "["]; count _ GGParseIn.ReadBlankAndNAT[f]; GGParseIn.ReadBlankAndRope[f, "]:"]; [newEntities, finger] _ GGUtility.StartSliceList[]; FOR i: NAT IN[1..count] DO entity _ FileinEntity[f, version, NIL]; IF entity#NIL THEN [newEntities, finger] _ GGUtility.AddSlice[entity, newEntities, finger]; ENDLOOP; GGScene.AddSlices[scene, newEntities]; f.Close[]; }; SkipOptions: PROC [f: IO.STREAM] = { keyWord, option: Rope.ROPE; good: BOOL; nextChar: CHAR; twoCRsFound: BOOL _ FALSE; UNTIL twoCRsFound DO [keyWord, good] _ GGParseIn.ReadKeyWord[f]; IF NOT good THEN { nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; LOOP}; good _ GGParseIn.ReadHorizontalBlank[f]; IF NOT good THEN { nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; LOOP}; option _ GGParseIn.ReadLine[f]; nextChar _ IO.PeekChar[f]; IF nextChar = IO.CR THEN { [] _ IO.GetChar[f]; twoCRsFound _ TRUE; }; ENDLOOP; }; FileinEntity: PROC [f: IO.STREAM, version: REAL, feedback: FeedbackData] RETURNS [entity: Slice] = { nextWord: Rope.ROPE; IF version > 8605.22 THEN { IF version >= 8705.14 THEN { entity _ FileinSlice[f, version, feedback]; } ELSE { nextWord _ GGParseIn.ReadBlankAndWord[f]; SELECT TRUE FROM Rope.Equal[nextWord, "Outline:"] => { class: SliceClass _ GGSlice.FetchSliceClass[$Outline]; entity _ class.filein[f, version, feedback]; }; Rope.Equal[nextWord, "Slice"] => { entity _ FileinSlice[f, version, feedback]; }; ENDCASE => ERROR } } ELSE { nextWord _ GGParseIn.ReadBlankAndWord[f]; SELECT TRUE FROM Rope.Equal[nextWord, "Outline:"] => { class: SliceClass _ GGSlice.FetchSliceClass[$Outline]; entity _ class.filein[f, version, feedback]; }; Rope.Equal[nextWord, "Cluster"] => { entity _ FileinSlice[f, version, feedback]; }; ENDCASE => ERROR; }; }; FileinSlice: PROC [f: IO.STREAM, version: REAL, feedback: FeedbackData] RETURNS [slice: Slice] = { className: Rope.ROPE; type: ATOM; class: SliceClass; IF version >= 8705.14 THEN { className _ GGParseIn.ReadBlankAndWord[f]; } ELSE { childCount: NAT; GGParseIn.ReadBlankAndRope[f, "(class:"]; className _ GGParseIn.ReadBlankAndWord[f]; GGParseIn.ReadBlankAndRope[f, ")"]; GGParseIn.ReadBlankAndRope[f, "["]; childCount _ GGParseIn.ReadBlankAndNAT[f]; GGParseIn.ReadBlankAndRope[f, "]:"]; GGParseIn.ReadBlankAndRope[f, "Data:"]; }; type _ SliceClassFromRope[className]; class _ GGSlice.FetchSliceClass[type]; slice _ class.filein[f, version, feedback]; }; SliceClassFromRope: PROC [className: Rope.ROPE] RETURNS [type: ATOM] = { RETURN[Atom.MakeAtom[className] ]; }; END. ψFile: GGFileInImpl.mesa Last edited by Bier on May 14, 1987 12:54:40 pm PDT Copyright c 1986 by Xerox Corporation. All rights reserved. Contents: Recreates a gargoyle database from a text file of the sort produced by GGFileOut.mesa. Pier, May 12, 1987 6:51:41 pm PDT Read in the Header Read in the alignment objects, etc. Read in the scene entities GGParseIn.ReadBlank[f]; Read in the Header Read in the alignment objects, etc. Read in the scene entities ProcessOption[keyWord, option, ggData]; Κ 6– "cedar" style˜procšœ™Kšœ3™3Jšœ Οmœ1™<šœ`™`Icode™!——K˜šΟk ˜ Kšœžœšžœ˜Υ—K˜šΟn œžœž˜KšžœKžœ˜ZKšžœ ž˜—˜Kšœžœ˜$Kšœžœ˜Jšœžœ!˜3Kšœžœ˜'Kšœ žœ˜%Kšœžœ˜!Kšœžœ˜!Kšœ žœ˜'Kšœžœ˜1Kšœžœ˜!Kšœ žœ˜+Kšœ žœ˜#Kšœžœ˜K˜KšŸœžœžœ žœ˜;—K˜š Ÿœžœžœžœžœ˜EKšœžœ˜Kšœ˜Kšœ žœ˜Kšœžœ˜ Kšœ˜šœžœžœ˜#KšΟb™—Kšœ:˜:Kšœ*˜*Kšœ5˜5šœ(˜(Kš #™#—šžœžœ!˜;Kš ™—Kšœ+˜+Kšœ#˜#Kšœ%˜%KšœA˜AKšœ3˜3šžœžœžœ ž˜Kšœ   œ˜3Lšžœžœžœ#Ÿœ˜[Kšžœ˜—Kšœ&˜&Kšœ ˜ Kšœ˜K˜—š Ÿ œžœžœžœ žœ˜CJšœžœ˜Jšœžœ˜ Jšœ žœ˜Jšœ žœžœ˜Jšœ™šžœ ž˜J˜+šžœžœžœ˜Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜—Jšžœ˜—Jšœ(˜(šžœžœžœ˜Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜—Jšžœ˜—Jšœ˜Jšœ0˜0Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜——Jšžœ˜J˜J˜—šŸ œžœžœ žœ˜RJš œžœžœžœžœ ˜)Jšœ žœžœžœ˜Jšœžœ˜ šžœžœž˜šœžœ˜(Jšœ4˜4š žœžœžœžœžœžœž˜GJšœ)˜)Jšœ œ˜(Jšžœ˜—Jšœ˜—šœžœ˜(Jšœ4˜4š žœžœžœžœžœžœž˜GJšœ)˜)Jšœ œ˜(Jšžœ˜—Jšœ˜—šœžœ˜)Jšœ4˜4š žœžœžœžœžœžœž˜GJšœ)˜)Jšœ œ˜)Jšžœ˜—Jšœ˜—šœ$žœ˜/Jšœ4˜4š žœžœžœžœžœžœž˜GJšœ)˜)Jšœ œ˜+Jšžœ˜—Jšœ˜—šœ!žœ˜,Jšœ žœ˜Jšœ7˜7Jšœ œ žœ˜2Jšœ˜—Lšžœžœ3˜D—LšœΟc˜J˜J˜—š Ÿœžœžœžœžœ˜=Kšœžœ˜Kšœ žœ˜Kšœžœ˜ Kšœ˜šœžœžœ˜#Kš ™—Kšœ:˜:Kšœ*˜*Kšœ5˜5šœ(˜(Kš #™#—šžœžœ˜*Kš ™—Kšœ+˜+Kšœ#˜#Kšœ%˜%Kšœ$˜$Kšœ3˜3šžœžœžœ ž˜Kšœ"žœ˜'Lšžœžœžœ# œ˜[Kšžœ˜—Kšœ&˜&Kšœ ˜ Kšœ˜K˜—šŸ œžœžœžœ˜$Jšœžœ˜Jšœžœ˜ Jšœ žœ˜Jšœ žœžœ˜šžœ ž˜J˜+šžœžœžœ˜Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜—Jšžœ˜—Jšœ(˜(šžœžœžœ˜Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜—Jšžœ˜—Jšœ˜Jšœ'™'Jšœ žœ ˜šžœ žœžœžœ˜Jšœžœ ˜Jšœžœ˜J˜——Jšžœ˜J˜J˜—š Ÿ œžœžœžœ žœžœ˜dKšœžœ˜šžœž˜šžœžœ˜Jšœ+˜+K˜—šžœ˜Kšœ)˜)šžœžœž˜šœ%˜%Jšœ6˜6Jšœ,˜,Kšœ˜—šœ"˜"Jšœ+˜+Kšœ˜—Kšžœž˜—K˜—K˜—šžœ˜Kšœ)˜)šžœžœž˜šœ%˜%Jšœ6˜6Jšœ,˜,Kšœ˜—šœ$˜$Jšœ+˜+Kšœ˜—Kšžœžœ˜—K˜—Kšœ˜K˜—š Ÿ œžœžœžœ žœžœ˜bKšœžœ˜Kšœžœ˜ K˜šžœžœ˜Kšœ*˜*K˜—šžœ˜Kšœ žœ˜Kšœ)˜)Kšœ*˜*Kšœ#˜#Kšœ#˜#Kšœ*˜*Kšœ$˜$Kšœ'˜'K˜—Kšœ%˜%Kšœ&˜&Kšœ+˜+K˜K˜—š Ÿœžœžœžœžœ˜HKšžœ˜"K˜—K˜Kšžœ˜—…—Ϊ(