From d31eb569b507399001494a74ad357ede58ff3417 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 2 Sep 2026 08:46:04 -0500 Subject: [PATCH 1/2] STYLE: Break the gersemi / end-of-file-fixer deadlock on empty CMakeLists src/External and src/GPU hold no examples yet, but src/CMakeLists.txt calls add_subdirectory() on both, so each needs a CMakeLists.txt. With those files empty, gersemi wrote a lone newline and end-of-file-fixer stripped it back, so `pre-commit run --all-files` never converged. Documenting why the files exist gives both hooks something to agree on. Also applies gersemi's pending reformat of ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt. --- src/External/CMakeLists.txt | 3 +- .../CMakeLists.txt | 47 ++++++++++++------- src/GPU/CMakeLists.txt | 3 +- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/External/CMakeLists.txt b/src/External/CMakeLists.txt index 8b1378917..4917e752c 100644 --- a/src/External/CMakeLists.txt +++ b/src/External/CMakeLists.txt @@ -1 +1,2 @@ - +# No examples in this category yet; this file exists because +# src/CMakeLists.txt calls add_subdirectory(External). diff --git a/src/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt b/src/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt index 62596ffa7..cb6bb5ba2 100644 --- a/src/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt +++ b/src/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.22.1) set(input_image ${CMAKE_CURRENT_BINARY_DIR}/BrainProtonDensitySlice.png) set(output_image Output.png) -set(test_options 5 0.125 3.0) +set( + test_options + 5 + 0.125 + 3.0 +) project(ComputeCurvatureAnisotropicDiffusion) @@ -10,37 +15,45 @@ find_package(ITK REQUIRED) itk_generate_factory_registration() add_executable(${PROJECT_NAME} Code.cxx) -target_link_libraries(${PROJECT_NAME} +target_link_libraries( + ${PROJECT_NAME} PRIVATE ITK::ITKImageIO ITK::ITKAnisotropicSmoothingModule ITK::ITKImageIntensityModule ) -install(TARGETS ${PROJECT_NAME} +install( + TARGETS + ${PROJECT_NAME} DESTINATION bin/ITKSphinxExamples/Filtering/AnisotropicSmoothing COMPONENT Runtime - ) +) -install(FILES Code.cxx CMakeLists.txt Code.py - DESTINATION share/ITKSphinxExamples/Code/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion +install( + FILES + Code.cxx + CMakeLists.txt + Code.py + DESTINATION + share/ITKSphinxExamples/Code/Filtering/AnisotropicSmoothing/ComputeCurvatureAnisotropicDiffusion COMPONENT Code ) enable_testing() -add_test(NAME ComputeCurvatureAnisotropicDiffusionTest - COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME} - ${input_image} - ${output_image} - ${test_options} +add_test( + NAME ComputeCurvatureAnisotropicDiffusionTest + COMMAND + ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME} ${input_image} + ${output_image} ${test_options} ) if(ITK_WRAP_PYTHON) string(REPLACE . "Python." output_image "${output_image}") - add_test(NAME ComputeCurvatureAnisotropicDiffusionTestPython - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py - ${input_image} - ${output_image} - ${test_options} - ) + add_test( + NAME ComputeCurvatureAnisotropicDiffusionTestPython + COMMAND + ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py ${input_image} + ${output_image} ${test_options} + ) endif() diff --git a/src/GPU/CMakeLists.txt b/src/GPU/CMakeLists.txt index 8b1378917..23f313c2a 100644 --- a/src/GPU/CMakeLists.txt +++ b/src/GPU/CMakeLists.txt @@ -1 +1,2 @@ - +# No examples in this category yet; this file exists because +# src/CMakeLists.txt calls add_subdirectory(GPU). From bdc606e3ac9d570b2da3c963a44207b5173ea09f Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 2 Sep 2026 08:38:59 -0500 Subject: [PATCH 2/2] COMP: Select the LevelSetNode container index type at runtime ITK 6.0 wraps VectorContainer>; ITK 5.4 wraps VectorContainer>. The two mangled template keys are disjoint, so a single spelling cannot run on both. Verified against ITK 5.4.6: the example completes in 171 iterations with RMS change 0.0198. --- .../SegmentWithGeodesicActiveContourLevelSet/Code.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Segmentation/LevelSets/SegmentWithGeodesicActiveContourLevelSet/Code.py b/src/Segmentation/LevelSets/SegmentWithGeodesicActiveContourLevelSet/Code.py index 7ebf54572..9263336a1 100755 --- a/src/Segmentation/LevelSets/SegmentWithGeodesicActiveContourLevelSet/Code.py +++ b/src/Segmentation/LevelSets/SegmentWithGeodesicActiveContourLevelSet/Code.py @@ -99,11 +99,17 @@ seedPosition[0] = args.seed_x seedPosition[1] = args.seed_y -node = itk.LevelSetNode[InputPixelType, Dimension]() +NodeType = itk.LevelSetNode[InputPixelType, Dimension] + +node = NodeType() node.SetValue(seedValue) node.SetIndex(seedPosition) -seeds = itk.VectorContainer[itk.UI, itk.LevelSetNode[InputPixelType, Dimension]].New() +try: + NodeContainer = itk.VectorContainer[itk.IT, NodeType] # ITK >= 6.0 +except TypeError: + NodeContainer = itk.VectorContainer[itk.UI, NodeType] # ITK <= 5.4 +seeds = NodeContainer.New() seeds.Initialize() seeds.InsertElement(0, node)