Skip to content

Commit 1218c40

Browse files
committed
update surface nets tests
1 parent f43ce98 commit 1218c40

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/runtests.jl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,24 @@ using LinearAlgebra: dot, norm
8585
resolution = 0.1
8686
sdf = SignedDistanceField(f, bounds, resolution)
8787

88-
for algorithm in (MarchingCubes(0.5),
89-
MarchingTetrahedra(0.5),
90-
NaiveSurfaceNets(0.5))
88+
for algorithm in (MarchingCubes(0.5), MarchingTetrahedra(0.5))
9189
mesh = @inferred GLNormalMesh(sdf, algorithm)
9290
# should be centered on the origin
9391
@test mean(vertices(mesh)) [0, 0, 0] atol=0.15*resolution
9492
# and should be symmetric about the origin
9593
@test maximum(vertices(mesh)) [0.5, 0.5, 0.5]
9694
@test minimum(vertices(mesh)) [-0.5, -0.5, -0.5]
9795
end
96+
# Naive Surface Nets has no accuracy guarantee, and is a weighted sum
97+
# so a larger tolerance is needed for this one. In addition,
98+
# quad -> triangle conversion is not functioning correctly
99+
# see: https://github.com/JuliaGeometry/GeometryTypes.jl/issues/169
100+
mesh = @inferred GLNormalMesh(sdf, NaiveSurfaceNets(0.5))
101+
# should be centered on the origin
102+
@test mean(vertices(mesh)) [0, 0, 0] atol=0.15*resolution
103+
# and should be symmetric about the origin
104+
@test maximum(vertices(mesh)) [0.5, 0.5, 0.5] atol=0.2
105+
@test minimum(vertices(mesh)) [-0.5, -0.5, -0.5] atol=0.2
98106
end
99107

100108
@testset "AbstractMeshingAlgorithm interface" begin
@@ -172,10 +180,10 @@ using LinearAlgebra: dot, norm
172180
0.1, Float16) do v
173181
(sqrt(v[1]^2+v[2]^2)-0.5)^2 + v[3]^2 - 0.25
174182
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())
183+
@test typeof(HomogenousMesh(sdf_torus,NaiveSurfaceNets())) ==
184+
PlainMesh{Float16,Face{4,Int}}
185+
m2 = HomogenousMesh(sdf_torus,MarchingTetrahedra())
186+
m3 = HomogenousMesh(sdf_torus,MarchingCubes())
179187
end
180188
end
181189
end

0 commit comments

Comments
 (0)