Skip to content

COMP: Build the VTK examples against ITK 5.4, ITK 6, and VTK 9 - #62

Merged
hjmjohnson merged 9 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-vtk-examples
Oct 13, 2026
Merged

hjmjohnson merged 9 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-vtk-examples

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

With LSTK_USE_VTK=ON the examples and visualization tools have not built since the ITK 5 SpatialObject refactoring, and CI never exercises that option. This replaces the VTK 8 era vtk_module_config() block with find_package(VTK 9 COMPONENTS ...), updates the examples to the ITK 5 SpatialObject API, and builds all five executables against ITK 6 and VTK 9.6. Closes #42. Rebased onto main after #61 merged; the first seven commits are separate by class of change, fixes first and the style change last, and the eighth bumps the ITK 5.4 CI action pin, and the ninth fixes an intermittent exit-time segfault in itkLesionSegmentationMethodTest1.

Commits
  1. COMP: find VTK 9 and link the module library (top-level CMakeLists.txt only).
  2. COMP: vtk_module_autoinit() for the five executables (two CMake files, one added line per target).
  3. COMP: ITK 5 SpatialObject API in the examples (CLI.h, ViewImageSlicesAndSegmentationContours.cxx).
  4. COMP: return nullptr for an Image::Pointer, and the missing <iostream>.
  5. BUG: misspelled include guard #define, one line.
  6. COMP: override on the two Execute() methods.
  7. STYLE: clang-format of the progress reporter header (whitespace only).
  8. COMP: ITKRemoteModuleBuildTestPackageAction @v5.4.6 to @v5.4.7 in both ITK 5.4 jobs (answers a review question on COMP: Build and test against ITK 5.4 and ITK 6 #61).
  9. BUG: LesionSegmentationMethod and FeatureAggregator kept a ProgressAccumulator member whose SetMiniPipelineFilter(this) SmartPointer formed a reference cycle, so neither was ever destroyed. The leaked PoolMultiThreader kept the global ThreadPool alive past its globals' teardown, and a late-starting pool thread then read a null ThreadPoolGlobals (itkThreadPool.cxx:193). The accumulator is now created in the call that uses it. On Linux with an ASan+UBSan ITK at 5d31af3cfdf the test crashed in 69 of 3000 parallel runs before and in 0 of 6000 after.

Nothing outside these classes changed (CI workflow pin aside): the existing CMake text is kept as written and only the required lines are added.

What was wrong
  • CMakeLists.txt defined its own vtk_module_config() that prefixed names with an undefined _target_prefix and never called find_package(VTK), so Examples/ and Utilities/Visualization/ targets received neither the module include directory nor any VTK:: target; the build failed at the first VTK header.
  • Examples/LesionSegmentationCLI.h and Utilities/Visualization/ViewImageSlicesAndSegmentationContours.cxx used SpatialObjectPoint::GetPosition()/SetPosition() and GroupSpatialObject::GetNumberOfObjects()/GetObjects(), all removed in ITK 5 (GetPositionInObjectSpace, SetPositionInObjectSpace, GetNumberOfChildren, GetChildren).
  • Examples/LesionSegmentation.cxx returned NULL as an Image::Pointer; LesionSurfaceExtraction.cxx used std::cerr without <iostream>; the progress-reporter header had a misspelled guard and virtual overrides without override.
Test plan

External-module build on macOS arm64 against ITK main (6.0) and VTK 9.6 with -DLSTK_USE_VTK=ON: configure succeeds, LesionSegmentation, ViewImageAndSegmentationSurface, ViewImageSlicesAndSegmentationContours, LesionSurfaceExtraction, and IsoSurfaceVolumeEstimation all build, and LesionSegmentation -h prints its MetaCommand usage. The default configuration (LSTK_USE_VTK=OFF) configures as before, which is what CI runs; every change is inside if(LSTK_USE_VTK) or in files only that option compiles. Not built against ITK 5.4 with VTK; the API names used exist in 5.4.

@hjmjohnson
hjmjohnson marked this pull request as ready for review October 8, 2026 18:44
With LSTK_USE_VTK=ON the examples failed at the first VTK header. The
VTK 8 era vtk_module_config() macro built target names from an
undefined _target_prefix and nothing called find_package(VTK), so the
targets received neither the VTK:: libraries nor their include
directories. Use find_package(VTK 9 COMPONENTS ...) for the modules the
sources include, link the module library the same way src/ does, and
add the module include directory.
VTK 9 registers the rendering and IO object factories of the modules an
executable links through vtk_module_autoinit(); without it, creating a
render window or an image writer finds no implementation at run time.
ITK 5 renamed SpatialObjectPoint::GetPosition()/SetPosition() to
GetPositionInObjectSpace()/SetPositionInObjectSpace(), and
GroupSpatialObject::GetNumberOfObjects()/GetObjects() to
GetNumberOfChildren()/GetChildren() with ChildrenListType.
LesionSegmentation.cxx returned NULL where an Image::Pointer is
expected, which does not convert once NULL is an integer constant, and
LesionSurfaceExtraction.cxx used std::cerr without including
<iostream>.
The header tested itkLesionSegmentationCommandLineProgressReporter_h but
defined itkLesionSegmentatioCommandLineProgressReporter_h, so the guard
never took effect and a second inclusion redefined the class.
Both Execute() overloads override itk::Command and trigger
-Winconsistent-missing-override on every file that includes the header.
Drop the indentation after # in the preprocessor directives, which the
repository .clang-format does not use.
…4 jobs

v5.4.7 defaults to ITK 5.4.7 and updates the GitHub Actions that
emit Node.js 20 deprecation warnings.
…ne filter

ProgressAccumulator::SetMiniPipelineFilter() holds a SmartPointer, so a
member accumulator pointed at its owner formed a reference cycle and
LesionSegmentationMethod and FeatureAggregator were never destroyed.

The leaked PoolMultiThreader kept the global ThreadPool alive past the
teardown of its globals, so a pool thread that started late read a null
ThreadPoolGlobals at exit and crashed intermittently.

Create the accumulator in the call that uses it, as the other filters do.
@hjmjohnson
hjmjohnson merged commit 28f2cf5 into InsightSoftwareConsortium:main Oct 13, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to successfully compile LesionSizingToolkit module

2 participants