Skip to content

Commit 0564487

Browse files
authored
Merge pull request #96 from JuliaGeometry/sjk/nodep2
sjk/nodep2
2 parents 2e89b3b + 8831634 commit 0564487

15 files changed

+174
-826
lines changed

bench/Project.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

bench/iso_masjk.jl

Lines changed: 0 additions & 27 deletions
This file was deleted.

docs/make.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ makedocs(
77
modules = [Meshing],
88
pages = ["Index" => "index.md",
99
"API" => "api.md",
10-
"Examples" => "examples.md",
11-
"Internals" => "internals.md"]
10+
"Examples" => "examples.md"]
1211
)
1312

1413
deploydocs(

docs/src/api.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ A = rand(50,50,50) # 3D Matrix
2222
points,faces = isosurface(A, MarchingCubes(iso=1))
2323
```
2424

25-
Alternatively, we can use the `isosurface` API to sample a function, avoiding allocations:
26-
27-
```julia
28-
using Meshing
29-
using LinearAlgebra
30-
using StaticArrays
31-
32-
points, faces = isosurface(origin=SVector(-1,-1,-1.), widths = SVector(2,2,2.), samples = (40,40,40)) do v
33-
sqrt(sum(dot(v,v))) - 1
34-
end
35-
36-
# by default MarchingCubes() is used, but we may specify a different algorithm as follows
37-
38-
points, faces = isosurface(MarchingTetrahedra(), origin=SVector(-1,-1,-1.), widths = SVector(2,2,2.), samples = (40,40,40)) do v
39-
sqrt(sum(dot(v,v))) - 1
40-
end
41-
```
42-
4325
## Isosurface
4426

4527
`isosurface` is the common and generic API for isosurface extraction with any type of abstract vector/vertex/face type.
@@ -48,30 +30,19 @@ end
4830
isosurface
4931
```
5032

51-
5233
## Meshing Algorithms
5334

5435
Three meshing algorithms exist:
5536

5637
* `MarchingCubes()`
5738
* `MarchingTetrahedra()`
58-
* `NaiveSurfaceNets()`
5939

60-
Each takes optional `iso`, `eps`, and `insidepositive` parameters, e.g. `MarchingCubes(iso=0.0,eps=1e-6,insidepositive=false)`.
40+
Each takes optional `iso` and `eps` parameters, e.g. `MarchingCubes(iso=0.0,eps=1e-6)`.
6141

6242
Here `iso` controls the offset for the boundary detection. By default this is set to 0. `eps` is the detection tolerance for a voxel edge intersection.
63-
`insidepositive` sets the sign convention for inside/outside the surface (default: false).
6443

6544
Users must construct an algorithm type and use it as an argument to a GeometryTypes mesh call or `isosurface` call.
6645

67-
Below is a comparison of the algorithms:
68-
69-
| Algorithm Type | Face Type | Unique Vertices | Performance | Interpolation |
70-
|---------------------|-----------|-----------------|-------------|-------------------|
71-
| Naive Surface Nets | Quad | Yes | ~1x | Voxel Edge Weight |
72-
| Marching Cubes | Triangle | No/Partial | 1x | Linear on Edge |
73-
| Marching Tetrahedra | Triangle | Yes | 3x | Linear on Edge |
74-
7546
Visual Comparison:
7647
From left: Marching Cubes, Naive Surface Nets, Marching Tetrahedra
7748

@@ -80,6 +51,5 @@ From left: Marching Cubes, Naive Surface Nets, Marching Tetrahedra
8051
```@docs
8152
MarchingCubes
8253
MarchingTetrahedra
83-
NaiveSurfaceNets
8454
Meshing.AbstractMeshingAlgorithm
8555
```

docs/src/examples.md

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,29 @@
55
The file for this example can be found here: [http://www.slicer.org/slicerWiki/images/0/00/CTA-cardio.nrrd](http://www.slicer.org/slicerWiki/images/0/00/CTA-cardio.nrrd)
66

77
```julia
8-
8+
using Meshing
99
using FileIO
1010
using NRRD
11-
using Meshing
12-
using MeshIO
11+
using WGLMakie
12+
using Downloads
1313
using GeometryBasics
1414

15+
nrrd = Downloads.download("http://www.slicer.org/slicerWiki/images/0/00/CTA-cardio.nrrd")
16+
1517
# load the file as an AxisArray
16-
ctacardio = load("CTA-cardio.nrrd")
18+
ctacardio = load(nrrd)
1719

1820
# use marching cubes with isolevel at 100
19-
algo = MarchingCubes(iso=100, insidepositive=true)
21+
#algo = MarchingCubes(iso=100)
2022
# use marching tetrahedra with iso at 100
21-
# algo = MarchingTetrahedra(iso=100, insidepositive=true)
22-
# use Naive Surface Nets with iso at 100
23-
# algo = NaiveSurfaceNets(iso=100, insidepositive=true)
23+
algo = MarchingTetrahedra(iso=100)
24+
2425

2526
# generate the mesh using marching cubes
26-
mc = Mesh(ctacardio, algo)
27+
vts, fcs = isosurface(ctacardio, algo)
2728

28-
# we can call isosurface to get a vector of points and vector of faces indexing to the points
29-
# vertices, faces = isosurface(ctacardio, algo, Point{3,Float32}, TriangleFace{Int})
29+
WGLMakie.mesh(vts, map(v -> GeometryBasics.TriangleFace(v...), fcs))
3030

31-
# save the file as a PLY file (change extension to save as STL, OBJ, OFF)
32-
save("ctacardio_mc.ply", mc)
3331
```
3432

3533
![cta cardio](./img/ctacardio.png)
@@ -60,44 +58,11 @@ Makie.mesh(gy_mesh, color=[norm(v) for v in coordinates(gy_mesh)])
6058
![gyroid](./img/gyroid.png)
6159

6260

63-
```julia
64-
using Meshing
65-
using GeometryBasics
66-
using LinearAlgebra: dot, norm
67-
using FileIO
68-
69-
# Mesh an equation of sphere in the Axis-Aligned Bounding box starting
70-
# at -1,-1,-1 and widths of 2,2,2 using Marching Cubes
71-
m = GLNormalMesh(Rect(Vec(-1,-1,-1.), Vec(2,2,2.)), MarchingCubes()) do v
72-
sqrt(sum(dot(v,v))) - 1
73-
end
74-
75-
# save the Sphere as a PLY file
76-
save("sphere.ply",m)
77-
```
78-
79-
For a full listing of concrete `AbstractMesh` types see [GeometryBasics.jl mesh documentation](http://juliageometry.github.io/GeometryBasics.jl/latest/types.html#Meshes-1).
80-
81-
Alternatively, we can use the `isosurface` API to sample a function:
82-
83-
```julia
84-
using Meshing
85-
using LinearAlgebra
86-
using StaticArrays
87-
88-
points, faces = isosurface(origin=SVector(-1,-1,-1.), widths = SVector(2,2,2.), samples = (40,40,40)) do v
89-
sqrt(sum(dot(v,v))) - 1
90-
end
91-
92-
# by default MarchingCubes() is used, but we may specify a different algorithm as follows
93-
94-
points, faces = isosurface(MarchingTetrahedra(), origin=SVector(-1,-1,-1.), widths = SVector(2,2,2.), samples = (40,40,40)) do v
95-
sqrt(sum(dot(v,v))) - 1
96-
end
97-
```
98-
9961
## Isocaps
10062

63+
We do not provide an equivalent to `isocaps` in Matlab, though
64+
a similar result may be achieved by setting the boundary to a large value:
65+
10166
```julia
10267
using GeometryTypes
10368

@@ -120,4 +85,4 @@ gy_mesh = GLNormalMesh(A, MarchingCubes())
12085
import Makie
12186
using LinearAlgebra
12287
Makie.mesh(gy_mesh, color=[norm(v) for v in gy_mesh.vertices])
123-
```
88+
```

docs/src/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Algorithms included:
66

77
* [Marching Tetrahedra](https://en.wikipedia.org/wiki/Marching_tetrahedra)
88
* [Marching Cubes](https://en.wikipedia.org/wiki/Marching_cubes)
9-
* [Naive Surface Nets](https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2/)
109

1110
## What is isosurface extraction?
1211

docs/src/internals.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/Meshing.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
module Meshing
22

3-
"""
4-
_DEFAULT_SAMPLES = (24,24,24)
5-
6-
Global default sampling count for functions.
7-
"""
8-
const _DEFAULT_SAMPLES = (24,24,24)
9-
103
include("algorithmtypes.jl")
114
include("common.jl")
125
include("marching_tetrahedra.jl")
136
include("marching_cubes.jl")
14-
include("roots.jl")
15-
include("adaptive.jl")
7+
include("isosurface.jl")
168

179
export isosurface,
1810
MarchingCubes,

0 commit comments

Comments
 (0)