|
117 | 117 | MarchingCubes.output(PlyIO, mc, tempname(); verbose = false) |
118 | 118 | end |
119 | 119 |
|
120 | | -@testset "types" begin |
121 | | - for F ∈ (Float16, Float32, Float64) |
122 | | - for I ∈ (Int16, Int32, Int64, Int128, UInt16, UInt32, UInt64, UInt128) |
123 | | - @test march(MarchingCubes.scenario(4, 4, 4; F, I)) isa Nothing |
124 | | - end |
125 | | - end |
126 | | -end |
127 | | - |
128 | 120 | @testset "normalize" begin |
129 | 121 | nx, ny, nz = 10, 20, 30 |
130 | 122 | start_x, stop_x = -0.1, 0.1 |
@@ -192,39 +184,48 @@ end |
192 | 184 | end |
193 | 185 |
|
194 | 186 | @testset "coordinate input variations" begin |
195 | | - epsLevel = 1e-3 # Precission level |
| 187 | + atol = 1e-3 # precision level |
| 188 | + |
| 189 | + # define coordinate ranges (also creating 3 different lengths) |
| 190 | + nx, ny, nz = 55, 46, 67 # these should be high enough to reach precision level |
| 191 | + start_x, stop_x = -1.0, 1.0 # range limits centered on 0 |
| 192 | + start_y, stop_y = -1.2, 1.2 # range limits centered on 0 |
| 193 | + start_z, stop_z = -2.3, 2.3 # range limits centered on 0 |
| 194 | + x = range(start_x, stop_x; length = nx) |
| 195 | + y = range(start_y, stop_y; length = ny) |
| 196 | + z = range(start_z, stop_z; length = nz) |
196 | 197 |
|
197 | | - # Define coordinate ranges (also creating 3 different lengths) |
198 | | - nx, ny, nz = 55, 46, 67 # These should be high enough to reach precission level |
199 | | - start_x, stop_x = -1.0, 1.0 # Range limits centered on 0.0 |
200 | | - start_y, stop_y = -1.2, 1.2 # Range limits centered on 0.0 |
201 | | - start_z, stop_z = -2.3, 2.3 # Range limits centered on 0.0 |
202 | | - x = range(start_x, stop_x, length = nx) |
203 | | - y = range(start_y, stop_y, length = ny) |
204 | | - z = range(start_z, stop_z, length = nz) |
| 198 | + # create image (simple coordinate norm leading to spherical isosurface) |
| 199 | + A = [√(xi^2 + yi^2 + zi^2) for xi ∈ x, yi ∈ y, zi ∈ z] |
205 | 200 |
|
206 | | - # Create image (simple coordinate norm leading to spherical isosurface) |
207 | | - A = [sqrt(x^2 + y^2 + z^2) for x in x, y in y, z in z] |
| 201 | + level = 0.5 # isolevel should produce sphere with this radius |
208 | 202 |
|
209 | | - level = 0.5 # isolevel should produce sphere with this radius |
| 203 | + # process isosurface with ranged coordinate input |
| 204 | + mc_ranged = MC(A, Int; x, y, z) |
| 205 | + march(mc_ranged, level) |
210 | 206 |
|
211 | | - # Process isosurface with ranged coordinate input |
212 | | - mc_ranged = MC(A,Int; x = x, y = y, z = z) |
213 | | - march(mc_ranged,level) |
| 207 | + xv, yv, zv = collect.(Float64, (x, y, z)) |
214 | 208 |
|
215 | | - # Process isosurface with vector coordinate input |
216 | | - mc_vector = MC(A,Int; x = collect(Float64, x), y = collect(Float64, y), z = collect(Float64, z)) |
217 | | - march(mc_vector,level) |
| 209 | + # process isosurface with vector coordinate input |
| 210 | + mc_vector = MC(A, Int; x = xv, y = yv, z = zv) |
| 211 | + march(mc_vector, level) |
218 | 212 |
|
219 | | - # Test equivalence between ranged and vector input |
| 213 | + # test equivalence between ranged and vector input |
220 | 214 | @test mc_ranged.vertices == mc_vector.vertices |
221 | 215 | @test mc_ranged.triangles == mc_vector.triangles |
222 | | - |
223 | | - # Test if coordinate input was used appropriately geometrically as expected |
| 216 | + |
| 217 | + # test if coordinate input was used appropriately geometrically as expected |
224 | 218 | n = length(mc_ranged.vertices) |
225 | | - c = sum(mc_ranged.vertices)/n # Mean coordinate i.e. centre |
226 | | - r = sum(v -> sqrt(sum(v.^2)), mc_ranged.vertices)/n # Mean radius |
227 | | - @test isapprox(c,[0.0,0.0,0.0], atol = epsLevel) # Approximately zero mean for sphere |
228 | | - @test isapprox(r, level, atol = epsLevel) # Approximately radius matching level |
| 219 | + c = sum(mc_ranged.vertices) / n # mean coordinate i.e. center |
| 220 | + r = sum(v -> √(sum(abs2, v)), mc_ranged.vertices) / n # mean radius |
| 221 | + @test isapprox(c, zeros(3); atol) # approximately zero mean for sphere |
| 222 | + @test isapprox(r, level; atol) # approximately radius matching level |
229 | 223 | end |
230 | 224 |
|
| 225 | +@testset "types" begin |
| 226 | + for F ∈ (Float16, Float32, Float64), |
| 227 | + I ∈ (Int16, Int32, Int64, Int128, UInt16, UInt32, UInt64, UInt128) |
| 228 | + |
| 229 | + @test march(MarchingCubes.scenario(4, 4, 4; F, I)) isa Nothing |
| 230 | + end |
| 231 | +end |
0 commit comments