PEConstraintsImpl.mesa
Copyright (C) 1984 by Xerox Corporation. All rights reserved.
Written by Darlene Plebon on August 22, 1983 10:38 am
Last editted by Pauline Ts'o on May 31, 1984 12:36:06 pm PDT
Routines for imposing continuity constaints on the bezier spline segments. First order continuity is achieved by imposing colinearity on the tangent vectors at the junction of the two bezier spline segments.
DIRECTORY
PEConstraints,
PEDisplay USING [DrawVertex, DrawSegment],
PERefresh USING [DisableSegmentRefresh, EnableSegmentRefresh],
PETrajectoryOps USING [FollowingVertex, PrecedingVertex],
PETypes,
ViewerClasses USING [Viewer];
PEConstraintsImpl:
CEDAR
PROGRAM
IMPORTS PEDisplay, PERefresh, PETrajectoryOps
EXPORTS PEConstraints =
BEGIN OPEN PEConstraints, PEDisplay, PERefresh, PETrajectoryOps, PETypes;
Constrain:
PUBLIC PROCEDURE [pathViewer: ViewerClasses.Viewer, vertex: VertexNode, segment: SegmentNode, newPosition: Point] = {
This updates the position of the specified vertex in the specified segment according to the continuity constraints specified for it with respect to adjacent vertices. The application of the constraints may result in other vertices being moved too. This routine also updates the display accordingly.
followingVertex, precedingVertex: VertexNode;
followingSegment, precedingSegment: SegmentNode;
[followingVertex, followingSegment] ← FollowingVertex[vertex, segment];
[precedingVertex, precedingSegment] ← PrecedingVertex[vertex, segment];
UnconstrainedUpdate[pathViewer, vertex, segment, newPosition];
};
UnconstrainedUpdate:
PROCEDURE [pathViewer: ViewerClasses.Viewer, vertex: VertexNode, segment: SegmentNode, newPosition: Point] = {
This routine updates the position of the specified vertex without applying any continuity constraints.
DrawVertexAndSegments[pathViewer: pathViewer, vertex: vertex, segment: segment, undo: TRUE];
vertex.first.point ← newPosition;
DrawVertexAndSegments[pathViewer: pathViewer, vertex: vertex, segment: segment];
};
DrawVertexAndSegments:
PRIVATE PROCEDURE [pathViewer: ViewerClasses.Viewer, vertex: VertexNode, segment: SegmentNode, undo:
BOOLEAN ←
FALSE] = {
This routine draws a vertex and all the segments containing that vertex. This routine disables refresh on the segments drawn if undo is true, and enables refresh if undo is false.
IF undo
THEN {
DisableSegmentRefresh[segment.first];
IF vertex.rest = NIL AND segment.rest # NIL THEN DisableSegmentRefresh[segment.rest.first];
}
ELSE {
EnableSegmentRefresh[segment.first];
IF vertex.rest = NIL AND segment.rest # NIL THEN EnableSegmentRefresh[segment.rest.first];
};
DrawVertex[pathViewer: pathViewer, vertex: vertex.first, undo: undo];
DrawSegment[pathViewer: pathViewer, segment: segment.first, undo: undo];
IF vertex.rest = NIL AND segment.rest # NIL THEN DrawSegment[pathViewer: pathViewer, segment: segment.rest.first, undo: undo];
};