Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nirmal-suthar committed Oct 7, 2020
1 parent 6304fd5 commit 71a42d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/rep/mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ end

function _compute_verts_packed(m::TriMesh, refresh::Bool = false)
if refresh || !(m._verts_packed_valid)
_compute_verts_list(m)
verts_packed = _list_to_packed(m._verts_list)
# avoiding setproperty!, as we are building packed
# from list and list is always valid
Expand All @@ -872,25 +873,25 @@ function _compute_verts_padded(m::TriMesh, refresh::Bool = false)
if refresh || !(m._verts_padded_valid)

# FIXME: #38 chamfer_loss gradient doesn't reach packed, so using temp fix
_packed = get_verts_packed(m)
_padded = _packed_to_padded(_packed, m._verts_len, 0)
m._verts_padded = _padded
_compute_verts_packed(m)
verts_padded = _packed_to_padded(m._verts_packed, m._verts_len, 0)
# m._verts_padded = _padded

# _list_to_padded!(m._verts_padded, m._verts_list, 0, (3, m.V))
# _list_to_padded!(m._verts_padded, get_verts_list(m), 0, (3, m.V))

# avoiding setproperty!, as we are building padded
# from list and list is always valid
# setfield!(m, :_verts_padded, verts_padded)
setfield!(m, :_verts_padded, verts_padded)
setfield!(m, :_verts_padded_valid, true)
return nothing
end
end

function _compute_verts_list(m::TriMesh, refresh::Bool = false)
if refresh || !(m._verts_list_valid)
if m._verts_packed !== nothing
if m._verts_packed_valid
verts_list = _packed_to_list(m._verts_packed, m._verts_len)
elseif m._verts_padded !== nothing
elseif m._verts_padded_valid
verts_list = _padded_to_list(m._verts_padded, m._verts_len)
else
error("not possible to contruct list without padded and packed")
Expand Down
4 changes: 3 additions & 1 deletion test/cuda/rep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ end
# IO Tests
@testset "IO" begin
mktempdir() do tmpdir
for ext in ["obj", "off", "stl", "ply", "2dm"]
# FIXME: MeshIO 2dm save/load breaking #62, #63
# for ext in ["obj", "off", "stl", "ply", "2dm"]
for ext in ["obj", "off", "stl", "ply"]
save_trimesh(joinpath(tmpdir, "test.$(ext)"), m)
m_loaded = load_trimesh(joinpath(tmpdir, "test.$(ext)"))
@test all(isapprox.(get_verts_packed(m_loaded), verts_list[1]))
Expand Down
2 changes: 1 addition & 1 deletion test/rep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end
# IO Tests
@testset "IO" begin
mktempdir() do tmpdir
# FIXME: MeshIO 2dm save/load breaking #62
# FIXME: MeshIO 2dm save/load breaking #62, #63
# for ext in ["obj", "off", "stl", "ply", "2dm"]
for ext in ["obj", "off", "stl", "ply"]
save_trimesh(joinpath(tmpdir, "test.$(ext)"), m)
Expand Down

0 comments on commit 71a42d7

Please sign in to comment.