DIRECTORY AtomButtonsTypes, CodeTimer, Feedback, FS, IO, Rope, SVSceneTypes, SVUtility, TFI3d, ViewerClasses, ViewerTools; SVUtilityImpl: CEDAR PROGRAM IMPORTS CodeTimer, Feedback, FS, IO, Rope, TFI3d, ViewerTools EXPORTS SVUtility = BEGIN Slice: TYPE = SVSceneTypes.Slice; SliceList: TYPE = SVSceneTypes.SliceList; FeedbackData: TYPE = AtomButtonsTypes.FeedbackData; MasterObject: TYPE = SVSceneTypes.MasterObject; MasterObjectList: TYPE = SVSceneTypes.MasterObjectList; SliceDescriptor: TYPE = SVSceneTypes.SliceDescriptor; Viewer: TYPE = ViewerClasses.Viewer; ReadTwoReals: PUBLIC PROC [textViewer: Viewer] RETURNS [x, y: REAL] = { wholeRope: Rope.ROPE _ ViewerTools.GetContents[textViewer]; wholeStream: IO.STREAM _ IO.RIS[wholeRope]; x _ TFI3d.ReadBlankAndReal[wholeStream]; TFI3d.ReadBlankAndRope[wholeStream, ","]; y _ TFI3d.ReadBlankAndReal[wholeStream]; }; AppendToMasterObjects: PUBLIC PROC [mo: MasterObject, list: MasterObjectList] RETURNS [MasterObjectList] = { z: MasterObjectList _ list; IF z = NIL THEN RETURN[CONS[mo,NIL]]; UNTIL z.rest = NIL DO z _ z.rest; ENDLOOP; z.rest _ CONS[mo,NIL]; RETURN[list]; }; AppendToAssemblyList: PUBLIC PROC [assembly: Slice, list: SliceList] RETURNS [SliceList] = { z: LIST OF Slice _ list.list; IF z = NIL THEN {list.list _ CONS[assembly, NIL]; RETURN[list]}; UNTIL z.rest = NIL DO z _ z.rest; ENDLOOP; z.rest _ CONS[assembly,NIL]; RETURN[list]; }; GetInterpressFileName: PUBLIC PROC [shortName: Rope.ROPE, workingDir: Rope.ROPE, feedback: FeedbackData] RETURNS [fullName: Rope.ROPE _ NIL, success: BOOL _ TRUE] = { [fullName, success, ----] _ GetGenericFileName[shortName, workingDir, "IP", LIST["pic", "gargoyle", "script", "mesa", "tioga"], feedback]; }; GetScriptFileName: PUBLIC PROC [scriptName: Rope.ROPE, currentWDir: Rope.ROPE, feedback: FeedbackData] RETURNS [fullName: Rope.ROPE _ NIL, success: BOOL _ TRUE] = { [fullName, success, ----] _ GetGenericFileName[scriptName, currentWDir, "script", LIST["gargoyle", "IP", "interpress", "mesa", "tioga", "pic"], feedback]; }; GetGenericFileName: PROC [fileName, wDir, defaultExt: Rope.ROPE, illegalExts: LIST OF Rope.ROPE, feedback: FeedbackData, emergency: BOOL _ FALSE] RETURNS [fullName: Rope.ROPE _ NIL, success: BOOL _ TRUE, versionSpecified: BOOL _ FALSE] = { cp: FS.ComponentPositions; extRope: Rope.ROPE; versionSpecified _ Rope.SkipTo[s: fileName, skip: "!"]#Rope.Length[fileName]; IF Rope.Length[fileName]=0 OR Rope.Equal[fileName, ""] THEN { IF NOT emergency THEN { Feedback.PutF[feedback, oneLiner, "No filename specified"]; Feedback.Blink[feedback]; }; RETURN[NIL, FALSE]; }; [fullName, cp, ] _ FS.ExpandName[fileName, wDir ! FS.Error => { success _ FALSE; IF NOT emergency THEN { Feedback.PutF[feedback, oneLiner, "FS Error during name expansion of %g", [rope[fileName]]]; Feedback.Blink[feedback]; }; CONTINUE; } ]; IF NOT success THEN RETURN; extRope _ Rope.Substr[base: fullName, start: cp.ext.start, len: cp.ext.length]; FOR ropeList: LIST OF Rope.ROPE _ illegalExts, ropeList.rest UNTIL ropeList=NIL DO IF Rope.Equal[ropeList.first, extRope, FALSE] THEN { IF NOT emergency THEN { Feedback.PutF[feedback, oneLiner, "%g extension for %g files not allowed", [rope[extRope]], [rope[defaultExt]] ]; Feedback.Blink[feedback]; }; success _ FALSE; RETURN; }; ENDLOOP; IF cp.ext.length=0 THEN fullName _ Rope.Cat[fullName, ".", defaultExt]; }; StartSliceList: PUBLIC PROC [] RETURNS [entityList, ptr: LIST OF Slice] = { ptr _ entityList _ NIL; }; AddSlice: PUBLIC PROC [slice: Slice, entityList, ptr: LIST OF Slice] RETURNS [newList, newPtr: LIST OF Slice] = { IF ptr = NIL THEN { IF NOT entityList = NIL THEN ERROR; newPtr _ newList _ CONS[slice, NIL]; RETURN; } ELSE { newList _ entityList; ptr.rest _ CONS[slice, NIL]; newPtr _ ptr.rest; }; }; StartList: PUBLIC PROC [] RETURNS [entityList, ptr: LIST OF REF ANY] = { ptr _ entityList _ NIL; }; AddEntity: PUBLIC PROC [entity: REF ANY, entityList, ptr: LIST OF REF ANY] RETURNS [newList, newPtr: LIST OF REF ANY] = { IF ptr = NIL THEN { IF NOT entityList = NIL THEN ERROR; newPtr _ newList _ CONS[entity, NIL]; RETURN; } ELSE { newList _ entityList; ptr.rest _ CONS[entity, NIL]; newPtr _ ptr.rest; }; }; StartSliceDescriptorList: PUBLIC PROC [] RETURNS [entityList, ptr: LIST OF SliceDescriptor] = { ptr _ entityList _ NIL; }; AddSliceDescriptor: PUBLIC PROC [entity: SliceDescriptor, entityList, ptr: LIST OF SliceDescriptor] RETURNS [newList, newPtr: LIST OF SliceDescriptor] = { IF ptr = NIL THEN { IF NOT entityList = NIL THEN ERROR; newPtr _ newList _ CONS[entity, NIL]; RETURN; } ELSE { newList _ entityList; ptr.rest _ CONS[entity, NIL]; newPtr _ ptr.rest; }; }; Init: PROC [] = { [] _ CodeTimer.CreateTable[$Solidviews]; }; Init[]; END. \SVUtilityImpl.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Bier on February 5, 1987 Contents: Some helpful Solidviews routines that don't fit anywhere in particular. A copy of List.Nconc1 for MasterObjectList instead of LIST OF REF ANY A copy of List.Nconc1 for LIST OF Slice instead of LIST OF REF ANY ส ˜J˜Icodešœ™Kšœ ฯmœ1™