PolyHackInsides.Mesa
Last Edited by: Spreitzer, September 19, 1985 7:25:02 pm PDT
DIRECTORY BiScrollers, Geom2D, Imager, IO, Misp, Random, Rope, Vector2, ViewerClasses, ViewRec;
PolyHackInsides: CEDAR DEFINITIONS =
BEGIN
LORA: TYPE = LIST OF REF ANY;
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
Box: TYPE = Imager.Box;
Color: TYPE = Imager.Color;
PointRef: TYPE = REF Point;
ViewerData: TYPE = REF ViewerDataRep;
ViewerDataRep:
TYPE =
RECORD [
viewer: Viewer ← NIL,
bs: BiScrollers.BiScroller ← NIL,
color, running: BOOLEAN ← FALSE,
runner: UNSAFE PROCESS ← NIL,
oldColumn: ViewerClasses.Column ← left,
polys: PolyList ← NIL,
bounds: Box ← emptyBounds,
bloatedBounds: Box ← [0, 0, 0, 0],
ctlPanel: CtlPanel ← NIL,
rv: ViewRec.RecordViewer ← NIL,
log: IO.STREAM ← NIL,
env: Misp.Environment ← NIL
];
emptyBounds: Box = [xmin: infinity, ymin: infinity, xmax: -infinity, ymax: -infinity];
infinity: Geom2D.Number = 1E20;
CtlPanel: TYPE = REF CtlPanelRep;
CtlPanelRep:
TYPE =
RECORD [
stop, noisy: BOOLEAN ← FALSE,
method: Method ← polygons,
round: BOOLEAN ← FALSE,
mode: Mode ← sweep,
speed: REAL ← 1.0,
Step: PROC [vd: ViewerData],
Run: PROC [vd: ViewerData, n: CARDINAL],
Continuous: PROC [vd: ViewerData],
SetPolys: PROC [vd: ViewerData],
PrintPolys: PROC [vd: ViewerData],
Clear: PROC [vd: ViewerData],
Fit: PROC [vd: ViewerData, paint: BOOLEAN ← TRUE],
ReadEvalPrint: PROC [vd: ViewerData]
];
Method: TYPE = {quadrilaterals, triangles, polygons};
Mode: TYPE = {sweep, outline, fill, trace};
PolyList: TYPE = LIST OF Poly;
Poly: TYPE = REF PolyRep;
PolyRep:
TYPE =
RECORD [
coloring: Coloring,
vertexCount: CARDINAL ← 0,
closed: BOOLEAN,
vertices: VertexRing ← NIL];
Coloring: TYPE = REF ColoringRep;
ColoringRep:
TYPE =
RECORD [
color: Color ← NIL,
constant: BOOL ← TRUE,
form: REF ANY ← NIL,
arg: Misp.Real ← NIL,
env: Misp.Environment ← NIL,
stack: Misp.Stack ← NIL];
VertexRing: TYPE = REF VertexRingRep;
VertexRingRep:
TYPE =
RECORD [
next, prev: VertexRing ← NIL,
paintHalf: BOOLEAN ← FALSE,
vertex: Vertex];
Vertex: TYPE = REF VertexRep;
VertexRep:
TYPE =
RECORD [
curLoc: Point,
class: VertexClass,
data: VertexData];
Point: TYPE = Vector2.VEC --RECORD [x, y: REAL]--;
VertexData: TYPE = REF ANY;
VertexClass: TYPE = REF VertexClassRep;
VertexClassRep:
TYPE =
RECORD [
name: ROPE,
StepVertex: PROC [Vertex, REAL],
Copy: PROC [VertexData] RETURNS [VertexData],
WriteData: PROC [to: IO.STREAM, data: VertexData],
VertexBounds: PROC [Vertex] RETURNS [Box]
];
Path: TYPE = REF PathRep;
PathRep:
TYPE =
RECORD [
length: NAT ← 0,
points: SEQUENCE size: NAT OF Point];
NewPath: PROC [size: NAT] RETURNS [Path];
ResetPath: PROC [Path];
ExtendPath: PROC [Path, Point];
DetailedPath:
TYPE =
RECORD [
coloring: Coloring,
path: Path ← NIL];
DetailedPathList: TYPE = LIST OF DetailedPath;
DrawAreas: TYPE = REF DrawAreasRep;
DrawAreasRep:
TYPE =
RECORD [
areaPaths: DetailedPathList ← NIL];
DrawStrokes: TYPE = REF DrawStrokesRep;
DrawStrokesRep:
TYPE =
RECORD [
strokePaths: DetailedPathList ← NIL];
DrawTriangles: TYPE = REF DrawTrianglesRep;
DrawTrianglesRep:
TYPE =
RECORD [
strict: BOOLEAN,
trianglePath: Path ← NIL];
Bounce: TYPE = REF BounceRep;
BounceRep:
TYPE =
RECORD [
dx, dy, xmin, xmax, ymin, ymax: REAL];
Sinusoid: TYPE = RECORD [base, amplitude, stepSize, theta: REAL];
WheelList: TYPE = LIST OF Wheel;
Wheel: TYPE = REF WheelRep;
WheelRep:
TYPE =
RECORD [
radius, where, initial, pen: REAL];
Int: TYPE = REF INT;
Real: TYPE = REF REAL;
rs: Random.RandomStream;
bounceClass, constantClass: VertexClass;
PaintHack: ViewerClasses.PaintProc;
ViewerDataOf: PROC [v: Viewer] RETURNS [ViewerData];
CreateHack: PROC [vi: ViewerClasses.ViewerRec, asBiScroller: BOOLEAN] RETURNS [vd: ViewerData];
NewPoly: PROC [close: BOOLEAN ← TRUE, coloring: Coloring] RETURNS [p: Poly];
ColoringColor: PROC [c: Coloring] RETURNS [color: Color];
UpdateColoring: PROC [coloring: Coloring];
AddVertexToPoly: PROC [v: Vertex, p: Poly];
Finish: PROC [poly: Poly];
Copy: PROC [v: Vertex] RETURNS [u: Vertex];
StepPoly: PROC [p: Poly];
VertexBounds:
PROC [v: Vertex]
RETURNS [bounds: Box] =
INLINE
{RETURN [v.class.VertexBounds[v]]};
NewSum: PROC [a, b: Vertex, aOld: BOOLEAN] RETURNS [c: Vertex];
NewLisasjous: PROC [x, y: Sinusoid] RETURNS [v: Vertex];
MakeRandomBouncePoly: PROC [nVerts: CARDINAL, xmax, ymax: INT ← 400, dxmax, dymax: INT ← 10, close: BOOLEAN ← TRUE] RETURNS [poly: Poly];
RandomBounce: PROC [xmax, ymax, dxmax, dymax: INT] RETURNS [v: Vertex];
NewBounce: PROC [x, y, dx, dy, xmin, ymin, xmax, ymax: REAL] RETURNS [v: Vertex];
Spiro: PROC [center: Point, stepSize: REAL, wheels: LORA] RETURNS [v: Vertex];
StepCmd: PROC [vd: ViewerData];
GetRunLock: PROC [vd: ViewerData] RETURNS [run: BOOLEAN];
UnRun: PROC [vd: ViewerData, unstop: BOOL];
AbortRunner: PROC [vd: ViewerData] RETURNS [wasRunning: BOOL];
PrepareToRun: PROC [vd: ViewerData] RETURNS [lda: LORA, da: DrawAreas, ds: DrawStrokes];
OKToRun: PROC [vd: ViewerData] RETURNS [ok: BOOLEAN];
StepHack: PROC [vd: ViewerData, lda: LORA, da: DrawAreas, ds: DrawStrokes];
WriteRefAny: PROC [to: IO.STREAM, asAny: REF ANY];
WriteVertex: PROC [to: IO.STREAM, v: Vertex];
Load: PROC [fileName: ROPE, env: Misp.Environment, stack: Misp.Stack];
DefineHackAStuff: PROC [environment: Misp.Environment, vd: ViewerData];
DefineHackBStuff: PROC [environment: Misp.Environment, vd: ViewerData];
END.