G3dTube.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 15, 1992 4:06 pm PDT
Glassner, June 28, 1989 5:10:57 pm PDT
DIRECTORY Draw2d, G2dContour, G3dBasic, G3dCurve, G3dMatrix, G3dPlane, G3dShape, G3dSpline, G3dVector, Imager, ImagerInterpress, IO, Rope, ViewerClasses;
Tube Definitions
Contour: TYPE ~ G2dContour.Contour;
ContourSequence: TYPE ~ G2dContour.ContourSequence; -- presumed ordered according to t
Frame: TYPE ~ G3dBasic.Frame;
Hull: TYPE ~ G3dBasic.Hull;
Pair: TYPE ~ G3dBasic.Pair;
PairSequence: TYPE ~ G3dBasic.PairSequence;
Ray: TYPE ~ G3dBasic.Ray;
Triad: TYPE ~ G3dBasic.Triad;
Triple: TYPE ~ G3dBasic.Triple;
TripleSequence: TYPE ~ G3dBasic.TripleSequence;
Curve: TYPE ~ G3dCurve.Curve;
Matrix: TYPE ~ G3dMatrix.Matrix;
Plane: TYPE ~ G3dPlane.Plane;
Shape: TYPE ~ G3dShape.Shape;
Bezier: TYPE ~ G3dSpline.Bezier;
NearSpline: TYPE ~ G3dSpline.NearSpline;
Spline: TYPE ~ G3dSpline.Spline;
NearSegment: TYPE ~ G3dVector.NearSegment;
Color: TYPE ~ Imager.Color;
STREAM: TYPE ~ IO.STREAM;
origin: Triple ~ [0.0, 0.0, 0.0];
RadiusMode:
TYPE ~ {linear, square};
XSection: TYPE ~ REF XSectionRep;
XSectionRep:
TYPE ~
RECORD [
t: REAL ¬ 0.0, -- parametric position on curve
frame: Frame ¬ [], -- reference frame
length: REAL ¬ 0.0, -- distance from beginning of curve
scale: REAL ¬ 1.0, -- scale
twist: REAL ¬ 0.0, -- twist
matrix: Matrix ¬ NIL, -- matrix (right-handed) w/ scale,twist
contour: Contour ¬ NIL, -- normalized to unit square
normals: PairSequence ¬ NIL -- normals of contour
];
XSectionSequence: TYPE ~ REF XSectionSequenceRep;
XSectionSequenceRep:
TYPE ~
RECORD [
length: NAT ¬ 0,
element: SEQUENCE maxLength: NAT OF XSection
];
Tube: TYPE ~ REF TubeRep;
TubeRep:
TYPE ~
RECORD [
geometric givens:
p0, p1: Triple ¬ origin, -- Hermite endpoints of curve
v0, v1: Triple ¬ origin, -- Hermite tangents of curve
circleRes: INTEGER ¬ 6, -- # sides of circular contour
epsilon: REAL ¬ 0.03, -- criterion for spline flatness
tw0, tw1: REAL ¬ 0.0, -- twists
tens0, tens1: REAL ¬ 1.0, -- tensions
r0, r1: REAL ¬ 0.05, -- radii
scale: REAL ¬ 1.0, -- applied to radii
taper: REAL ¬ 0.0, -- applied to r1
contours: ContourSequence ¬ NIL, -- optional contours
geometric derivations:
spline: Spline ¬ NIL, -- coefficients of curve
xSpline: Spline ¬ NIL, -- curve xformed to screen
bezier: Bezier ¬ [], -- useful in proximity testing
refVec: Triple ¬ origin, -- reference vector to make xSections
length: REAL ¬ 0.0, -- length of the tube
length0, length1: REAL ¬ 0.0, -- distances from root
plane: Plane ¬ [], -- plane at p1 perpendicular to curve
xSections: XSectionSequence ¬ NIL, -- reference xSections, ordered by t
derivations status:
planeValid: BOOL ¬ FALSE, -- if plane ok
splineValid: BOOL ¬ FALSE, -- if tube.spline were set
lengthsValid: BOOL ¬ FALSE, -- if length, length0, and length1 ok
xSectionsValid: BOOL ¬ FALSE, -- if xSections ok
topology:
prev, next: Tube ¬ NIL, -- parent and continuing tubes
branches: TubeSequence ¬ NIL, -- branch (non-continuing) tubes
nearness:
nearSpline: NearSpline ¬ [], -- relative to a previous query
nearSegment: NearSegment ¬ [], -- relative to a previous query
miscellaneous:
name: ROPE ¬ NIL, -- optional name of tube
color: Color ¬ NIL, -- Imager color
refAny: REF ANY ¬ NIL, -- for client data
selected: BOOL ¬ FALSE -- selected for drawing?
];
TubeSequence: TYPE ~ REF TubeSequenceRep;
TubeSequenceRep:
TYPE ~
RECORD [
length: NAT ¬ 0,
element: SEQUENCE maxLength: NAT OF Tube
];
TubePlace:
TYPE ~
RECORD [tube: Tube, t:
REAL];
DetailType:
TYPE ~ {
autoSimplify, -- kill details if mouse held
label, -- label vectors
skeleton, -- draw straight line skeleton
spline, -- draw spline axis
ends, -- draw spline ends
pick, -- draw picked point
enabled, -- enable viewing of details
xSections, -- reference xSections
lines, -- longitudinal lines
curvature, -- curvature
velocity, -- velocity
acceleration, -- acceleration
contours, -- true: contours, false: circles
points, -- points
normals, -- normals
shape, -- xSections or curvature or velocity or acceleration
skin -- contours or normals
};
Details: TYPE ~ REF DetailsRep;
DetailsRep:
TYPE ~
ARRAY DetailType
OF
BOOL ¬ [
FALSE, -- autoSimplify
TRUE, -- label
FALSE, -- skeleton
TRUE, -- spline
TRUE, -- ends
TRUE, -- pick
TRUE, -- enabled
FALSE, -- xSections
FALSE, -- lines
FALSE, -- curvature
FALSE, -- velocity
FALSE, -- acceleration
FALSE, -- contours
FALSE, -- points
FALSE, -- normals
FALSE, -- shape
FALSE -- skin
];
Miscellany
ShapeFromTube:
PROC [tube: Tube]
RETURNS [Shape];
Create a polygonal shape given tube.
CopyTubeSection:
PROC [tube: Tube, copy: Tube ¬
NIL]
RETURNS [Tube];
Return a copy of the input tube.
CopyEntireTube:
PROC [tube: Tube]
RETURNS [copy: Tube];
Copy tube and all its descendents.
Find:
PROC [searchee, search: Tube]
RETURNS [
BOOL];
Return true iff searchee is somewhere within search.
Where:
PROC [searchee, search: Tube]
RETURNS [
ROPE];
Return the whereabouts of serachee within search; returns NIL if searchee no in search.
SetLastTubePicked:
PROC [tube: Tube];
Set the most recently ScreenPicked tube to be tube.
LastTubePicked:
PROC [copy:
BOOL ¬
TRUE]
RETURNS [Tube];
Return the tube most recently ScreenPicked; if copy then return copy.
First:
PROC [tube: Tube]
RETURNS [Tube];
Return the first antecedent of tube (that is, tube.prev.prev etc. such that tube.prev = NIL).
Last:
PROC [tube: Tube]
RETURNS [Tube];
Return the first last of tube (that is, tube.next.next etc. such that tube.next = NIL).
Divide:
PROC [tube: Tube, t:
REAL];
Divide tube into two parts, from 0 to t, and from t to 1.
Delete:
PROC [tube: Tube];
Delete this tube and all its descendents.
SelectAll:
PUBLIC
PROC [tube: Tube];
Set select field TRUE for tube and its descendents.
UnSelectAll:
PUBLIC
PROC [tube: Tube];
Set select field FALSE for tube and its descendents.
ExtractTubeName:
PROC [fileName:
ROPE]
RETURNS [
ROPE];
Return the base name of the tube.
SetTubeColors:
PROC [tube: Tube];
Set the tube colors according to their recursive depths.
Attributes
TubeHull:
PROC [tube: Tube]
RETURNS [Hull];
Return interesting attributes of the tube.
InvalidateTubeAttributes:
PROC [tube: Tube];
Set splineValid, lengthsValid and xSectionsValid to false for tube and its descendents.
NTubes:
PROC [tube: Tube]
RETURNS [
INTEGER];
Return the number of tubes (tube and its descendents).
NBranches:
PROC [tube: Tube, nextAlso:
BOOL ¬
FALSE]
RETURNS [
INTEGER];
Return the number of branches of tube. Iff nextAlso, add 1 if tube.next # NIL.
NSiblings:
PROC [tube: Tube, tubeAlso:
BOOL ¬
TRUE]
RETURNS [
INTEGER];
Return the number of siblings of tube, including, iff tubeAlso, tube.
NPoints:
PROC [tube: Tube]
RETURNS [
INT];
Return the number of points in the tube.
NPolys:
PROC [tube: Tube]
RETURNS [
INT];
Return the number of polygons in the tube.
NSplinesInBranch:
PROC [tube: Tube]
RETURNS [
INT];
Return the number of splines in the branch.
Depth:
PROC [tube: Tube]
RETURNS [
NAT];
Return the depth of recursion of tube; that is, its recursive distance from its first antecedent.
Info:
PROC [tube: Tube]
RETURNS [nPoints, nPolys, minCres, maxCres:
INT];
Return the total number of points and polygons in a tube, and the extremes of circle res.
Call Backs
Points:
PROC [tube: Tube, pointProc: PointProc, view: Matrix ¬
NIL]
RETURNS [nPoints:
INT];
Apply pointProc to the points in tube; first transform the points by view, if non-nil.
Polys:
PROC [tube: Tube, polyProc: PolyProc]
RETURNS [nPolys:
INT];
Apply polyProc to the polygons in tube.
tubeProc is applied to a subset of tube; a tubeProc is called only if its argument is non-NIL.
ApplyToTube:
PROC [tube: Tube, tubeProc: TubeProc];
Apply tubeProc recursively to tube and its descendant tubes (tube.next, and tube.branches).
ApplyToBranches:
PROC [tube: Tube, tubeProc: TubeProc, nextAlso:
BOOL ¬
TRUE];
Apply tubeProc to tube.branches and, iff nextAlso true, to tube.next.
ApplyToSiblings:
PROC [tube: Tube, tubeProc: TubeProc, tubeAlso:
BOOL ¬
TRUE];
Apply tubeProc to siblings of tube and, iff tubeAlso true, to tube.
IO
ReadTube:
PROC [stream:
STREAM]
RETURNS [Tube];
Read from stream.
WriteTube:
PROC [stream:
STREAM, tube: Tube, m: Matrix ¬
NIL];
Write tube to stream, multiplying points and tangents by m if non-nil.
WritePointsPolys:
PROC [tube: Tube, fileName:
ROPE, m: Matrix ¬
NIL]
RETURNS [nPoints, nPolys: INT];
Write out the points and polygons to the given file;
points are indexed and contain xyz, normal, and uvw data.
WriteIP:
PROC [ref: ImagerInterpress.Ref, tube: Tube, details: Details, m: Matrix]
;
Write the tube to ref; leaving the file open until ImagerInterpress.Close[ref].
TubeFromFile:
PROC [fileName:
ROPE]
RETURNS [tube: Tube];
Return a tube given the file name.
TubeToFile:
PROC [tube: Tube, fileName:
ROPE, matrix: Matrix ¬
NIL];
Write tube to the given file name; transform the tube points according to matrix, if not NIL.
Drawing
DrawType: TYPE ~ Draw2d.DrawType;
MarkType: TYPE ~ Draw2d.MarkType;
Viewport: TYPE ~ G3dMatrix.Viewport;
Context:
TYPE ~ Imager.Context;
DrawTube:
PROC [
context: Context,
tube: Tube,
details: Details,
view: Matrix,
viewport: Viewport ¬ [],
drawType: DrawType ¬ solid];
Draw entire tube according to the details; splines as solid, if selected, or dotted, otherwise.
DrawSkeleton:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
drawType: DrawType ¬ solid];
Draw the entire tube with straight lines.
DrawSplines:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
drawType: DrawType ¬ solid];
Draw splines as drawType, if selected, or dotted, otherwise.
DrawSplineEnds:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
mark: MarkType ¬ dot];
Draw ends of splines with mark.
DrawPoints:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
markType: MarkType ¬ dot];
Draw the contour points.
DrawContours:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
drawType: DrawType ¬ solid];
Draw circles.
DrawLines:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
drawType: DrawType ¬ solid];
Draw lines.
DrawXSections:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
label: BOOL,
drawType: DrawType ¬ solid];
Draw xSections.
DrawNormals:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
label: BOOL,
drawType: DrawType ¬ solid];
Draw normals to the tube.
DrawCurvature:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
label: BOOL,
drawType: DrawType ¬ solid];
Draw curvature vectors.
DrawVelocity:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
label: BOOL,
drawType: DrawType ¬ solid];
Draw tangent vectors.
DrawAcceleration:
PROC [
context: Context,
tube: Tube,
view: Matrix,
viewport: Viewport ¬ [],
label: BOOL,
drawType: DrawType ¬ solid];
Draw acceleration vectors.
NVectors:
PROC [tube: Tube, details: Details]
RETURNS [
INTEGER];
Count number of vectors to draw.