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

ENH: Add default factory initialization #26

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions include/itkVkComplexToComplexFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct FFTImageFilterTraits<VkComplexToComplexFFTImageFilter>
using InputPixelType = std::complex<TUnderlying>;
template <typename TUnderlying>
using OutputPixelType = std::complex<TUnderlying>;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
74 changes: 74 additions & 0 deletions include/itkVkFFTImageFilterInitFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkVkFFTImageFilterInitFactory_h
#define itkVkFFTImageFilterInitFactory_h
#include "VkFFTBackendExport.h"

#include "itkLightObject.h"

namespace itk
{
/**
*\class VkFFTImageFilterInitFactory
* \brief Initialize Vk FFT image filter factory backends.
*
* The purpose of VkFFTImageFilterInitFactory is to perform
* one-time registration of factory objects that handle
* creation of Vk-backend FFT image filter classes
* through the ITK object factory singleton mechanism.
*
* \ingroup FourierTransform
* \ingroup ITKFFT
* \ingroup ITKSystemObjects
* \ingroup VkFFTBackend
*/
class VkFFTBackend_EXPORT VkFFTImageFilterInitFactory : public LightObject
{
public:
ITK_DISALLOW_COPY_AND_MOVE(VkFFTImageFilterInitFactory);

/** Standard class type aliases. */
using Self = VkFFTImageFilterInitFactory;
using Superclass = LightObject;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Method for class instantiation. */
itkFactorylessNewMacro(Self);

/** Run-time type information (and related methods). */
itkTypeMacro(VkFFTImageFilterInitFactory, LightObject);

/** Mimic factory interface for Python initialization */
static void
RegisterOneFactory()
{
RegisterFactories();
}

/** Register all Vk FFT factories */
static void
RegisterFactories();

protected:
VkFFTImageFilterInitFactory();
~VkFFTImageFilterInitFactory() override = default;
};
} // end namespace itk

#endif
1 change: 1 addition & 0 deletions include/itkVkForward1DFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ struct FFTImageFilterTraits<VkForward1DFFTImageFilter>
using InputPixelType = TUnderlying;
template <typename TUnderlying>
using OutputPixelType = std::complex<TUnderlying>;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
1 change: 1 addition & 0 deletions include/itkVkForwardFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct FFTImageFilterTraits<VkForwardFFTImageFilter>
using InputPixelType = TUnderlying;
template <typename TUnderlying>
using OutputPixelType = std::complex<TUnderlying>;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
1 change: 1 addition & 0 deletions include/itkVkHalfHermitianToRealInverseFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct FFTImageFilterTraits<VkHalfHermitianToRealInverseFFTImageFilter>
using InputPixelType = std::complex<TUnderlying>;
template <typename TUnderlying>
using OutputPixelType = TUnderlying;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
1 change: 1 addition & 0 deletions include/itkVkInverse1DFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct FFTImageFilterTraits<VkInverse1DFFTImageFilter>
using InputPixelType = std::complex<TUnderlying>;
template <typename TUnderlying>
using OutputPixelType = TUnderlying;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
1 change: 1 addition & 0 deletions include/itkVkInverseFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct FFTImageFilterTraits<VkInverseFFTImageFilter>
using InputPixelType = std::complex<TUnderlying>;
template <typename TUnderlying>
using OutputPixelType = TUnderlying;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
1 change: 1 addition & 0 deletions include/itkVkRealToHalfHermitianForwardFFTImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct FFTImageFilterTraits<VkRealToHalfHermitianForwardFFTImageFilter>
using InputPixelType = TUnderlying;
template <typename TUnderlying>
using OutputPixelType = std::complex<TUnderlying>;
using FilterDimensions = std::integer_sequence<unsigned int, 3, 2, 1>;
};

} // namespace itk
Expand Down
2 changes: 2 additions & 0 deletions itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ itk_module(VkFFTBackend
ITKImageIntensity
DESCRIPTION
"${DOCUMENTATION}"
FACTORY_NAMES
"FFTImageFilterInit::Vk"
EXCLUDE_FROM_DEFAULT
ENABLE_SHARED
)
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(VkFFTBackend_SRCS
itkVkCommon.cxx
itkVkGlobalConfiguration.cxx
itkVkFFTImageFilterInitFactory.cxx
)

itk_module_add_library(VkFFTBackend ${VkFFTBackend_SRCS})
Expand Down
67 changes: 67 additions & 0 deletions src/itkVkFFTImageFilterInitFactory.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "ITKFFTExport.h"

#include "itkVkComplexToComplex1DFFTImageFilter.h"
#include "itkVkComplexToComplexFFTImageFilter.h"
#include "itkFFTImageFilterFactory.h"
#include "itkVkForward1DFFTImageFilter.h"
#include "itkVkForwardFFTImageFilter.h"
#include "itkVkHalfHermitianToRealInverseFFTImageFilter.h"
#include "itkVkInverse1DFFTImageFilter.h"
#include "itkVkInverseFFTImageFilter.h"
#include "itkVkRealToHalfHermitianForwardFFTImageFilter.h"

#include "itkVkFFTImageFilterInitFactory.h"

namespace itk
{
VkFFTImageFilterInitFactory::VkFFTImageFilterInitFactory()
{
VkFFTImageFilterInitFactory::RegisterFactories();
}

void VkFFTImageFilterInitFactory::RegisterFactories()
{
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkComplexToComplex1DFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkComplexToComplexFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkForward1DFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkForwardFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkHalfHermitianToRealInverseFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkInverse1DFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkInverseFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
itk::ObjectFactoryBase::RegisterFactory(FFTImageFilterFactory<VkRealToHalfHermitianForwardFFTImageFilter>::New(),
itk::ObjectFactoryEnums::InsertionPosition::INSERT_AT_FRONT);
}

// Undocumented API used to register during static initialization.
// DO NOT CALL DIRECTLY.
void VkFFTBackend_EXPORT
VkFFTImageFilterInitFactoryRegister__Private()
{
VkFFTImageFilterInitFactory::RegisterFactories();
}

} // end namespace itk
11 changes: 11 additions & 0 deletions test/itkVkFFTImageFilterFactoryTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "itkComplexToComplex1DFFTImageFilter.h"
#include "itkVkComplexToComplex1DFFTImageFilter.h"
#include "itkVnlComplexToComplex1DFFTImageFilter.h"
#include "itkVkFFTImageFilterInitFactory.h"

#include "itkFFTImageFilterFactory.h"
#include "itkTestingMacros.h"
Expand Down Expand Up @@ -63,5 +64,15 @@ itkVkFFTImageFilterFactoryTest(int, char *[])
ITK_TEST_EXPECT_TRUE(vnlFFT != nullptr);
ITK_EXERCISE_BASIC_OBJECT_METHODS(vnlFFT, VnlComplexToComplex1DFFTImageFilter, ComplexToComplex1DFFTImageFilter);

// Verify factory initialization successfully registers factories
using FactoryInitializerType = itk::VkFFTImageFilterInitFactory;
FactoryInitializerType::RegisterFactories();

fft = FFTBaseType::New();
vkFFT = dynamic_cast<FFTVkSubclassType *>(fft.GetPointer());
ITK_TEST_EXPECT_TRUE(vkFFT != nullptr);
ITK_EXERCISE_BASIC_OBJECT_METHODS(vkFFT, VkComplexToComplex1DFFTImageFilter, ComplexToComplex1DFFTImageFilter);


return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions wrapping/itkVkFFTImageFilterInitFactory.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
itk_wrap_simple_class("itk::VkFFTImageFilterInitFactory" POINTER)