Skip to content

Commit b23ad5b

Browse files
committed
STYLE: Simplify code by calling ProcessObject::SetRequiredOutputs
Reduced amount of duplicate code.
1 parent e919e91 commit b23ad5b

File tree

7 files changed

+12
-46
lines changed

7 files changed

+12
-46
lines changed

Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,8 @@ namespace itk
3030
template <typename TInputImage, typename TOutputImage, typename TVoronoiImage>
3131
DanielssonDistanceMapImageFilter<TInputImage, TOutputImage, TVoronoiImage>::DanielssonDistanceMapImageFilter()
3232
{
33-
this->SetNumberOfRequiredOutputs(3);
34-
35-
// distance map
36-
this->SetNthOutput(0, this->MakeOutput(0));
37-
38-
// voronoi map
39-
this->SetNthOutput(1, this->MakeOutput(1));
40-
41-
// distance vectors
42-
this->SetNthOutput(2, this->MakeOutput(2));
33+
// distance map, voronoi map, distance vectors
34+
ProcessObject::SetRequiredOutputs(*this, 3);
4335

4436
m_SquaredDistance = false;
4537
m_InputIsBinary = false;

Modules/Filtering/DistanceMap/include/itkSignedDanielssonDistanceMapImageFilter.hxx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,8 @@ template <typename TInputImage, typename TOutputImage, typename TVoronoiImage>
3232
SignedDanielssonDistanceMapImageFilter<TInputImage, TOutputImage, TVoronoiImage>::
3333
SignedDanielssonDistanceMapImageFilter()
3434
{
35-
this->SetNumberOfRequiredOutputs(3);
36-
37-
// distance map
38-
this->SetNthOutput(0, static_cast<OutputImageType *>(this->MakeOutput(0).GetPointer()));
39-
40-
// voronoi map
41-
this->SetNthOutput(1, static_cast<VoronoiImageType *>(this->MakeOutput(1).GetPointer()));
42-
43-
// distance vectors
44-
this->SetNthOutput(2, static_cast<VectorImageType *>(this->MakeOutput(2).GetPointer()));
35+
// distance map, voronoi map, distance vectors
36+
ProcessObject::SetRequiredOutputs(*this, 3);
4537

4638
// Default values
4739
this->m_SquaredDistance = false; // Should we remove this ?

Modules/Numerics/Eigen/include/itkEigenAnalysis2DImageFilter.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ template <typename TInputImage, typename TEigenValueImage, typename TEigenVector
2828
EigenAnalysis2DImageFilter<TInputImage, TEigenValueImage, TEigenVectorImage>::EigenAnalysis2DImageFilter()
2929
{
3030
this->SetNumberOfRequiredInputs(3);
31-
this->SetNumberOfRequiredOutputs(3);
32-
this->SetNthOutput(0, this->MakeOutput(0));
33-
this->SetNthOutput(1, this->MakeOutput(1));
34-
this->SetNthOutput(2, this->MakeOutput(2));
31+
ProcessObject::SetRequiredOutputs(*this, 3);
3532
static_assert(EigenVectorType::Dimension == 2, "Error: PixelType of EigenVector Image must have exactly 2 elements!");
3633
}
3734

Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ template <typename TSample>
2828
CovarianceSampleFilter<TSample>::CovarianceSampleFilter()
2929
{
3030
this->ProcessObject::SetNumberOfRequiredInputs(1);
31-
this->ProcessObject::SetNumberOfRequiredOutputs(2);
32-
33-
this->ProcessObject::SetNthOutput(0, this->MakeOutput(0));
34-
this->ProcessObject::SetNthOutput(1, this->MakeOutput(1));
31+
ProcessObject::RequiredOutputs(*this, 2);
3532
}
3633

3734
template <typename TSample>

Modules/Numerics/Statistics/include/itkStandardDeviationPerComponentSampleFilter.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ template <typename TSample>
2929
StandardDeviationPerComponentSampleFilter<TSample>::StandardDeviationPerComponentSampleFilter()
3030
{
3131
this->ProcessObject::SetNumberOfRequiredInputs(1);
32-
this->ProcessObject::SetNumberOfRequiredOutputs(2);
33-
34-
this->ProcessObject::SetNthOutput(0, this->MakeOutput(0));
35-
this->ProcessObject::SetNthOutput(1, this->MakeOutput(1));
32+
ProcessObject::RequiredOutputs(*this, 2);
3633
}
3734

3835
template <typename TSample>

Modules/Registration/Common/include/itkBlockMatchingImageFilter.hxx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,8 @@ BlockMatchingImageFilter<TFixedImage, TMovingImage, TFeatures, TDisplacements, T
3939
this->m_BlockRadius.Fill(2);
4040
this->m_SearchRadius.Fill(3);
4141

42-
// make the outputs
43-
this->ProcessObject::SetNumberOfRequiredOutputs(2);
44-
typename DisplacementsType::Pointer displacements =
45-
static_cast<DisplacementsType *>(this->MakeOutput(0).GetPointer());
46-
this->SetNthOutput(0, displacements.GetPointer());
47-
typename SimilaritiesType::Pointer similarities = static_cast<SimilaritiesType *>(this->MakeOutput(1).GetPointer());
48-
this->SetNthOutput(1, similarities.GetPointer());
42+
// make the outputs (Displacements, Similarities)
43+
ProcessObject::SetRequiredOutputs(*this, 2);
4944

5045
// all inputs are required
5146
this->SetPrimaryInputName("FeaturePoints");

Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,13 +1354,9 @@ Segmenter<TInputImage>::Segmenter()
13541354
m_SortEdgeLists = true;
13551355
m_Connectivity.direction = nullptr;
13561356
m_Connectivity.index = nullptr;
1357-
typename OutputImageType::Pointer img = static_cast<OutputImageType *>(this->MakeOutput(0).GetPointer());
1358-
typename SegmentTableType::Pointer st = static_cast<SegmentTableType *>(this->MakeOutput(1).GetPointer());
1359-
typename BoundaryType::Pointer bd = static_cast<BoundaryType *>(this->MakeOutput(2).GetPointer());
1360-
this->SetNumberOfRequiredOutputs(3);
1361-
this->ProcessObject::SetNthOutput(0, img.GetPointer());
1362-
this->ProcessObject::SetNthOutput(1, st.GetPointer());
1363-
this->ProcessObject::SetNthOutput(2, bd.GetPointer());
1357+
1358+
// OutputImage, SegmentTable, Boundary
1359+
ProcessObject::SetRequiredOutputs(*this, 3);
13641360

13651361
// Allocate memory for connectivity
13661362
m_Connectivity.size = 2 * ImageDimension;

0 commit comments

Comments
 (0)