Skip to content

Commit c6bf2d2

Browse files
committed
remove NaiveSurfaceNets and cleanup tests (support autodiff again)
1 parent 03ceb63 commit c6bf2d2

File tree

6 files changed

+51
-365
lines changed

6 files changed

+51
-365
lines changed

src/Meshing.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ include("algorithmtypes.jl")
1111
include("common.jl")
1212
include("marching_tetrahedra.jl")
1313
include("marching_cubes.jl")
14-
include("surface_nets.jl")
1514
include("roots.jl")
1615
include("adaptive.jl")
1716

1817
export isosurface,
1918
MarchingCubes,
20-
MarchingTetrahedra,
21-
NaiveSurfaceNets
19+
MarchingTetrahedra
2220

2321
end # module

src/algorithmtypes.jl

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,9 @@ making this algorithm useful for topological analysis.
4141
- `iso` specifies the iso level to use for surface extraction.
4242
- `eps` is the tolerence around a voxel corner to ensure manifold mesh generation.
4343
"""
44-
Base.@kwdef struct MarchingTetrahedra{T} <: AbstractMeshingAlgorithm
44+
Base.@kwdef struct MarchingTetrahedra{T,E} <: AbstractMeshingAlgorithm
4545
iso::T = 0.0
46-
eps::T = 1e-3
47-
end
48-
49-
"""
50-
NaiveSurfaceNets(iso=0.0, eps=1e-3)
51-
NaiveSurfaceNets(;iso=0.0, eps=1e-3)
52-
NaiveSurfaceNets(iso)
53-
NaiveSurfaceNets(iso,eps)
54-
55-
Specifies the use of the Naive Surface Nets algorithm for isosurface extraction.
56-
This algorithm has a slight performance advantage in some cases over Marching Cubes.
57-
Each vertex is guaranteed to not be repeated (useful for topological analysis),
58-
however the algorithm does not guarantee accuracy and generates quad faces.
59-
60-
- `iso` specifies the iso level to use for surface extraction.
61-
- `eps` is the tolerence around a voxel corner to ensure manifold mesh generation.
62-
- `reduceverts` reserved for future use.
63-
"""
64-
struct NaiveSurfaceNets{T} <: AbstractMeshingAlgorithm
65-
iso::T
66-
eps::T
67-
reduceverts::Bool
68-
insidepositive::Bool
46+
eps::E = 1e-3
6947
end
7048

7149
"""
@@ -83,7 +61,7 @@ may be large and it will be difficult to extract topological/connectivity inform
8361
- `eps` (default: 1e-3) is the tolerence around a voxel corner to ensure manifold mesh generation.
8462
- `reduceverts` (default: true) if true will merge vertices within a voxel to reduce mesh size by around 30% and with slight performance improvement.
8563
"""
86-
struct AdaptiveMarchingCubes{T} <: AbstractAdaptiveMeshingAlgorithm
64+
struct AdaptiveMarchingCubes{T,E} <: AbstractAdaptiveMeshingAlgorithm
8765
iso::T
8866
eps::T
8967
rtol::T
@@ -104,4 +82,3 @@ end
10482
#
10583

10684
default_face_length(::Union{MarchingCubes,MarchingTetrahedra}) = 3
107-
default_face_length(::NaiveSurfaceNets) = 4

src/marching_cubes.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ include("lut/mc.jl")
55
function isosurface(sdf::AbstractArray{T,3}, method::MarchingCubes, X=-1:1, Y=-1:1, Z=-1:1) where {T}
66
nx, ny, nz = size(sdf)
77

8-
vts = NTuple{3,float(T)}[]
8+
# find widest type
9+
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T), typeof(method.iso))
10+
11+
vts = NTuple{3,float(FT)}[]
912
fcs = NTuple{3,Int}[]
1013

1114
xp = LinRange(first(X), last(X), nx)
@@ -44,7 +47,7 @@ function isosurface(f::Function, method::MarchingCubes, X=-1:1, Y=-1:1, Z=-1:1;
4447
nx, ny, nz = samples[1], samples[2], samples[3]
4548

4649
# find widest type
47-
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T))
50+
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T), typeof(method.iso))
4851

4952
vts = NTuple{3,float(FT)}[]
5053
fcs = NTuple{3,Int}[]

src/marching_tetrahedra.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ end
128128

129129
function isosurface(sdf::AbstractArray{T, 3}, method::MarchingTetrahedra, X=-1:1, Y=-1:1, Z=-1:1) where {T}
130130

131+
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T), typeof(method.iso), typeof(method.eps))
132+
131133
vts = Dict{Int, Int}()
132134
fcs = NTuple{3,Int}[]
133-
vtsAry = NTuple{3,float(T)}[]
135+
vtsAry = NTuple{3,float(FT)}[]
134136

135137
# process each voxel
136138
nx::Int, ny::Int, nz::Int = size(sdf)
@@ -163,7 +165,7 @@ end
163165
function isosurface(f::F, method::MarchingTetrahedra, X=-1:1, Y=-1:1, Z=-1:1;
164166
samples::NTuple{3,T}=_DEFAULT_SAMPLES) where {F, T}
165167

166-
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T))
168+
FT = promote_type(eltype(first(X)), eltype(first(Y)), eltype(first(Z)), eltype(T), typeof(method.iso), typeof(method.eps))
167169

168170
vts = Dict{Int, Int}()
169171
fcs = NTuple{3,Int}[]

src/surface_nets.jl

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

0 commit comments

Comments
 (0)