DIRECTORY SVCoordSys, FileNames, GGParseOut, Imager, IO, Rope, SVShading, SV2d, SV3d, SVArtwork, SVGraphics, SVModelTypes, SVSceneTypes, SVParseOut; SVParseOutImpl: CEDAR PROGRAM IMPORTS SVCoordSys, FileNames, GGParseOut, IO, SVShading, SVArtwork, SVGraphics EXPORTS SVParseOut = BEGIN Artwork: TYPE = SVModelTypes.Artwork; ArtworkClass: TYPE = SVModelTypes.ArtworkClass; Box: TYPE = SVModelTypes.Box; Color: TYPE = Imager.Color; DrawStyle: TYPE = SVModelTypes.DrawStyle; Point2d: TYPE = SV2d.Point2d; FileCamera: TYPE = SVSceneTypes.FileCamera; FrameBox: TYPE = SVModelTypes.FrameBox; Material: TYPE = SVModelTypes.Material; Matrix3by3: TYPE = SV2d.Matrix3by3; Matrix4by4: TYPE = SV3d.Matrix4by4; OMap: TYPE = SVModelTypes.OMap; Plane: TYPE = SV3d.Plane; Point3d: TYPE = SV3d.Point3d; Slice: TYPE = SVSceneTypes.Slice; SpaceFunction: TYPE = SVModelTypes.SpaceFunction; Tube: TYPE = SVModelTypes.Tube; SMap: TYPE = SVModelTypes.SMap; FileoutMatrix: PUBLIC PROC [f: IO.STREAM, mat: Matrix4by4] = { f.PutF["[[%g",[real[mat[1][1]]]]; FOR j: NAT IN[2..4] DO f.PutF[",%g",[real[mat[1][j]]]]; ENDLOOP; f.PutF["]"]; FOR i: NAT IN[2..3] DO f.PutF[", [%g",[real[mat[i][1]]]]; FOR j: NAT IN[2..4] DO f.PutF[",%g",[real[mat[i][j]]]]; ENDLOOP; f.PutF["]"]; ENDLOOP; f.PutF["]"]; }; FileoutMatrix3by3: PUBLIC PROC [f: IO.STREAM, mat: Matrix3by3] = { f.PutF["[[%g",[real[mat[1][1]]]]; FOR j: NAT IN[2..3] DO f.PutF[",%g",[real[mat[1][j]]]]; ENDLOOP; f.PutF["]"]; f.PutF[", [%g",[real[mat[2][1]]]]; FOR j: NAT IN[2..3] DO f.PutF[",%g",[real[mat[2][j]]]]; ENDLOOP; f.PutF["]]"]; }; FileoutPoint2d: PUBLIC PROC [f: IO.STREAM, point2d: Point2d] = { f.PutF["[%g,%g]", [real[point2d[1]]], [real[point2d[2]]]]; }; FileoutPoint3d: PUBLIC PROC [f: IO.STREAM, point3d: Point3d] = { f.PutF["[%g,%g,%g]",[real[point3d[1]]],[real[point3d[2]]],[real[point3d[3]]]]; }; FileoutPoint3dAsPoint2d: PUBLIC PROC [f: IO.STREAM, point3d: Point3d] = { f.PutF["[%g,%g]",[real[point3d[1]]],[real[point3d[2]]]]; }; FileoutPlane: PUBLIC PROC [f: IO.STREAM, plane: Plane] = { f.PutF["[%g,%g,%g,%g]", [real[plane.A]], [real[plane.B]], [real[plane.C]], [real[plane.D]]]; }; FileoutColor: PUBLIC PROC [f: IO.STREAM, color: Color] = { r, g, b: REAL; [r, g, b] _ SVShading.ExtractRGB[color]; f.PutF["[%g,%g,%g]",[real[r]], [real[g]], [real[b]]]; }; FileoutSurface: PUBLIC PROC [f: IO.STREAM, surface: REF ANY] = { IF surface = NIL THEN f.PutF["NIL"] ELSE { WITH surface SELECT FROM tube: Tube => f.PutF["tube [radius: %g, height: %g]", [real[tube.R]], [real[tube.H]]]; box: Box =>{ f.PutF["box "]; FileoutPoint3d[f, [box.x, 2*box.halfY, box.z]]; }; spaceFunction: SpaceFunction => f.PutF["NIL "]; ENDCASE => ERROR; }; }; FileoutMaterial: PUBLIC PROC [f: IO.STREAM, material: Material] = { matRope: Rope.ROPE; matRope _ SVArtwork.MaterialToRope[material]; f.PutRope[matRope]; }; FileoutSMap: PUBLIC PROC [f: IO.STREAM, sMap: SMap] = { mapRope: Rope.ROPE; mapRope _ SVArtwork.SMapToRope[sMap]; f.PutRope[mapRope]; }; FileoutOMap: PUBLIC PROC [f: IO.STREAM, oMap: OMap] = { mapRope: Rope.ROPE; mapRope _ SVArtwork.OMapToRope[oMap]; f.PutRope[mapRope]; }; FileoutCamera: PUBLIC PROC [f: IO.STREAM, fileCamera: FileCamera] = { f.PutRope["Camera: "]; f.PutRope[fileCamera.name]; f.PutRope[" origin: "]; FileoutPoint3d[f, fileCamera.origin]; f.PutRope[" focusPoint: "]; FileoutPoint3d[f, fileCamera.focusPoint]; f.PutF[" slant: %g", [real[fileCamera.slant]]]; f.PutChar[IO.CR]; f.PutF["resolution: %g", [real[fileCamera.resolution]]]; f.PutF[" focalLength: %g", [real[fileCamera.focalLength]]]; f.PutF[" projection: %g", [rope[SVGraphics.ProjectionToRope[fileCamera.projection]]]]; f.PutChar[IO.CR]; f.PutRope[" frame: "]; FileoutFrame[f, fileCamera.frame]; f.PutChar[IO.CR]; f.PutRope["clippingPlanes: "]; FileoutClippingPlanes[f, fileCamera.clippingPlanes]; f.PutChar[IO.CR]; f.PutRope["visibleAssemblies: "]; FileoutListOfRope[f, fileCamera.visibleAssemblies]; f.PutChar[IO.CR]; }; FileoutFrame: PUBLIC PROC [f: IO.STREAM, frame: FrameBox] = { f.PutChar['[]; FileoutPoint2d[f, [frame.downLeft[1], frame.upRight[2]]]; f.PutRope[", "]; FileoutPoint2d[f, [frame.upRight[1], frame.downLeft[2]]]; f.PutRope[" fullScreen: "]; GGParseOut.WriteBool[f, frame.fullScreen]; f.PutChar[']]; }; FileoutClippingPlanes: PUBLIC PROC [f: IO.STREAM, clippingPlanes: LIST OF Plane] = { firstPlane: Plane; IF clippingPlanes = NIL THEN RETURN; firstPlane _ clippingPlanes.first; FileoutPlane[f, firstPlane]; FOR list: LIST OF Plane _ clippingPlanes.rest, list.rest UNTIL list = NIL DO f.PutChar[',]; FileoutPlane[f, list.first]; ENDLOOP; }; CountClippingPlanes: PROC [clippingPlanes: LIST OF Plane] RETURNS [count: NAT] = { count _ 0; FOR list: LIST OF Plane _ clippingPlanes, list.rest UNTIL list = NIL DO count _ count + 1; ENDLOOP; }; FileoutVisibleAssemblies: PUBLIC PROC [f: IO.STREAM, assemblyList: LIST OF Slice] = { IF assemblyList = NIL THEN RETURN; f.PutRope[assemblyList.first.name]; FOR list: LIST OF Slice _ assemblyList.rest, list.rest UNTIL list = NIL DO f.PutRope[", "]; f.PutRope[list.first.name]; ENDLOOP; }; FileoutStyle: PUBLIC PROC [f: IO.STREAM, style: DrawStyle] = { styleRope: Rope.ROPE _ SVGraphics.DrawStyleToRope[style]; f.PutRope[styleRope]; }; ArtworkClassToRope: PROC [class: ArtworkClass] RETURNS [className: Rope.ROPE] = { SELECT class FROM justColor => className _ "c"; simpleSurface => className _ "simpleSurface"; spaceFunction => className _ "spaceFunction"; ENDCASE => ERROR; }; WriteArtwork: PUBLIC PROC [f: IO.STREAM, artwork: Artwork] = { IF artwork = NIL THEN {f.PutF["NIL"]; RETURN}; f.PutF["%g ", [rope[ArtworkClassToRope[artwork.class] ]] ]; FileoutMaterial[f, artwork.material]; f.PutChar[IO.SP]; SELECT artwork.class FROM justColor => { FileoutColor[f, artwork.color]; }; simpleSurface => { aisName: Rope.ROPE; IF artwork.coordSys = NIL THEN f.PutF["coordSys: %g ", IO.rope["NIL"]] ELSE f.PutF["coordSys: %g ", IO.rope[SVCoordSys.Name[artwork.coordSys]] ]; f.PutF[" surface: "]; FileoutSurface[f, artwork.surface]; f.PutChar[IO.CR]; f.PutF["SMap: "]; FileoutSMap[f, artwork.sMap]; f.PutF[" OMap: "]; 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: "]; FileoutMatrix3by3[f, artwork.artWRTPad.mat]; f.PutF[" color: "]; FileoutColor[f, artwork.color]; }; spaceFunction => { spaceFunction: SpaceFunction _ NARROW[artwork.surface]; IF artwork.coordSys = NIL THEN f.PutF["coordSys: %g ", IO.rope["NIL"]] ELSE f.PutF["coordSys: %g ", IO.rope[SVCoordSys.Name[artwork.coordSys]] ]; f.PutF[" surface: "]; FileoutSurface[f, artwork.surface]; f.PutF[" scalars: "]; FileoutPoint3d[f, spaceFunction.scalars]; f.PutF[" func: colorcube"]; }; ENDCASE => ERROR; }; FileoutListOfRope: PUBLIC PROC [f: IO.STREAM, ropeList: LIST OF Rope.ROPE] = { IF ropeList = NIL THEN RETURN; f.PutRope[ropeList.first]; FOR list: LIST OF Rope.ROPE _ ropeList.rest, list.rest UNTIL list = NIL DO f.PutRope[", "]; f.PutRope[list.first]; ENDLOOP; }; END. ฎFile: SVParseOutImpl.mesa Last edited by Bier on September 11, 1987 2:25:20 pm PDT Copyright c 1984 by Xerox Corporation. All rights reserved. Contents: Useful functions for creating text files to describe 3d objects and scenes. (used by Fileout3dImpl, BasicObject3dImpl and intended for use by programs which define other master objects to implement their FileoutProc [see DisplayList3d]). Only writes the first 2 rows. ส ฟ– "cedar" style˜Iheadšœ™Iprocšœ8™8Jšœ ฯmœ1™Lšœ!˜!šžœžœžœž˜Lšœ ˜ —Lšžœ˜Lšœ ˜ šžœžœžœž˜Lšœ"˜"šžœžœžœž˜Lšœ ˜ —Lšžœ˜Lšœ ˜ —Lšžœ˜Lšœ ˜ Lšœ˜—š Ÿœžœžœžœžœ˜BLšœ™Lšœ!˜!šžœžœžœž˜Lšœ ˜ —Lšžœ˜Lšœ ˜ Lšœ"˜"šžœžœžœž˜Lšœ ˜ —Lšžœ˜Lšœ ˜ Lšœ˜—š Ÿœžœžœžœžœ˜@Lšœ:˜:L˜—š Ÿœžœžœžœžœ˜@LšœN˜NLšœ˜—š Ÿœžœžœžœžœ˜ILšœ8˜8Lšœ˜—š Ÿ œžœžœžœžœ˜:Lš œ$žœžœžœžœ˜\L˜—L˜š Ÿ œžœžœžœžœ˜:Lšœ žœ˜Lšœ(˜(Lšœ5˜5Lšœ˜—šŸœžœžœžœžœ žœžœ˜@Lšžœ žœžœ˜#šžœ˜šžœ žœž˜LšœAžœžœ˜Všœ˜Lšœ/˜/Lšœ˜—Lšœ/˜/Lšžœžœ˜—Lšœ˜—Lšœ˜—š Ÿœžœžœžœžœ˜CLšœžœ˜Lšœ-˜-Lšœ˜Lšœ˜—š Ÿ œžœžœžœžœ˜7Lšœžœ˜Lšœ%˜%Lšœ˜Lšœ˜—š Ÿ œžœžœžœžœ˜7Lšœžœ˜Lšœ%˜%Lšœ˜Lšœ˜—L˜š Ÿ œžœžœžœžœ˜ELšœ˜Lšœ˜Lšœ˜Lšœ%˜%Lšœ˜Lšœ)˜)Lšœ/˜/Lšœ žœžœ˜Lšœ8˜8Lšœ;˜;LšœV˜VLšœ žœžœ˜Lšœ˜Lšœ"˜"Lšœ žœžœ˜Lšœ˜Lšœ4˜4Lšœ žœžœ˜L˜L˜!Lšœ3˜3Lšœ žœžœ˜L˜Lšœ˜—š Ÿ œžœžœžœžœ˜=L˜Lšœ9˜9L˜Lšœ9˜9Lšœ˜Lšœ*˜*L˜L˜—šŸœžœžœžœžœžœžœ ˜TLšœ˜Lšžœžœžœžœ˜$Lšœ"˜"Lšœ˜š žœžœžœ(žœžœž˜LL˜Lšœ˜—Lšžœ˜L˜—š Ÿœžœžœžœžœ žœ˜RLšœ ˜ š žœžœžœ#žœžœž˜GLšœ˜—Lšžœ˜Lšœ˜—šŸœžœžœžœžœžœžœ ˜ULšžœžœžœžœ˜"Lšœ#˜#š žœžœžœ&žœžœž˜JL˜Lšœ˜—Lšžœ˜Lšœ˜—L˜š Ÿ œžœžœžœžœ˜>Lšœžœ%˜9Lšœ˜L˜—šŸœžœžœžœ˜QLšžœž˜Lšœ˜Lšœ-˜-Lšœ-˜-Lšžœžœ˜L˜—šŸ œž œžœžœ˜>Lšžœ žœžœžœ˜.Lšœ;˜;Lšœ%˜%Lšœ žœžœ˜L˜Lšžœž˜˜Lšœ˜L˜—˜Lšœžœ˜Lšžœžœžœžœ ˜FLšžœžœ+˜JLšœ˜Lšœ#˜#Lšœ žœžœ˜Lšœ˜Lšœ˜Lšœ˜Lšœ˜Lšœ žœžœ˜Lšœ1˜1Lšœ'˜'Lšžœžœžœ˜FLšœ8˜8Lšœ˜Lšœ,˜,Lšœ˜Lšœ˜Lšœ˜—˜Lšœžœ˜7Lšžœžœžœžœ ˜FLšžœžœ+˜KLšœ˜Lšœ#˜#Lšœ˜Lšœ)˜)Lšœ˜L˜—Lšžœžœ˜Lšœ˜—šŸœžœžœžœžœ žœžœžœ˜NLšžœ žœžœžœ˜Lšœ˜š žœžœžœžœžœžœž˜JL˜Lšœ˜—Lšžœ˜L˜—L˜Lšžœ˜—…—๊'W