DIRECTORY Commander, CommanderOps, FileNames, FS, G3dBasic, G3dShape, G3dTool, G3dVector, IO, Rope; G3dShapeFromPolygonsCmdImpl: CEDAR PROGRAM IMPORTS CommanderOps, FileNames, FS, G3dBasic, G3dShape, G3dTool, G3dVector, IO ~ BEGIN Shape: TYPE ~ G3dShape.Shape; VertexRep: TYPE ~ G3dShape.VertexRep; ROPE: TYPE ~ Rope.ROPE; CommandProc: Commander.CommandProc ~ { argv: CommanderOps.ArgumentVector ¬ CommanderOps.Parse[cmd]; IF argv.argc # 3 THEN RETURN[$Failure, usage] ELSE { MaybeAdd: PROC [t: G3dBasic.Triple] RETURNS [NAT] ~ { IF vertices # NIL THEN FOR n: NAT IN [0..vertices.length) DO IF G3dVector.Equal[t, vertices[n].point] THEN RETURN[n]; ENDLOOP; vertices ¬ G3dShape.AddToVertexSequence[vertices, NEW[VertexRep ¬ [point: t]]]; RETURN[vertices.length-1]; }; in: IO.STREAM ¬ FS.StreamOpen[FileNames.ResolveRelativePath[argv[1]]]; vertices: G3dShape.VertexSequence ¬ NIL; polygons: G3dBasic.SurfaceSequence ¬ NIL; DO ris: IO.STREAM ¬ IO.RIS[IO.GetLineRope[in ! IO.EndOfStream => EXIT]]; IF IO.GetChar[ris ! IO.EndOfStream => LOOP] = '( THEN { IF IO.GetInt[ris ! IO.EndOfStream, IO.Error => LOOP] = 98 THEN { nVertices: NAT; polygon: G3dBasic.Surface; FOR n: NAT IN [0..3) DO [] ¬ IO.GetTokenRope[ris]; ENDLOOP; -- skipping nVertices ¬ IO.GetInt[ris]; [] ¬ IO.GetTokenRope[ris]; -- skip "vertices" polygon ¬ [NIL, NEW[G3dBasic.NatSequenceRep[nVertices]]]; polygon.vertices.length ¬ nVertices; FOR n: NAT IN [0..nVertices) DO reals: ARRAY [0..3) OF REAL; FOR j: NAT IN [0..3) DO reals[j] ¬ IO.GetReal[in]; ENDLOOP; polygon.vertices[nVertices-1-n] ¬ MaybeAdd[[reals[0], reals[1], reals[2]]]; ENDLOOP; polygons ¬ G3dBasic.AddToSurfaceSequence[polygons, polygon]; }; }; ENDLOOP; G3dShape.ShapeToFile[ FileNames.ResolveRelativePath[argv[2]], NEW[G3dShape.ShapeRep ¬ [name: argv[1], surfaces: polygons, vertices: vertices]]]; }; }; usage: ROPE ¬ "ShapeFromPolygons "; G3dTool.Register["ShapeFromPolygons", CommandProc, usage]; END. ” G3dShapeFromPolygonsCmdImpl.mesa Copyright Σ 1985, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 23, 1992 10:44 am PDT ΚΦ–"cedarcode" style•NewlineDelimiter ™™ Jšœ Οeœ6™B™'J˜—JšΟk œZ˜cJ˜—šΠblœžœž˜*JšžœH˜OJ˜—šœž˜J˜Jšœ žœ˜ Jšœ žœ˜'Jšžœžœžœ˜J˜šΠbn œ˜&J˜<šžœ˜Jšžœžœ˜šžœ˜šΟnœžœžœžœ˜5š žœ žœžœžœžœžœž˜