Skip to content

Use RegionConstIteratorWithIndex in ContourExtractor2DImageFilter, deprecate nested RegionIterator aliases#5806

Merged
thewtex merged 4 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Use-ImageRegionConstIteratorWithIndex-in-ContourExtractor2DImageFilter
Feb 16, 2026
Merged

Use RegionConstIteratorWithIndex in ContourExtractor2DImageFilter, deprecate nested RegionIterator aliases#5806
thewtex merged 4 commits intoInsightSoftwareConsortium:mainfrom
N-Dekker:Use-ImageRegionConstIteratorWithIndex-in-ContourExtractor2DImageFilter

Conversation

@N-Dekker
Copy link
Contributor

  • Replaced using RegionConstIterator with using ImageRegionConstIteratorWithIndex in ContourExtractor2DImageFilter::GenerateDataForLabels(), to avoid potentially expensive index computation with each iteration.
  • Removed a GoToBegin() call, following pull request Remove GoToBegin() calls on local ImageRegionIteratorWithIndex variables #5736
  • Deprecated (FUTURE_LEGACY_REMOVE) the type aliases RegionIterator and RegionConstIterator that were nested withing ContourExtractor2DImageFilter, as they are no longer being used.

Replaced using RegionConstIterator with using ImageRegionConstIteratorWithIndex
in `ContourExtractor2DImageFilter<TInputImage>::GenerateDataForLabels()`,  to
avoid potentially expensive index computation with each iteration.
Avoided calling `inputIt.GetIndex()` repetitively during one and the same
iteration. This is just a style improvement, as it is not a major performance
improvement. (`inputIt.GetIndex()` is likely to be very fast.)
Reduced the scope of the local `inputIt` variable in `GenerateDataForLabels()`,
by moving its declaration into the _init-statement_ of its `for` loop. Following
C++ Core Guidelines, Jul 8, 2025 "Declare names in for-statement initializers
and conditions to limit scope",
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#res-cond

Removed the `inputIt.GoToBegin()` call, following pull request
InsightSoftwareConsortium#5736
commit f10bd8f
"STYLE: Remove GoToBegin() calls on ImageRegionIteratorWithIndex"
These nested type aliases are no longer used. Originally, they were just used
internally, within the implementation of `ContourExtractor2DImageFilter`.
@github-actions github-actions bot added the area:Filtering Issues affecting the Filtering module label Feb 15, 2026
@N-Dekker N-Dekker marked this pull request as ready for review February 15, 2026 19:52
Copy link
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.

🚀

@thewtex thewtex merged commit d00d73d into InsightSoftwareConsortium:main Feb 16, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants