G3dTriangle.mesa
Copyright © 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, November 21, 1992 3:51 pm PST
Types
Triple: TYPE ~ G3dBasic.Triple;
Patch: TYPE ~ G3dPatch.Patch;
MajorPlane: TYPE ~ G3dPlane.MajorPlane;
Plane:
TYPE ~ G3dPlane.Plane;
Segment: TYPE ~ RECORD [p1, p2: Triple, length: REAL, info: ATOM];
Segments:
TYPE ~
RECORD [length:
INT ¬ 0, s:
SEQUENCE maxLength:
INT
OF Segment];
IntTriple: TYPE ~ RECORD [i, j, k: INT ¬ 0];
IntTriples:
TYPE ~
RECORD [length:
INT ¬ 0, s:
SEQUENCE maxLength:
INT
OF IntTriple];
Triangle:
TYPE ~
RECORD [
p1, p2, p3: Triple ¬ [],
l1, l2, l3: Triple ¬ [], -- connect pts 1-2, 2-3, 3-1 in majorPlane
plane: Plane ¬ [], -- plane of triangle
majorPlane: MajorPlane ¬ xy -- major plane of triangle
];
Triangles: TYPE ~ RECORD [length: INT¬0, s: SEQUENCE maxLength: INT OF REF Triangle];
TriangleProc:
TYPE ~
PROC
[p1, p2:
Triple,
t:
REF
Triangle]
RETURNS
[continue:
BOOL¬
TRUE];
TriIntersection: TYPE ~ RECORD [intersect: BOOL, point: Triple];
Triangle Operations
DistanceToTriangles:
PROC [triangles:
REF
Triangles, p: Triple]
RETURNS [
REAL];
Return the signed distance to the nearest triangle surface, edge, or vertex.
TriangleCenter:
PROC
[t:
REF Triangle]
RETURNS
[c:
Triple];
Return the center of the triangle.
AverageTriangleNormals:
PROC [triangles:
REF Triangles]
RETURNS [Triple];
Return the average of all the triangle normals, which are presumed of unit length.
MaxDeviationFromNormal:
PROC
[normal:
Triple,
triangles:
REF Triangles]
RETURNS
[
REAL];
Return the maximum deviation in degrees of the triangle normals from the given normal.
normal and triangle plane normals presumed unit length.
ApplyToTrianglesSides:
PROC [triangles:
REF Triangles, action: TriangleProc];
Call action for each of the triangles and their edges.
MakeTriangle:
PROC
[p1,
p2,
p3:
Triple, scratch:
REF Triangle ¬
NIL]
RETURNS [
REF Triangle];
Return a set triangle from the three vertices.
SetTriangle:
PROC [t:
REF Triangle];
Set the triangle plane, majorPlane, and lines.
SetTriangles:
PROC [triangles:
REF Triangles];
Set the triangle planes, majorPlanes, and lines.
InsideTriangle:
PROC [p: Triple, t:
REF Triangle]
RETURNS [
BOOL];
Test if the point on the plane of the triangle is contained by the triangle.
IntersectTriangle:
PROC [p1, p2: Triple, t:
REF Triangle]
RETURNS [TriIntersection];
Return the intersection of the line segment with the triangle.
TrianglesFromPatch:
PROC [patch: Patch, sRes, tRes:
INT]
RETURNS [
REF
Triangles];
Return a sequence of set triangles spanning the patch at the given resolution.
BoundaryFromPatch:
PROC [patch: Patch, sRes, tRes:
INT, cullColinearPoints:
BOOL ¬
FALSE]
RETURNS [REF Segments];
Make the boundary given the patch and resolutions.
Normal:
PROC [p1, p2, p3: Triple]
RETURNS [Triple];
Return the normal of the triangle defined by the three points.
ObtainTriangles:
PROC
RETURNS [
REF Triangles];
Obtain a sequence from a scratch pool.
ReleaseTriangles:
PROC [scratch:
REF Triangles];
Return the scratch sequence to the scratch pool.
AddTriangle:
PROC [t:
REF Triangle, triangles:
REF Triangles]
RETURNS [
REF Triangles];
Add the triangle to the sequence.
CopyTriangles:
PROC [triangles:
REF Triangles]
RETURNS [
REF Triangles];
Return a copy of the input sequence of triangles.
AddIntTriple:
PROC [i: IntTriple, intTriples:
REF IntTriples]
RETURNS [
REF IntTriples];
Add i to the sequence.