Skip to content

Commit

Permalink
add convience constructors with pre-specified sample size of 128
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly committed Jun 23, 2019
1 parent 38ef674 commit 70bc91c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/marching_cubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,7 @@ end
function (::Type{MT})(f::Function, h::HyperRectangle, size::NTuple{3,Int}, method::MarchingCubes)::MT where {MT <: AbstractMesh}
marching_cubes(f, h, size, method.iso, MT, method.eps)
end

function (::Type{MT})(f::Function, h::HyperRectangle, method::MarchingCubes; size::NTuple{3,Int}=(128,128,128))::MT where {MT <: AbstractMesh}
marching_cubes(f, h, size, method.iso, MT, method.eps)
end
4 changes: 4 additions & 0 deletions src/surface_nets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,7 @@ function (::Type{MT})(f::Function, bounds::HyperRectangle, size::NTuple{3,Int},
orig)
MT(vts, fcs)::MT
end

function (::Type{MT})(f::Function, bounds::HyperRectangle, method::NaiveSurfaceNets;size::NTuple{3,Int}=(128,128,128)) where {MT <: AbstractMesh}
MT(f,bounds,size,method)
end
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ using LinearAlgebra: dot, norm
sqrt(sum(dot(v,v))) - 1 # sphere
end

# test convience constructors
HomogenousMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), NaiveSurfaceNets()) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end
HomogenousMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), NaiveSurfaceNets(), size=(5,5,5)) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end

sphere = HomogenousMesh(sdf_sphere, NaiveSurfaceNets())
torus = HomogenousMesh(sdf_torus, NaiveSurfaceNets())
@test length(vertices(sphere)) == 1832
Expand Down Expand Up @@ -87,6 +95,14 @@ using LinearAlgebra: dot, norm
sqrt(sum(dot(v,v))) - 1 # sphere
end

# convience constructors
SimpleMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), MarchingCubes()) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end
SimpleMesh(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.)), MarchingCubes(), size=(5,6,7)) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end

m = marching_cubes(sdf,0)
m2 = marching_cubes(sdf)
@test length(vertices(m)) == 10968
Expand Down

0 comments on commit 70bc91c

Please sign in to comment.