Skip to content

Commit

Permalink
STYLE: Remove ITKv4 compatibility support
Browse files Browse the repository at this point in the history
ITKv4 compile time API support is removed.
  • Loading branch information
hjmjohnson committed May 31, 2024
1 parent 7bfecf3 commit dee58d5
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 293 deletions.
3 changes: 0 additions & 3 deletions CMake/ITKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ set(ITK_VERSION_MAJOR "@ITK_VERSION_MAJOR@")
set(ITK_VERSION_MINOR "@ITK_VERSION_MINOR@")
set(ITK_VERSION_PATCH "@ITK_VERSION_PATCH@")

# If ITK was built with version 4 compatibility features.
set(ITKV4_COMPATIBILITY "@ITKV4_COMPATIBILITY@")

# Remove all legacy code completely.
set(ITK_LEGACY_REMOVE "@ITK_LEGACY_REMOVE@")

Expand Down
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,16 @@ cmake_dependent_option(
OFF
"NOT ITK_LEGACY_REMOVE"
OFF)
# The disabling of legacy code, and the ITKv4 compatibility option can not both be
# requested. If removal of legacy code is requested, then ITKV4_COMPATIBILITY must
# be off.
cmake_dependent_option(
ITKV4_COMPATIBILITY
"Enable LEGACY compatibility with ITK4.x when possible."
OFF
"NOT ITK_LEGACY_REMOVE"
OFF)

mark_as_advanced(
ITK_LEGACY_SILENT
ITK_LEGACY_REMOVE
ITK_FUTURE_LEGACY_REMOVE
ITKV4_COMPATIBILITY)
)

if(ITKV4_COMPATIBILITY)
message(FATAL_ERROR "ITKV4_COMPATIBILITY is removed starting in ITK version 4.0, this option is no longer valid.")
endif()

if(ITKV3_COMPATIBILITY)
message(FATAL_ERROR "ITKV3_COMPATIBILITY is removed starting in ITK version 5.0, this option is no longer valid.")
Expand Down
4 changes: 4 additions & 0 deletions Documentation/docs/migration_guides/itk_6_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ deprecations and API changes. The new behavior is activated by setting
`ITK_LEGACY_REMOVE` to `ON`. By default, compatibility with v5 is retained
(`ITK_LEGACY_REMOVE=OFF`).

Remove support for ITKv4 interfaces
-----------------------------------

ITKV4_COMPATIBILITY is no longer a supported option.

Require modern C++ language feature use
---------------------------------------
Expand Down
14 changes: 0 additions & 14 deletions Modules/Compatibility/Deprecated/include/itkImageTransformer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,6 @@ ImageTransformer<TInputImage>::ThreaderCallback(void * arg)
if (threadId < total)
{
str->Filter->ThreadedGenerateData(splitRegion, threadId);
#if defined(ITKV4_COMPATIBILITY)
if (str->Filter->GetAbortGenerateData())
{
std::string msg;
ProcessAborted e(__FILE__, __LINE__);
msg += "Object " + std::string(str->Filter->GetNameOfClass()) + ": AbortGenerateData was set!";
e.SetDescription(msg);
throw e;
}
else if (str->Filter->GetProgress() == 0.0f) // progress was not set after at least the first chunk finished
{
str->Filter->UpdateProgress(static_cast<float>(threadId + 1) / total); // this will be the only progress update
}
#endif
}
// else
// {
Expand Down
3 changes: 0 additions & 3 deletions Modules/Compatibility/Deprecated/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ set(DOCUMENTATION "This is a collection of classes that are intended to be
removed from the toolkit.")

set(ITKDeprecatedOnByDefault EXCLUDE_FROM_DEFAULT)
if(ITKV4_COMPATIBILITY)
set(ITKDeprecatedOnByDefault "")
endif()

itk_module(
ITKDeprecated
Expand Down
19 changes: 0 additions & 19 deletions Modules/Core/Common/include/itkImageSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ ImageSource<TOutputImage>::ImageSource()
this->ProcessObject::SetNumberOfRequiredOutputs(1);
this->ProcessObject::SetNthOutput(0, output.GetPointer());

#if defined(ITKV4_COMPATIBILITY)
m_DynamicMultiThreading = false;
#else
m_DynamicMultiThreading = true;
#endif

// Set the default behavior of an image source to NOT release its
// output bulk data prior to GenerateData() in case that bulk data
Expand Down Expand Up @@ -287,21 +283,6 @@ ImageSource<TOutputImage>::ThreaderCallback(void * arg)
if (workUnitID < total)
{
str->Filter->ThreadedGenerateData(splitRegion, workUnitID);
#if defined(ITKV4_COMPATIBILITY)
if (str->Filter->GetAbortGenerateData())
{
std::string msg;
ProcessAborted e(__FILE__, __LINE__);
msg += "Object " + std::string(str->Filter->GetNameOfClass()) + ": AbortGenerateData was set!";
e.SetDescription(msg);
throw e;
}
else if (!str->Filter->GetDynamicMultiThreading() // progress reporting is not done in MultiThreaders
&& str->Filter->GetProgress() == 0.0f) // and progress was not set after at least the first chunk finished
{
str->Filter->UpdateProgress(static_cast<float>(workUnitID + 1) / total); // this will be the only progress update
}
#endif
}
// else don't use this thread. Threads were not split conveniently.
return ITK_THREAD_RETURN_DEFAULT_VALUE;
Expand Down
6 changes: 1 addition & 5 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,11 +1359,7 @@ compilers.
* classes can be achieved with defining ITKV4_COMPATIBILITY. Code
* should be migrated to no longer rely on the old virtual interface.
*/
#if defined(ITKV4_COMPATIBILITY)
# define ITK_ITERATOR_VIRTUAL virtual
# define ITK_ITERATOR_OVERRIDE override
# define ITK_ITERATOR_FINAL
#elif !defined(ITK_LEGACY_REMOVE)
#if !defined(ITK_LEGACY_REMOVE)
# define ITK_ITERATOR_VIRTUAL virtual
# define ITK_ITERATOR_OVERRIDE override
# define ITK_ITERATOR_FINAL final
Expand Down
6 changes: 0 additions & 6 deletions Modules/Core/Common/include/itkProcessObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,6 @@ class ITKCommon_EXPORT ProcessObject : public Object
itkSetClampMacro(NumberOfWorkUnits, ThreadIdType, 1, ITK_MAX_THREADS);
itkGetConstReferenceMacro(NumberOfWorkUnits, ThreadIdType);

#if !defined(ITK_LEGACY_REMOVE) || defined(ITKV4_COMPATIBILITY)
itkLegacyMacro(void SetNumberOfThreads(ThreadIdType count)) { this->SetNumberOfWorkUnits(count); }

itkLegacyMacro(ThreadIdType GetNumberOfThreads() const) { return this->GetNumberOfWorkUnits(); }
#endif // !ITK_LEGACY_REMOVE

/** Return the multithreader used by this class. */
MultiThreaderType *
GetMultiThreader() const
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/src/itkConfigure.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#endif
#cmakedefine ITK_DYNAMIC_LOADING

#cmakedefine ITKV4_COMPATIBILITY
#cmakedefine ITK_LEGACY_REMOVE
#cmakedefine ITK_LEGACY_SILENT
#cmakedefine ITK_FUTURE_LEGACY_REMOVE
Expand Down
6 changes: 0 additions & 6 deletions Modules/Core/Common/src/itkPoolMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ PoolMultiThreader::PoolMultiThreader()
}

ThreadIdType defaultThreads = std::max(1u, GetGlobalDefaultNumberOfThreads());
#if !defined(ITKV4_COMPATIBILITY)
if (defaultThreads > 1) // one work unit for only one thread
{
defaultThreads *= 4;
}
#endif
m_NumberOfWorkUnits = std::min<ThreadIdType>(ITK_MAX_THREADS, defaultThreads);
m_MaximumNumberOfThreads = m_ThreadPool->GetMaximumNumberOfThreads();
}
Expand Down
4 changes: 0 additions & 4 deletions Modules/Core/Common/src/itkTBBMultiThreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ namespace itk
TBBMultiThreader::TBBMultiThreader()
{
ThreadIdType defaultThreads = std::max(1u, GetGlobalDefaultNumberOfThreads());
#if defined(ITKV4_COMPATIBILITY)
m_NumberOfWorkUnits = defaultThreads;
#else
if (defaultThreads > 1) // one work unit for only one thread
{
m_NumberOfWorkUnits = 16 * defaultThreads;
}
#endif
}

TBBMultiThreader::~TBBMultiThreader() = default;
Expand Down
25 changes: 5 additions & 20 deletions Modules/Core/ImageFunction/include/itkInterpolateImageFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,13 @@ class ITK_TEMPLATE_EXPORT InterpolateImageFunction
return (static_cast<RealType>(this->GetInputImage()->GetPixel(index)));
}

/** Get the radius required for interpolation.
*
* This defines the number of surrounding pixels required to interpolate at
* a given point.
*/
#if defined(ITKV4_COMPATIBILITY)
virtual SizeType
GetRadius() const
{
// if ITKv4 compatibility is enabled then set the radius to the
// largest by default.
const InputImageType * input = this->GetInputImage();
if (!input)
{
itkExceptionMacro("Input image required!");
}
return input->GetLargestPossibleRegion().GetSize();
}
#else
/** Get the radius required for interpolation.
*
* This defines the number of surrounding pixels required to interpolate at
* a given point.
*/
virtual SizeType
GetRadius() const = 0;
#endif

protected:
InterpolateImageFunction() = default;
Expand Down
29 changes: 3 additions & 26 deletions Modules/Filtering/Smoothing/include/itkBoxMeanImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,9 @@ BoxMeanImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
accImage->SetRegions(accumRegion);
accImage->Allocate();

#if defined(ITKV4_COMPATIBILITY)
// Dummy reporter for compatibility
ProgressReporter progress(this, 1, 2 * accumRegion.GetNumberOfPixels());
#endif

BoxAccumulateFunction<TInputImage, AccumImageType>(inputImage,
accImage,
accumRegion,
accumRegion
#if defined(ITKV4_COMPATIBILITY)
,
progress);
#else
);
#endif
BoxMeanCalculatorFunction<AccumImageType, TOutputImage>(accImage.GetPointer(),
outputImage,
accumRegion,
outputRegionForThread,
this->GetRadius()
#if defined(ITKV4_COMPATIBILITY)
,
progress);
#else
);
#endif
BoxAccumulateFunction<TInputImage, AccumImageType>(inputImage, accImage, accumRegion, accumRegion);
BoxMeanCalculatorFunction<AccumImageType, TOutputImage>(
accImage.GetPointer(), outputImage, accumRegion, outputRegionForThread, this->GetRadius());
}
} // end namespace itk
#endif
29 changes: 3 additions & 26 deletions Modules/Filtering/Smoothing/include/itkBoxSigmaImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,9 @@ BoxSigmaImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
accImage->SetRegions(accumRegion);
accImage->Allocate();

#if defined(ITKV4_COMPATIBILITY)
// Dummy reporter for compatibility
ProgressReporter progress(this, 1, 2 * accumRegion.GetNumberOfPixels());
#endif

BoxSquareAccumulateFunction<TInputImage, AccumImageType>(inputImage,
accImage,
accumRegion,
accumRegion
#if defined(ITKV4_COMPATIBILITY)
,
progress);
#else
);
#endif
BoxSigmaCalculatorFunction<AccumImageType, TOutputImage>(accImage,
outputImage,
accumRegion,
outputRegionForThread,
this->GetRadius()
#if defined(ITKV4_COMPATIBILITY)
,
progress);
#else
);
#endif
BoxSquareAccumulateFunction<TInputImage, AccumImageType>(inputImage, accImage, accumRegion, accumRegion);
BoxSigmaCalculatorFunction<AccumImageType, TOutputImage>(
accImage, outputImage, accumRegion, outputRegionForThread, this->GetRadius());
}
} // end namespace itk
#endif
Loading

0 comments on commit dee58d5

Please sign in to comment.