TubeGeometry.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, January 22, 1987 3:40:13 pm PST
DIRECTORY Controls, Imager, IO, Matrix3d, Menus, Rope, Spline3d, TubeDefs, Vector3d;
TubeGeometry: CEDAR DEFINITIONS
~ BEGIN
OPEN TubeDefs;
Setting Spline Coefficients
SetCoeffs: PUBLIC PROC [tube: Tube];
Set the spline coefficients for tube and its descendents.
SetSectionCoeffs: PUBLIC PROC [tube: Tube];
Set the spline coefficients for tube only.
Setting Tube Lengths
SetLengths: PUBLIC PROC [tube: Tube];
Set the length0 and length1 fields for tube and its descendents.
SetSectionLengths: PUBLIC PROC [tube: Tube];
Set the length0 and length1 fields for tube only.
Creating Tube Frames
Make: PUBLIC PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale: REAL ← 1.0,
taper: REAL ← 0.0,
skin: BOOLFALSE,
roundTip: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL];
Create spline coefficients and reference frames for the entire tube (its descendants and
antecedants). For each tube section, points, tangents, radii, and twists are presumed defined.
scale is the amount by which a frame matrix is scaled at the base of the tree.
The scale is reduced according to distance from the tube base and taper; if taper is 0, no
tapering occurs; if taper is 1, then scale is reduced to zero after a distance of 1.
If skin is TRUE then the curve subdivison considers the variation in any associated contours
and at each frame the contour is computed.
If roundTip is TRUE then make the ends of those tubes without branches be hemispherical
by adding additional frames.
If view is NIL, the tube is considered only in object space and epsilon is the same
discriminator as in Spline3d.FlatBezier; if view is non-NIL, epsilon is the number of pixels
the straight line approximation is permitted to deviate from the curve as transformed to
screen space.
If frameProc is non-NIL, it is used to create the each frame; otherwise a standard procedure,
return a frame consisting of a circular cross-section.
MakeFrames: PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale: REAL ← 1.0,
taper: REAL ← 0.0,
skin: BOOLFALSE,
roundTip: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL];
Make the frames for the tube sub-tree (tube and its descendants only).
epsilon, scale, taper, skin, roundTip, view, and frameProc have same meaning as in Make[].
MakeSectionFrames: PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale0, scale1: REAL ← 1.0,
skin: BOOLFALSE,
roundTip: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL];
Create a frame sequence for the tube section only.
epsilon, skin, roundTip, view, and frameProc have the same meaning as in Make[].
scale0 and scale1 are the scales applied at the beginning and end of the tube section.
Altering Tube Frames
ReScale: PUBLIC PROC [tube: Tube, scale: REAL ← 1.0, taper: REAL ← 0.0];
Resize tube.frames to scale*tube.r.
SetCircles: PUBLIC PROC [tube: Tube, circleRes: NAT];
Set all tube frames to be circular, with the given resolution.
Miscellaneous Frame Operations
NFrames: PUBLIC PROC [tube: Tube] RETURNS [INTEGER];
Return the number of frames in tube.
GetFrame: PUBLIC PROC [tube: Tube, t: REAL] RETURNS [Frame];
Return the frame at parametric position t, t IN [0..1].
PutFrame: PUBLIC PROC [tube: Tube, frame: Frame];
Insert the frame in the tube.
CopyFrame: PUBLIC PROC [frames: Frame] RETURNS [Frame];
Return a copy of the input frame.
CopyFrames: PUBLIC PROC [frames: FrameSequence] RETURNS [FrameSequence];
Return a copy of the input frame sequence.
Frame Geometric Operations
Basis: PUBLIC PROC [v, vv, rv: Triple] RETURNS [Triad];
Given tangent v along a curve, previous tangent vv, and reference vector rv, compute
vectors n and b; v, n, and b form a new set of axes; the transformation of the x, y, and z
axes to v, n, and b accomodates the twist in the curve; n and b are unitized.
RefMatrix: PUBLIC PROC [position: Triple, triad: Triad, scale, twist: REAL, out: Matrix ← NIL]
RETURNS [Matrix];
Return matrix which transforms origin to p, xaxis to x, yaxis to y and zaxis to z;
twist around z by t degrees and scale by s.
XYFromFrame: PUBLIC PROC [point: Triple, tube: Tube, t: REAL] RETURNS [Pair];
Return the point as transformed to the x-y plane determined by tube.frames at t.
END.