Skip Array data when constructing VTKData #65
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regarding issue #63, when reading data from a vtk/pvtk file, the current read implementation only work if all elements in the
PointData
/CellData
section are of typeDataArray
. In some use cases, string data is stored in these sections asArray
type, (e.g., as label for visualization projects, link). These elements have the form:Currently, if there is a single
Array
element in thePointData
/CellData
section, reading data will fail due to an assertion breach in theget_data_section
method:ReadVTK.jl/src/ReadVTK.jl
Line 425 in c914447
In the new implementation I present in this pull request, XML elements that are not
DataArray
type are skipped over inget_data_section
, but error later when one attempts to index theVTKData
object with a key that references non-numeric data:ReadVTK.jl/src/ReadVTK.jl
Line 530 in c914447
This new logic allows for the reading of numeric data from files with both numeric and non-numeric contents.
I have also expanded existing tests to:
.vti
file,.pvti
file,KeyError
s when attempting to read the string data for the.vti
file, andKeyError
s when attempting to read the string data for the.pvti
fileAnd the fact that the existing tests for reading cell/point data pass as they previously were doing indicates that numeric data can still be correctly read from
.vti
and.pvti
files.Feedback is appreciated!