Meshing.jl
Meshing.jl copied to clipboard
Mesh from isosurface
This following used to work when using:
mc = GeometryBasics.Mesh(s, algo), but now I needed to do the extra step with Meshing's isosurface. Not sure where this happened.
Now, in the latest releases as of today, this is the example that works.
using GLMakie
using Meshing, GeometryBasics
GLMakie.activate!()
function show_isosurface(f,h,ξ; color=(:dodgerblue,0.5), isoval=100)
algo = MarchingCubes(; iso=isoval)
s = [h(x,y,z) for x in ξ, y in ξ, z in ξ] .+ isoval
# generate the mesh using marching cubes
vts, fcs = isosurface(s, algo)
# mc = GeometryBasics.Mesh(s, algo)
return mesh(f, vts, map(v -> GeometryBasics.TriangleFace(v...), fcs); color,
diffuse = Vec3f0(0.8),
specular = Vec3f0(1.1),
shininess = 30f0,
backlight = 5f0,
transparency=true,
axis = (; show_axis = false)
)
end
# ### Torus
# isosurfaces for h(x,y,z)=0
torus(x,y,z; c=20, a=15) = ((hypot(x,y)-c)^2+z^2-a^2)
with_theme(theme_dark()) do
ξ = -40:0.5:40
f = Figure(size=(900, 900))
show_isosurface(f[1,1], torus, ξ; color = (:orangered, 0.5))
f
end
oh, here is where things changed: https://github.com/JuliaGeometry/Meshing.jl/commit/05644873623c46d02c524044caae195b65a4813c