DIRECTORY CoordSys, DisplayList3d, Fileout3d, IO, Matrix3d, Rope, Shading, SVArtwork, SweepGeometry, TFO3d; Fileout3dImpl: PROGRAM IMPORTS CoordSys, IO, DisplayList3d, TFO3d EXPORTS Fileout3d = BEGIN Artwork: TYPE = SVArtwork.Artwork; Assembly: TYPE = REF AssemblyObj; AssemblyList: TYPE = REF AssemblyListObj; AssemblyListObj: TYPE = DisplayList3d.AssemblyListObj; AssemblyObj: TYPE = DisplayList3d.AssemblyObj; CoordSysList: TYPE = CoordSys.CoordSysList; CoordSysObj: TYPE = CoordSys.CoordSysObj; CoordSystem: TYPE = REF CoordSysObj; FileCamera: TYPE = DisplayList3d.FileCamera; FileCameraList: TYPE = DisplayList3d.FileCameraList; LightSource: TYPE = REF LightSourceObj; LightSourceList: TYPE = LIST OF LightSource; LightSourceObj: TYPE = Shading.LightSourceObj; LinearMesh: TYPE = REF LinearMeshRecord; LinearMeshArray: TYPE = SweepGeometry.LinearMeshArray; LinearMeshRecord: TYPE = SweepGeometry.LinearMeshRecord; MasterObject: TYPE = REF MasterObjectRec; MasterObjectList: TYPE = DisplayList3d.MasterObjectList; MasterObjectRec: TYPE = DisplayList3d.MasterObjectRec; Matrix4by4: TYPE = Matrix3d.Matrix4by4; Point3d: TYPE = Matrix3d.Point3d; RevoluteMesh: TYPE = REF RevoluteMeshRecord; RevoluteMeshArray: TYPE = SweepGeometry.RevoluteMeshArray; RevoluteMeshRecord: TYPE = SweepGeometry.RevoluteMeshRecord; Scene: TYPE = REF SceneObj; SceneObj: TYPE = DisplayList3d.SceneObj; FileoutScene: PUBLIC PROC [scene: Scene, f: IO.STREAM, fileName: Rope.ROPE] = { f.PutF["File: %g\n",[rope[fileName]]]; f.PutF["3D file for scene: %g\n",[rope[fileName]]]; f.PutF["Produced by %g\n\n", [rope[DisplayList3d.versionRope]]]; f.PutF["Background color: "]; TFO3d.FileoutColor[f, scene.backgroundColor]; f.PutChar[IO.CR]; f.PutF["Shadows: "]; TFO3d.FileoutBOOL[f, scene.shadows]; f.PutChar[IO.CR]; f.PutChar[IO.CR]; scene.coordSystems _ CoordSys.SortCoordSysListByBreadth[scene.coordSystems]; FileoutCoordSystems[f,scene.coordSystems]; FileoutLightSources[f,scene.lightSources]; FileoutObjects[f,scene.masterObjects]; FileoutAssembly[f, scene.assembly, scene.masterObjects]; FileoutCameras[f, scene.cameras]; FileoutCameraOrder[f, scene.cameraOrder]; f.PutF["END"]; f.Close[]; scene.dirty _ FALSE; }; CountCoordSystems: PROC [csl: CoordSysList] RETURNS [count: NAT] = { count _ 0; FOR list: CoordSysList _ csl, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutCoordSystems: PROC [f: IO.STREAM, csl: CoordSysList] = { count: NAT _ CountCoordSystems[csl]; thisCS: CoordSystem; f.PutF["CoordSystems [%g]:\n",[integer[count]]]; FOR thisCSL: CoordSysList _ csl, thisCSL.rest UNTIL thisCSL = NIL DO thisCS _ thisCSL.first; f.PutF["CoordSys: %g mat: ",[rope[thisCS.name]]]; TFO3d.FileoutMatrix[f,thisCS.mat]; f.PutF[" withRespectTo: "]; IF thisCS.withRespectTo = NIL THEN f.PutF["NIL"] ELSE f.PutRope[thisCS.withRespectTo.name]; f.PutChar[IO.CR]; ENDLOOP; f.PutChar[IO.CR]; }; CountLightSources: PROC [lsl: LightSourceList] RETURNS [count: NAT] = { count _ 0; FOR list: LightSourceList _ lsl, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutLightSources: PUBLIC PROC [f: IO.STREAM, lsl: LightSourceList] = { count: NAT _ CountLightSources[lsl]; thisLS: LightSource; f.PutF["LightSources [%g]:\n",[integer[count]]]; FOR thisLSL: LightSourceList _ lsl, thisLSL.rest UNTIL thisLSL = NIL DO thisLS _ thisLSL.first; FileoutLightSource[f, thisLS]; f.PutChar[IO.CR]; ENDLOOP; f.PutChar[IO.CR]; }; FileoutLightSource: PROC [f: IO.STREAM, lightSource: LightSource] = { f.PutF["LightSource: %g position: ",[rope[lightSource.name]]]; TFO3d.FileoutPoint3d[f,lightSource.position]; f.PutF[" color: "]; TFO3d.FileoutColor[f, lightSource.color]; }; FileoutCameras: PUBLIC PROC [f: IO.STREAM, cameras: FileCameraList] = { count: NAT _ CountCameras[cameras]; thisCamera: FileCamera; f.PutF["Cameras [%g]:\n",[integer[count]]]; FOR list: FileCameraList _ cameras, list.rest UNTIL list = NIL DO thisCamera _ list.first; TFO3d.FileoutCamera[f, thisCamera]; f.PutChar[IO.CR]; ENDLOOP; f.PutChar[IO.CR]; }; FileoutCameraOrder: PUBLIC PROC [f: IO.STREAM, cameraOrder: LIST OF Rope.ROPE] = { count: NAT _ CountRopes[cameraOrder]; f.PutF["Initial Camera Order [%g]: ", [integer[count]]]; IF count > 0 THEN { f.PutRope[cameraOrder.first]; FOR list: LIST OF Rope.ROPE _ cameraOrder.rest, list.rest UNTIL list = NIL DO f.PutF[", %g", [rope[list.first]]]; ENDLOOP; f.PutChar[IO.CR]; f.PutChar[IO.CR]; }; }; CountRopes: PROC [ropes: LIST OF Rope.ROPE] RETURNS [count: NAT] = { count _ 0; FOR list: LIST OF Rope.ROPE _ ropes, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; CountCameras: PROC [cameras: FileCameraList] RETURNS [count: NAT] = { count _ 0; FOR list: FileCameraList _ cameras, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; CountAssemblies: PROC [asl: AssemblyList] RETURNS [count: NAT] = { count _ 0; FOR list: LIST OF Assembly _ asl.list, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutArtwork: PRIVATE PROC [f: IO.STREAM, artwork: Artwork] = { f.PutF["material: "]; TFO3d.FileoutMaterial[f, artwork.material]; f.PutF[" surface: "]; TFO3d.FileoutSurface[f, artwork.surface]; f.PutChar[IO.CR]; IF artwork.source # NIL THEN{ f.PutF["SMap: "]; TFO3d.FileoutSMap[f, artwork.sMap]; f.PutF[" OMap: "]; TFO3d.FileoutOMap[f, artwork.oMap]; f.PutChar[IO.SP]; f.PutF["source: %g ", [rope[artwork.source]]]; IF artwork.isColorFile THEN f.PutF["colorFile"] ELSE f.PutF["bwFile"]; f.PutF[" resolution: %g\n", [real[artwork.resolution]]]; f.PutF["mat: "]; TFO3d.FileoutMatrix3by3[f, artwork.artWRTPad.mat]; }; f.PutF[" color: "]; TFO3d.FileoutColor[f, artwork.color]; }; FileoutAssembly: PROC [f: IO.STREAM, assem: Assembly, mol: MasterObjectList] = { pointSetOp: Rope.ROPE; f.PutF["Assembly: %g, coordSys: %g, scalars: ", [rope[assem.name]],[rope[assem.coordSys.name]]]; TFO3d.FileoutPoint3d[f, assem.scalars]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; f.PutF["artwork: "]; FileoutArtwork[f, assem.artwork]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; WITH assem.object SELECT FROM alist: AssemblyList => { SELECT alist.pointSetOp FROM union => pointSetOp _ "union"; intersection => pointSetOp _ "intersection"; difference => pointSetOp _ "difference"; ENDCASE => ERROR; f.PutF["subassemblies [point set op: %g]\n", [rope[pointSetOp]]]; FileoutSubassemblyNames[f,alist]; f.PutChar[IO.CR]; FileoutAssemblies[f,alist,mol];}; ENDCASE => { f.PutF["object: "]; FileoutObjectName[f,assem.object]}; f.PutChar[IO.CR]; }; -- end of FileoutAssembly FileoutAssemblies: PROC [f: IO.STREAM, as: AssemblyList, mol: MasterObjectList] = { count: NAT _ CountAssemblies[as]; f.PutF["Subassemblies [%g]:\n",[integer[count]]]; FOR aso: LIST OF Assembly _ as.list, aso.rest UNTIL aso = NIL DO FileoutAssembly[f, aso.first, mol]; ENDLOOP; -- next assembly f.PutChar[IO.CR]; }; -- end of FileoutAssemblies FileoutObjectName: PROC [f: IO.STREAM, object: REF ANY] = { mo: MasterObject _ NARROW[object]; f.PutRope[mo.name]; }; FileoutSubassemblyNames: PROC [f: IO.STREAM, asl: AssemblyList] = { count: NAT _ CountAssemblies[asl]; thisA: Assembly; f.PutF[" [%g]: (", [integer[count]]]; IF count = 0 THEN {f.PutF[")\n"]; RETURN}; thisA _ asl.list.first; f.PutRope[thisA.name]; FOR list: LIST OF Assembly _ asl.list.rest, list.rest UNTIL list = NIL DO thisA _ list.first; f.PutF[", %g",[rope[thisA.name]]]; ENDLOOP; f.PutF[")\n"]; }; CountObjects: PROC [ol: MasterObjectList] RETURNS [count: NAT] = { count _ 0; FOR list: MasterObjectList _ ol, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutObjects: PROC [f: IO.STREAM, ol: MasterObjectList] = { mo: MasterObject; count: NAT _ CountObjects[ol]; f.PutF["Objects [%g]:\n",[integer[count]]]; FOR mol: MasterObjectList_ ol, mol.rest UNTIL mol = NIL DO mo _ mol.first; f.PutF["Master Object: %g class: %g\n", [rope[mo.name]], [rope[mo.class.name]]]; mo.class.fileout[f, mo]; ENDLOOP; f.PutChar[IO.CR]; }; END. πFile: Fileout3dImpl.mesa Last edited by Bier on August 8, 1983 12:37 pm Contents: Facilities for creating text files and writing out a human-readable version of a 3d object database File out subassembly or master object information. Κ – "cedar" style˜Iheadšœ™Iprocšœ.™.Lšœn™nL˜šΟk ˜ Lšœ ˜ Lšœ˜Lšœ ˜ Lšœ˜Lšœ ˜ Lšœ˜Lšœ˜Lšœ ˜ Lšœ˜Lšœ˜—L˜šœ˜Lšœ œ˜*Lšœ ˜—L˜Lš˜˜Lšœ œ˜"Lšœ œœ ˜!Lšœœœ˜)Lšœœ!˜6Lšœ œ˜.Lšœœ˜+Lšœ œ˜)Lšœ œœ ˜$Lšœ œ˜,Lšœœ ˜4Lšœ œœ˜'Lšœœœœ ˜,Lšœœ˜.Lšœ œœ˜(Lšœœ!˜6Lšœœ"˜8Lšœœœ˜)Lšœœ"˜8Lšœœ!˜6Lšœ œ˜'Lšœ œ˜!Lšœœœ˜,Lšœœ#˜:Lšœœ$˜Lšœ˜—Lšœ˜Lšœ˜—L˜š žœœœœœ˜ILšœœ˜$Lšœ˜Lšœ0˜0šœ.œ œ˜GLšœ˜Lšœ˜Lšœ œœ˜—Lšœ˜Lšœ œœ˜Lšœ˜—L˜šžœœœœ˜ELšœ>˜>Lšœ-˜-Lšœ˜Lšœ)˜)Lšœ˜—š žœœœœœ˜GLšœœ˜#Lšœ˜Lšœ+˜+šœ+œœ˜ALšœ˜Lšœ#˜#Lšœ œœ˜—Lšœ˜Lšœ œœ˜Lšœ˜—šžœœœœœœœœ˜RLšœœ˜%Lšœ8˜8šœ œ˜Lšœ˜š œœœœœœ˜MLšœ#˜#—Lšœ˜Lšœ œœ˜Lšœ œœ˜L˜—L˜L˜—šž œœ œœœœ œ˜DLšœ ˜ š œœœœœœ˜BLšœ˜—Lšœ˜Lšœ˜—šž œœœ œ˜ELšœ ˜ šœ+œœ˜ALšœ˜—Lšœ˜Lšœ˜—L˜šžœœœ œ˜BLšœ ˜ š œœœ œœ˜DLšœ˜—Lšœ˜Lšœ˜—L˜š žœœœœœ˜ALšœ˜Lšœ+˜+Lšœ˜Lšœ)˜)Lšœ œœ˜šœœœ˜Lšœ˜Lšœ#˜#Lšœ˜Lšœ#˜#Lšœ œœ˜Lšœ.˜.Lšœœœ˜FLšœ8˜8Lšœ˜Lšœ2˜2Lšœ˜—Lšœ˜Lšœ%˜%Lšœ˜—L˜šžœœœœ-˜PLšœœ˜Lšœ/˜/Lšœ0˜0Lšœ'˜'Lšœ œœ˜Lšœ œœ˜Lšœ˜Lšœ!˜!Lšœ œœ˜Lšœ2™2Lšœ œœ˜šœœ˜šœ˜šœ˜Lšœ˜Lšœ,˜,Lšœ(˜(Lšœœ˜—LšœA˜ALšœ!˜!Lšœ œœ˜Lšœ!˜!—šœ˜ Lšœ˜Lšœ#˜#——Lšœ œœ˜LšœΟc˜—L˜šžœœœœ.˜SLšœœ˜!Lšœ1˜1š œœœœœ˜@Lšœ#˜#—LšœŸ˜Lšœ œœ˜LšœŸ˜—L˜š žœœœœ œœ˜;Lšœœ ˜"Lšœ˜Lšœ˜—L˜šžœœœœ˜CLšœœ˜"Lšœ˜Lšœ%˜%Lšœ œœ˜*Lšœ˜Lšœ˜š œœœ%œœ˜ILšœ˜Lšœ"˜"—Lšœ˜Lšœ˜Lšœ˜—L˜šž œœœ œ˜BLšœ ˜ šœ(œœ˜>Lšœ˜—Lšœ˜Lšœ˜—L˜šžœœœœ˜=Lšœ˜Lšœœ˜Lšœ+˜+šœ%œœ˜:Lšœ˜LšœP˜PLšœ˜—Lšœ˜Lšœ œœ˜Lšœ˜—L˜—Lšœ˜—…—ή*Χ