Skip to content

Commit 3e4a56d

Browse files
committed
Better integrate Naive Surface Nets into test suite
1 parent f4a7e32 commit 3e4a56d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

test/runtests.jl

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ using LinearAlgebra: dot, norm
2121
@test length(vertices(torus)) == 5532
2222
@test length(faces(sphere)) == 1830
2323
@test length(faces(torus)) == 5532
24-
@test for vt in vertices(sphere)
25-
d = sqrt(sum(vt .^ 2))
26-
if 0.001 < (d-1) < 0.001
27-
continue
28-
else
29-
return false
30-
end
31-
true
32-
end
3324
end
3425

3526

@@ -94,7 +85,9 @@ using LinearAlgebra: dot, norm
9485
resolution = 0.1
9586
sdf = SignedDistanceField(f, bounds, resolution)
9687

97-
for algorithm in (MarchingCubes(0.5), MarchingTetrahedra(0.5))
88+
for algorithm in (MarchingCubes(0.5),
89+
MarchingTetrahedra(0.5),
90+
NaiveSurfaceNets(0.5))
9891
mesh = @inferred GLNormalMesh(sdf, algorithm)
9992
# should be centered on the origin
10093
@test mean(vertices(mesh)) [0, 0, 0] atol=0.15*resolution
@@ -121,6 +114,10 @@ using LinearAlgebra: dot, norm
121114
@test_nowarn GLNormalMesh(sdf.data, MarchingTetrahedra(0.5))
122115
@inferred GLNormalMesh(sdf.data, MarchingTetrahedra(0.5))
123116
end
117+
@testset "naive surface nets" begin
118+
@test_nowarn GLNormalMesh(sdf, NaiveSurfaceNets())
119+
@inferred GLNormalMesh(sdf, NaiveSurfaceNets())
120+
end
124121
end
125122

126123
@testset "mixed types" begin
@@ -169,5 +166,16 @@ using LinearAlgebra: dot, norm
169166
@inferred(Meshing.marchingTetrahedra(Float32.(data), Float64(iso), Float16(eps), Int32))
170167
@inferred(Meshing.marchingTetrahedra(Float64.(data), Float32(iso), Float64(eps), Int64))
171168
end
169+
@testset "Float16" begin
170+
sdf_torus = SignedDistanceField(HyperRectangle(Vec{3,Float16}(-2,-2,-2.),
171+
Vec{3,Float16}(4,4,4.)),
172+
0.1, Float16) do v
173+
(sqrt(v[1]^2+v[2]^2)-0.5)^2 + v[3]^2 - 0.25
174+
end
175+
@test typeof(HomogenousMesh(sdf,NaiveSurfaceNets())) ==
176+
HomgenousMesh{Face{4,Int},Point{3,Float16}}
177+
m2 = HomogenousMesh(sdf,MarchingTetrahedra())
178+
m3 = HomogenousMesh(sdf,MarchingCubes())
179+
end
172180
end
173181
end

0 commit comments

Comments
 (0)