Skip to content

Commit

Permalink
ENH: Add GradientImageFilter::OverrideBoundaryCondition(std::unique_ptr)
Browse files Browse the repository at this point in the history
Added `GradientImageFilter::OverrideBoundaryCondition` overload, to allows
specifying the argument by a `unique_ptr`. Aims to make it more clear that the
filter takes the ownership of the specified `BoundaryCondition` object.

Triggered by a comment from Bradley Lowekamp at
#4512 (comment)
on March 13, 2024.
  • Loading branch information
N-Dekker committed Mar 25, 2024
1 parent 2de2c7f commit 337ccde
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class ITK_TEMPLATE_EXPORT GradientImageFilter : public ImageToImageFilter<TInput
void
OverrideBoundaryCondition(BoundaryConditionType * boundaryCondition);

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

#ifdef ITK_USE_CONCEPT_CHECKING
// Begin concept checking
itkConceptMacro(InputConvertibleToOutputCheck, (Concept::Convertible<InputPixelType, OutputValueType>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ GradientImageFilter<TInputImage, TOperatorValueType, TOutputValue, TOutputImage>
m_BoundaryCondition.reset(boundaryCondition);
}

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
GradientImageFilter<TInputImage, TOperatorValueType, TOutputValueType, TOutputImageType>::GenerateInputRequestedRegion()
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

0 comments on commit 337ccde

Please sign in to comment.