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

Add 1 to VTKPrimitives connectivity indices to follow convention in ReadVTK.jl #47

Merged
merged 1 commit into from
Nov 9, 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
9 changes: 6 additions & 3 deletions src/ReadVTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@ function get_cells(vtk_file::VTKFile)
# Create VTKCells container and convert VTK's zero-based indices to Julia's one-based indices
# Note: the offsets do not need to be updated since they point *past* the last entry
# in VTK files (C-style), while in Julia it is custom to point *at* the last entry.
return VTKCells(get_data(connectivity) + oneunit.(get_data(connectivity)),
connectivity_data = get_data(connectivity)
return VTKCells(connectivity_data .+ oneunit(eltype(connectivity_data)),
sloede marked this conversation as resolved.
Show resolved Hide resolved
get_data(offsets),
get_data(types))
end
Expand Down Expand Up @@ -1130,8 +1131,10 @@ function get_primitives(vtk_file::VTKFile, primitive_type::AbstractString)
@assert !isnothing(connectivity)
@assert !isnothing(offsets)

# Create VTKPrimitives container
return VTKPrimitives(get_data(connectivity), get_data(offsets))
# Create VTKPrimitives container and convert VTK's zero-based indices to Julia's one-based indices
connectivity_data = get_data(connectivity)
return VTKPrimitives(connectivity_data .+ oneunit(eltype(connectivity_data)),
get_data(offsets))
end

# Convenience functions for working with `VTKPrimitives` container
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ clean_directory(TEST_EXAMPLES_DIR) = @test_nowarn rm(TEST_EXAMPLES_DIR, recursiv
out = []
first = 1
for last in primitives.offsets
push!(out, primitives.connectivity[first:last] .+ 1)
push!(out, primitives.connectivity[first:last])
first = last + 1
end
return out
Expand Down
Loading