<> <> <> <> <<>> DIRECTORY GGDescribe, GGModelTypes, GGTouch, IO, Rope; GGDescribeImpl: CEDAR PROGRAM IMPORTS GGTouch, IO, Rope EXPORTS GGDescribe = BEGIN EntityGenerator: TYPE = GGModelTypes.EntityGenerator; Cluster: TYPE = GGModelTypes.Cluster; Outline: TYPE = GGModelTypes.Outline; Sequence: TYPE = GGModelTypes.Sequence; SequenceGenerator: TYPE = GGModelTypes.SequenceGenerator; TouchItem: TYPE = GGModelTypes.TouchItem; TouchItemGenerator: TYPE = GGTouch.TouchItemGenerator; TouchGroup: TYPE = GGModelTypes.TouchGroup; Traj: TYPE = GGModelTypes.Traj; TrajGenerator: TYPE = GGModelTypes.TrajGenerator; NotYetImplemented: PUBLIC SIGNAL = CODE; DescribeCluster: PUBLIC PROC [cluster: Cluster] RETURNS [text: Rope.ROPE] = { SIGNAL NotYetImplemented; }; DescribeOutline: PUBLIC PROC [outline: Outline] RETURNS [text: Rope.ROPE] = { SIGNAL NotYetImplemented; }; DescribeTraj: PUBLIC PROC [traj: Traj] RETURNS [text: Rope.ROPE] = { SELECT traj.role FROM open => text _ IO.PutFR["an open trajectory with %g segments", [integer[traj.segCount]]]; fence => text _ IO.PutFR["a fence trajectory with %g segments", [integer[traj.segCount]]]; hole => text _ IO.PutFR["a hole trajectory with %g segments", [integer[traj.segCount]]]; ENDCASE => ERROR; }; DescribeSegment: PUBLIC PROC [traj: Traj, segNum: NAT] RETURNS [text: Rope.ROPE] = { segRope: Rope.ROPE; segRope _ IO.PutFR["segment %g on ", [integer[segNum]]]; text _ Rope.Concat[segRope, DescribeTraj[traj]]; }; DescribeJoint: PUBLIC PROC [traj: Traj, jointNum: NAT] RETURNS [text: Rope.ROPE] = { jointRope: Rope.ROPE; jointRope _ IO.PutFR["joint %g on ", [integer[jointNum]]]; text _ Rope.Concat[jointRope, DescribeTraj[traj]]; }; DescribeSequence: PUBLIC PROC [seq: Sequence] RETURNS [text: Rope.ROPE] = { seqRope: Rope.ROPE; IF seq.parts.rest = NIL THEN seqRope _ IO.PutFR["From joint %g to %g on ", [integer[seq.parts.first.start]], [integer[seq.parts.first.end]] ] ELSE seqRope _ IO.PutFR["Several parts of "]; text _ Rope.Concat[seqRope, DescribeTraj[seq.traj]]; }; DescribeItem: PROC [f: IO.STREAM, item: TouchItem] = { SELECT item.touchingPartType FROM joint => f.PutF["Item: joint on %g", [rope[DescribeTraj[item.traj]]]]; segment => f.PutF["Item: segment on %g", [rope[DescribeTraj[item.traj]]]]; ENDCASE => ERROR; }; DescribeTouchGroup: PUBLIC PROC [group: TouchGroup] RETURNS [text: Rope.ROPE] = { f: IO.STREAM; touchGen: TouchItemGenerator; f _ IO.ROS[]; f.PutF["TouchGroup: (%6.1f, %6.1f)\n", [real[group.point[1]]], [real[group.point[2]]]]; touchGen _ GGTouch.AllTouchItems[group]; FOR item: TouchItem _ GGTouch.NextTouchItem[touchGen], GGTouch.NextTouchItem[touchGen] UNTIL item = NIL DO f.PutChar[IO.TAB]; DescribeItem[f, item]; f.PutChar[IO.CR]; ENDLOOP; text _ IO.RopeFromROS[f]; }; END.