# BitArray{3} mesh

**URL:** https://discourse.julialang.org/t/bitarray-3-mesh/49697
**Category:** New to Julia
**Tags:** package, mesh
**Created:** [November 6, 2020, 6:30pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697 "2020-11-06T18:30:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![dalarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dalarev/32/9881_2.png) [@dalarev](https://discourse.julialang.org/u/dalarev)
#### Post date: [November 6, 2020, 6:30pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697/1 "2020-11-06T18:30:11Z")

</div>

What is the recommended process to mesh a BitArray?

The meshing method requires an `isovalue`. For a BitArray, an `isovalue` of `1`, `true` or `:true` don’t seem to work: 0 faces are returned.

Another method is to convert from BitArray to an Array: `MyData = 1MyData`. Then `isovalue=0.5` could work.

In general, is `isovalue` to be interpreted as “everything in `MyArray .>= isovalue`”?

Thanks!

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 8, 2020, 12:55pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697/2 "2020-11-08T12:55:33Z")

</div>

> [@dalarev](#):
>
> mesh a BitArray

I don’t know what this means. Lack of context may be the reason why you are not getting answers to this.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

### Author: ![dalarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dalarev/32/9881_2.png) [@dalarev](https://discourse.julialang.org/u/dalarev)
#### Post date: [November 9, 2020, 3:00pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697/3 "2020-11-09T15:00:19Z")

</div>

You’re right, thanks for the reminder, Tamas. Couldn’t edit my post, so here’s a MWE:

```julia
# 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 tolerance](https://juliageometry.github.io/Meshing.jl/stable/api/#Meshing.MarchingCubes) `eps = 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.

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [November 9, 2020, 5:44pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697/4 "2020-11-09T17:44:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dalarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dalarev/32/9881_2.png) [@dalarev](https://discourse.julialang.org/u/dalarev)
#### Post date: [November 9, 2020, 8:22pm UTC](https://discourse.julialang.org/t/bitarray-3-mesh/49697/5 "2020-11-09T20:22:06Z")

</div>

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=1` _will_ work.
