DIRECTORY
CADTypes USING [Scad, VariableRec, VisibleMask],
Geometry3dVector USING [Triple],
Rope USING [ROPE],
ThreeDBasics USING [Context, RGB];
SurfaceViewer:
CEDAR
DEFINITIONS ~
BEGIN
Type declarations
SurfaceRec:
TYPE ~
RECORD [
scad: CADTypes.Scad,
id: NAT,
mask: REF CADTypes.VisibleMask];
SurfaceSeq:
TYPE ~
RECORD [
surfaces: SEQUENCE length: NAT OF SurfaceRec];
SurfaceViewer:
TYPE ~
RECORD [
context3d: REF ThreeDBasics.Context,
surfaces: REF SurfaceSeq,
numberOfSurfaces: NAT,
nextID: NAT];
Error:
ERROR[why:
ATOM];
Raised when something goes wrong. Possibilities are $AllFilledUp (tried to load too many surfaces), or $InvalidID (referred to a surface that doesn't exist).
CreateSurfaceViewer:
PROC[displayType:
ATOM ← $PseudoColor]
RETURNS[sviewer:
REF SurfaceViewer];
Opens a color viewer and instantiates its 3D context. Position, orientation, and scope will default. Draws a frame. Another interesting displayType is $ImagerGray.
GetThreeDContext:
PROC[sviewer:
REF SurfaceViewer]
RETURNS[context3d:
REF ThreeDBasics.Context];
Returns sviewer's ThreeDWorld context. This context is needed for all ThreeDWorld operations involving the sviewer. Among other things, it has a slot containing the sviewer's actual color viewer.
LoadSurface:
PROC[surface: CADTypes.Scad, sviewer:
REF SurfaceViewer]
RETURNS[id:
NAT];
Loads a surface into the SurfaceViewer context and draws a new frame. Returns an ID number for the surface, which is used to refer to the surface after it has been added. If there is no more room, raises Error[$AllFilledUp].
MaskSurface:
PROC[id:
NAT, mask:
REF CADTypes.VisibleMask, sviewer:
REF SurfaceViewer];
Masks cells in the surface indicated by id. The mask specifies which cells in the CAD should be displayed and which shouldn't. If id does not refer to a surface, raises Error[$InvalidID].
HideSurface:
PROC[id:
NAT, sviewer:
REF SurfaceViewer];
Hides the surface indicated by id and draws a new frame. If id does not refer to a surface, raises Error[$InvalidID].
UnHideSurface:
PROC[id:
NAT, sviewer:
REF SurfaceViewer];
Unhides the surface indicated by id and draws a new frame. If id does not refer to a surface, raises Error[$InvalidID].
DeleteSurface:
PROC[id:
NAT, sviewer:
REF SurfaceViewer];
Removes a surface from the SurfaceViewer context and draws a new frame. If id does not refer to a surface, raises Error[$InvalidID].
SetSurfaceRenderingMode:
PROC[id:
NAT, mode:
ATOM, sviewer:
REF SurfaceViewer, twoCellsOnly:
BOOL ←
TRUE];
Sets the rendering mode of the surface indicated by id and draws a new frame. Mode is one of $Lines, $Faceted, $Smooth, $HiddenLines, $NormaledLines, $ShadedLines. If id does not refer to a surface, raises Error[$InvalidID]. If mode is not a valid mode, raises Error[$InvalidRenderingMode]. If twoCellsOnly is true, then only 2-cells are affected.
SetSurfaceColor:
PROC[id:
NAT, color: ThreeDBasics.
RGB, sviewer:
REF SurfaceViewer, twoCellsOnly:
BOOL ←
TRUE];
Sets the color of the surface indicated by id and draws a new frame. If id does not refer to a surface, raises Error[$InvalidID]
FlushSurfaces:
PROC[sviewer:
REF SurfaceViewer];
Removes all surfaces from the SurfaceViewer context and draws a new (blank) frame.
DrawFrame:
PROC [sviewer:
REF SurfaceViewer];
Moves the light source to the eyepoint and redraws in the color viewer.
ToInterpress:
PROC [sviewer:
REF SurfaceViewer, fileName: Rope.
ROPE];
Writes an IP file for the contents of the surface viewer.
InvokeRayTracer:
PROC[variables: CADTypes.VariableRec, filename: Rope.
ROPE, pixelsU, pixelsV:
NAT, sviewer:
REF SurfaceViewer];
Calls SurfaceTracer to generate a ray-traced image of the current view in the SurfaceViewer context. The image is written as three AIS files. This no longer works!