Skip to content

Commit f43ce98

Browse files
committed
add iso value to surface nets algorithm type
1 parent 3e4a56d commit f43ce98

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/surface_nets.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,29 @@ function surface_nets(data::Vector{T}, dims,eps,scale,origin) where {T}
206206
end
207207

208208
struct NaiveSurfaceNets{T} <: AbstractMeshingAlgorithm
209-
eps::T
209+
iso::T
210+
eps::T
210211
end
211212

212-
NaiveSurfaceNets() = NaiveSurfaceNets(1e-6)
213+
NaiveSurfaceNets(iso::T1=0.0, eps::T2=1e-3) where {T1, T2} = NaiveSurfaceNets{promote_type(T1, T2)}(iso, eps)
213214

214215
function (::Type{MT})(sdf::SignedDistanceField, method::NaiveSurfaceNets) where {MT <: AbstractMesh}
215216
bounds = sdf.bounds
216217
orig = origin(bounds)
217218
w = widths(bounds)
218219
scale = w ./ Point(size(sdf) .- 1) # subtract 1 because an SDF with N points per side has N-1 cells
219-
vts, fcs = surface_nets(vec(sdf.data),
220+
221+
d = vec(sdf.data)
222+
223+
# Run iso surface additions here as to not
224+
# penalize surface net inner loops, and we are using a copy anyway
225+
if method.iso != 0.0
226+
for i = eachindex(d)
227+
d[i] -= method.iso
228+
end
229+
end
230+
231+
vts, fcs = surface_nets(d,
220232
size(sdf.data),
221233
method.eps,
222234
scale,

0 commit comments

Comments
 (0)