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

WIP (Not ready): Add GradientImageFilter::OverrideBoundaryCondition(std::unique_ptr<BoundaryConditionType>) #4533

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Modules/Filtering/ImageGradient/include/itkGradientImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class ITK_TEMPLATE_EXPORT GradientImageFilter : public ImageToImageFilter<TInput
using CovariantVectorType = CovariantVector<OutputValueType, Self::OutputImageDimension>;
using OutputImageRegionType = typename OutputImageType::RegionType;

/** Helper typedef for the parameter type of OverrideBoundaryCondition. */
using BoundaryConditionType = ImageBoundaryCondition<TInputImage>;

/** GradientImageFilter needs a larger input requested region than
* the output requested region. As such, GradientImageFilter needs
* to provide an implementation for GenerateInputRequestedRegion()
Expand Down Expand Up @@ -138,9 +141,16 @@ class ITK_TEMPLATE_EXPORT GradientImageFilter : public ImageToImageFilter<TInput
}
#endif

#ifndef ITK_FUTURE_LEGACY_REMOVE
/** Allows to change the default boundary condition
* \note This filter takes ownership of the specified boundary condition object. */
[[deprecated("Deprecated in favor of `OverrideBoundaryCondition(std::unique_ptr<BoundaryConditionType>)`.")]] void
OverrideBoundaryCondition(BoundaryConditionType * boundaryCondition);
#endif

/** Allows to change the default boundary condition */
void
OverrideBoundaryCondition(ImageBoundaryCondition<TInputImage> * boundaryCondition);
OverrideBoundaryCondition(std::unique_ptr<BoundaryConditionType> && boundaryCondition);

#ifdef ITK_USE_CONCEPT_CHECKING
// Begin concept checking
Expand Down Expand Up @@ -227,8 +237,8 @@ class ITK_TEMPLATE_EXPORT GradientImageFilter : public ImageToImageFilter<TInput
// when computing the derivatives.
bool m_UseImageDirection{ true };

// allow setting the the m_BoundaryCondition
std::unique_ptr<ImageBoundaryCondition<TInputImage, TInputImage>> m_BoundaryCondition{
// allow setting the m_BoundaryCondition
std::unique_ptr<BoundaryConditionType> m_BoundaryCondition{
std::make_unique<ZeroFluxNeumannBoundaryCondition<TInputImage>>()
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ GradientImageFilter<TInputImage, TOperatorValueType, TOutputValueType, TOutputIm
this->ThreaderUpdateProgressOff();
}

#ifndef ITK_FUTURE_LEGACY_REMOVE
template <typename TInputImage, typename TOperatorValueType, typename TOutputValue, typename TOutputImage>
void
GradientImageFilter<TInputImage, TOperatorValueType, TOutputValue, TOutputImage>::OverrideBoundaryCondition(
ImageBoundaryCondition<TInputImage> * boundaryCondition)
BoundaryConditionType * boundaryCondition)
{
m_BoundaryCondition.reset(boundaryCondition);
}
#endif

template <typename TInputImage, typename TOperatorValueType, typename TOutputValue, typename TOutputImage>
void
GradientImageFilter<TInputImage, TOperatorValueType, TOutputValue, TOutputImage>::OverrideBoundaryCondition(
std::unique_ptr<BoundaryConditionType> && boundaryCondition)
{
m_BoundaryCondition = std::move(boundaryCondition);
}

template <typename TInputImage, typename TOperatorValueType, typename TOutputValueType, typename TOutputImageType>
void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ itkGradientImageFilterTest(int argc, char * argv[])

using PeriodicBoundaryType = itk::PeriodicBoundaryCondition<InputImageType2>;
// Test the OverrideBoundaryCondition setting;
filter2->OverrideBoundaryCondition(new PeriodicBoundaryType);
filter2->OverrideBoundaryCondition(std::make_unique<PeriodicBoundaryType>());

ITK_EXERCISE_BASIC_OBJECT_METHODS(filter2, GradientImageFilter, ImageToImageFilter);

Expand Down
Loading