ImplicitPatchCmdImpl.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Bloomenthal, August 11, 1992 4:02 pm PDT
DIRECTORY Commander, CommanderOps, Convert, FS, G3dBasic, G3dControl, G3dCurve, Imager, ImplicitConvolve, ImplicitDefs, ImplicitDesign, IO, Rope;
ImplicitPatchCmdImpl: CEDAR PROGRAM
IMPORTS Convert, CommanderOps, FS, G3dBasic, G3dControl, ImplicitConvolve, ImplicitDesign, IO
~ BEGIN
An S-Patch
Triple:     TYPE ~ G3dBasic.Triple;
TripleSequence:   TYPE ~ G3dBasic.TripleSequence;
PrimitiveList:   TYPE ~ ImplicitConvolve.PrimitiveList;
ROPE:      TYPE ~ Rope.ROPE;
PatchData:    TYPE ~ REF PatchDataRep;
PatchDataRep:   TYPE ~ RECORD [
cmd:        Commander.Handle ¬ NIL,
tool:        ImplicitDesign.Tool ¬ NIL,
primitives:      PrimitiveList ¬ NIL
];
res:      ImplicitConvolve.IntegerPair ¬ [50, 50];
extent:     REAL ¬ 0.05;
intensity:     REAL ¬ 1.0;
PatchCmd: Commander.CommandProc ~ {
args: CommanderOps.ArgumentVector ¬ CommanderOps.Parse[cmd];
p: PatchData ¬ NEW[PatchDataRep ¬ [cmd: cmd]];
s: IO.STREAM ¬ FS.StreamOpen["/mesa/ImpS/spolys" ! FS.Error => GOTO Bad];
IF args.argc = 3 THEN extent ¬ Convert.RealFromRope[args[2]];
DO
ENABLE IO.Error, IO.EndOfStream => EXIT;
x1: REAL ¬ IO.GetReal[s];
z1: REAL ¬ IO.GetReal[s];
y1: REAL ¬ IO.GetReal[s];
x2: REAL ¬ IO.GetReal[s];
z2: REAL ¬ IO.GetReal[s];
y2: REAL ¬ IO.GetReal[s];
x3: REAL ¬ IO.GetReal[s];
z3: REAL ¬ IO.GetReal[s];
y3: REAL ¬ IO.GetReal[s];
pts: TripleSequence ¬ TripleSequenceFromList[LIST[[x1, y1, z1], [x2, y2, z2], [x3, y3, z3]]];
p.primitives ¬ CONS[ImplicitConvolve.MakePrimitive[pts, extent,, intensity,,, res], p.primitives];
ENDLOOP;
IO.PutF[cmd.out, "%g primitives\n", IO.int[NPrimitives[p.primitives]]];
p.tool ¬ ImplicitConvolve.MakeTool[
cmd: cmd,
name: "PATCH IT!",
primitives: p.primitives,
clientData: p,
toolSettings: [trackSize: .02, threshold: 0.25]
];
G3dControl.UpdateControl[p.tool.renderTool.camera, p.tool.renderTool.camera.scale, 8.0];
EXITS Bad => RETURN[$Failure, "can't open file"];
};
NPrimitives: PROC [p: PrimitiveList] RETURNS [n: NAT ¬ 0] ~ {
FOR l: PrimitiveList ¬ p, l.rest WHILE l # NIL DO n ¬ n+1; ENDLOOP;
};
TripleSequenceFromList: PROC [points: LIST OF Triple] RETURNS [t: TripleSequence] ~ {
t ¬ G3dBasic.TripleSequenceFromList[points];
t.length ¬ t.maxLength;
};
ImplicitDesign.Register["Patch", PatchCmd, "\ta puffed-patch?", "ImplicitConvolve"];
END.
..
-31.674 15.594 -105.059 0 0 2.75 1 45
0.2
-24.439 17.324 -103.014 0 0 2.75 1 45

LightSource "ambientlight" 1 "lightcolor" [0.5 0.5 0.5] "intensity" 0.5
LightSource "distantlight" 2 "lightcolor" [1.0 1.0 1.0] "intensity" [1.0] "from" [100.0 90.0 -30.0] "to" [0.0 0.0 0.0]
LightSource "distantlight" 3 "lightcolor" [1.0 1.0 1.0] "intensity" [1.0] "from" [-100.0 0.0 -50.0] "to" [0.0 0.0 0.0]