Skip to content

BUG: Add VTKPolyDataMeshIO FIELD data support (forward-port of #4859)#6188

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:vtk-field-main
May 8, 2026
Merged

BUG: Add VTKPolyDataMeshIO FIELD data support (forward-port of #4859)#6188
thewtex merged 1 commit intoInsightSoftwareConsortium:mainfrom
hjmjohnson:vtk-field-main

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

@hjmjohnson hjmjohnson commented May 2, 2026

Forward-port of #4859 from release-5.4 to main, with the bug that made itkMeshFileReadWriteTestField fail now fixed. Adds reading of VTK legacy FIELD FieldData N blocks inside POINT_DATA/CELL_DATA sections of .vtk PolyData files; data lands as VariableLengthVector pixels. Closes #4859.

The bug fix

#4859 set m_PointPixelType=VARIABLELENGTHVECTOR in ReadMeshInformation but didn't teach Read{Point,Cell}DataBufferAs{ASCII,BINARY} how to parse the FIELD layout. The extra array-header line:

POINT_DATA <N>
FIELD FieldData <K>
<arrayName> <numComponents> <numTuples> <dataType>   ← this line was parsed as data
<value1> ...

was consumed as the first data values, producing garbage. The fix adds a find("FIELD") branch alongside the existing SCALARS branch in all four buffer readers to consume the array-header line first.

Closes #4859.

@hjmjohnson hjmjohnson mentioned this pull request May 2, 2026
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:IO Issues affecting the IO module labels May 2, 2026
@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptileai review this draft before I make it official

@greptile-apps

This comment was marked as resolved.

Comment thread Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx Outdated
@hjmjohnson hjmjohnson requested a review from thewtex May 2, 2026 18:04
@hjmjohnson hjmjohnson marked this pull request as ready for review May 2, 2026 18:26
@hjmjohnson hjmjohnson added this to the ITK 6.0 Release Candidate 1 milestone May 5, 2026
@thewtex
Copy link
Copy Markdown
Member

thewtex commented May 5, 2026

@hjmjohnson thanks! Have you verified that the result can be read by a VTK-based reader, e.g. Slicer?

@hjmjohnson
Copy link
Copy Markdown
Member Author

hjmjohnson commented May 5, 2026

@thewtex both files read fine by Slicer; visually identical.

Same surface: 326 points, 648 polygons, same per-cell scalar.

@hjmjohnson
Copy link
Copy Markdown
Member Author

hjmjohnson commented May 6, 2026

@thewtex merge if approved.

Read VTK legacy FIELD data entries in POINT_DATA and CELL_DATA
sections as VariableLengthVector when the tuple count matches the
point/cell count. Read{Point,Cell}DataBufferAs{ASCII,BINARY} now
consume the array-header line after the FIELD keyword (without
this fix the header was parsed as data and the test failed).

Only the first field-data array per section is used. Adds gourd.vtk
fixture exercising the path. Forward-port of InsightSoftwareConsortium#4859.

Co-Authored-By: Matt McCormick <matt@mmmccormick.com>
Copy link
Copy Markdown
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hjmjohnson thank you!

@thewtex thewtex merged commit 4396da1 into InsightSoftwareConsortium:main May 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants