-- File: SweepGeometry.mesa
-- Last edited by Bier on December 18, 1982 1:19 am
-- Author: Eric Allan Bier on June 9, 1982 1:21 pm
-- Contents: Definitions for a package which creates and displays linear and revolute 3D structures

DIRECTORY
 CoordSys,
 CSGGraphics,
 DisplayList3d,
 Graphics,
 Matrix3d,
 Shading,
 SV2d,
 SVVector3d;

SweepGeometry: DEFINITIONS =
BEGIN

Camera: TYPE = CSGGraphics.Camera;
CoordSystem: TYPE = REF CoordSysObj;
CoordSysObj: TYPE = CoordSys.CoordSysObj;
Path: TYPE = REF PathObj;
PathObj: TYPE = SV2d.PathObj;
Polygon: TYPE = REF PolygonObj;
PolygonObj: TYPE = SV2d.PolygonObj;
Point2d: TYPE = SV2d.Point2d;
Point3d: TYPE = Matrix3d.Point3d;
Vector: TYPE = SVVector3d.Vector;

LinearMesh: TYPE = REF LinearMeshRecord;
LinearMeshRecord: TYPE = RECORD [
 len: NAT,
 array: LinearMeshArray,
 surfaces: LinearSurfaceMesh];
RevoluteMesh: TYPE = REF RevoluteMeshRecord;
RevoluteMeshRecord: TYPE = RECORD [
 linesOfLongitude: NAT,
 linesOfLatitude: NAT,
 array: RevoluteMeshArray,
 surfaces: RevoluteSurfaceMesh];
ToroidalMesh: TYPE = REF ToroidalMeshRecord;
ToroidalMeshRecord: TYPE = RECORD [
 linesOfLongitude: NAT,
 linesOfLatitude: NAT,
 array: RevoluteMeshArray,
 surfaces: ToroidalSurfaceMesh];

maxMeshLen: NAT = 30;
LinearMeshArray: TYPE = ARRAY [1..maxMeshLen] OF ARRAY [1..2] OF Point3d;

maxLinesOfLat: NAT = 20;
maxLinesOfLong: NAT = 12;
RevoluteMeshArray: TYPE = ARRAY [1..maxLinesOfLat] OF ARRAY [1..maxLinesOfLong] OF Point3d;

LinearSurfaceMesh: TYPE = RECORD [
 front: SweepSurface,
 back: SweepSurface,
 sides: ARRAY [1..maxMeshLen] OF SweepSurface];

RevoluteSurfaceMesh: TYPE = RECORD [
 top: SweepSurface,
 bottom: SweepSurface,
 sides: ARRAY [1..maxLinesOfLat-1] OF ARRAY [1..maxLinesOfLong] OF SweepSurface];

ToroidalSurfaceMesh: TYPE = RECORD [
 sides: ARRAY [1..maxLinesOfLat] OF ARRAY [1..maxLinesOfLong] OF SweepSurface];

SweepSurface: TYPE = RECORD [normal: Vector];

LightSource: TYPE = REF LightSourceObj;
LightSourceObj: TYPE = Shading.LightSourceObj;
LightSourceList: TYPE = LIST OF LightSource;

MasterObject: TYPE = REF MasterObjectRec;
MasterObjectRec: TYPE = DisplayList3d.MasterObjectRec;
Assembly: TYPE = REF AssemblyObj;
AssemblyObj: TYPE = DisplayList3d.AssemblyObj;
PlanarSurface: TYPE = REF PlanarSurfaceObj;
PlanarSurfaceObj: TYPE = DisplayList3d.PlanarSurfaceObj;
PlanarSurfaceList: TYPE = DisplayList3d.PlanarSurfaceList;

LinearSweep: PROC [poly: Polygon, frontDepth: REAL ← 0.5, backDepth: REAL ← -0.5] RETURNS [meshRecord: LinearMesh];
RevoluteSweep: PROC [path: Path, linesOfLongitude: NAT ← 10] RETURNS [meshRecord: RevoluteMesh];

ToroidalSweep: PROC [poly: Polygon, linesOfLongitude: NAT ← 10] RETURNS [meshRecord: ToroidalMesh];
-- Like RevoluteSweep but wraps around

GetLinearPoly: PROC [linMesh: LinearMesh] RETURNS [poly: Polygon];
GetRevolutePath
: PROC [revMesh: RevoluteMesh] RETURNS [path: Path];


LineDrawLinearSweep: PROC [dc: Graphics.Context, meshRecord: LinearMesh, camera: Camera, localCS: CoordSystem];
LineDrawRevoluteSweep: PROC [dc: Graphics.Context, meshRecord: RevoluteMesh, camera: Camera, localCS: CoordSystem];
LineDrawToroidalSweep: PROC [dc: Graphics.Context, meshRecord: ToroidalMesh, camera: Camera, localCS: CoordSystem];

DrawNormalsLinearSweep: PROC [dc: Graphics.Context, meshRecord: LinearMesh, camera: Camera, localCS: CoordSystem];
DrawNormalsRevoluteSweep: PROC [dc: Graphics.Context, meshRecord: RevoluteMesh, camera: Camera, localCS: CoordSystem];
DrawNormalsToroidalSweep: PROC [dc: Graphics.Context, meshRecord: ToroidalMesh, camera: Camera, localCS: CoordSystem];

PlanarSurfacesLinearSweep: PROC [meshRecord: LinearMesh, assembly: Assembly, cameraCS: CoordSystem] RETURNS [psl: PlanarSurfaceList];
PlanarSurfacesRevoluteSweep: PROC [meshRecord: RevoluteMesh, assembly: Assembly, cameraCS: CoordSystem] RETURNS [psl: PlanarSurfaceList];
PlanarSurfacesToroidalSweep: PROC [meshRecord: ToroidalMesh, assembly: Assembly, cameraCS: CoordSystem] RETURNS [psl: PlanarSurfaceList];

CountPlanarSurfacesLinearSweep: PROC [meshRecord: LinearMesh] RETURNS [len: NAT];
CountPlanarSurfacesRevoluteSweep: PROC [meshRecord: RevoluteMesh] RETURNS [len: NAT];
CountPlanarSurfacesToroidalSweep: PROC [meshRecord: ToroidalMesh] RETURNS [len: NAT];

CountVerticesLinearSweep: PROC [meshRecord: LinearMesh] RETURNS [len: NAT];
CountVerticesRevoluteSweep: PROC [meshRecord: RevoluteMesh] RETURNS [len: NAT];
CountVerticesToroidalSweep: PROC [meshRecord: ToroidalMesh] RETURNS [len: NAT];

DrawPlanarSurfaceLinearSweep: PROC [dc: Graphics.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera];
DrawPlanarSurfaceRevoluteSweep: PROC [dc: Graphics.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera];
DrawPlanarSurfaceToroidalSweep: PROC [dc: Graphics.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera];

END.