-
Notifications
You must be signed in to change notification settings - Fork 13
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
isosurface is interupted #103
Comments
Here is a more minimal example that does not appear to suffer the interruptions: using GLMakie
using GeometryBasics
using MarchingCubes
using Meshing
function getIsosurface(A; level=0.0)
mc = MarchingCubes.MC(A,Int)
MarchingCubes.march(mc,level)
F = [TriangleFace{Int64}(f) for f in mc.triangles]
V = [Point{3,Float64}(p) for p in mc.vertices]
return F,V
end
function getIsosurface2(A; level=0.0)
vv, ff = isosurface(A, Meshing.MarchingCubes(iso=level))
F = [TriangleFace{Int64}(f) for f in ff]
V = [Point{3,Float64}(v) for v in vv]
return F,V
end
nSteps = 10 # Use this to set the density
xr,yr,zr = ntuple(_->range(0,pi*4,nSteps),3)
A = [ cos(x)*sin(y)+cos(y)*sin(z)+cos(z)*sin(x) for x in xr, y in yr, z in zr]
level = 0.0
F1,V1 = getIsosurface(A; level=level)
F2,V2 = getIsosurface2(A; level=level)
# Visualization
fig = Figure(size=(800,800))
ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "MarchingCubes.jl")
if ~isempty(F1)
hp1 = poly!(ax1,GeometryBasics.Mesh(V1,F1), strokewidth=1,color=:white,shading=FastShading,transparency=false)
end
ax2 = Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Meshing.MarchingCubes")
if ~isempty(F2)
hp2 = poly!(ax2,GeometryBasics.Mesh(V2,F2), strokewidth=1,color=:white,shading=FastShading,transparency=false)
end
fig Since with |
@sjkelly I've done some more digging it looks like the issue occurs when the spacing between the sheets becomes too small. The value temp_triply_issue.mp4 |
Indeed MATLAB's So it seems a normal/expected behaviour, and not really a bug at all. But, like I said, it does happen sooner with using GLMakie
using GeometryBasics
using MarchingCubes
using Meshing
function getIsosurface(A; level=0.0)
mc = MarchingCubes.MC(A,Int)
MarchingCubes.march(mc,level)
F = [TriangleFace{Int64}(f) for f in mc.triangles]
V = [Point{3,Float64}(p) for p in mc.vertices]
return F,V
end
function getIsosurface2(A; level=0.0)
vv, ff = isosurface(A, Meshing.MarchingCubes(iso=level))
F = [TriangleFace{Int64}(f) for f in ff]
V = [Point{3,Float64}(v) for v in vv]
return F,V
end
gyroid(v) = cos(v[1])*sin(v[2])+cos(v[2])*sin(v[3])+cos(v[3])*sin(v[1])
gyroid_shell(v,s) = max(gyroid(v)-s,-gyroid(v)-s)
function getmeshes(s,nSteps,level)
xr,yr,zr = ntuple(_->range(0,pi*4,nSteps),3)
A = [gyroid_shell((x,y,z),s) for x in xr, y in yr, z in zr]
F1,V1 = getIsosurface(A; level=level)
F2,V2 = getIsosurface2(A; level=level)
return F1,V1,F2,V2
end
nSteps = 50
level = 0.0
s = 0.15
F1,V1,F2,V2 = getmeshes(s,nSteps,level)
# Visualization
strokewidth = 0
fig = Figure(size=(800,800))
ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "MarchingCubes.jl")
hp1 = poly!(ax1,GeometryBasics.Mesh(V1,F1), strokewidth=strokewidth,color=:white,shading=FastShading,transparency=false)
ax2 = Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Meshing.MarchingCubes")
hp2 = poly!(ax2,GeometryBasics.Mesh(V2,F2), strokewidth=strokewidth,color=:white,shading=FastShading,transparency=false)
stepRange1 = range(0.01,0.8,50)
hSlider1 = Slider(fig[2, :], range = stepRange1, startvalue = 0,linewidth=30)
on(hSlider1.value) do stepVal
F1,V1,F2,V2 = getmeshes(stepVal,nSteps,level)
hp1[1] = GeometryBasics.Mesh(V1,F1)
hp2[1] = GeometryBasics.Mesh(V2,F2)
end
fig |
As I mentioned a while back on Slack, I've been comparing this library to MarchingCubes.jl, I found that when one "under samples" the structure e.g. like the below code where
nSteps=25
. Then I notice the surface can get "crummy" interrupted.With MarchingCubes.jl the surface remains intact longer it seems (if I go too sparse it will also speak up). Not sure if the "intactness" is wrong or if the "crummy/splits" is wrong but perhaps you can check.
The text was updated successfully, but these errors were encountered: