You’re right, thanks for the reminder, Tamas. Couldn’t edit my post, so here’s a MWE:
# Packages
using Random
using Meshing
using GeometryBasics
using Makie#master
# Generate Mesh
A = bitrand(5,5,5)
algo = MarchingCubes(iso=1, insidepositive=true)
vertices, faces = isosurface(A, algo, Point{3,Float32}, TriangleFace{Int})
m = GeometryBasics.Mesh(vertices,faces)
# Visualize Mesh
Makie.mesh(m, color=:blue, shading=false)
Makie.wireframe!(m)
Question is: why doesn’t iso=1 work given that this is a BitArray? It returns 0 faces.
After playing with the isovalue, I see that any value 0 <= iso < 1 will return a consistent number of faces. I am a bit puzzled as to why iso=1 does not work.
I guess I’m looking to answer the general question of how the isovalue is interpreted. Is it A .>= iso?
Much appreciated!
edit: I wonder if it has to do with the default toleranceeps = 1e-3. It breaks down when it can’t find a value greater than 1 in a boolean array. If I set eps=0, iso=1 still does not work.
Your isosurface should follow grid edges between nodes with value 1 which are connected nodes with value 0. Since marching cubes doesn’t seem to like this situation where there is no value greater than 1, I would just set iso to some value close to but less than 1, say 0.999 and then round-up all the resulting isosurface coordinates to the nearest grid node.
Yes, that seems to work. As I mention in my previous post, any value 0 <= iso < 1 will work (and produce the same results), so I suppose this is the solution in this case.
Just as an additional data point, when visualizing with Makie.volume, isovalue=1will work.