Closed Pan-Maciek closed 2 years ago
What would be needed to get this patch merged? Having binary PLY support would be a great addition
I guess improve code coverage, by adding test reading binary PLY with quads. It is the only line that is not covered. Also in general I think PLY format needs some love. Right now it assumes
element vertex n
property x
property y
property z
element face n
property list uchar int vertex_indices
Should we just merge this?
Hey there,
I've just tested this to see if binary .ply files will load. I receive an error. The steps I took were:
dev https://github.com/Pan-Maciek/MeshIO.jl Convert an .obj file to a binary and non-binary version of .ply format using meshlab. Then run:
using MeshIO
using FileIO
mesh_path = "cortical.ply"
mesh = load(mesh_path)
This works as expected for non-binary .ply files but not for the binary file. The error I receive is:
mesh = load(mesh_path) Error encountered while load File{DataFormat{:PLY_BINARY}, String}("cortical.ply").
mesh = load(mesh_path)
Error encountered while load File{DataFormat{:PLY_BINARY}, String}("cortical.ply").
Fatal error:
ERROR: LoadError: EOFError: read end of file
Stacktrace:
[1] read(s::IOStream, #unused#::Type{UInt8})
@ Base ./iostream.jl:399
[2] load(fs::Stream{DataFormat{:PLY_BINARY}, IOStream, String}; facetype::Type, pointtype::Type{GeometryBasics.Point{3, Float32}})
@ MeshIO ~/.julia/dev/MeshIO/src/io/ply.jl:130
[3] load
@ ~/.julia/dev/MeshIO/src/io/ply.jl:99 [inlined]
[4] #24
@ ~/.julia/dev/MeshIO/src/MeshIO.jl:29 [inlined]
[5] open(f::MeshIO.var"#24#25"{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, args::File{DataFormat{:PLY_BINARY}, String}; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base ./io.jl:330
[6] open
@ ./io.jl:328 [inlined]
[7] #load#23
@ ~/.julia/dev/MeshIO/src/MeshIO.jl:27 [inlined]
[8] load(fn::File{DataFormat{:PLY_BINARY}, String})
@ MeshIO ~/.julia/dev/MeshIO/src/MeshIO.jl:27
[9] #invokelatest#2
@ ./essentials.jl:708 [inlined]
[10] invokelatest
@ ./essentials.jl:706 [inlined]
[11] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Formatted; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:216
[12] action
@ ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:196 [inlined]
[13] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:185
[14] action
@ ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:185 [inlined]
[15] load(::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:113
[16] load(::String)
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:110
[17] top-level scope
@ ~/Projects/test/testfilio.jl:6
[18] eval
@ ./boot.jl:360 [inlined]
[19] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1094
[20] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base ./essentials.jl:708
[21] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)
@ Base ./essentials.jl:706
[22] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:201
[23] (::VSCodeServer.var"#57#61"{Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:155
[24] withpath(f::VSCodeServer.var"#57#61"{Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/repl.jl:155
[25] (::VSCodeServer.var"#56#60"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:153
[26] hideprompt(f::VSCodeServer.var"#56#60"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/repl.jl:36
[27] (::VSCodeServer.var"#55#59"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:121
[28] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging ./logging.jl:491
[29] with_logger
@ ./logging.jl:603 [inlined]
[30] (::VSCodeServer.var"#54#58"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:191
[31] #invokelatest#2
@ ./essentials.jl:708 [inlined]
[32] invokelatest(::Any)
@ Base ./essentials.jl:706
[33] macro expansion
@ ~/.vscode-insiders/extensions/julialang.language-julia-1.1.40/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
[34] (::VSCodeServer.var"#52#53")()
@ VSCodeServer ./task.jl:411
Stacktrace:
[1] handle_error(e::EOFError, q::Base.PkgId, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/error_handling.jl:61
[2] handle_exceptions(exceptions::Vector{Tuple{Any, Union{Base.PkgId, Module}, Vector{T} where T}}, action::String)
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/error_handling.jl:56
[3] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Formatted; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:225
[4] action
@ ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:196 [inlined]
[5] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:185
[6] action
@ ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:185 [inlined]
[7] load(::String; options::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:113
[8] load(::String)
@ FileIO ~/.julia/packages/FileIO/3jBq2/src/loadsave.jl:110
[9] top-level scope
@ ~/Projects/test/testfilio.jl:6
in expression starting at /Users/pavanchaggar/Projects/test/testfilio.jl:6
Using Julia 1.6.1 through rosetta on m1 Mac with the following environment:
Status `~/Projects/test/Project.toml`
[5789e2e9] FileIO v1.9.0
[7269a6da] MeshIO v0.4.6 `~/.julia/dev/MeshIO`
Let me know if I can do anything else to push this along.
Can you send header for this .ply file? To get it open ply file with a notepad and copy first few readable lines. Right now this code can only parse small subset of all ply files
Sure, here it is:
ply
format binary_little_endian 1.0
comment VCGLIB generated
element vertex 271266
property float x
property float y
property float z
element face 542524
property list uchar int vertex_indices
property uchar red
property uchar green
property uchar blue
property uchar alpha
end_header
Codecov Report
32.00% <0.00%> (-2.79%)
98.88% <96.55%> (-1.12%)
Continue to review full report at Codecov.