Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh from isosurface #98

Open
lazarusA opened this issue Aug 6, 2024 · 0 comments
Open

Mesh from isosurface #98

lazarusA opened this issue Aug 6, 2024 · 0 comments

Comments

@lazarusA
Copy link

lazarusA commented Aug 6, 2024

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: 0564487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant