ENH: Ingest ITKIOMeshMZ3 into Modules/IO#6214
Merged
hjmjohnson merged 22 commits intoInsightSoftwareConsortium:mainfrom May 5, 2026
Merged
ENH: Ingest ITKIOMeshMZ3 into Modules/IO#6214hjmjohnson merged 22 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson merged 22 commits intoInsightSoftwareConsortium:mainfrom
Conversation
Read and write, vertex, cells, point data. Compressed or uncompressed.
To address macos-14 CI build warning: src/itkMZ3MeshIO.cxx:484:11: warning: 11 enumeration values not handled in switch: 'UNKNOWNCOMPONENTTYPE', 'UCHAR', 'CHAR'... [-Wswitch]
COMP: Add switch default for point component type
Member
Author
|
@greptileai review this draft before I make it official |
This comment was marked as resolved.
This comment was marked as resolved.
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
May 5, 2026
Two upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6214: 1. WritePointData() printed to std::cerr and returned silently when m_PointPixelComponentType was UNKNOWNCOMPONENTTYPE, leaving the output file in a partially-written state. Replace with itkExceptionMacro so the failure surfaces to the caller. 2. ~MZ3MeshIO() never closed m_Ofstream — a write that threw between WriteMeshInformation()'s open and Write()'s explicit close leaked the output stream. Close both m_Ifstream and m_Ofstream in the destructor's uncompressed branch (guarded by is_open() so closing twice is safe). Also rewrites the 20 C-style (char *)& casts on gzread / gzwrite / ifstream / ofstream calls to reinterpret_cast<char *>(&...) per ITK style guide (Greptile P2 #6). Also fixes the WriteCells CHAR case that cast the buffer to unsigned char * instead of char *, which would silently corrupt negative vertex indices on signed cell-component types (Greptile P2 #5).
dzenanz
approved these changes
May 5, 2026
Brings IOMeshMZ3 from a configure-time remote fetch into the ITK source tree at Modules/IO/IOMeshMZ3/ using the v4 ingestion pipeline (whitelist filter-repo + per-commit clang-format + black + commit-prefix sanitization). Upstream repo: https://github.com/InsightSoftwareConsortium/ITKIOMeshMZ3.git Upstream tip: fbeed91e6800830e84a7ba5e3461addd98a2e772 Ingest date: 2026-05-05 Whitelist: IOMeshMZ3.list Per-commit transforms applied across all 13 commits: - filter-repo --paths-from-file (whitelist) - filter-repo --to-subdirectory-filter Modules/IO/IOMeshMZ3 - clang-format -style=file (ITK main's .clang-format) for *.cxx/.h/.hxx/... - black for *.py - heuristic ITK prefix added to commit subjects without one Merge topology preserved: 4 -> 1 merge(s). Primary author: Matt McCormick <matt@mmmccormick.com> Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu>
The Phase A sanitizer's text/cmake classifier did not pick this small file up as 'cmake' (its sniff treated it as 'text'), so gersemi's pass was skipped. Apply the formatter now to satisfy ITK's pre-commit gersemi hook. Same one-off observed on PR InsightSoftwareConsortium#6215 (IOFDF).
Two upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6214: 1. WritePointData() printed to std::cerr and returned silently when m_PointPixelComponentType was UNKNOWNCOMPONENTTYPE, leaving the output file in a partially-written state. Replace with itkExceptionMacro so the failure surfaces to the caller. 2. ~MZ3MeshIO() never closed m_Ofstream — a write that threw between WriteMeshInformation()'s open and Write()'s explicit close leaked the output stream. Close both m_Ifstream and m_Ofstream in the destructor's uncompressed branch (guarded by is_open() so closing twice is safe). Also rewrites the 20 C-style (char *)& casts on gzread / gzwrite / ifstream / ofstream calls to reinterpret_cast<char *>(&...) per ITK style guide (Greptile P2 #6). Also fixes the WriteCells CHAR case that cast the buffer to unsigned char * instead of char *, which would silently corrupt negative vertex indices on signed cell-component types (Greptile P2 #5).
- Drop a duplicate consecutive 'protected:' access specifier in itkMZ3MeshIO.h (harmless, but warned by some compilers). - Correct the Doxygen \ingroup tag on itkMZ3MeshIOFactory.h from the outdated upstream remote-module name 'ITKIOMeshMZ3' to 'IOMeshMZ3' so the factory class shows up under the module's Doxygen group alongside MZ3MeshIO.
…shMZ3
In-tree, ITK_SOURCE_DIR is always defined and ITK's top-level
CMakeLists pins the CMake minimum version. The per-module
cmake_minimum_required line and if(NOT ITK_SOURCE_DIR) ... else()
itk_module_impl() endif() guard are dead code. The 'set(ITK_DIR
${CMAKE_BINARY_DIR})' line that was inside the in-tree else branch
is preserved (now unconditional) since it actually had effect during
the in-tree build path. Matches the v4 ingest-pipeline rules in
PR InsightSoftwareConsortium#6204 (sanitize-history.py:patch_drop_cmake_minimum_required and
:patch_standalone_build_guard).
3f87c0b to
bfea698
Compare
Symmetric counterpart to the gzopen() failure check in the gzip branch of the same function: when m_Ofstream.open() fails (target directory absent, filesystem read-only, permissions), the open silently leaves the stream in failbit state. Every subsequent m_Ofstream.write() in WriteCells / WritePoints / WritePointData / Write() then no-ops, and Write() closes the stream without surfacing an error — the caller believes the write succeeded while the output file is empty or absent. Throw itkExceptionMacro if !m_Ofstream.is_open() after the open call, matching the existing gzopen guard. Greptile P1 review on PR InsightSoftwareConsortium#6214 (post-rebase re-review).
a6863cc
into
InsightSoftwareConsortium:main
13 of 17 checks passed
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Two upstream bugs caught by Greptile review on PR InsightSoftwareConsortium#6214: 1. WritePointData() printed to std::cerr and returned silently when m_PointPixelComponentType was UNKNOWNCOMPONENTTYPE, leaving the output file in a partially-written state. Replace with itkExceptionMacro so the failure surfaces to the caller. 2. ~MZ3MeshIO() never closed m_Ofstream — a write that threw between WriteMeshInformation()'s open and Write()'s explicit close leaked the output stream. Close both m_Ifstream and m_Ofstream in the destructor's uncompressed branch (guarded by is_open() so closing twice is safe). Also rewrites the 20 C-style (char *)& casts on gzread / gzwrite / ifstream / ofstream calls to reinterpret_cast<char *>(&...) per ITK style guide (Greptile P2 #6). Also fixes the WriteCells CHAR case that cast the buffer to unsigned char * instead of char *, which would silently corrupt negative vertex indices on signed cell-component types (Greptile P2 #5).
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
Symmetric counterpart to the gzopen() failure check in the gzip branch of the same function: when m_Ofstream.open() fails (target directory absent, filesystem read-only, permissions), the open silently leaves the stream in failbit state. Every subsequent m_Ofstream.write() in WriteCells / WritePoints / WritePointData / Write() then no-ops, and Write() closes the stream without surfacing an error — the caller believes the write succeeded while the output file is empty or absent. Throw itkExceptionMacro if !m_Ofstream.is_open() after the open call, matching the existing gzopen guard. Greptile P1 review on PR InsightSoftwareConsortium#6214 (post-rebase re-review).
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
May 6, 2026
…est-iomeshmz3 ENH: Ingest ITKIOMeshMZ3 into Modules/IO
50 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Ingests ITKIOMeshMZ3 (read/write of Surf Ice's MZ3 surface-mesh format via
itk::MZ3MeshIO+ factory) intoModules/IO/IOMeshMZ3/using the v4 ingestion pipeline. Tier-A Wave-1 candidate from #6160. Upstream: InsightSoftwareConsortium/ITKIOMeshMZ3 atfbeed91e; will be archived after this lands.Sanitizer report (Phase A)
Smaller and more recent upstream than the other v4 ingests so far (PolarTransform, SplitComponents) — fewer style and prefix fixups needed.
Topology and CI expectations
upstream/main@777a69ffab(zero commits behind at push time)Expected CI state: all green except
ghostflow-check-main's single root-commit error — accepted perINGESTION_STRATEGY_v4.md§"Known artifacts at PR-review time".Local verification
pre-commit run --all-files→ exit 0cmake -DModule_IOMeshMZ3:BOOL=ON .configure cleanninja IOMeshMZ3TestDriver8/8 build steps OKninja ITKDatato populate fixtures — all 4 CIDs already published on the ITKTestingData GitHub Pages mirror, HTTP 200:bafkreid6pbxwl6yr76kgqjaim3ibqefco5oxdxwzxpamwlyichrmjkf3cu—11ScalarMesh.mz3bafkreidhhxis77p7idu2oqko5u3tix665he65kn4yssrweivvtjpbg5yv4—3Mesh.mz3bafkreib5l2ftbgzhluru2wssotet4l74te3zmmqaj6cr7sl34q4in6cr6i—BrainMesh_ICBM152.lh.motor.mz3bafkreieag2mwi2fs5p7lka542fxis2o6tonz5h2v545pnlxtaqvbogwlie—cortex_5124.mz3ctest -R MZ3: 6/6 tests pass (itkMZ3MeshIOTest1..4, plusKWStyleandInDoxygenGroup)Phase B (post-merge) plan
Once this PR lands on
main:~/src/ITK-ingest-v4/Utilities/Maintenance/RemoteModuleIngest/archive-remote-module.sh IOMeshMZ3Phase B publishes the upstream-side removal commit (whitelisted files deleted,
MIGRATION_README.mdpromoted toREADME.md) directly toInsightSoftwareConsortium/ITKIOMeshMZ3'smainand flipsarchived=trueon the GitHub repo settings, perfeedback_ingest_archive_readme.md.