Skip to content

Commit f4a7e32

Browse files
committed
allow SDF types for propogate through to Naive Surface Nets
1 parent 88e90da commit f4a7e32

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/surface_nets.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const sn_edge_table = [0, 7, 25, 30, 98, 101, 123, 124, 168, 175, 177, 182, 202,
4646
Generate a mesh using naive surface nets.
4747
This takes the center of mass of the voxel as the vertex for each cube.
4848
"""
49-
function surface_nets(data, dims,eps,scale,origin)
49+
function surface_nets(data::Vector{T}, dims,eps,scale,origin) where {T}
5050

51-
vertices = Point{3,Float64}[]
51+
vertices = Point{3,T}[]
5252
faces = Face{4,Int}[]
5353

5454
sizehint!(vertices,ceil(Int,maximum(dims)^2/2))
@@ -59,9 +59,9 @@ function surface_nets(data, dims,eps,scale,origin)
5959
R = Array{Int}([1, (dims[1]+1), (dims[1]+1)*(dims[2]+1)])
6060
buf_no = 1
6161

62-
buffer = fill(zero(Int32),R[3]*2)
62+
buffer = fill(zero(Int),R[3]*2)
6363

64-
v = [0.0,0.0,0.0]
64+
v = Vector{T}([0.0,0.0,0.0])
6565

6666
#March over the voxel grid
6767
x[3] = 0
@@ -158,7 +158,7 @@ function surface_nets(data, dims,eps,scale,origin)
158158

159159
#Add vertex to buffer, store pointer to vertex index in buffer
160160
buffer[m+1] = length(vertices)
161-
push!(vertices, Point{3,Float64}(v[1],v[2],v[3]))
161+
push!(vertices, Point{3,T}(v[1],v[2],v[3]))
162162

163163
#Now we need to add faces together, to do this we just loop over 3 basis components
164164
for i=0:2
@@ -216,7 +216,7 @@ function (::Type{MT})(sdf::SignedDistanceField, method::NaiveSurfaceNets) where
216216
orig = origin(bounds)
217217
w = widths(bounds)
218218
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(reshape(sdf.data,(1,length(sdf.data))),
219+
vts, fcs = surface_nets(vec(sdf.data),
220220
size(sdf.data),
221221
method.eps,
222222
scale,

0 commit comments

Comments
 (0)