-- File: SVFaces.mesa
-- Last edited by Bier on December 18, 1982 1:15 am
-- Author: Eric Bier on August 27, 1982 10:03 am
-- Contents: Definitions of various face types such as Cone, Disk Ring, and Cylinder and procedures which make them from simpler data

DIRECTORY
 SV2d,
 SVBoundBox,
 SVVector3d;

SVFaces: DEFINITIONS =
BEGIN
BoundBox: TYPE = SVBoundBox.BoundBox;
BoundHedron: TYPE = SVBoundBox.BoundHedron;
TrigLineSeg: TYPE = REF TrigLineSegObj;
TrigLineSegObj: TYPE = SV2d.TrigLineSegObj;
Vector: TYPE = SVVector3d.Vector;

-- the cone described here is revolute around the y-axis. Otherwise it is very general, allowing for an arbitrary apex point (on the y-axis) and an arbitrary spread ratio.
Cone: TYPE = REF ConeObj;
ConeObj: TYPE = RECORD [
 h: REAL, -- y at the apex
M: REAL, -- r/|y-h|
 yHi, yLo: REAL,
 normalPointsOut: BOOL,
 noseIsUp: BOOL,
 boundHedron: BoundHedron,
 boundBox: BoundBox];

-- the disk ring described here is revolute around the y-axis. Otherwise it is very general. It may be in an arbitrary horizontal plane (y = yPlane), may have any two radii, rIn and rOut subject to rIn, rOut >= 0 AND rOut > rIn, and may have an upward or downward pointing normal.

DiskRing: TYPE = REF DiskRingObj;
DiskRingObj: TYPE = RECORD [
 yPlane: REAL,
 normal: Vector,
 rInSquared, rOutSquared: REAL,
boundHedron: BoundHedron,
 boundBox: BoundBox];

-- the cylinder described here is revolute around the y-axis. Otherwise it is very general. It may have its top and bottom in arbitrary horizontal planes (y = yHigh and y = yLow) subject to yHigh > yLow and may have an arbitrary radius r.

Cylinder: TYPE = REF CylinderObj;
CylinderObj: TYPE = RECORD [
 yHi, yLo: REAL,
 r: REAL,
 rSquared: REAL,
 normalPointsOut: BOOL,
boundHedron: BoundHedron,
 boundBox: BoundBox];

-- the edge on rectangle has a surface normal parallel to the xy plane. That is, it is edge on when viewed from the z direction.

EdgeOnRect: TYPE = REF EdgeOnRectObj;
EdgeOnRectObj: TYPE = RECORD [
 frontZ, backZ: REAL,
A, B, D: REAL, -- plane equation Ax + By + D = 0.
 normal: Vector,
 valHi, valLo: REAL,
 valIsY: BOOL,-- valHi and valLo will be y values if the edge on rectangle is more closely verical than horizontal and x values otherwise
boundHedron: BoundHedron,
 boundBox: BoundBox
 ];

ConeFromTrigLineSeg: PROC [seg: TrigLineSeg] RETURNS [cone: Cone];
AttemptToCreateDegenerateCone: ERROR;
DiskRingFromTrigLineSeg: PROC [seg: TrigLineSeg] RETURNS [diskRing: DiskRing];
AttemptToCreateDegenerateDiskRing: ERROR;
CylinderFromTrigLineSeg: PROC [seg: TrigLineSeg] RETURNS [cylinder: Cylinder];
AttemptToCreateDegenerateCylinder: ERROR;
EdgeOnRectFromTrigLineSeg: PROC [seg: TrigLineSeg, frontZ, backZ: REAL] RETURNS [edgeOnRect: EdgeOnRect];
AttemptToCreateDegenerateEdgeOnRect: ERROR;

END.