Skip to content

Conversation

@N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Nov 1, 2024


Also removed the local shrinkFactors variable from the default-constructor of ImageRegistrationMethodv4, and instead, simply "filled" the elements of its m_ShrinkFactorsPerLevel directly.

@github-actions github-actions bot added area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module area:Numerics Issues affecting the Numerics module labels Nov 1, 2024
Simply filled the elements of m_ShrinkFactorsPerLevel directly.
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
    Replace with: $1auto $3 = MakeFilled<$2>\(
    Filters: itk*.h;itk*.hxx;itk*.cxx
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded "itkVectorMeanImageFunction.hxx", because it may try to fill a
`VariableLengthVector` (which is not supported by `MakeFilled`).

Follow-up to pull request InsightSoftwareConsortium#4891
commit d6c9eed
"STYLE: Replace Fill calls with `auto var = itk::MakeFilled<T>` in tests"
@N-Dekker N-Dekker force-pushed the Replace-Fill-with-MakeFilled branch from 1c43f34 to 612e6b0 Compare November 1, 2024 11:00
@N-Dekker N-Dekker marked this pull request as ready for review November 1, 2024 13:21
@N-Dekker
Copy link
Contributor Author

N-Dekker commented Nov 1, 2024

Note to self: After this PR, I hope I have some time to do follow-ups on the ITK SW Guide, examples, etc., as suggested by Jon at #4887 (review)


typename NeighborhoodIteratorType::RadiusType radius;
radius.Fill(1);
auto radius = MakeFilled<typename NeighborhoodIteratorType::RadiusType>(1);
Copy link
Member

Choose a reason for hiding this comment

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

Should these now be "const auto" ?

I'm approving, and think this PR should not be held up to add const, but it might be another benefit of using MakeFilled.

Copy link
Contributor Author

@N-Dekker N-Dekker Nov 3, 2024

Choose a reason for hiding this comment

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

Should these now be "const auto" ?

Good question @hjmjohnson Actually maybe even "constexpr auto"!!! However, it's a bit risky to just blindly add const or constexpr to all such cases, as those variables might need to be modified later on. So I'm hoping that this can be achieved by a follow-up PR, using some intelligent code analysis tool, which checks that those variables aren't modified after their initialization 😃

Thanks for your approval!

@dzenanz dzenanz merged commit 6cb6bf9 into InsightSoftwareConsortium:master Nov 4, 2024
15 checks passed
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 4, 2024
Suggests evaluating its value at compile-time, rather than at runtime.

Found by regular expressions:

    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(-?\d+\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(\d.0\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(false\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(true\);)

Inspired by a comment by Hans Johnson at
InsightSoftwareConsortium#4924 (comment)
hjmjohnson pushed a commit that referenced this pull request Nov 5, 2024
Suggests evaluating its value at compile-time, rather than at runtime.

Found by regular expressions:

    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(-?\d+\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(\d.0\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(false\);)
    ^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(true\);)

Inspired by a comment by Hans Johnson at
#4924 (comment)
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request Nov 15, 2024
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request Nov 15, 2024
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request Nov 15, 2024
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:Filtering Issues affecting the Filtering module area:Numerics Issues affecting the Numerics module area:Registration Issues affecting the Registration module area:Segmentation Issues affecting the Segmentation module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants