Skip to content

Commit

Permalink
Add 1 to VTKPrimitives connectivity indices to follow convention in R…
Browse files Browse the repository at this point in the history
…eadVTK.jl (#47)
  • Loading branch information
eliascarv authored Nov 9, 2023
1 parent bff54c3 commit 8386a58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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)),
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

0 comments on commit 8386a58

Please sign in to comment.