diff --git a/examples/snoop.jl b/examples/snoop.jl index 3c33b6e..2aef281 100644 --- a/examples/snoop.jl +++ b/examples/snoop.jl @@ -107,8 +107,6 @@ s = LinRange(-1, 1, 40) v = 1 .- (s .^ 2 .+ (s .^ 2)' .+ reshape(s,1,1,:) .^ 2) .^ 0.5 isosurface(v, isovalue=0.2) -GR.GR3.terminate() - volume(randn(rng, 50, 50, 50)) N = 1_000_000 diff --git a/src/jlgr.jl b/src/jlgr.jl index 19f8d6f..9677c0f 100644 --- a/src/jlgr.jl +++ b/src/jlgr.jl @@ -277,7 +277,7 @@ function minmax(kind, plt=plt[]) x0, x1 = Extrema64(x) xmin = min(x0, xmin) xmax = max(x1, xmax) - elseif kind === :volume + elseif kind === :volume || kind === :isosurface xmin, xmax = -1, 1 else xmin, xmax = 0, 1 @@ -289,7 +289,7 @@ function minmax(kind, plt=plt[]) y0, y1 = Extrema64(y) ymin = min(y0, ymin) ymax = max(y1, ymax) - elseif kind === :volume + elseif kind === :volume || kind === :isosurface ymin, ymax = -1, 1 else ymin, ymax = 0, 1 @@ -301,7 +301,7 @@ function minmax(kind, plt=plt[]) z0, z1 = Extrema64(z) zmin = min(z0, zmin) zmax = max(z1, zmax) - elseif kind === :volume + elseif kind === :volume || kind === :isosurface zmin, zmax = -1, 1 else zmin, zmax = 0, 1 @@ -1056,9 +1056,22 @@ function plot_iso(V, plt=plt[]) else color = (0.0, 0.5, 0.8) end - GR.setwindow3d(-1, 1, -1, 1, -1, 1) - GR.setspace3d(-rotation, tilt, 45, 2.5) - GR.gr3.isosurface(V, isovalue, color) + w, h, ratio = GR.inqvpsize() + GR.selntran(0) + GR.gr3.clear() + vmin, vmax = extrema(V) + data = trunc.(UInt16, (V .- vmin) ./ (vmax - vmin) * 65535) + mesh = GR.gr3.createisosurfacemesh(data, (2 / (nx - 1), 2 / (ny - 1), 2 / (nz - 1)), (-1.0, -1.0, -1.0), trunc(Int64, (isovalue - vmin) / (vmax - vmin) * 65535)) + GR.gr3.setbackgroundcolor(1, 1, 1, 0) + GR.gr3.drawmesh(mesh, 1, (0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 0.5, 0.8), (1, 1, 1)) + r = 2.5 + rotation *= π / 180 + tilt *= π / 180 + GR.gr3.cameralookat(r * sin(tilt) * sin(rotation), r * cos(tilt), r * sin(tilt) * cos(rotation), 0, 0, 0, 0, 1, 0) + vp = plt.kvs[:viewport] + GR.gr3.drawimage(vp..., trunc(Int, w * ratio), trunc(Int, h * ratio), GR.gr3.DRAWABLE_GKS) + GR.gr3.deletemesh(mesh) + GR.selntran(1) end function plot_polar(θ, ρ, plt=plt[]) @@ -1446,6 +1459,7 @@ function plot_data(flag=true, plt=plt[]) end draw_axes(kind, 2) colorbar(0.05) + GR.gr3.terminate() elseif kind === :volume algorithm = get(plt.kvs, :algorithm, 0) w, h, ratio = GR.inqvpsize()