Skip to content

Comments

Deprecate ImageConstIterator::GetIndex(), use ComputeIndex() in tests and examples#5803

Merged
hjmjohnson merged 5 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Deprecate-ImageConstIterator-GetIndex-use-ComputeIndex
Feb 15, 2026
Merged

Deprecate ImageConstIterator::GetIndex(), use ComputeIndex() in tests and examples#5803
hjmjohnson merged 5 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Deprecate-ImageConstIterator-GetIndex-use-ComputeIndex

Conversation

@N-Dekker
Copy link
Contributor

@github-actions github-actions bot added area:Examples Demonstration of the use of classes type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module labels Feb 13, 2026
@N-Dekker N-Dekker marked this pull request as ready for review February 13, 2026 23:38
@N-Dekker N-Dekker force-pushed the Deprecate-ImageConstIterator-GetIndex-use-ComputeIndex branch 2 times, most recently from b7d5400 to a422e03 Compare February 14, 2026 10:33
Copy link
Member

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

@N-Dekker This looks good as is. Adding a note to this change in the migration guide now will be useful in the future when the GetIndex is removed in a few years form now.

@N-Dekker
Copy link
Contributor Author

@N-Dekker This looks good as is. Adding a note to this change in the migration guide now will be useful in the future when the GetIndex is removed in a few years form now.

Thanks, Hans. I'm adding the following note, please check:


GetIndex() replaced with ComputeIndex(), for iterators without index

ImageConstIterator::GetIndex() is marked to be removed in the future. This iterator does not have an index,
internally, so its GetIndex() member function does a potentially expensive computation. For an iterator that is
derived from ImageConstIterator, please use its newly introduced ComputeIndex() member function instead. Or use an
iterator with index (like ImageIteratorWithIndex).

Replaced `outputIt.GetIndex()` with `outputIt.ComputeIndex()`, in
`PolylineMaskImageFilter::GenerateData()`.

Follow-up to pull request InsightSoftwareConsortium#5787
commit cc5b301
"STYLE: Replace GetIndex() calls on iterators with ComputeIndex()"
Replaced function calls of the form `iterator.GetIndex()` with
`iterator.ComputeIndex()`, for iterators derived from `ImageConstIterator`, in
tests.

Follow-up to pull request InsightSoftwareConsortium#5787
commit cc5b301
"STYLE: Replace GetIndex() calls on iterators with ComputeIndex()"
Replaced function calls of the form `iterator.GetIndex()` with
`iterator.ComputeIndex()`, for iterators derived from `ImageConstIterator`, in
Modules/Registration/Common/test/RegistrationITKv3

Follow-up to pull request InsightSoftwareConsortium#5787
commit cc5b301
"STYLE: Replace GetIndex() calls on iterators with ComputeIndex()"
Replaced function calls of the form `iterator.GetIndex()` with
`iterator.ComputeIndex()`, for iterators derived from `ImageConstIterator`, in
Examples.

Follow-up to pull request InsightSoftwareConsortium#5787
commit cc5b301
"STYLE: Replace GetIndex() calls on iterators with ComputeIndex()"
Indicated that `ImageConstIterator::GetIndex()` will be removed in the future.
Adding a note to the migration guide.

The name "ComputeIndex" appears much clearer, as it indicates that it does a
potentially expensive computation, in order to retrieve the index.

Follow-up to pull request InsightSoftwareConsortium#5787
commit 3e5a75a
"ENH: Add `ComputeIndex()` member function to ImageConstIterator"
@N-Dekker N-Dekker force-pushed the Deprecate-ImageConstIterator-GetIndex-use-ComputeIndex branch from a422e03 to 2b7c077 Compare February 15, 2026 10:31
@github-actions github-actions bot added the area:Documentation Issues affecting the Documentation module label Feb 15, 2026
@hjmjohnson hjmjohnson merged commit 86e93b2 into InsightSoftwareConsortium:main Feb 15, 2026
18 checks passed
@blowekamp
Copy link
Member

@N-Dekker I am seeing some new build errors on the dashboard that I presume is related to this work:
https://open.cdash.org/index.php?project=Insight

https://open.cdash.org/viewBuildError.php?buildid=11052824

In file included from [Modules/Nonunit/Review/include/itkScalarChanAndVeseLevelSetFunction.h:147](https://github.com/InsightSoftwareConsortium/ITK/blob/e7ac8e35219206f680416fc4780920b75281354d/Modules/Nonunit/Review/include/itkScalarChanAndVeseLevelSetFunction.h#L147):
[Modules/Nonunit/Review/include/itkScalarChanAndVeseLevelSetFunction.hxx:116](https://github.com/InsightSoftwareConsortium/ITK/blob/e7ac8e35219206f680416fc4780920b75281354d/Modules/Nonunit/Review/include/itkScalarChanAndVeseLevelSetFunction.hxx#L116):22: error: no member named 'GetIndex' in 'itk::ImageRegionConstIterator<itk::Image<float, 3>>'    inputIndex = fIt.GetIndex();
                 ~~~ ^

There may be others.

Are you able to address these issues?

@N-Dekker
Copy link
Contributor Author

@blowekamp Thanks, I think you're presumption is correct!

Is https://open.cdash.org/viewBuildError.php?buildid=11052824 built using ITK_FUTURE_LEGACY_REMOVE=ON ?

  • ITK_FUTURE_LEGACY_REMOVE will remove ImageConstIterator::GetIndex()
  • ITK_LEGACY_REMOVE will only produce a warning ("deprecated") for each ImageConstIterator::GetIndex() call

@blowekamp
Copy link
Member

@blowekamp Thanks, I think you're presumption is correct!

Is https://open.cdash.org/viewBuildError.php?buildid=11052824 built using ITK_FUTURE_LEGACY_REMOVE=ON ?

  • ITK_FUTURE_LEGACY_REMOVE will remove ImageConstIterator::GetIndex()
  • ITK_LEGACY_REMOVE will only produce a warning ("deprecated") for each ImageConstIterator::GetIndex() call

I think that is a reasonable presumption. You'd have to dig into the configuration log and files on the dashboard to confirm.

@N-Dekker
Copy link
Contributor Author

OK, thanks @blowekamp, I'll do a local build with Module_ITKReview enabled, to see if I can reproduce it locally.

N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Feb 17, 2026
Replaced function calls of the form `iterator.GetIndex()` with
`iterator.ComputeIndex()`, for iterators derived from `ImageConstIterator`, in
"Modules/Nonunit/Review"

Fixes compile errors that occur when compiling with `Module_ITKReview=ON` _and_
`ITK_FUTURE_LEGACY_REMOVE=ON`, like:

    error: no member named 'GetIndex' in 'itk::ImageRegionConstIterator'

As occurred at RogueResearch24/Mac13.x-AppleClang-dbg-Universal:
https://open.cdash.org/viewBuildError.php?buildid=11052824

Reported by Bradley Lowekamp at
InsightSoftwareConsortium#5803 (comment)
SimonRit pushed a commit to SimonRit/RTK that referenced this pull request Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:Documentation Issues affecting the Documentation module area:Examples Demonstration of the use of classes area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants