Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TransformPhysicalPointToIndex, TransformPhysicalPointToContinuousIndex [[nodiscard]] warnings #4000

Conversation

N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Apr 6, 2023

Replacing TransformPhysicalPointToIndex(point, index) with index = TransformPhysicalPointToIndex(point) appeared to be a no-brainer, while replacing the TransformPhysicalPointToContinuousIndex calls was somewhat more challenging... but still no rocket science.

Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

When the `bool` return value of a `TransformPhysicalPointToIndex(point, index)`
call can be ignored, it is preferable (for performance reasons) to call the
`TransformPhysicalPointToIndex(point)` overload that just returns the index,
preventing `[[nodiscard]]` compile warnings.

These cases are found in Visual Studio, using the following regular expression:
`  [^ ]+->TransformPhysicalPointToIndex\(.*,`
Did find code like this:

    ContinuousIndexType index;
    image->TransformPhysicalPointToContinuousIndex(point, index);

And replaced it by something like:

    const ContinuousIndexType index =
      image->template TransformPhysicalPointToContinuousIndex<ContinuousIndexValueType>(point);

When the `bool` return value is ignored, it is preferable (for performance
reasons) to call the overload that just returns the continuous index, preventing
`[[nodiscard]]` compile warnings.

These cases are found in Visual Studio, using the following regular expression:
`  [^ ]+->TransformPhysicalPointToContinuousIndex\(.*,`
@N-Dekker N-Dekker force-pushed the Fix-TransformPhysicalPointTo-nodiscard-warnings branch from 5f42e74 to 3f16044 Compare April 6, 2023 14:37
@github-actions github-actions bot added 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:Registration Issues affecting the Registration module labels Apr 6, 2023
@N-Dekker N-Dekker marked this pull request as ready for review April 6, 2023 14:47
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.

Thanks for addressing the warnings 💚

Possible follow-up noted inline.

@@ -38,8 +38,7 @@ ScalarChanAndVeseSparseLevelSetImageFilter<TInputImage, TFeatureImage, TOutputIm
InputPointType origin = input->GetOrigin();

// In the context of the global coordinates
FeatureIndexType start;
this->GetInput()->TransformPhysicalPointToIndex(origin, start);
FeatureIndexType start = this->GetInput()->TransformPhysicalPointToIndex(origin);
Copy link
Member

Choose a reason for hiding this comment

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

It seems many of these could be marked const now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, thanks Matt! Maybe for another PR? (I would like to have this one merged as soon as it's "good enough", because it fixes a few warnings at https://open.cdash.org/index.php?project=Insight)

@dzenanz dzenanz merged commit 7cda5ba into InsightSoftwareConsortium:master Apr 6, 2023
5 checks passed
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 7, 2023
Fixed compile errors saying:

> error C2039: 'ContinuousIndexType': is not a member of 'itk::ContinuousIndex'

These compile errors were introduced by pull request InsightSoftwareConsortium#4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 7, 2023
Fixed compile errors saying:

> error C2065: 'cindex': undeclared identifier

These compile errors were introduced by pull request InsightSoftwareConsortium#4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
hjmjohnson pushed a commit that referenced this pull request Apr 7, 2023
Fixed compile errors saying:

> error C2039: 'ContinuousIndexType': is not a member of 'itk::ContinuousIndex'

These compile errors were introduced by pull request #4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
hjmjohnson pushed a commit that referenced this pull request Apr 7, 2023
Fixed compile errors saying:

> error C2065: 'cindex': undeclared identifier

These compile errors were introduced by pull request #4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 9, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex
calls in Nonunit/Review tests.

Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying:

> error: expected primary-expression before '>' token

These compile errors were introduced by pull request InsightSoftwareConsortium#4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 9, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex
calls in Nonunit/Review tests.

Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying:

> error: expected primary-expression before '>' token

These compile errors were introduced by pull request InsightSoftwareConsortium#4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
dzenanz pushed a commit that referenced this pull request Apr 10, 2023
Added missing `template` keywords to TransformPhysicalPointToContinuousIndex
calls in Nonunit/Review tests.

Addressed compile errors from Ubuntu-22.04-gcc11.2-TBB-Debug saying:

> error: expected primary-expression before '>' token

These compile errors were introduced by pull request #4000
commit 7cda5ba
"COMP: Fix TransformPhysicalPointToContinuousIndex `nodiscard` warnings"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 17, 2023
Declared local "IndexType" variables in "Nonunit/Review" that are initialized
by the result of a TransformPhysicalPointToIndex(point) call `const`.

Follow-up to commit 49ece7f
"COMP: Fix TransformPhysicalPointToIndex `nodiscard` warnings"

Suggested by Matt McCormick at
InsightSoftwareConsortium#4000 (comment)
dzenanz pushed a commit that referenced this pull request Apr 17, 2023
Declared local "IndexType" variables in "Nonunit/Review" that are initialized
by the result of a TransformPhysicalPointToIndex(point) call `const`.

Follow-up to commit 49ece7f
"COMP: Fix TransformPhysicalPointToIndex `nodiscard` warnings"

Suggested by Matt McCormick at
#4000 (comment)
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:Registration Issues affecting the Registration 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.

None yet

3 participants