Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret string datasets as field data #129

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WriteVTK"
uuid = "64499a7a-5c06-52f2-abe2-ccb03c286192"
authors = ["Juan Ignacio Polanco <[email protected]>"]
version = "1.18.0"
version = "1.18.1"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
1 change: 1 addition & 0 deletions src/write_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ guess_data_location(data::Tuple, args...) =
guess_data_location(first(data), args...)

guess_data_location(data::Tuple{}, args...) = VTKPointData()
guess_data_location(data::AbstractString, args...) = VTKFieldData() # a single string is always field data

# Return the VTK string representation of a numerical data type.
function datatype_str(::Type{T}) where {T <: VTKDataType}
Expand Down
2 changes: 1 addition & 1 deletion test/checksums.sha1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ d6b447652cbfdbae70a389d5d0cdc825d9ef4ce6 multiblock_4_kmax.vtu
e5e396469b59d25c970ec67172f70fed82fa810d rectilinear_2D.vtr
18e7e3793ec552d60e3f689d4631d48d2f98f9c0 rectilinear_3D.vtr
9e82744afa51ece188c8819349cd206183e9216d imagedata.vti
f9915492cb2a02daa807ed8e23c754349aae8eaf imagedata_2D.vti
380430ce33fd6e4f22cd28382ff359eb07b0ea54 imagedata_2D.vti
1e79d437255388e3bb38cf997c83960f90724296 imagedata_LinRange_2D.vti
d117834ade2c49f0b789287f97c63d87aedff160 imagedata_StepRangeLen_2D.vti
8e3ce81c0e22074483e6c3fdc371031c779400df imagedata_LinRange.vti
Expand Down
6 changes: 6 additions & 0 deletions test/imagedata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ function main()
vtk["p_values"] = p[:, :, 1]
vtk["myVector"] = vec[:, :, :, 1]
vtk["myCellData"] = cdata[:, :, 1]
# Pass string whose length is equal to the number of points.
# The idea is to make sure it's written as field data and not point data.
n = Ni * Nj
str = String(('0' + 1):('0' + n))
@assert length(str) == n
vtk["string"] = str
end

append!(outfiles, outfiles_2D)
Expand Down
Loading