<> <> <> <> <> <<>> DIRECTORY Atom, GGDescribe, GGInterfaceTypes, GGModelTypes, GGSegmentTypes, GGTraj, IO, Rope; GGDescribeImpl: CEDAR PROGRAM IMPORTS Atom, GGTraj, IO, Rope EXPORTS GGDescribe = BEGIN AlignmentPoint: TYPE = GGInterfaceTypes.AlignmentPoint; EntityGenerator: TYPE = GGModelTypes.EntityGenerator; FeatureData: TYPE = GGInterfaceTypes.FeatureData; GGData: TYPE = GGInterfaceTypes.GGData; Outline: TYPE = GGModelTypes.Outline; OutlineDescriptor: TYPE = GGModelTypes.OutlineDescriptor; Segment: TYPE = GGSegmentTypes.Segment; Sequence: TYPE = GGModelTypes.Sequence; SequenceGenerator: TYPE = GGModelTypes.SequenceGenerator; Slice: TYPE = GGModelTypes.Slice; SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor; SliceParts: TYPE = GGModelTypes.SliceParts; Traj: TYPE = GGModelTypes.Traj; TrajGenerator: TYPE = GGModelTypes.TrajGenerator; NotYetImplemented: PUBLIC SIGNAL = CODE; DescribeFeature: PUBLIC PROC [feature: FeatureData, hitData: REF ANY, ggData: GGData] RETURNS [rope: Rope.ROPE] = { IF feature = NIL THEN RETURN["nothing"] ELSE { SELECT feature.type FROM outline, slice => { slice: Slice _ NARROW[feature.shape, SliceDescriptor].slice; rope _ slice.class.describeHit[slice, hitData]; }; distanceLine => rope _ "distance line"; slopeLine => rope _ "slope line"; angleLine => rope _ "angle line"; symmetryLine => rope _ "symmetry line"; radiiCircle => rope _ "compass circle"; intersectionPoint => { firstObj, secondObj: Rope.ROPE; alignPoint: AlignmentPoint _ NARROW[feature.shape]; line1: FeatureData _ alignPoint.curve1; line2: FeatureData _ alignPoint.curve2; tangent: BOOL _ alignPoint.tangent; IF line1 = NIL AND line2 = NIL THEN { rope _ IO.PutFR["the anchor"]; } ELSE { firstObj _ IF line1 # NIL THEN DescribeSourceFeature[line1, ggData] ELSE "unknown"; secondObj _ IF line2 # NIL THEN DescribeSourceFeature[line2, ggData] ELSE "unknown"; IF tangent THEN rope _ IO.PutFR["a %g/%g tangency point", [rope[firstObj]], [rope[secondObj]] ] ELSE rope _ IO.PutFR["a %g/%g intersection point", [rope[firstObj]], [rope[secondObj]] ]; }; }; midpoint => { <> <> alignPoint: AlignmentPoint _ NARROW[feature.shape]; curveFeature: FeatureData _ alignPoint.curve1; SELECT curveFeature.type FROM outline, slice => { slice: Slice _ NARROW[curveFeature.shape, SliceDescriptor].slice; rope _ slice.class.describeHit[slice, hitData]; }; ENDCASE => rope _ "unknown"; rope _ IO.PutFR["midpoint of %g", [rope[rope]]]; }; anchor => { rope _ IO.PutFR["anchor"]; }; ENDCASE => ERROR; }; }; DescribeSourceFeature: PUBLIC PROC [feature: FeatureData, ggData: GGData] RETURNS [rope: Rope.ROPE] = { IF feature = NIL THEN RETURN["nothing"] ELSE { SELECT feature.type FROM outline, slice => rope _ Rope.Concat[Atom.GetPName[NARROW[feature.shape, SliceDescriptor].slice.class.type], " slice"]; distanceLine => rope _ "distance line"; slopeLine => rope _ "slope line"; angleLine => rope _ "angle line"; symmetryLine => rope _ "symmetry line"; radiiCircle => rope _ "compass circle"; intersectionPoint => { firstObj, secondObj: Rope.ROPE; firstObj _ IF NARROW[feature.shape, AlignmentPoint].curve1 # NIL THEN DescribeSourceFeature[NARROW[feature.shape, AlignmentPoint].curve1, ggData] ELSE "unknown"; secondObj _ IF NARROW[feature.shape, AlignmentPoint].curve2 # NIL THEN DescribeSourceFeature[NARROW[feature.shape, AlignmentPoint].curve2, ggData] ELSE "unknown"; rope _ IO.PutFR["a %g/%g intersection point", [rope[firstObj]], [rope[secondObj]] ]; }; midpoint => rope _ IO.PutFR["midpoint of segment ???"]; ENDCASE => ERROR; }; }; DescribeTraj: PUBLIC PROC [traj: Traj] RETURNS [text: Rope.ROPE] = { text _ SELECT traj.role FROM open => IO.PutFR["a %g-segment open trajectory", [integer[traj.segCount]]], fence => IO.PutFR["a %g-segment fence", [integer[traj.segCount]]], hole => IO.PutFR["a %g-segment hole", [integer[traj.segCount]]], ENDCASE => ""; }; DescribeJoint: PUBLIC PROC [traj: Traj, jointNum: NAT] RETURNS [text: Rope.ROPE] = { end: BOOL; end _ GGTraj.IsEndJoint[traj, jointNum]; IF end THEN text _ IO.PutFR["end joint %g on ", [integer[jointNum]] ] ELSE text _ IO.PutFR["joint %g on ", [integer[jointNum]] ]; text _ Rope.Concat[text, DescribeSegment[traj, IF GGTraj.HiJoint[traj]=jointNum AND traj.role=open THEN jointNum-1 ELSE jointNum]]; <> }; DescribeControlPoint: PUBLIC PROC [traj: Traj, segNum: NAT, cpNum: NAT] RETURNS [text: Rope.ROPE] = { text _ Rope.Cat[IO.PutFR["control point %g on ", [integer[cpNum]]], DescribeSegment[traj, segNum] ]; }; DescribeSegment: PUBLIC PROC [traj: Traj, segNum: NAT] RETURNS [text: Rope.ROPE] = { IF segNum=LAST[NAT] THEN text _ Rope.Cat["a segment on ", DescribeTraj[traj]] ELSE { seg: Segment _ GGTraj.FetchSegment[traj, segNum]; text _ Rope.Cat[seg.class.describe[seg, TRUE, TRUE, TRUE, NIL], IO.PutFR[" segment %g on ", [integer[segNum]]], DescribeTraj[traj]]; <> }; }; DescribeSequence: PUBLIC PROC [seq: Sequence] RETURNS [text: Rope.ROPE] = { text _ Rope.Cat[IO.PutFR["One or more parts of "], DescribeTraj[seq.traj]]; }; <> <