Skip to content

Commit 70bc91c

Browse files
committed
add convience constructors with pre-specified sample size of 128
1 parent 38ef674 commit 70bc91c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/marching_cubes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,7 @@ end
521521
function (::Type{MT})(f::Function, h::HyperRectangle, size::NTuple{3,Int}, method::MarchingCubes)::MT where {MT <: AbstractMesh}
522522
marching_cubes(f, h, size, method.iso, MT, method.eps)
523523
end
524+
525+
function (::Type{MT})(f::Function, h::HyperRectangle, method::MarchingCubes; size::NTuple{3,Int}=(128,128,128))::MT where {MT <: AbstractMesh}
526+
marching_cubes(f, h, size, method.iso, MT, method.eps)
527+
end

src/surface_nets.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,7 @@ function (::Type{MT})(f::Function, bounds::HyperRectangle, size::NTuple{3,Int},
419419
orig)
420420
MT(vts, fcs)::MT
421421
end
422+
423+
function (::Type{MT})(f::Function, bounds::HyperRectangle, method::NaiveSurfaceNets;size::NTuple{3,Int}=(128,128,128)) where {MT <: AbstractMesh}
424+
MT(f,bounds,size,method)
425+
end

test/runtests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ using LinearAlgebra: dot, norm
2424
sqrt(sum(dot(v,v))) - 1 # sphere
2525
end
2626

27+
# test convience constructors
28+
HomogenousMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), NaiveSurfaceNets()) do v
29+
sqrt(sum(dot(v,v))) - 1 # sphere
30+
end
31+
HomogenousMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), NaiveSurfaceNets(), size=(5,5,5)) do v
32+
sqrt(sum(dot(v,v))) - 1 # sphere
33+
end
34+
2735
sphere = HomogenousMesh(sdf_sphere, NaiveSurfaceNets())
2836
torus = HomogenousMesh(sdf_torus, NaiveSurfaceNets())
2937
@test length(vertices(sphere)) == 1832
@@ -87,6 +95,14 @@ using LinearAlgebra: dot, norm
8795
sqrt(sum(dot(v,v))) - 1 # sphere
8896
end
8997

98+
# convience constructors
99+
SimpleMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), MarchingCubes()) do v
100+
sqrt(sum(dot(v,v))) - 1 # sphere
101+
end
102+
SimpleMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), MarchingCubes(), size=(5,6,7)) do v
103+
sqrt(sum(dot(v,v))) - 1 # sphere
104+
end
105+
90106
m = marching_cubes(sdf,0)
91107
m2 = marching_cubes(sdf)
92108
@test length(vertices(m)) == 10968

0 commit comments

Comments
 (0)