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

All #3

Open
wants to merge 10,000 commits into
base: release-3.20
Choose a base branch
from
Open

Conversation

Marklovesmichelle69
Copy link

See the CONTRIBUTING guide. Specifically:

Start ITK commit messages with a standard prefix (and a space):

  • BUG: fix for runtime crash or incorrect result
  • COMP: compiler error or warning fix
  • DOC: documentation change
  • ENH: new functionality
  • PERF: performance improvement
  • STYLE: no logic impact (indentation, comments)
  • WIP: Work In Progress not ready for merge

Provide a short, meaningful message that describes the change you made.

When the PR is based on a single commit, the commit message is usually left as the PR message.

A reference to a related issue or pull request in your repository. You can automatically close a related issues using keywords

@mentions of the person or team responsible for reviewing proposed changes.

Thanks for contributing to ITK!

kwrobot pushed a commit that referenced this pull request Sep 6, 2018
cmake_minimum_required(VERSION 3.9.5 FATAL_ERROR)
foreach(p
    ## Only policies introduced after the cmake_minimum_required
    ## version need to explicitly be set to NEW.
    CMP0070 #3.10.0 Define ``file(GENERATE)`` behavior for relative paths.
    CMP0071 #3.10.0 Let ``AUTOMOC`` and ``AUTOUIC`` process ``GENERATED`` files.
    )
  if(POLICY ${p})
    cmake_policy(SET ${p} NEW)
  endif()
endforeach()

Change-Id: I30c9a4f2401bf83bcdb56ba89d44b24ca8342853
kwrobot pushed a commit that referenced this pull request Mar 4, 2021
…n metric

Fix uninitialized variable use in `ANTS` neighborhood correlation metric:
ensure that `fixedImageGradient` and `movingImageGradient` have valid
values before assigning them to the `scanMem` struct that scans over
images.

Fixes:
```
Run-Time Check Failure #3 - The variable 'fixedImageGradient' is being
used without being initialized.
```

The bug was affecting a number of tests in the
`ITKRegistrationMethodsv4Test` module.

Signaled at
https://open.cdash.org/viewTest.php?onlyfailed&buildid=7067466
and
https://open.cdash.org/viewTest.php?onlyfailed&buildid=7069241
kwrobot pushed a commit that referenced this pull request Apr 29, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
kwrobot pushed a commit that referenced this pull request May 30, 2024
Found with thread sanitizer (TSan) running the `itkANTSNeighborhoodCorrelationImageToImageRegistrationTest` unit test.

There was already a `m_ANTSAssociateOnceFlag` flag for use with `std::call_once`, so I just used that in this place too (it's already used elsewhere).

Partial backtrace from TSan:

```
WARNING: ThreadSanitizer: data race (pid=79176)
  Write of size 8 at 0x000108f02240 by thread T2:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)

  Previous write of size 8 at 0x000108f02240 by thread T14:
    #0 void itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution_impl<itk::ThreadedIndexedContainerPartitioner>(itk::IdentityHelper<itk::ThreadedIndexedContainerPartitioner>, itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx:118 (ITKMetricsv4TestDriver:arm64+0x1004bfe50)
    #1 itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>, itk::ANTSNeighborhoodCorrelationImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreadedExecution(itk::Index<2u> const&, unsigned int) itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.h:235 (ITKMetricsv4TestDriver:arm64+0x1004bf9c0)
    #2 itk::DomainThreader<itk::ThreadedIndexedContainerPartitioner, itk::ImageToImageMetricv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double, itk::DefaultImageToImageMetricTraitsv4<itk::Image<double, 2u>, itk::Image<double, 2u>, itk::Image<double, 2u>, double>>>::ThreaderCallback(void*) itkDomainThreader.hxx:123 (ITKMetricsv4TestDriver:arm64+0x100259b6c)
    #3 std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()::operator()() const itkThreadPool.h:92 (ITKMetricsv4TestDriver:arm64+0x1007d3228)
    #4 decltype(std::declval<void* (*&)(void*)>()(std::declval<itk::PoolMultiThreader::ThreadPoolInfoStruct*>())) std::__1::__invoke[abi:v160006]<std::__1::future<std::__1::invoke_result<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>::type> itk::ThreadPool::AddWork<void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&)::'lambda'()&>(void* (*&)(void*), itk::PoolMultiThreader::ThreadPoolInfoStruct*&&) invoke.h:394 (ITKMetricsv4TestDriver:arm64+0x1007d31a4)
```
N-Dekker and others added 26 commits October 3, 2024 08:54
Aims to reduce code duplication.

- Follow-up to pull request #4855
commit 3b04ad1
"STYLE: Clean-up ByteSwapper, using private `SwapBytes` helper function"
Allows an algorithm to process the points of a `PointSet` object, without
having to know its `PixelType` at compile-time. The algorithm may then just use
a pointer or reference to its abstract base class, `PointSetBase`. Doing so may
reduce the "code bloat" caused by template instantiations, and ease wrapping the
algorithm for Python.

With this commit, its `PixelType` and its `PointData` container are still
defined inside `itk::PointSet`, while the other properties (its points and
its region information) are moved to its base class, `PointSetBase`.
Avoided MSVC 2022 warning level 4 warnings, saying:

> warning C4389: '!=': signed/unsigned mismatch
Avoided MSVC 2022 warning level 4 warnings, saying:

> warning C4189: 'res': local variable is initialized but not referenced

Note that it is OK to ignore the return value of these four `PyBuffer_FillInfo`
calls, as it is always zero anyway, for the specified arguments. As implemented
at https://github.com/python/cpython/blob/v3.12.7/Objects/abstract.c#L709-L743
`PyBuffer_FillInfo` is not declared `[[nodiscard]]` either.
Calling `PyBuffer_Release` is unnecessary after a `PyBuffer_FillInfo` call that
has null as its second argument, just like it says at
https://github.com/python/cpython/blob/v3.12.7/Modules/_io/bufferedio.c#L1566 :

    /* NOTE: the buffer needn't be released as its object is NULL. */

The documentation of `PyBuffer_Release` even says:

> It is an error to call this function on a buffer that was not obtained via
> `PyObject_GetBuffer()`.

Source: https://docs.python.org/3.12/c-api/buffer.html#c.PyBuffer_Release
`PyBuffer_Release` should only be called after a _successful_
`PyObject_GetBuffer` call. As specified at
https://docs.python.org/3.12/c-api/buffer.html#c.PyObject_GetBuffer
The original implementations of `PyBuffer::_GetImageViewFromArray`,
`PyVectorContainer::_vector_container_from_array`,
`PyVnl::_GetVnlVectorFromArray`, and `PyVnl<TElement>::_GetVnlMatrixFromArray`
might leak memory from `Py_buffer` in case of an exception.

This commit avoids such leaks by replacing the manual
`PyBuffer_Release(&pyBuffer)` calls in those member functions with scope guards.
ENH: Add `itk::PointSetBase` as abstract base class of `itk::PointSet`
Remove unnecessary PyBuffer_Release calls, and other "Bridge/NumPy"  style improvements
Make the index type of VectorContainer `itk::SizeValueType` by default
Add a template instantiation to check that the
`itk::RelabelComponentImageFilter` class does not trigger compiler
warnings with signed pixel types.

Ensures regressions are not introduced after the fix in commit 108a2cf.
Follow-up to pull request #4863
commit aaff35c
"STYLE: Replace `memset(&pyBuffer, 0, sizeof(Py_buffer))` with `{}`"

Also added `constexpr` to a local variable, named `zero`.
Removed an unsafe `(void *)pPar` cast from `PhilipsPAR::ReadPAR`.
Replaced code of the form

    p = new T;
    memset(p, 0, sizeof(T))

with `p = new T()`. The added `()` parentheses will ensure proper
value-initialization.
`m_Header` is already has a `{}` default member initializer, in the class
definition of `MRCHeaderObject`.
`xfm.emplace_back()` already properly initializes the added element.
These nine `ByteSwapper` member functions were only for internal use. They are
replaced now with private member functions `SwapBytes` and `SwapWriteRange`, by:
- pull request #4855
commit 3b04ad1, and
- pull request #4862
commit 9413dc4
Removing this `const` enables move semantics, which may improve the performance.

Following C++ Core Guidelines, Oct 3, 2024, Don’t return `const T`:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-return-const

See also:
https://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html
Aims to address Windows specific wrapping failures at the CI
(https://open.cdash.org/viewBuildError.php?type=1&buildid=9948358), including:

    itkQuadEdgeMeshBase: warning(4): ITK type not wrapped, or currently not known: itk::QuadEdgeMeshPoint< float, 2 >

And locally, from Visual Studio 2022:

    Bin\ITK\Wrapping\Typedefs\itkQuadEdgeMeshBase.i(1220): warning 401: Nothing known about base class 'itk::PointSetBase< itk::MapContainer< unsigned long long,itk::QuadEdgeMeshPoint< float,2,itk::GeometricalQuadEdge< unsigned long long,unsigned long long,bool,bool > > > >'. Ignored.
    Bin\ITK\Wrapping\Typedefs\itkQuadEdgeMeshBase.i(1220): warning 401: Maybe you forgot to instantiate 'itk::PointSetBase< itk::MapContainer< unsigned long long,itk::QuadEdgeMeshPoint< float,2,itk::GeometricalQuadEdge< unsigned long long,unsigned long long,bool,bool > > > >' using %template.

As mentioned at #4867 (comment)
…n-type

STYLE: Remove `const` from `const std::string` return types
Fixed compile errors encountered using Linux, GCC 14.2.1, cmake 3.30.5.
Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
Simplified the tests by just using the default element identifier type, which is
`itk::SizeValueType`.

Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
Following pull request #4856
commit edae0bc
"STYLE: Remove IdentifierType template argument from VectorContainer uses"
Replaced code of the form

    T var;
    var.Fill(0);

with `T var{};`

Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+[^ ].* )(\w+);[\r\n]+ [ ]+\2\.Fill\(0\);
    Replace with: $1$2{};
    Filters: itk*Test*.cxx
    [v] Match case
    (*) Regular expression

The empty initializer list `{}` effectively zero-fills those variables.
Removing these `const` keywords enables move semantics, which may improve the
performance.

Follow-up to pull request #4872
commit 8a1498c
"STYLE: Remove `const` from `const std::string` return types"
blowekamp and others added 30 commits November 22, 2024 09:02
BUG: Update libtiff's ITK module include paths
Simplify the code by returning as soon as the condition is known to be
false.
Remove unnecessary "ok" temporary variable.
For most ITK types, `p->Initialize()` has no effect, directly after
`p = T::New()`, so the `Initialize()` call might as well be removed.

Excluded a `randomNumberGenerator->Initialize()` call from this commit, as that
call appears to actually have an effect (randomizing the seed).

- Follow-up to pull request #4972
commit 674b3d2
"STYLE: Remove `p->Initialize()` calls directly after `p = T::New()`"
- Follow-up to pull request #4972
commit 674b3d2
"STYLE: Remove `p->Initialize()` calls directly after `p = T::New()`"
Avoided GCC warnings about an implicitly-declared copy-constructor
[-Wdeprecated-copy].
Using Notepad++, Replace in Files, doing:

    Find what: ^( [ ]+)([^ ][^=\r\n]*)([ ]+)(\w+);[\r\n]+\1\4\ =
    Replace with: $1$2$3$4 =
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Excluded a few cases where the syntax `T var; var = x` appears intentional (in
ConceptChecking, ImageKmeansModelEstimator, MahalanobisDistanceThresholdImageFunction,
QuasiNewtonOptimizerv4Template, and VariableSizeMatrix).

- Following pull request #4970
commit 89b5bd0
"STYLE: Replace `Iterator it; it = x` with `Iterator it = x`"
and other similar commits for different types of variables.
Search for loop patterns for common locations
where indexes can be initialized rather than assigned.

regex:   \( *[ijrc] *= *0;
Finds and replaces integer literals which are cast to bool.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-bool-literals  -header-filter=.* -fix
Move copying input to output to before threaded methods, to ensure
the operation has been completed before modifications.
Remove support for system installed versions of GDCM that are more than
10 years old.

This simplifies the codebase for code that has likely not been
explicitly tested in a very long time.
The emptiness of a container should be checked using the empty() method
instead of the size() method. It is not guaranteed that size() is a
constant-time function, and it is generally more efficient and also
shows clearer intent to use empty(). Furthermore some containers may
implement the empty() method but not implement the size() method. Using
empty() whenever possible makes it easier to switch to another container
in the future.

cd ${BLDDIR}
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,readability-container-size-empty  -header-filter=.* -fix
cmake 3.31 does an implicit conversion of paths like:
```
/myvenv/site-packages//itk --> /myvenv/site-packages/itk
                     ^^                             ^
```

which produces many warnings like:

```txt
ITKCommon: Creating itkAnatomicalOrientation submodule.
 CMake Warning (dev) at Wrapping/Generators/Python/CMakeLists.txt:88 (install):
   Policy CMP0177 is not set: install() DESTINATION paths are normalized.  Run
   "cmake --help-policy CMP0177" for policy details.  Use the cmake_policy
   command to set the policy and suppress this warning.
 Call Stack (most recent call first):
   Wrapping/Generators/Python/CMakeLists.txt:305 (wrap_itk_python_bindings_install)
   Wrapping/Generators/Python/CMakeLists.txt:380 (itk_setup_swig_python)
   Wrapping/macro_files/itk_auto_load_submodules.cmake:328 (itk_end_wrap_submodule_python)
   Wrapping/TypedefMacros.cmake:1331 (itk_auto_load_submodules)
   Modules/Core/Common/wrapping/CMakeLists.txt:63 (itk_auto_load_and_end_wrap_submodules)
```

Explicitly normalizing the path before calling the install command suppresses the message.
Don't use imported CMath::CMath target, use raw library to avoid
having to export library in ITK.
COMP: itktiff - Use raw math library
BUG: Address race condition with threaded copying input to output
Aims to make template parameter names for coordinate types clearer.

Following the ITKSoftwareGuide/CodingStyleGuide guideline on Naming Conventions,
saying, "Names are generally spelled out; use of abbreviations is discouraged".
Multiple declarations in a single statement reduces readability.

Detect local variable declaration statements and update to have only one
statement per declaration.

The clang-tidy readability-isolate-declaration check with fix options automatically
identified these changes.
Addresses warning about undefined GDCM_MAJOR_VERSION.
COMP: Move GDCM version check to cxx file
Code extracted from:

    https://github.com/Kitware/MetaIO.git

at commit 56c9257467fa901e51e67ca5934711869ed84e49 (master).
# By MetaIO Maintainers
* upstream-MetaIO:
  MetaIO 2024-11-29 (56c92574)
"CoordinateType" appears more readable than "CoordRepType".

Using Notepad++, Replace in Files, doing:

    Find what: ( [ ]+)using CoordRepType = (\w+);
    Replace with: $1using CoordinateType = $2;\r\n$1using CoordRepType = CoordinateType;
    Filters: itk*.h
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Manually excluded "itkQuadEdgeMeshEulerOperatorsTestHelper.h", as it only
declares `CoordRepType` locally inside a function.

- Follow-up to pull request #4995
commit c1d9ff5
"STYLE: Rename `TCoordRep` template parameters to `TCoordinate`"
Did Replace in Files on "itk*Test*.cxx" and "itk*Test*.h".
Did Notepad++ Replace in Files in ITK/Modules, on "itk*.cxx", "itk*.hxx", and
"itk*.h". Skipped the `using CoordRepType = CoordinateType` declarations.
Deprecated using `CoordRepType`, as was suggested by Dženan Zukić.
This code seemed misplaced anyway, this is a getter, it shouldn't be mutating with a call like pthread_setconcurrency().

Anyway, with ITK_LEGACY_REMOVE this code is already dead.
It's not supported by either macOS nor linux.

It's likely some old leftover.

Fixed some nearby comments too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.