DIRECTORY Commander, G3dBasic, G3dSpline, G3dTool, G3dVector, ImplicitConvolve, ImplicitDefs, ImplicitDesign, IO, RealFns, Rope; ImplicitConvolveCmdsImpl: CEDAR PROGRAM IMPORTS G3dBasic, G3dSpline, G3dVector, ImplicitConvolve, ImplicitDesign, IO, RealFns ~ BEGIN Triple: TYPE ~ G3dBasic.Triple; TripleSequence: TYPE ~ G3dBasic.TripleSequence; AnimProc: TYPE ~ G3dTool.AnimateProc; Primitive: TYPE ~ ImplicitConvolve.Primitive; PrimitiveList: TYPE ~ ImplicitConvolve.PrimitiveList; Tool: TYPE ~ ImplicitConvolve.Tool; TripleList: TYPE ~ ImplicitConvolve.TripleList; ROPE: TYPE ~ Rope.ROPE; Data: TYPE ~ RECORD [tool: Tool]; MakeTool: PROC [name: ROPE, level: REAL, primitives: PrimitiveList, anim: AnimProc ¬ NIL] ~ { data: REF Data ¬ NEW[Data]; data.tool ¬ ImplicitConvolve.MakeTool[ name: name, client: [animate: anim, data: data], toolSettings: [level: level], primitives: primitives]; }; Triangle: Commander.CommandProc ~ { primitives: PrimitiveList ¬ MakePolys[LIST[LIST[[0, 0, 0], [-.4, 0, .4], [.4, 0, .4]]]]; MakeTool["triangle", 0.2, primitives]; }; SegTri: Commander.CommandProc ~ { a: Triple ¬ [-.4, 0, .4]; -- upper left triangle b: Triple ¬ [.4, 0, .4]; -- upper right triangle c: Triple ¬ [.096, 0, 0]; -- lower right triangle, upper right segment d: Triple ¬ [-.096, 0, 0]; -- lower left triangle, upper left segment e: Triple ¬ [.096, 0, -.45]; -- lower right segment f: Triple ¬ [-.096, 0, -.45]; -- lower left segment primitives: PrimitiveList ¬ MakePolys[LIST[LIST[a, b, c, d], LIST[c, d, f, e]]]; MakeTool["segtri", 0.1, primitives]; }; Sticks: Commander.CommandProc ~ { primitives: PrimitiveList ¬ MakePolys[LIST[LIST[[0, 0, -.5], [0, 0, .5]], LIST[[-.5, 0, 0], [.5, 0, 0]]]]; MakeTool["sticks", 0.1, primitives]; }; Cylinder: Commander.CommandProc ~ { primitives: PrimitiveList ¬ MakePolys[LIST[LIST[[-.5, 0, 0], [.5, 0, 0]]]]; MakeTool["cylinder", 0.2, primitives]; }; Twist: Commander.CommandProc ~ { a: Triple ¬ [.4, 0, -.2]; -- lower right b: Triple ¬ [-.4, 0, -.2]; -- lower left c: Triple ¬ [-.4, 0, .2]; -- upper left d: Triple ¬ [.4, 0, .2]; -- upper right twist: ImplicitConvolve.Twist ¬ [0.0, 90.0*3.1415926535/180.0, [-.4, 0, 0], [.4, 0, 0]]; triples: TripleSequence ¬ G3dBasic.TripleSequenceFromList[LIST[a, b, c, d]]; twister: Primitive ¬ ImplicitConvolve.MakePrimitive[points: triples, extent: 0.1, twist: twist]; MakeTool["twist", 0.1, LIST[twister]]; }; CurveMake: PROC [a: REAL, nPts: NAT ¬ 10] RETURNS [l: LIST OF TripleList] ~ { bez0: G3dSpline.Bezier ¬ [[-.5, -.2, -.25], [-.25, -.1, .25], [.25, .1, .25], [.5, .2, -.25]]; bez1: G3dSpline.Bezier ¬ [[-.15, -.1, -.3], [-.05, -.05, .3], [.05, .05, .3], [.15, .1, -.3]]; bez: G3dSpline.Bezier ¬ [ G3dVector.Interp[a, bez0.b0, bez1.b0], G3dVector.Interp[a, bez0.b1, bez1.b1], G3dVector.Interp[a, bez0.b2, bez1.b2], G3dVector.Interp[a, bez0.b3, bez1.b3]]; spline: G3dSpline.Spline ¬ G3dSpline.SplineFromBezier[bez]; p0: Triple ¬ G3dSpline.Position[spline, 0.0]; IF nPts > 2 THEN FOR n: NAT IN [1..nPts) DO p1: Triple ¬ G3dSpline.Position[spline, REAL[n]/REAL[nPts-1]]; l ¬ CONS[LIST[p0, p1], l]; p0 ¬ p1; ENDLOOP; }; CurveAnim: AnimProc ~ {SetPolysFromPoints[clientData, CurveMake[alpha]]}; Curve: Commander.CommandProc ~ { MakeTool["curve", 0.2, MakePolys[CurveMake[0.0]], CurveAnim]; }; CrossRectangles: PROC [degrees: REAL] RETURNS [LIST OF TripleList] ~ { MakeRectangle: PROC [p0, p1: Triple] RETURNS [rect: TripleList] ~ { axis: Triple ¬ G3dVector.Sub[p1, p0]; v: Triple ¬ G3dVector.SetVectorLength[G3dVector.Cross[axis, [0, 0, 1]], 0.5]; v ¬ G3dVector.RotateAbout[v, axis, degrees]; rect ¬ LIST[p0, G3dVector.Add[p0, v], G3dVector.Add[p1, v], p1]; }; square: TripleList ¬ LIST[[-.1, -.1, 0], [-.1, .1, 0], [.1, .1, 0], [.1, -.1, 0]]; left: TripleList ¬ MakeRectangle[[-.1, .1, 0], [-.1, -.1, 0]]; right: TripleList ¬ MakeRectangle[[.1, .1, 0], [-.1, .1, 0]]; top: TripleList ¬ MakeRectangle[[.1, -.1, 0], [.1, .1, 0]]; bottom: TripleList ¬ MakeRectangle[[-.1, -.1, 0], [.1, -.1, 0]]; RETURN[LIST[square, left, right, top, bottom]]; }; CrossAnim: AnimProc ~ {SetPolysFromPoints[clientData, CrossRectangles[90.0*alpha]]}; Cross: Commander.CommandProc ~ { MakeTool["cross", 0.2, MakePolys[CrossRectangles[0]], CrossAnim]; }; RectsPoints: PROC [angle: REAL] RETURNS [points: LIST OF TripleList] ~ { x: REAL ¬ 0.4*RealFns.Cos[angle]; y: REAL ¬ 0.4*RealFns.Sin[angle]; a: Triple ¬ [x, .4, y]; -- upper right rectangle1 b: Triple ¬ [-x, .4, -y]; -- upper left rectangle1 c: Triple ¬ [-x, 0, -y]; -- lower left rectangle1 d: Triple ¬ [x, 0, y]; -- lower right rectangle1 e: Triple ¬ [.4, 0, 0]; -- upper right rectangle2 f: Triple ¬ [-.4, 0, 0]; -- upper left rectangle2 g: Triple ¬ [-.4, -.4, 0]; -- lower left rectangle2 h: Triple ¬ [.4, -.4, 0]; -- lower right rectangle2 points ¬ LIST[LIST[e, f, g, h], LIST[a, b, c, d]]; }; RectsAnim: AnimProc ~ {SetPolysFromPoints[clientData, RectsPoints[0.5*3.1415926535*alpha]]}; Rects: Commander.CommandProc ~ { MakeTool["rectangles", .2, MakePolys[RectsPoints[0]], RectsAnim]; }; SetPolysFromPoints: PROC [data: REF ANY, points: LIST OF TripleList] ~ { t: Tool ¬ NARROW[data, REF Data].tool; t.primitives ¬ MakePolys[points]; IO.PutRope[t.cmd.out, "SetPolysFromPoints: calling make maps\n"]; ImplicitConvolve.DoMakeMaps[t]; }; MakePolys: PROC [points: LIST OF TripleList] RETURNS [primitives: PrimitiveList ¬ NIL] ~ { FOR l: LIST OF TripleList ¬ points, l.rest WHILE l # NIL DO triples: TripleSequence ¬ G3dBasic.TripleSequenceFromList[l.first]; primitives ¬ CONS[ImplicitConvolve.MakePrimitive[points: triples, extent: 0.15, color: [0, 0, 0]], primitives]; ENDLOOP; }; ImplicitDesign.Register["Triangle", Triangle, "a triangle", "ImplicitConvolve"]; ImplicitDesign.Register["SegTri", SegTri, "a segment and triangle", "ImplicitConvolve"]; ImplicitDesign.Register["Cylinder", Cylinder, "a cylinder", "ImplicitConvolve"]; ImplicitDesign.Register["Rects", Rects, "two rectangles", "ImplicitConvolve"]; ImplicitDesign.Register["Cross", Cross, "a cross", "ImplicitConvolve"]; ImplicitDesign.Register["Sticks", Sticks, "\ttwo sticks", "ImplicitConvolve"]; ImplicitDesign.Register["Twist", Twist, "\ttwisted rectangle", "ImplicitConvolve"]; ImplicitDesign.Register["Curve", Curve, "a curve in several segments", "ImplicitConvolve"]; END. θ ImplicitConvolveCmdsImpl.mesa Copyright Σ 1990 by Xerox Corporation. All rights reserved. Bloomenthal, November 21, 1992 7:37 pm PST Types Simple Commands Animated Curve Animated Cross Animated Rectangles Support Start Code ΚΖ•NewlineDelimiter ™™Jšœ<™Jšœœœ ˜J˜Jšœ˜—˜J˜——š  œ@˜IJ˜—š œ˜ Jšœ=˜=Jšœ˜——šŸ™š  œœ œœœœ˜Fš  œœœ˜CJ˜%J˜MJ˜,Jšœœ5˜@J˜—Jšœœ9˜RJ˜>J˜=J˜;J˜@Jšœœ$˜/˜J˜——š  œK˜TJ˜—š œ˜ JšœA˜AJšœ˜——šŸ™š   œœ œœ œœ˜HJšœœ˜!Jšœœ˜!Jšœ’˜3Jšœ’˜4Jšœ’˜3Jšœ’˜3Jšœ’˜3Jšœ’˜4Jšœ’˜5Jšœ’˜6Jšœ œœœ˜2Jšœ˜J˜—š  œS˜\J˜—š œ˜ JšœA˜AJšœ˜——šŸ™š  œœœœ œœ˜HJšœ œœ ˜&J˜!Jšœ œ˜AJšœ˜Jšœ˜Jšœ˜—š   œœ œœ œœ˜Zš œœœœœ˜;J˜CJšœ œ^˜oJšœ˜—J˜——šŸ ™ JšœP˜PJšœX˜XJšœP˜PJšœN˜NJšœG˜GJšœN˜NJšœS˜SJšœ[˜[—Icode˜Jšœ˜J˜J˜—…—Δr