SVUtilityImpl.mesa
Copyright © 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.
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.STREAMIO.RIS[wholeRope];
x ← TFI3d.ReadBlankAndReal[wholeStream];
TFI3d.ReadBlankAndRope[wholeStream, ","];
y ← TFI3d.ReadBlankAndReal[wholeStream];
};
AppendToMasterObjects: PUBLIC PROC [mo: MasterObject, list: MasterObjectList] RETURNS [MasterObjectList] = {
A copy of List.Nconc1 for MasterObjectList instead of LIST OF REF ANY
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] = {
A copy of List.Nconc1 for LIST OF Slice instead of LIST OF REF ANY
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.ROPENIL, success: BOOLTRUE] = {
[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.ROPENIL, success: BOOLTRUE] = {
[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: BOOLFALSE] RETURNS [fullName: Rope.ROPENIL, success: BOOLTRUE, versionSpecified: BOOLFALSE] = {
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.