DIRECTORY Controls, Draw2d, Draw3d, Imager, Matrix3d, Rope, Spline3d, TubeDefs, TubeDisplay, TubeStructure, Vector3d; TubeDisplayImpl: CEDAR PROGRAM IMPORTS Controls, Draw2d, Draw3d, Matrix3d, Spline3d, TubeStructure, Vector3d EXPORTS TubeDisplay ~ BEGIN OPEN TubeDefs; ShowTube: PUBLIC PROC [tube: Tube, context: Context, details: Details, view: Matrix] ~ { IF details.skel THEN ShowSkel[tube, context, view]; IF details.spline THEN ShowSplines[tube, context, view]; IF details.lines THEN ShowLines[tube, context, view]; IF details.circles THEN ShowCircles[tube, context, view]; IF details.frames THEN ShowFrames[tube, context, view, details.label]; IF details.normals THEN ShowNormals[tube, context, view, details.label]; IF details.curv THEN ShowCurv[tube, context, view, details.label]; IF details.vel THEN ShowVel[tube, context, view, details.label]; IF details.acc THEN ShowAcc[tube, context, view, details.label]; }; ShowSkel: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { IF tube = NIL THEN RETURN; Draw3d.PP[tube.p0, tube.p1, context, view, IF tube.selected THEN solid ELSE dot]; ShowSkel[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowSkel[tube.branches[n], context, view]; ENDLOOP; }; ShowSplines: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { IF tube = NIL THEN RETURN; IF tube.selected THEN Draw3d.DrawCurve[tube.c, context, view] ELSE Draw3d.DotCurve[tube.c, context, view]; ShowSplines[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowSplines[tube.branches[n], context, view]; ENDLOOP; }; ShowSplineEnds: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, mark: Draw2d.MarkType _ dot] ~ { IF tube = NIL THEN RETURN; Draw3d.Mark[tube.p0, context, view, mark]; Draw3d.Mark[tube.p1, context, view, mark]; ShowSplineEnds[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowSplines[tube.branches[n], context, view]; ENDLOOP; }; ShowCircles: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { InnerShowCircles: PROC [t: Tube] ~ { circle: PairSequence _ TubeStructure.GetCircle[tube.circleRes]; FOR i: NAT IN[0..(IF t.next = NIL THEN t.axialRes ELSE t.axialRes-1)) DO p0, psave: Pair _ Matrix3d.TransformD[Matrix3d.TransformPair[circle[0], t.frames[i].m], view]; FOR j: NAT IN[1..tube.circleRes) DO p1: Pair _ Matrix3d.TransformD[Matrix3d.TransformPair[circle[j], t.frames[i].m], view]; Draw2d.Solid[context, p0, p1]; p0 _ p1; ENDLOOP; Draw2d.Solid[context, p0, psave]; ENDLOOP; }; IF tube = NIL THEN RETURN; InnerShowCircles[tube]; ShowCircles[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowCircles[tube.branches[n], context, view]; ENDLOOP; }; ShowLines: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { circle: PairSequence; IF tube = NIL THEN RETURN; circle _ TubeStructure.GetCircle[tube.circleRes]; FOR i: NAT IN[0..tube.circleRes) DO p0: Pair _ Matrix3d.TransformD[Matrix3d.TransformPair[circle[i], tube.frames[0].m], view]; FOR j: NAT IN[1..tube.axialRes) DO p1: Pair _ Matrix3d.TransformD[Matrix3d.TransformPair[circle[i],tube.frames[j].m],view]; Draw2d.Solid[context, p0, p1]; p0 _ p1; ENDLOOP; ENDLOOP; ShowLines[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowLines[tube.branches[n], context, view]; ENDLOOP; }; ShowFrames: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, label: BOOL] ~ { names: ARRAY[0..2] OF Rope.ROPE _ ["x", "y", "z"]; ShowMatrix: PROC [m: Matrix] ~ { o: Pair _ Matrix3d.TransformD[[m[3][0], m[3][1], m[3][2]], view]; FOR i: NAT IN[0..2] DO p: Pair _ Matrix3d.TransformD[[m[3][0]+m[i][0],m[3][1]+m[i][1],m[3][2]+m[i][2]],view]; Draw2d.Solid[context, o, p]; IF label THEN Draw2d.Label[context, p, names[i]]; ENDLOOP; }; IF tube = NIL THEN RETURN; FOR i: NAT IN[0..(IF tube.next = NIL THEN tube.axialRes ELSE tube.axialRes-1)) DO IF tube.frames[i].m # NIL THEN ShowMatrix[tube.frames[i].m]; ENDLOOP; ShowFrames[tube.next, context, view, label]; FOR n: NAT IN [0..tube.nBranches) DO ShowFrames[tube.branches[n], context, view, label]; ENDLOOP; }; ShowNormals: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, label: BOOL] ~ { tapered: BOOL; vFactor: REAL; circle: PairSequence; ShowN: PROC [f: Frame] ~ { FOR j: NAT IN[0..tube.circleRes) DO p: Triple _ Matrix3d.TransformPair[circle[j], f.m]; n: Triple _ Matrix3d.TransformVec[[circle[j].x, circle[j].y, 0.0], f.m]; IF tapered THEN { v: Triple _ Spline3d.Velocity[tube.c, f.t]; len: REAL _ Vector3d.Mag[n]; n _ Vector3d.Add[n, Vector3d.Mul[v, len*vFactor/Vector3d.Mag[v]]]; }; n _ Vector3d.Normalize[n]; Draw3d.PV[p, n, IF label THEN "n" ELSE NIL, context, view, , 0.1]; ENDLOOP; }; IF tube = NIL THEN RETURN; circle _ TubeStructure.GetCircle[tube.circleRes]; tapered _ tube.r1 # tube.r0; IF tapered THEN vFactor _ (tube.r0-tube.r1)/Vector3d.Distance[tube.p0, tube.p1]; FOR i: NAT IN[0..(IF tube.next = NIL THEN tube.axialRes ELSE tube.axialRes-1)) DO IF tube.frames[i].m # NIL THEN ShowN[tube.frames[i]]; ENDLOOP; ShowNormals[tube.next, context, view, label]; FOR n: NAT IN [0..tube.nBranches) DO ShowNormals[tube.branches[n], context, view, label]; ENDLOOP; }; ShowCurv: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, label: BOOL] ~ { ShowK: PROC [f: Frame] ~ { p: Triple _ [f.m[3][0], f.m[3][1], f.m[3][2]]; k: Triple _ Spline3d.Curvature[tube.c, f.t]; Draw3d.PV[p, k, IF label THEN "k" ELSE NIL, context, view]; }; IF tube = NIL THEN RETURN; FOR i: NAT IN[0..(IF tube.next = NIL THEN tube.axialRes ELSE tube.axialRes-1)) DO IF tube.frames[i].m # NIL THEN ShowK[tube.frames[i]]; ENDLOOP; ShowCurv[tube.next, context, view, label]; FOR n: NAT IN [0..tube.nBranches) DO ShowCurv[tube.branches[n], context, view, label]; ENDLOOP; }; ShowVel: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, label: BOOL] ~ { ShowV: PROC [f: Frame] ~ { p: Triple _ [f.m[3][0], f.m[3][1], f.m[3][2]]; v: Triple _ Spline3d.Velocity[tube.c, f.t]; Draw3d.PV[p, v, IF label THEN "v" ELSE NIL, context, view]; }; IF tube = NIL THEN RETURN; ShowV[tube.frames[0]]; IF tube.next = NIL THEN ShowV[tube.frames[tube.axialRes-1]]; ShowVel[tube.next, context, view, label]; FOR n: NAT IN [0..tube.nBranches) DO ShowVel[tube.branches[n], context, view, label]; ENDLOOP; }; ShowAcc: PUBLIC PROC [tube: Tube, context: Context, view: Matrix, label: BOOL] ~ { ShowA: PROC [f: Frame] ~ { p: Triple _ [f.m[3][0], f.m[3][1], f.m[3][2]]; a: Triple _ Spline3d.Acceleration[tube.c, f.t]; Draw3d.PV[p, a, IF label THEN "a" ELSE NIL, context, view]; }; IF tube = NIL THEN RETURN; FOR i: NAT IN[0..(IF tube.next = NIL THEN tube.axialRes ELSE tube.axialRes-1)) DO IF tube.frames[i].m # NIL THEN ShowA[tube.frames[i]]; ENDLOOP; ShowAcc[tube.next, context, view, label]; FOR n: NAT IN [0..tube.nBranches) DO ShowAcc[tube.branches[n], context, view, label]; ENDLOOP; }; NVectors: PUBLIC PROC [tube: Tube, details: Details] RETURNS [NAT] ~ { sum: NAT _ 0; IF details.on THEN FOR t: Tube _ tube, t.next WHILE t # NIL DO sum _ sum +(IF details.circles THEN t.circleRes*t.axialRes ELSE 0) +(IF details.lines THEN t.circleRes*t.axialRes ELSE 0) +(IF details.frames THEN 3*t.axialRes ELSE 0); ENDLOOP; RETURN[sum]; }; ToggleDetail: PUBLIC PROC [details: Details, toToggle: DetailType, trueName, falseName: Rope.ROPE, outerData: Controls.OuterData] ~ { state: BOOL; SELECT toToggle FROM auto => state _ details.auto _ NOT details.auto; label => state _ details.label _ NOT details.label; skel => state _ details.skel _ NOT details.skel; pick => state _ details.pick _ NOT details.pick; spline => state _ details.spline _ NOT details.spline; circles => state _ details.circles _ NOT details.circles; lines => state _ details.lines _ NOT details.lines; frames => state _ details.frames _ NOT details.frames; normals => state _ details.normals _ NOT details.normals; curv => state _ details.curv _ NOT details.curv; vel => state _ details.vel _ NOT details.vel; acc => state _ details.acc _ NOT details.acc; ENDCASE => NULL; details.shape _ details.circles OR details.lines OR details.frames OR details.normals; details.on _ details.spline OR details.shape OR details.curv OR details.vel OR details.acc; Controls.EntryToggle[outerData, state, trueName, falseName]; }; END. .. ςTubeDisplayImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, May 23, 1986 1:25:44 pm PDT See TubeIOImpl.Points FOR i: NAT IN[0..(IF tube.next = NIL THEN tube.axialRes ELSE tube.axialRes-1)) DO IF tube.frames[i].m # NIL THEN ShowV[tube.frames[i]]; ENDLOOP; ShowCircles: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { InnerShowCircles: PROC [t: Tube] ~ { circle: PairSequence _ TubeStructure.GetCircle[tube.circleRes]; FOR i: NAT IN[0..(IF t.next = NIL THEN t.axialRes ELSE t.axialRes-1)) DO m: Matrix _ Matrix3d.Mul[t.frames[i].m, view]; psave, p0: Pair _ Matrix3d.TransformPairD[circle[0], m]; FOR j: NAT IN[1..tube.circleRes) DO p1: Pair _ Matrix3d.TransformPairD[circle[j], m]; Draw2d.Solid[context, p0, p1]; p0 _ p1; ENDLOOP; Draw2d.Solid[context, p0, psave]; ENDLOOP; }; IF tube = NIL THEN RETURN; InnerShowCircles[tube]; ShowCircles[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowCircles[tube.branches[n], context, view]; ENDLOOP; }; ShowLines: PUBLIC PROC [tube: Tube, context: Context, view: Matrix] ~ { circle: PairSequence; IF tube = NIL THEN RETURN; circle _ TubeStructure.GetCircle[tube.circleRes]; IF xmats = NIL OR tube.axialRes > xmats.length THEN xmats _ NEW[MatrixSeqRep[tube.axialRes]]; FOR i: NAT IN[0..tube.axialRes) DO xmats[i] _ Matrix3d.Mul[tube.frames[i].m, view--, xmats[i]--]; ENDLOOP; FOR i: NAT IN[0..tube.circleRes) DO p0: Pair _ Matrix3d.TransformPairD[circle[i], xmats[0]]; FOR j: NAT IN[1..tube.axialRes) DO p1: Pair _ Matrix3d.TransformPairD[circle[i], xmats[j]]; Draw2d.Solid[context, p0, p1]; p0 _ p1; ENDLOOP; ENDLOOP; ShowLines[tube.next, context, view]; FOR n: NAT IN [0..tube.nBranches) DO ShowLines[tube.branches[n], context, view]; ENDLOOP; }; Κ ˜šœ™Jšœ Οmœ1™šœ ˜ Jšœžœžœžœ˜8Jšœžœžœžœ˜6Jšœžœžœžœ˜.—Kšžœ˜—Kšžœ˜ J˜—J˜š  œžœžœDžœ$˜…Jšœžœ˜ J˜šžœ ž˜Jšœ!žœ˜2Jšœ#žœ˜5Jšœ!žœ˜2Jšœ!žœ˜2Jšœ%žœ˜8Jšœ&žœ˜:Jšœ#žœ˜5Jšœ$žœ˜7Jšœ&žœ˜:Jšœ"žœ˜3Jšœ žœ ˜0Jšœ žœ ˜0Jšžœžœ˜J˜—Jšœ žœžœžœ˜VJš œžœžœžœ žœ ˜[J˜Jšœ<˜™>Kšžœ™—J™šžœžœžœž™#J™8šžœžœžœž™"J™8J™J™Jšžœ™—Jšžœ™J™—K™$J™šžœžœžœž™$Jšœ+™+Jšžœ™—J™J™—J™——…— `3ί