PETrajectoryOps.mesa
Written by Darlene Plebon on August 22, 1983 1:41 pm
Vertex, segment, and trajectory data structure manipulation routines for the Path Editor.
PETrajectoryOps: CEDAR DEFINITIONS =
BEGIN OPEN PETypes;
Vertex, segment, and trajectory list traversal routines.
VertexProc: TYPE = PROCEDURE [v: VertexNode];
SegmentProc: TYPE = PROCEDURE [s: SegmentNode];
TrajectoryProc: TYPE = PROCEDURE [t: TrajectoryNode];
ForAllVertices:
PROCEDURE [vertexList: VertexList, proc: VertexProc];
This routine traverses a vertex list, calling the client supplied routine for each vertex node.
ForAllSegments:
PROCEDURE [segmentList: SegmentList, proc: SegmentProc];
This routine traverses a segment list, calling the client supplied routine for each segment node.
ForAllTrajectories:
PROCEDURE [trajectoryList: TrajectoryList, proc: TrajectoryProc];
This routine traverses a trajectory list, calling the client supplied routine for each trajectory node.
Vertex manipulation routines.
IsAKnot:
PROCEDURE [vertexNode: VertexNode]
RETURNS [isAKnot:
BOOLEAN];
This routine determines whether the specified vertex is a knot.
IsAControlPoint:
PROCEDURE [vertexNode: VertexNode]
RETURNS [isAControlPoint:
BOOLEAN];
This routine determines whether the specified vertex is a control point.
IsFirstVertex:
PROCEDURE [vertexNode: VertexNode]
RETURNS [isFirst:
BOOLEAN];
This routine determines whether the specified vertex node is the first vertex of the vertex list (segment) containing it.
IsLastVertex:
PROCEDURE [vertexNode: VertexNode]
RETURNS [isLast:
BOOLEAN];
This routine determines whether the specified vertex node is the last vertex of the vertex list (segment) containing it.
InsertVertex:
PROCEDURE [vertexList: VertexList, vertex: Vertex, node: VertexNode]
RETURNS [newVertexList: VertexList, newNode: VertexNode];
This routine inserts the specified vertex into vertexList immediately following the specified node. If the node is NIL, the vertex is inserted at the start of the vertex list. This routine returns the new vertexList, and the new node (for the new vertex).
RemoveVertex:
PROCEDURE [vertexList: VertexList, vertex: VertexNode]
RETURNS [newVertexList: VertexList, prevVertex: VertexNode];
This routine removes the specified vertex from vertexList. This routine returns the new vertexList, along with the vertex node which preceded vertex in the original list.
LastVertexNode:
PROCEDURE [list: VertexList]
RETURNS [vertexNode: VertexNode];
This routine returns the last node in a vertex list.
PrecedingVertex:
PROCEDURE [vertex: VertexNode, segment: SegmentNode]
RETURNS [pVertex: VertexNode, pSegment: SegmentNode];
Given a vertex and the segment containing it, this routine returns the preceding vertex in the segment list and the segment containing it.
FollowingVertex:
PROCEDURE [vertex: VertexNode, segment: SegmentNode]
RETURNS [fVertex: VertexNode, fSegment: SegmentNode];
Given a vertex and the segment containing it, this routine returns the following vertex in the segment list and the segment containing it.
FreeVertexList:
PROCEDURE [vertexList: VertexList];
This routine NILs all the back pointers in a vertex list, so that the garbage collector can collect it.
VertexListLength: PROCEDURE [list: VertexList] RETURNS [length: CARDINAL];
VertexListAppend: PROCEDURE [list1: VertexList, list2: VertexList ← NIL] RETURNS [list: VertexList];
VertexListNthElement:
PROCEDURE [list: VertexList, n:
INTEGER]
RETURNS [vertex: Vertex];
This routine returns NIL if the vertex list has too few elements, unlike the corresponding routine in the list interface which raises a signal.
Segment manipulation routines.
IsFirstSegment:
PROCEDURE [segmentNode: SegmentNode]
RETURNS [isFirst:
BOOLEAN];
This routine determines whether the specified segment node is the first segment of the segment list (trajectory) containing it.
IsLastSegment:
PROCEDURE [segmentNode: SegmentNode]
RETURNS [isLast:
BOOLEAN];
This routine determines whether the specified segment node is the last segment of the segment list (trajectory) containing it.
InsertSegment:
PROCEDURE [segmentList: SegmentList, segment: Segment, node: SegmentNode]
RETURNS [newSegmentList: SegmentList, newNode: SegmentNode];
This routine inserts the specified segment into segmentList immediately following the specified node. If the node is NIL, the segment is inserted at the start of the segment list. This routine returns the new segmentList, and the new node (for the new segment).
SetFP:
PROCEDURE [segment: SegmentNode];
This routine sets the first point field of a segment according to its context (i.e. the nodes around it).
RemoveSegment:
PROCEDURE [segmentList: SegmentList, segment: SegmentNode]
RETURNS [newSegmentList: SegmentList, prevSegment: SegmentNode];
This routine removes the specified segment from segmentList. This routine returns the new segmentList, along with the segment node which preceded segment in the original list.
LastSegmentNode:
PROCEDURE [list: SegmentList]
RETURNS [segmentNode: SegmentNode];
This routine returns the last node in a segment list.
FreeSegmentList:
PROCEDURE [segmentList: SegmentList];
This routine NILs all the back pointers in a segment list (including those in all of its segment and vertex nodes), so that the garbage collector can collect it. This routine also prevents freed nodes from being refreshed.
SwapSegments:
PROCEDURE [segmentList: SegmentList, newSegments: SegmentList, oldSegment: SegmentNode, n:
CARDINAL ← 1]
RETURNS [newSegmentList, oldSegments: SegmentList];
This routine replaces a number of segments in the specified segment list. newSegments is a list of replacements, not necessarily the same length as the piece being removed. oldSegment is the first segment to be replaced in segmentList. n is the number of segments to be replaced. This routine returns the new segment list along with a list of removed segments.
Trajectory manipulation routines.
InsertTrajectory:
PROCEDURE [trajectoryList: TrajectoryList, trajectory: Trajectory, node: TrajectoryNode]
RETURNS [newTrajectoryList: TrajectoryList, newNode: TrajectoryNode];
This routine inserts the specified trajectory into trajectoryList immediately following the specified node. If the node is NIL, the trajectory is inserted at the start of the trajectory list. This routine returns the new trajectoryList, and the new node (for the new trajectory).
RemoveTrajectory:
PROCEDURE [trajectoryList: TrajectoryList, trajectory: TrajectoryNode]
RETURNS [newTrajectoryList: TrajectoryList, prevTrajectory: TrajectoryNode];
This routine removes the specified trajectory from trajectoryList. This routine returns the new trajectoryList, along with the trajectory node which preceded trajectory in the original list.
LastTrajectoryNode:
PROCEDURE [list: TrajectoryList]
RETURNS [trajectoryNode: TrajectoryNode];
This routine returns the last node in a trajectory list.
FreeTrajectoryList:
PROCEDURE [trajectoryList: TrajectoryList];
This routine NILs all the back pointers for a trajectory list (including all those in its trajectory, segment and vertex nodes), so that the garbage collector can collect it. This routine also prevents freed nodes from being refreshed.
END.