Commit af3cc15b authored by Julien Michel's avatar Julien Michel

ENH: Add template using to ease the retrieval of input image types

parent cec70438
......@@ -209,7 +209,9 @@ public:
// the functor
using InputHasNeighborhood = typename FunctorFilterSuperclassHelper<TFunction>::InputHasNeighborhood;
using InputTypesTupleType = typename Superclass::InputTypesTupleType;
template<size_t I> using InputImageType = typename Superclass::template InputImageType<I>;
/** Run-time type information (and related methods). */
itkTypeMacro(FunctorImageFilter, ImageToImageFilter);
......
......@@ -33,16 +33,18 @@ public:
using Pointer = itk::SmartPointer<Self>;
using ConstPointer = itk::SmartPointer<const Self>;
using Superclass = itk::ImageSource<TOuptut>;
using InputTypesTupleType = std::tuple<TInputs...>;
template <size_t I> using InputImageType = typename std::tuple_element<I,InputTypesTupleType>::type;
itkNewMacro(Self);
template <std::size_t I> void SetVInput(const typename std::tuple_element<I,InputTypesTupleType>::type * inputPtr)
{
this->SetNthInput(I,const_cast<typename std::tuple_element<I,InputTypesTupleType>::type *>(inputPtr));
}
#define DefineLegacySetInputMacro(n) \
template<typename Tuple = InputTypesTupleType, typename Check = typename std::enable_if<n<=std::tuple_size<Tuple>::value >::type> \
void SetInput ## n(const typename std::tuple_element<n-1,Tuple>::type * img) \
......
......@@ -101,7 +101,7 @@ template <typename T> struct TypesCheck
auto filter = NewFunctorFilter(functor);
using FilterType = typename decltype(filter)::ObjectType;
static_assert(std::is_same<typename std::tuple_element<0, typename FilterType::Superclass::InputTypesTupleType>::type, InputImageType>::value, "");
static_assert(std::is_same<typename FilterType::template InputImageType<0>, InputImageType>::value, "");
filter->SetVInputs(in);
filter->SetInput1(in);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment