ELSE {
ENABLE G3dVoxel.Error => IF reason = $NoSuchFile THEN GOTO NoFile;
ReadGrid:
PROC
RETURNS [grid: G3dVoxel.Grid] ~ {
IO.PutF[cmd.out, "Reading %g . . .", IO.rope[argv[2]]];
grid ¬ G3dVoxel.ReadGridFromFile[FileNames.ResolveRelativePath[argv[2]]];
G3dVoxel.SetGridBox[grid, [[-1.0, -1.0, -1.0], [1.0, 1.0, 1.0]]];
IO.PutRope[cmd.out, " done!\n"];
};
g: Grid ¬ ReadGrid[];
d: REF GridData ¬ NEW[GridData ¬ [grid: g]];
range: Triple ¬ G3dVector.Sub[g.box.max, g.box.min];
size: Triple ¬ G3dVector.DivVectors[range, [REAL[g.res.x], REAL[g.res.y], REAL[g.res.z]]];
d.tool ¬ ImplicitDesign.MakeTool[
name: Rope.Concat["Grid ", argv[2]],
startProc: GridStart,
valueProc: GridValue,
client: [data: d],
toolSettings: [trackSize: MIN[size.x, size.y, size.z]]];
toolSettings: [trackSize: 0.02, threshold: 0.5]];
G3dControl.UpdateControl[d.tool.renderTool.camera, d.tool.renderTool.camera.scale, 2.0/MAX[range.x, range.y, range.z]];
[] ¬ ImplicitDesign.DoMakeOctree[d.tool];
[] ¬ ImplicitDesign.DoMakePolygons[d.tool];
ImplicitMisc.WriteToFile[NIL, d.tool.shape,, TRUE];
ViewerOps.DestroyViewer[d.tool.renderTool.outer];
EXITS NoFile => RETURN[$Failure, "\tno such file"];
};