ImplicitDesign.mesa
Copyright Ó 1985, 1990 by Xerox Corporation. All rights reserved.
Bloomenthal, November 29, 1992 7:13 pm PST
DIRECTORY CedarProcess, Commander, Controls, G3dBasic, G3dTool, G3dTriangle, ImplicitDefs, ImplicitMinimal, Rope;
ImplicitDesign: CEDAR DEFINITIONS
~ BEGIN
Imported Types
ForkableProc:  TYPE ~ CedarProcess.ForkableProc;
CommandProc: TYPE ~ Commander.CommandProc;
ButtonList:   TYPE ~ Controls.ButtonList;
ControlList:   TYPE ~ Controls.ControlList;
ControlSizes:  TYPE ~ Controls.ControlSizes;
Triple:    TYPE ~ G3dBasic.Triple;
Client:    TYPE ~ G3dTool.Client;
Operations:   TYPE ~ G3dTool.Operations;
Tool3d:    TYPE ~ G3dTool.Tool;
CameraRep:  TYPE ~ G3dTool.CameraRep;
StartProc:   TYPE ~ ImplicitDefs.StartProc;
Function:   TYPE ~ ImplicitMinimal.Function;
ROPE:    TYPE ~ Rope.ROPE;
Local Types
Triangle:   TYPE ~ RECORD [p1, p2, p3: Triple];
Tool:    TYPE ~ REF ToolRep;
ToolRep:   TYPE ~ RECORD [
tool3d:     Tool3d ¬ NIL,     -- for 3d display
size:      REAL ¬ 0.02,
level:      REAL ¬ 1.0,
triangle:     Triangle ¬ [],     -- current polygonized triangle
function:     Function ¬ NIL,     -- to evaluate space
startProc:     StartProc ¬ NIL,     -- to init client and/or find start point
client:      Client ¬ []       -- client supplied procs and data
];
Implicit Design Tool Creation
MakeTool: PROC [
name:     ROPE,         -- name of the tool
function:    Function,       -- to evaluate implicit function
start:     StartProc ¬ NIL,      -- init function +/or find poly start
ops:     Operations ¬ G3dTool.allOps,
extraButtons:   ButtonList ¬ NIL,     -- in addition to the standard set
extraControls:  ControlList ¬ NIL,     -- in addition to the standard set
controlSizes:   ControlSizes ¬ [],     -- adjust size of controls
useArcBalls:   BOOL ¬ TRUE,      -- use arc balls? 
arcBallSize:   INT ¬ 136,
client:     Client ¬ [],       -- client supplied data and procs
graphicsHeight:  INT ¬ 475,
background:   Triple ¬ [0.3, 0.3, 1.0],
noOpen:    BOOL ¬ FALSE,
camera:    CameraRep ¬ [[0,2,0],[],1,60],  -- client can preset camera
nViews:    NAT ¬ 1,        -- number of views
toolSettings:   ToolRep ¬ [],      -- client can preset tool modes
tool3dSettings:  G3dTool.ToolRep ¬ []]    -- client can preset 3d tool modes
RETURNS [Tool];
Return a tool for manipulation/polygonization/rendering of an implicit design.
function must be a top level proc; it is passed clientData.
When ray-tracing, the camera views the ray tracing world, including the object being ray
traced, the image plane, the eye-point and eye-direction, and, optionally, individual rays.
Simple Triangulation
Triangulate: PROC [tool: Tool];
Tile the implicit surface using a simple triangulation algorithm;
compute vertex location and normal.
Tool Control
ToolBusy: PROC [tool: Tool] RETURNS [BOOL];
Return true if the tool is currently busy with a forked process.
MaybeFork: PROC [tool: Tool, proc: ForkableProc, clientData: REF ¬ NIL]
RETURNS [forked: BOOL];
Fork proc if tool isn't busy; pass clientData (or tool if clientData is NIL) to proc.
StopTool: PROC [tool: Tool, reason: ROPE ¬ NIL, waitTilAborted: BOOL ¬ FALSE];
This will halt any implicit tool operation and print the reason in the typescript.
Repaint: PROC [tool: Tool, whatChanged: REF ANY ¬ NIL];
Repaint the graphics viewer associated with the tool.
Log-keeping
UpdateLog: PROC [tool: Tool, key, entry: ROPE] RETURNS [error: ROPE];
In the log file, if key found, replace its entry; otherwise, add entry under key.
An entry is presumed to occupy a single line of the file.
GetLogEntry: PROC [tool: Tool, key: ROPE] RETURNS [entry: ROPE];
Return entry given the key; NIL is returned if no such entry or no such file.
ParametersMessage: PROC [tool: Tool] RETURNS [ROPE];
Return a rope describing the parameter settings of the tool.
Registration and Dispatching
Register: PROC [
function: ROPE,     -- name of implicit function
action: CommandProc,   -- proc to be called
doc: ROPE,      -- documentation of function
command: ROPE ¬ NIL];  -- name of CommandTool command (default: "ImplicitDesign")
Register a command proc with ImplicitDesign.
Subsequently, it may be invoked from the commander by "<command> <function>."
ToolOptions: PROC [command: ROPE] RETURNS [toolOptions: ROPE];
Return a rope listing those functions registered under the named command.
ExecuteOption: CommandProc;
Execute the named option; may return [$Failure, "No such option."].
DesignCmd: CommandProc;
The user level command for applications wishing to register under a different command name.
END.