DIRECTORY GGBasicTypes, Feedback, GGInterfaceTypes, GGModelTypes, GGOutline, GGScene, GGSelect, GGSegmentTypes, GGSequence, GGSlice, GGTraj, GGUtility, GList, Imager, Rope; GGOutlineImplB: CEDAR PROGRAM IMPORTS Feedback, GGScene, GGSlice, GGOutline, GGSelect, GGSequence, GGTraj, GGUtility, GList EXPORTS GGOutline = BEGIN OPEN GGOutline; BitVector: TYPE = GGBasicTypes.BitVector; BoundBox: TYPE = GGBasicTypes.BoundBox; CameraData: TYPE = GGModelTypes.CameraData; Circle: TYPE = GGBasicTypes.Circle; Color: TYPE = Imager.Color; ControlPointGenerator: TYPE = GGModelTypes.ControlPointGenerator; FeatureData: TYPE = GGInterfaceTypes.FeatureData; GGData: TYPE = GGInterfaceTypes.GGData; Joint: TYPE = GGSegmentTypes.Joint; JointGenerator: TYPE = GGModelTypes.JointGenerator; Line: TYPE = GGBasicTypes.Line; AlignBag: TYPE = GGInterfaceTypes.AlignBag; Outline: TYPE = REF OutlineObj; OutlineObj: TYPE = GGModelTypes.OutlineObj; OutlineClass: TYPE = REF OutlineClassObj; OutlineClassObj: TYPE = GGModelTypes.OutlineClassObj; OutlineData: TYPE = GGOutline.OutlineData; OutlineDataObj: TYPE = GGOutline.OutlineDataObj; OutlineDescriptor: TYPE = GGModelTypes.OutlineDescriptor; OutlineDescriptorObj: TYPE = GGModelTypes.OutlineDescriptorObj; OutlineParts: TYPE = REF OutlinePartsObj; OutlinePartsObj: TYPE = GGOutline.OutlinePartsObj; OutlineSequence: TYPE = GGSelect.OutlineSequence; OutlineSequenceGenerator: TYPE = GGSelect.OutlineSequenceGenerator; Point: TYPE = GGBasicTypes.Point; PointGenerator: TYPE = GGModelTypes.PointGenerator; PointPairGenerator: TYPE = GGModelTypes.PointPairGenerator; Scene: TYPE = GGModelTypes.Scene; Segment: TYPE = GGSegmentTypes.Segment; SegmentGenerator: TYPE = GGModelTypes.SegmentGenerator; SelectMode: TYPE = GGModelTypes.SelectMode; SelectionClass: TYPE = GGSegmentTypes.SelectionClass; Sequence: TYPE = GGModelTypes.Sequence; Slice: TYPE = GGModelTypes.Slice; SliceClass: TYPE = REF SliceClassObj; SliceClassObj: TYPE = GGModelTypes.SliceClassObj; SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor; SliceParts: TYPE = GGModelTypes.SliceParts; Traj: TYPE = REF TrajObj; TrajEnd: TYPE = GGModelTypes.TrajEnd; TrajGenerator: TYPE = REF TrajGeneratorObj; TrajGeneratorObj: TYPE = GGModelTypes.TrajGeneratorObj; TrajObj: TYPE = GGModelTypes.TrajObj; TrajPartType: TYPE = GGModelTypes.TrajPartType; TriggerBag: TYPE = GGInterfaceTypes.TriggerBag; Vector: TYPE = GGBasicTypes.Vector; Problem: PUBLIC SIGNAL [msg: Rope.ROPE] = Feedback.Problem; UnpackOnePointDescriptor: PUBLIC PROC [outlineD: SliceDescriptor] RETURNS [traj: Traj, isACP: BOOL, segNum, cpNum, jointNum: NAT] = { parts: OutlineParts; theSeq: Sequence; IF outlineD = NIL OR outlineD.slice.class.type#$Outline THEN RETURN[NIL, FALSE, 999, 999, 999]; parts _ NARROW[outlineD.parts]; traj _ NIL; FOR list: LIST OF Sequence _ parts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN { IF traj # NIL THEN RETURN[NIL, FALSE, 999, 999, 999] ELSE { theSeq _ list.first; traj _ theSeq.traj; [isACP, segNum, cpNum, jointNum] _ GGSequence.UnpackOnePointSequence[theSeq]; }; }; ENDLOOP; }; UnpackSimpleDescriptor: PUBLIC PROC [outlineD: SliceDescriptor] RETURNS [success: BOOL, partType: TrajPartType, traj: Traj, joint: Joint _ NIL, jointNum: NAT _ 999, cp: Point, cpNum: NAT _ 999, seg: Segment _ NIL, segNum: NAT _ 999] = { parts: OutlineParts; -- list of seq theSeq: Sequence; IF outlineD = NIL OR outlineD.slice.class.type#$Outline THEN RETURN[FALSE, joint, NIL, NIL, 999, [0,0]]; parts _ NARROW[outlineD.parts]; traj _ NIL; FOR list: LIST OF Sequence _ parts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN { IF traj # NIL THEN RETURN[FALSE, joint, NIL, NIL, 999, [0,0]] ELSE { theSeq _ list.first; traj _ theSeq.traj; [success, partType, traj, joint, jointNum, cp, cpNum, seg, segNum] _ GGSequence.UnpackSimpleSequence[theSeq]; }; }; ENDLOOP; }; UnpackOneSegmentDescriptor: PUBLIC PROC [outlineD: SliceDescriptor] RETURNS [traj: Traj, segNum: NAT] = { parts: OutlineParts; theSeq: Sequence; IF outlineD = NIL OR outlineD.slice.class.type#$Outline THEN RETURN[NIL, 999]; parts _ NARROW[outlineD.parts]; traj _ NIL; FOR list: LIST OF Sequence _ parts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN { IF traj # NIL THEN RETURN[NIL, 999] ELSE { theSeq _ list.first; traj _ theSeq.traj; [segNum] _ GGSequence.UnpackOneSegmentSequence[theSeq]; }; }; ENDLOOP; }; FindTrajInDescriptor: PUBLIC PROC [outlineD: OutlineDescriptor, traj: Traj] RETURNS [seq: Sequence] = { outlineParts: OutlineParts; outlineParts _ NARROW[outlineD.parts]; FOR list: LIST OF Sequence _ outlineParts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL AND list.first.traj = traj THEN RETURN[list.first]; ENDLOOP; RETURN[NIL]; }; PartsFromSequence: PUBLIC PROC [outline: Outline, seq: Sequence] RETURNS [sliceParts: SliceParts] = { realParts: OutlineParts; ptr: LIST OF Sequence; trajGen: GGModelTypes.TrajGenerator; sliceParts _ realParts _ NEW[OutlinePartsObj]; [realParts.seqs, ptr] _ GGUtility.StartSequenceList[]; trajGen _ TrajsInOutline[outline]; FOR traj: Traj _ GGScene.NextTraj[trajGen], GGScene.NextTraj[trajGen] UNTIL traj = NIL DO IF traj = seq.traj THEN [realParts.seqs, ptr] _ GGUtility.AddSequence[seq, realParts.seqs, ptr] ELSE [realParts.seqs, ptr] _ GGUtility.AddSequence[NIL, realParts.seqs, ptr]; ENDLOOP; }; DescriptorFromSequence: PUBLIC PROC [outline: Outline, seq: Sequence] RETURNS [sliceD: OutlineDescriptor] = { outlineParts: SliceParts; outlineParts _ PartsFromSequence[outline, seq]; sliceD _ GGSlice.DescriptorFromParts[outline, outlineParts]; }; CopyParts: PUBLIC PROC [outline: Outline, parts: SliceParts] RETURNS [copy: SliceParts] = { realParts, realCopyParts: OutlineParts; copySeq: Sequence; ptr: LIST OF Sequence; realParts _ NARROW[parts]; copy _ realCopyParts _ NEW[OutlinePartsObj]; [realCopyParts.seqs, ptr] _ GGUtility.StartSequenceList[]; FOR list: LIST OF Sequence _ realParts.seqs, list.rest UNTIL list = NIL DO IF list.first = NIL THEN [realCopyParts.seqs, ptr] _ GGUtility.AddSequence[NIL, realCopyParts.seqs, ptr] ELSE { copySeq _ GGSequence.Copy[list.first]; [realCopyParts.seqs, ptr] _ GGUtility.AddSequence[copySeq, realCopyParts.seqs, ptr] }; ENDLOOP; }; AddHole: PUBLIC PROC [outline: Outline, hole: Traj] RETURNS [holier: Outline] = { holyData: OutlineData; holier _ outline.class.copy[outline]; holyData _ NARROW[holier.data, OutlineData]; holyData.children _ AppendTrajList[holyData.children, LIST[hole]]; hole.parent _ holier; hole.role _ hole; UpdateBoundBox[holier]; }; ReplaceFence: PUBLIC PROC [outline: Outline, newFence: Traj] RETURNS [newOutline: Outline] = { newData: OutlineData; holeGen: TrajGenerator; newTraj: Traj; newOutline _ GGOutline.CreateOutline[newFence, NARROW[outline.data, OutlineData].fillColor]; newData _ NARROW[newOutline.data]; holeGen _ HolesOfOutline[outline]; FOR hole: Traj _ GGScene.NextTraj[holeGen], GGScene.NextTraj[holeGen] UNTIL hole = NIL DO newTraj _ GGTraj.CopyTraj[hole]; newData.children _ AppendTrajList[newData.children, LIST[newTraj]]; newTraj.parent _ newOutline; ENDLOOP; UpdateBoundBox[newOutline]; }; ReplaceHole: PUBLIC PROC [outline: Outline, oldHole, newHole: Traj] RETURNS [newOutline: Outline] = { newData: OutlineData; holeGen: TrajGenerator; newTraj, fence: Traj; fence _ FenceOfOutline[outline]; newTraj _ GGTraj.CopyTraj[fence]; newOutline _ CreateOutline[newTraj, NARROW[outline.data, OutlineData].fillColor]; newData _ NARROW[newOutline.data]; holeGen _ HolesOfOutline[outline]; FOR hole: Traj _ GGScene.NextTraj[holeGen], GGScene.NextTraj[holeGen] UNTIL hole = NIL DO IF hole = oldHole THEN { newData.children _ AppendTrajList[newData.children, LIST[newHole]]; newHole.parent _ newOutline; } ELSE { newTraj _ GGTraj.CopyTraj[hole]; newData.children _ AppendTrajList[newData.children, LIST[newTraj]]; newTraj.parent _ newOutline; }; ENDLOOP; UpdateBoundBox[newOutline]; }; OutlineOfTraj: PUBLIC PROC [traj: Traj] RETURNS [outline: Outline] = { outline _ traj.parent; }; TrajectoriesOfOutline: PUBLIC PROC [outline: Slice] RETURNS [children: LIST OF Traj] = { IF outline.class.type#$Outline THEN ERROR; -- temporary check children _ NARROW[outline.data, OutlineData].children; }; SaveSelectionsInOutline: PUBLIC PROC [outline: Slice, scene: Scene] = { outlineD: OutlineDescriptor; outlineParts: OutlineParts; IF outline.class.type#$Outline THEN ERROR; outlineD _ GGSelect.FindSelectedSlice[outline, scene, hot]; ClearSelectionInOutline[outline, hot]; IF outlineD # NIL THEN { outlineParts _ NARROW[outlineD.parts]; FOR seqList: LIST OF Sequence _ outlineParts.seqs, seqList.rest UNTIL seqList = NIL DO IF seqList.first#NIL THEN GGTraj.SaveSelectionInSequence[seqList.first, hot]; ENDLOOP; }; outlineD _ GGSelect.FindSelectedSlice[outline, scene, normal]; ClearSelectionInOutline[outline, normal]; IF outlineD # NIL THEN { outlineParts _ NARROW[outlineD.parts]; FOR seqList: LIST OF Sequence _ outlineParts.seqs, seqList.rest UNTIL seqList = NIL DO IF seqList.first#NIL THEN GGTraj.SaveSelectionInSequence[seqList.first, normal]; ENDLOOP; }; outlineD _ GGSelect.FindSelectedSlice[outline, scene, active]; ClearSelectionInOutline[outline, active]; IF outlineD # NIL THEN { outlineParts _ NARROW[outlineD.parts]; FOR seqList: LIST OF Sequence _ outlineParts.seqs, seqList.rest UNTIL seqList = NIL DO IF seqList.first#NIL THEN GGTraj.SaveSelectionInSequence[seqList.first, active]; ENDLOOP; }; }; ClearSelectionInOutline: PROC [outline: Slice, selectClass: SelectionClass] = { trajGen: GGModelTypes.TrajGenerator; IF outline.class.type#$Outline THEN ERROR; trajGen _ TrajsInOutline[outline]; FOR traj: Traj _ GGScene.NextTraj[trajGen], GGScene.NextTraj[trajGen] UNTIL traj = NIL DO GGTraj.ClearSelection[traj, selectClass]; ENDLOOP; }; RemakeSelectionsFromOutline: PUBLIC PROC [outline: Outline, scene: Scene] = { trajGen: GGModelTypes.TrajGenerator; trajGen _ TrajsInOutline[outline]; FOR traj: Traj _ GGScene.NextTraj[trajGen], GGScene.NextTraj[trajGen] UNTIL traj = NIL DO GGTraj.RemakeSelection[traj, scene, hot]; GGTraj.RemakeSelection[traj, scene, normal]; GGTraj.RemakeSelection[traj, scene, active]; ENDLOOP; }; SequencesOfOutline: PUBLIC PROC [sliceD: OutlineDescriptor] RETURNS [seqList: LIST OF Sequence] = { outlineParts: OutlineParts _ NARROW[sliceD.parts]; ptr: LIST OF Sequence; [seqList, ptr] _ GGUtility.StartSequenceList[]; FOR list: LIST OF Sequence _ outlineParts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN [seqList, ptr] _ GGUtility.AddSequence[list.first, seqList, ptr]; ENDLOOP; }; RemoveTraj: PUBLIC PROC [outlineD: OutlineDescriptor, traj: Traj] RETURNS [newD: OutlineDescriptor] = { outlineParts: OutlineParts _ NARROW[outlineD.parts]; seq: Sequence; FOR list: LIST OF Sequence _ outlineParts.seqs, list.rest UNTIL list = NIL DO IF list.first#NIL AND list.first.traj = traj THEN { seq _ list.first; GOTO Done; }; REPEAT Done => { newSeqs: LIST OF Sequence _ NARROW[GList.Subst[NIL, seq, outlineParts.seqs]]; newParts: SliceParts _ NEW[OutlinePartsObj _ [newSeqs]]; newD _ GGSlice.DescriptorFromParts[outlineD.slice, newParts]; }; FINISHED => newD _ outlineD; ENDLOOP; }; UnpackHitData: PUBLIC PROC [hitData: REF ANY] RETURNS [traj: Traj, hitType: TrajPartType, segNum, cpNum, jointNum: INT, hitPoint: Point] = { outlineHitData: OutlineHitData _ NARROW[hitData]; traj _ outlineHitData.traj; hitType _ outlineHitData.hitType; segNum _ outlineHitData.segNum; cpNum _ outlineHitData.cpNum; jointNum _ outlineHitData.jointNum; hitPoint _ outlineHitData.hitPoint; }; HasHoles: PUBLIC PROC [outline: Outline] RETURNS [BOOL] = { data: OutlineData _ NARROW[outline.data]; RETURN[data.children.rest # NIL]; }; FenceOfOutline: PUBLIC PROC [outline: Outline] RETURNS [fence: Traj] = { data: OutlineData _ NARROW[outline.data]; RETURN[data.children.first]; }; HolesOfOutline: PUBLIC PROC [outline: Outline] RETURNS [trajGen: TrajGenerator] = { data: OutlineData _ NARROW[outline.data]; list: LIST OF Traj _ data.children.rest; trajGen _ NEW[TrajGeneratorObj _ [ list: list ]]; }; TrajsInOutline: PUBLIC PROC [outline: Outline] RETURNS [trajGen: TrajGenerator] = { data: OutlineData _ NARROW[outline.data]; list: LIST OF Traj _ data.children; trajGen _ NEW[TrajGeneratorObj _ [ list: list ]]; }; END.  GGOutlineImplB.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Bier on January 22, 1987 Contents: Procedures to implement the Outline Slice Class in Gargoyle. Outlines consist of Trajectories which in turn consist of Segments. Outline is the most important slice class. OutlineDescribeProc: TYPE = GGModelTypes.OutlineDescribeProc; OutlineFileoutProc: TYPE = GGModelTypes.OutlineFileoutProc; OutlineFileinProc: TYPE = GGModelTypes.OutlineFileinProc; OutlineUnionPartsProc: TYPE = GGModelTypes.OutlineUnionPartsProc; OutlineDifferencePartsProc: TYPE = GGModelTypes.OutlineDifferencePartsProc; OutlineAugmentPartsProc: TYPE = GGModelTypes.OutlineAugmentPartsProc; OutlinePointsInDescriptorProc: TYPE = GGModelTypes.OutlinePointsInDescriptorProc; OutlinePointPairsInDescriptorProc: TYPE = GGModelTypes.OutlinePointPairsInDescriptorProc; OutlineNextPointProc: TYPE = GGModelTypes.OutlineNextPointProc; OutlineNextPointPairProc: TYPE = GGModelTypes.OutlineNextPointPairProc; OutlineClosestPointProc: TYPE = GGModelTypes.OutlineClosestPointProc; OutlineClosestPointAndTangentProc: TYPE = GGModelTypes.OutlineClosestPointAndTangentProc; OutlineClosestSegmentProc: TYPE = GGModelTypes.OutlineClosestSegmentProc; OutlineSetArrowsProc: TYPE = GGModelTypes.OutlineSetArrowsProc; OutlineGetArrowsProc: TYPE = GGModelTypes.OutlineGetArrowsProc; Outline-Only operations. outlineD describes either a single control point or a single joint. Return the [segNum, cpNum] pair or the jointNum as appropriate. UnpackSimpleDescriptorOld: PUBLIC PROC [outlineD: OutlineDescriptor] RETURNS [success: BOOL, partType: TrajPartType, traj: Traj, joint: Joint _ NIL, jointNum: NAT _ 999, cp: Point, cpNum: NAT _ 999, seg: Segment _ NIL, segNum: NAT _ 999] = { parts: OutlineParts; theSeq: Sequence; IF outlineD = NIL THEN RETURN[FALSE, joint, NIL, NIL, 999, [0,0]]; parts _ NARROW[outlineD.parts]; traj _ NIL; FOR list: LIST OF Sequence _ parts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN { IF traj # NIL THEN RETURN[FALSE, joint, NIL, NIL, 999, [0,0]] ELSE { theSeq _ list.first; traj _ theSeq.traj; [success, partType, traj, joint, jointNum, cp, cpNum, seg, segNum] _ GGSequence.UnpackSimpleSequence[theSeq]; }; }; ENDLOOP; }; outlineD describes either a single control point or a single joint. Return the [segNum, cpNum] pair or the jointNum as appropriate. DescriptorFromParts: PUBLIC PROC [outline: Outline, sliceParts: SliceParts] RETURNS [sliceD: OutlineDescriptor] = { sliceD _ NEW[OutlineDescriptorObj _ [outline, sliceParts]]; }; AddHole: PUBLIC PROC [outline: Outline, hole: Traj] RETURNS [holier: Outline] = { Holes can be removed using DeleteSequence. Should check for duplicates. -- Bier, February 20 holier _ outline.class.copy[outline]; holier.children _ AppendTrajList[holier.children, LIST[hole]]; hole.parent _ holier; hole.role _ hole; UpdateBoundBox[holier]; }; Holes can be removed using DeleteSequence. Should check for duplicates. -- Bier, February 20 Like CopyOutline except in one place. Like CopyOutline except in one place. Finds the unique outline to which traj belongs. hotness. normal selection. active selection. This outline has just been created by copying parts from an existing outline. The selection information was copied as well. Make sequences from the selection bits, and select these sequences. hotness. normal selection. active selection. Used by GGSelect to do a DeselectTraj. This will go away when the Caret machinery is revised. UpdateDescriptorBoundBoxes: PUBLIC PROC [outlineD: OutlineDescriptor] = { Update the bound boxes of all contained sequences. parts: OutlineParts _ NARROW[outlineD.parts]; FOR list: LIST OF Sequence _ parts.seqs, list.rest UNTIL list = NIL DO IF list.first # NIL THEN GGSequence.UpdateBoundBox[list.first]; ENDLOOP; }; Queries about Outlines. Returns the unique fence trajectory of outline. Generates all of the holes of outline. Generates the fence and all of the holes of outline. Κί˜J˜Icodešœ™Kšœ Οmœ1™Kšœ™Kšœ™Kšœ™Kšœ™K™—šŸœžœžœ žœ˜QK™*K™1Kšœ˜Kšœ%˜%Kšœ žœ˜,Kšœ6žœ˜BKšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—šŸ œž œ$žœ˜^K™%Kšœ˜K˜Kšœ˜Kšœ/žœ'˜\Kšœ žœ˜"Kšœ"˜"šžœCžœžœž˜YKšœ ˜ Kšœ4žœ ˜CKšœ˜Kšžœ˜—Kšœ˜K˜K˜K˜—šŸ œž œ,žœ˜eK™%Kšœ˜K˜Kšœ˜Kšœ ˜ Kšœ!˜!Kšœ$žœ'˜QKšœ žœ˜"Kšœ"˜"šžœCžœžœž˜Yšžœžœ˜Kšœ4žœ ˜CKšœ˜K˜—šžœ˜Kšœ ˜ Kšœ4žœ ˜CKšœ˜K˜—Kšžœ˜—Kšœ˜K˜K˜—šŸ œžœžœžœ˜FKšœ/™/Kšœ˜K˜K˜—š Ÿœžœžœžœ žœžœ ˜XKšžœžœžœ ˜=Kšœ žœ%˜6K˜K˜—šŸœžœžœ#˜GKšœ˜˜JšΟb™—Kšžœžœžœ˜*Kšœ6‘œ˜;Jšœ!‘œ˜&šžœ žœžœ˜Kšœžœ˜&šžœ=žœ žœž˜VJšžœžœžœ/‘œ˜MJšžœ˜—J˜Jš‘™—Kšœ6‘œ˜>Jšœ!‘œ˜)šžœ žœžœ˜Kšœžœ˜&šžœ=žœ žœž˜VJšžœžœžœ7˜PJšžœ˜—J˜Jš‘™—Kšœ6‘œ˜>Jšœ!‘œ˜)šžœ žœžœ˜Kšœžœ˜&š žœ žœžœ,žœ žœž˜VJšžœžœžœ/‘œ˜PJšžœ˜—J˜—J˜K˜—šŸœžœ2˜OJšœ$˜$Kšžœžœžœ˜*Jšœ"˜"šžœCžœžœž˜YJšœ)˜)Jšžœ˜—Jšœ˜J˜—šŸœžœžœ%˜MK™ΑJšœ$˜$Jšœ"˜"šžœCžœžœž˜YJš‘™Jšœ$‘œ˜)Jš‘™Jšœ$‘œ˜,Jš‘™Jšœ$‘œ˜,Jšžœ˜—K˜K˜—š Ÿœžœžœžœ žœžœ˜cKšœžœ˜2Kšœžœžœ ˜Kšœ/˜/š žœžœžœ)žœžœž˜MJšžœžœžœB˜ZJšžœ˜—K˜K˜—šŸ œžœžœ+žœ˜gK™&Kšœžœ˜4K˜š žœžœžœ)žœžœž˜Mšžœ žœžœžœ˜3J˜Jšžœ˜ J˜—šž˜˜ Jš œ žœžœ žœ žœ˜MJšœžœ˜8Jšœ=˜=J˜—Jšžœ˜—Jšžœ˜—K˜—K™šŸ œžœžœ žœžœžœ>žœ˜ŒK™6Kšœ!žœ ˜1Kšœ˜Kšœ!˜!Kšœ˜Kšœ˜Kšœ#˜#Kšœ#˜#K˜K˜—šŸœžœžœ"™IK™2Kšœžœ™-š žœžœžœ"žœžœž™FJšžœžœžœ'™?Jšžœ™—K™—K™Kšœ‘œ™š Ÿœžœžœžœžœ˜