@@ -46,9 +46,9 @@ const sn_edge_table = [0, 7, 25, 30, 98, 101, 123, 124, 168, 175, 177, 182, 202,
46
46
Generate a mesh using naive surface nets.
47
47
This takes the center of mass of the voxel as the vertex for each cube.
48
48
"""
49
- function surface_nets (data, dims,eps,scale,origin)
49
+ function surface_nets (data:: Vector{T} , dims,eps,scale,origin) where {T}
50
50
51
- vertices = Point{3 ,Float64 }[]
51
+ vertices = Point{3 ,T }[]
52
52
faces = Face{4 ,Int}[]
53
53
54
54
sizehint! (vertices,ceil (Int,maximum (dims)^ 2 / 2 ))
@@ -59,9 +59,9 @@ function surface_nets(data, dims,eps,scale,origin)
59
59
R = Array {Int} ([1 , (dims[1 ]+ 1 ), (dims[1 ]+ 1 )* (dims[2 ]+ 1 )])
60
60
buf_no = 1
61
61
62
- buffer = fill (zero (Int32 ),R[3 ]* 2 )
62
+ buffer = fill (zero (Int ),R[3 ]* 2 )
63
63
64
- v = [0.0 ,0.0 ,0.0 ]
64
+ v = Vector {T} ( [0.0 ,0.0 ,0.0 ])
65
65
66
66
# March over the voxel grid
67
67
x[3 ] = 0
@@ -158,7 +158,7 @@ function surface_nets(data, dims,eps,scale,origin)
158
158
159
159
# Add vertex to buffer, store pointer to vertex index in buffer
160
160
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 ]))
162
162
163
163
# Now we need to add faces together, to do this we just loop over 3 basis components
164
164
for i= 0 : 2
@@ -216,7 +216,7 @@ function (::Type{MT})(sdf::SignedDistanceField, method::NaiveSurfaceNets) where
216
216
orig = origin (bounds)
217
217
w = widths (bounds)
218
218
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),
220
220
size (sdf. data),
221
221
method. eps,
222
222
scale,
0 commit comments