From 9332084028ee9368bc51ed22528d14c925e3a707 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Mon, 4 Oct 2021 12:49:13 -0400 Subject: [PATCH] BUG: Fixups for adding 1D FFT classes from ITKUltrasound to ITK - Fix smart pointer references from object factory - Remove references to OpenCL implementations - Fix Python name test --- .../itkComplexToComplex1DFFTImageFilter.hxx | 13 +++----- .../include/itkForward1DFFTImageFilter.hxx | 30 +++++-------------- .../include/itkInverse1DFFTImageFilter.hxx | 30 +++++-------------- .../include/itkVnlForward1DFFTImageFilter.hxx | 2 +- .../include/itkVnlInverse1DFFTImageFilter.hxx | 2 +- ...tkComplexToComplex1DFFTImageFilterTest.cxx | 11 ------- .../FFT/test/itkFFT1DImageFilterTest.cxx | 13 -------- .../test/itkForward1DFFTImageFilterTest.cxx | 11 ------- .../test/itkInverse1DFFTImageFilterTest.cxx | 13 +------- .../Generators/Python/Tests/getNameOfClass.py | 3 ++ 10 files changed, 26 insertions(+), 102 deletions(-) diff --git a/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx index 25db3e9ac08..3c0ed50b155 100644 --- a/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx @@ -26,10 +26,6 @@ # include "itkFFTWComplexToComplex1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLComplexToComplex1DFFTImageFilter.h" -#endif - #include "itkMetaDataDictionary.h" #include "itkMetaDataObject.h" @@ -42,13 +38,12 @@ ComplexToComplex1DFFTImageFilter::New() { Pointer smartPtr = ObjectFactory::Create(); -#ifdef ITKUltrasound_USE_clFFT - if (smartPtr.IsNull()) + if (smartPtr.IsNotNull()) { - smartPtr = - dynamic_cast(OpenCLComplexToComplex1DFFTImageFilter::New().GetPointer()); + // Decrement ITK SmartPointer produced from object factory + smartPtr->UnRegister(); } -#endif + #ifdef ITK_USE_FFTWD if (smartPtr.IsNull()) { diff --git a/Modules/Filtering/FFT/include/itkForward1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkForward1DFFTImageFilter.hxx index 2e49a4d9f1d..55219eb703d 100644 --- a/Modules/Filtering/FFT/include/itkForward1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkForward1DFFTImageFilter.hxx @@ -26,26 +26,10 @@ # include "itkFFTWForward1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLForward1DFFTImageFilter.h" -#endif - #include "itkMetaDataObject.h" namespace itk { -#ifdef ITKUltrasound_USE_clFFT -template -struct Dispatch_1DRealToComplexConjugate_New -{ - static TSelfPointer - Apply() - { - return OpenCLForward1DFFTImageFilter::New().GetPointer(); - } -}; -#else - template class VnlForward1DFFTImageFilter; @@ -59,7 +43,7 @@ struct Dispatch_1DRealToComplexConjugate_New } }; -# ifdef ITK_USE_FFTWD +#ifdef ITK_USE_FFTWD template struct Dispatch_1DRealToComplexConjugate_New { @@ -69,9 +53,9 @@ struct Dispatch_1DRealToComplexConjugate_New::New().GetPointer(); } }; -# endif +#endif // ITK_USE_FFTWD -# ifdef ITK_USE_FFTWF +#ifdef ITK_USE_FFTWF template struct Dispatch_1DRealToComplexConjugate_New { @@ -81,9 +65,7 @@ struct Dispatch_1DRealToComplexConjugate_New::New().GetPointer(); } }; -# endif - -#endif // ITKUltrasound_USE_clFFT +#endif // ITK_USE_FFTWF template typename Forward1DFFTImageFilter::Pointer @@ -99,6 +81,10 @@ Forward1DFFTImageFilter::New() TOutputImage, typename NumericTraits::ValueType>::Apply(); } + else + { + smartPtr->UnRegister(); + } return smartPtr; } diff --git a/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx index 2bdcba2b0b7..1f8770e961f 100644 --- a/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx @@ -26,27 +26,11 @@ # include "itkFFTWInverse1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLInverse1DFFTImageFilter.h" -#endif - #include "itkMetaDataDictionary.h" #include "itkMetaDataObject.h" namespace itk { -#ifdef ITKUltrasound_USE_clFFT -template -struct Dispatch_1DComplexConjugateToReal_New -{ - static TSelfPointer - Apply() - { - return OpenCLInverse1DFFTImageFilter::New().GetPointer(); - } -}; -#else - template struct Dispatch_1DComplexConjugateToReal_New { @@ -57,7 +41,7 @@ struct Dispatch_1DComplexConjugateToReal_New } }; -# ifdef ITK_USE_FFTWD +#ifdef ITK_USE_FFTWD template struct Dispatch_1DComplexConjugateToReal_New { @@ -67,10 +51,10 @@ struct Dispatch_1DComplexConjugateToReal_New::New().GetPointer(); } }; -# endif +#endif // ITK_USE_FFTWD -# ifdef ITK_USE_FFTWF +#ifdef ITK_USE_FFTWF template struct Dispatch_1DComplexConjugateToReal_New { @@ -80,9 +64,7 @@ struct Dispatch_1DComplexConjugateToReal_New::New().GetPointer(); } }; -# endif - -#endif // ITKUltrasound_USE_clFFT +#endif // ITK_USE_FFTWF template typename Inverse1DFFTImageFilter::Pointer @@ -98,6 +80,10 @@ Inverse1DFFTImageFilter::New() TOutputImage, typename NumericTraits::ValueType>::Apply(); } + else + { + smartPtr->UnRegister(); + } return smartPtr; } diff --git a/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx index ab94a030e4d..e0c12906998 100644 --- a/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx @@ -58,7 +58,7 @@ VnlForward1DFFTImageFilter::GenerateData() multiThreader->template ParallelizeImageRegionRestrictDirection( direction, output->GetRequestedRegion(), - [this, input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) { + [input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) { using InputIteratorType = ImageLinearConstIteratorWithIndex; using OutputIteratorType = ImageLinearIteratorWithIndex; InputIteratorType inputIt(input, lambdaRegion); diff --git a/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx index 96d6134e0bf..934f2f0f062 100644 --- a/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx @@ -52,7 +52,7 @@ VnlInverse1DFFTImageFilter::GenerateData() multiThreader->template ParallelizeImageRegionRestrictDirection( direction, output->GetRequestedRegion(), - [this, input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) { + [input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) { using InputIteratorType = ImageLinearConstIteratorWithIndex; using OutputIteratorType = ImageLinearIteratorWithIndex; InputIteratorType inputIt(input, lambdaRegion); diff --git a/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx index a4a196a2f98..6d5689da7ae 100644 --- a/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkComplexToComplex1DFFTImageFilterTest.cxx @@ -29,9 +29,6 @@ #if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF) # include "itkFFTWComplexToComplex1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLComplexToComplex1DFFTImageFilter.h" -#endif template int @@ -90,7 +87,6 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[]) std::cerr << " 0 default\n"; std::cerr << " 1 VNL\n"; std::cerr << " 2 FFTW\n"; - std::cerr << " 3 OpenCL via clFFT\n"; std::cerr << std::flush; return EXIT_FAILURE; } @@ -122,13 +118,6 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[]) return doTest(argv[1], argv[2], argv[3]); #endif } - else if (backend == 3) - { -#if defined(ITKUltrasound_USE_clFFT) - using FFTInverseType = itk::OpenCLComplexToComplex1DFFTImageFilter; - return doTest(argv[1], argv[2], argv[3]); -#endif - } std::cerr << "Backend " << backend << " (" << argv[4] << ") not implemented" << std::endl; return EXIT_FAILURE; diff --git a/Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx index e74de30b46b..7a2ea9351dd 100644 --- a/Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx @@ -31,10 +31,6 @@ # include "itkFFTWForward1DFFTImageFilter.h" # include "itkFFTWInverse1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLForward1DFFTImageFilter.h" -# include "itkOpenCLInverse1DFFTImageFilter.h" -#endif template int @@ -89,7 +85,6 @@ itkFFT1DImageFilterTest(int argc, char * argv[]) std::cerr << " 0 default\n"; std::cerr << " 1 VNL\n"; std::cerr << " 2 FFTW\n"; - std::cerr << " 3 OpenCL via clFFT\n"; std::cerr << std::flush; return EXIT_FAILURE; } @@ -126,14 +121,6 @@ itkFFT1DImageFilterTest(int argc, char * argv[]) return doTest(argv[1], argv[2]); #endif } - else if (backend == 3) - { -#if defined(ITKUltrasound_USE_clFFT) - using FFTForwardType = itk::OpenCLForward1DFFTImageFilter; - using FFTInverseType = itk::OpenCLInverse1DFFTImageFilter; - return doTest(argv[1], argv[2]); -#endif - } std::cerr << "Backend " << backend << " (" << argv[3] << ") not implemented" << std::endl; return EXIT_FAILURE; diff --git a/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx index f00c253ef60..586d92df312 100644 --- a/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx @@ -29,9 +29,6 @@ #if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF) # include "itkFFTWForward1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLForward1DFFTImageFilter.h" -#endif template int @@ -89,7 +86,6 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[]) std::cerr << " 0 default\n"; std::cerr << " 1 VNL\n"; std::cerr << " 2 FFTW\n"; - std::cerr << " 3 OpenCL via clFFT\n"; std::cerr << std::flush; return EXIT_FAILURE; } @@ -123,13 +119,6 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[]) return doTest(argv[1], argv[2]); #endif } - else if (backend == 3) - { -#if defined(ITKUltrasound_USE_clFFT) - using FFTForwardType = itk::OpenCLForward1DFFTImageFilter; - return doTest(argv[1], argv[2]); -#endif - } std::cerr << "Backend " << backend << " (" << argv[3] << ") not implemented" << std::endl; return EXIT_FAILURE; diff --git a/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx index c1e053603c1..b24980fdefa 100644 --- a/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx @@ -28,9 +28,6 @@ #if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF) # include "itkFFTWInverse1DFFTImageFilter.h" #endif -#if defined(ITKUltrasound_USE_clFFT) -# include "itkOpenCLInverse1DFFTImageFilter.h" -#endif template int @@ -84,7 +81,6 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[]) std::cerr << " 0 default\n"; std::cerr << " 1 VNL\n"; std::cerr << " 2 FFTW\n"; - std::cerr << " 3 OpenCL via clFFT\n"; std::cerr << std::flush; return EXIT_FAILURE; } @@ -98,7 +94,7 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[]) int backend = 0; if (argc > 3) { - for (size_t idx = 0; idx < argc; ++idx) + for (size_t idx = 0; idx < static_cast(argc); ++idx) { std::cout << argv[idx] << std::endl; } @@ -122,13 +118,6 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[]) return doTest(argv[1], argv[2], argv[3]); #endif } - else if (backend == 3) - { -#if defined(ITKUltrasound_USE_clFFT) - using FFTInverseType = itk::OpenCLInverse1DFFTImageFilter; - return doTest(argv[1], argv[2], argv[3]); -#endif - } std::cerr << "Backend " << backend << " (" << argv[4] << ") not implemented" << std::endl; return EXIT_FAILURE; diff --git a/Wrapping/Generators/Python/Tests/getNameOfClass.py b/Wrapping/Generators/Python/Tests/getNameOfClass.py index 4b3db24eacd..9adbe848c68 100644 --- a/Wrapping/Generators/Python/Tests/getNameOfClass.py +++ b/Wrapping/Generators/Python/Tests/getNameOfClass.py @@ -41,11 +41,14 @@ def wrongClassName(cl, name): # method, which return a subclass of the current class exclude = [ "ForwardFFTImageFilter", + "Forward1DFFTImageFilter", "InverseFFTImageFilter", + "Inverse1DFFTImageFilter", "OutputWindow", "MultiThreaderBase", "FFTComplexToComplexImageFilter", "ComplexToComplexFFTImageFilter", + "ComplexToComplex1DImageFilter", "templated_class", "HalfHermitianToRealInverseFFTImageFilter", "RealToHalfHermitianForwardFFTImageFilter",