DIRECTORY CoordSys, CSG, SVScene, DisplayListToTree, Fileout3d, FileNames, IO, Rope, SV3d, SVModelTypes, SVSceneTypes, SweepGeometry, TFO3d; Fileout3dImpl: CEDAR PROGRAM IMPORTS CoordSys, CSG, IO, SVScene, DisplayListToTree, FileNames, Rope, TFO3d EXPORTS Fileout3d = BEGIN Artwork: TYPE = SVModelTypes.Artwork; ArtworkClass: TYPE = SVModelTypes.ArtworkClass; Assembly: TYPE = SVSceneTypes.Assembly; AssemblyList: TYPE = SVSceneTypes.AssemblyList; CoordSystem: TYPE = SVModelTypes.CoordSystem; CoordSysList: TYPE = SVModelTypes.CoordSysList; FileCamera: TYPE = SVSceneTypes.FileCamera; FileCameraList: TYPE = SVSceneTypes.FileCameraList; LightSource: TYPE = SVModelTypes.LightSource; LightSourceList: TYPE = LIST OF LightSource; LinearMesh: TYPE = REF LinearMeshRecord; LinearMeshArray: TYPE = SweepGeometry.LinearMeshArray; LinearMeshRecord: TYPE = SweepGeometry.LinearMeshRecord; MasterObject: TYPE = SVSceneTypes.MasterObject; MasterObjectList: TYPE = SVSceneTypes.MasterObjectList; Matrix4by4: TYPE = SV3d.Matrix4by4; Point3d: TYPE = SV3d.Point3d; RevoluteMesh: TYPE = REF RevoluteMeshRecord; RevoluteMeshArray: TYPE = SweepGeometry.RevoluteMeshArray; RevoluteMeshRecord: TYPE = SweepGeometry.RevoluteMeshRecord; Scene: TYPE = SVSceneTypes.Scene; Shape: TYPE = SVSceneTypes.Shape; SpaceFunction: TYPE = SVModelTypes.SpaceFunction; FileoutScene: PUBLIC PROC [scene: Scene, f: IO.STREAM, fileName: Rope.ROPE] = { csList: CoordSysList; fileName _ FileNames.GetShortName[fileName]; 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[SVScene.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.PutF["Ambient: "]; TFO3d.FileoutColor[f, scene.lightSources.first.color]; f.PutChar[IO.CR]; f.PutChar[IO.CR]; csList _ DisplayListToTree.CoordSysListFromScene[scene]; FileoutCoordSystems[f, csList]; FileoutLightSources[f, scene.lightSources.rest]; 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.parent = NIL THEN f.PutF["NIL"] ELSE f.PutRope[thisCS.parent.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] = { IF artwork.coordSys = NIL THEN f.PutF["coordSys: %g class: %g ", IO.rope["NIL"], IO.rope[ArtworkClassToRope[artwork.class]]] ELSE f.PutF["coordSys: %g class: %g ", IO.rope[artwork.coordSys.name], IO.rope[ArtworkClassToRope[artwork.class]]]; f.PutF["material: "]; TFO3d.FileoutMaterial[f, artwork.material]; f.PutF[" surface: "]; TFO3d.FileoutSurface[f, artwork.surface]; SELECT artwork.class FROM justColor => { f.PutF[" color: "]; TFO3d.FileoutColor[f, artwork.color]; }; simpleSurface => { aisName: Rope.ROPE; f.PutChar[IO.CR]; f.PutF["SMap: "]; TFO3d.FileoutSMap[f, artwork.sMap]; f.PutF[" OMap: "]; TFO3d.FileoutOMap[f, artwork.oMap]; f.PutChar[IO.SP]; aisName _ FileNames.GetShortName[artwork.source]; f.PutF["source: %g ", [rope[aisName]]]; 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]; }; spaceFunction => { spaceFunction: SpaceFunction _ NARROW[artwork.surface]; f.PutF[" scalars: "]; TFO3d.FileoutPoint3d[f, spaceFunction.scalars]; f.PutF[" func: colorcube"]; }; ENDCASE => ERROR; }; ArtworkClassToRope: PROC [class: ArtworkClass] RETURNS [className: Rope.ROPE] = { SELECT class FROM justColor => className _ "justColor"; simpleSurface => className _ "simpleSurface"; spaceFunction => className _ "spaceFunction"; ENDCASE => ERROR; }; FileoutAssembly: PROC [f: IO.STREAM, assem: Assembly, mol: MasterObjectList] = { pointSetOp: Rope.ROPE; f.PutF["Assembly: %g, coordSys: %g", [rope[assem.name]],[rope[assem.coordSys.name]]]; WITH assem.shape SELECT FROM alist: AssemblyList => { f.PutF[", Composite"]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; f.PutF["artwork: "]; FileoutArtwork[f, assem.artwork]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; pointSetOp _ CSG.PointSetOpToRope[alist.pointSetOp]; f.PutF["subassemblies [%g]\n", [rope[pointSetOp]]]; FileoutSubassemblyNames[f, alist]; f.PutChar[IO.CR]; FileoutAssemblies[f,alist,mol]; }; shape: Shape => { f.PutF[", Primitive scalars: "]; TFO3d.FileoutPoint3d[f, CoordSys.GetScalars[shape.coordSys]]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; f.PutF["artwork: "]; FileoutArtwork[f, assem.artwork]; f.PutChar[IO.CR]; f.PutChar[IO.TAB]; f.PutF["object: "]; f.PutRope[shape.mo.name]; IF Rope.Equal[shape.mo.name, "jack", FALSE] THEN { f.PutF[" sittingOn: "]; IF assem.sittingOn = NIL THEN f.PutF["NIL"] ELSE f.PutRope[assem.sittingOn]; }; f.PutChar[IO.CR]; }; ENDCASE => ERROR; }; -- 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 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 January 28, 1987 12:47:21 pm PST Copyright c 1984 by Xerox Corporation. All rights reserved. Contents: Facilities for creating text files and writing out a human-readable version of a 3d object database File out subassembly information. Κ °– "cedar" style˜Iheadšœ™Iprocšœ7™7Jšœ Οmœ1™Lšœ˜—Lšžœ˜Lšœ˜—š Ÿœžœžœžœžœ˜ILšœžœ˜$Lšœ˜Lšœ0˜0šžœ.žœ žœž˜GLšœ˜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šœ˜—šŸœžœžœ žœ˜BLšœ ˜ š žœžœžœ žœžœž˜DLšœ˜—Lšžœ˜Lšœ˜—š Ÿœžœžœžœžœ˜ALš žœžœžœ#žœžœ)˜|Lšžœ$žœžœ*˜tL˜Lšœ˜Lšœ+˜+Lšœ˜Lšœ)˜)Lšžœž˜˜Lšœ˜Lšœ%˜%L˜—˜Lšœžœ˜Lšœ žœžœ˜Lšœ˜Lšœ#˜#Lšœ˜Lšœ#˜#Lšœ žœžœ˜Lšœ1˜1Lšœ'˜'Lšžœžœžœ˜FLšœ8˜8Lšœ˜Lšœ2˜2Lšœ˜Lšœ%˜%Lšœ˜—˜Lšœžœ˜7Lšœ˜Lšœ/˜/Lšœ˜L˜—Lšžœžœ˜Lšœ˜—šŸœžœžœžœ˜QLšžœž˜Lšœ%˜%Lšœ-˜-Lšœ-˜-Lšžœžœ˜L˜—šŸœžœžœžœ-˜PLšœžœ˜Lšœ$˜$Lšœ0˜0Lšžœ žœž˜šœ˜Lšœ˜Lšœ žœžœ˜Lšœ žœžœ˜Lšœ˜Lšœ!˜!šœ žœžœ˜Lšœ!™!—Lšœ žœžœ˜Lšœ žœ$˜4šœ3˜3Lšœ"˜"Lšœ žœžœ˜Lšœ˜Lšœ˜—šœ˜Lšœ ˜ Lšœ=˜=Lš œ žœžœ žœžœ˜$Lšœ˜Lšœ!˜!Lš œ žœžœ žœžœ˜$Lšœ˜Lšœ˜šžœ#žœžœ˜2Lšœ˜Lšžœžœžœ˜+Lšžœ˜ L˜—Lšœ žœžœ˜L˜—Lšžœžœ˜—LšœΟc˜—šŸœžœžœžœ.˜SLšœžœ˜!Lšœ1˜1š žœžœžœžœžœž˜@Lšœ#˜#—Lšžœ ˜Lšœ žœžœ˜Lšœ ˜L˜—šŸœžœžœžœ˜CLšœžœ˜"Lšœ˜Lšœ%˜%Lšžœ žœžœ˜*Lšœ˜Lšœ˜š žœžœžœ%žœžœž˜ILšœ˜Lšœ"˜"—Lšžœ˜Lšœ˜Lšœ˜—šŸ œžœžœ žœ˜BLšœ ˜ šžœ(žœžœž˜>Lšœ˜—Lšžœ˜Lšœ˜—šŸœžœžœžœ˜=Lšœ˜Lšœžœ˜Lšœ+˜+šžœ%žœžœž˜:Lšœ˜LšœP˜PLšœ˜—Lšžœ˜Lšœ žœžœ˜Lšœ˜L˜—L˜Lšžœ˜—…—"β/Έ