Skip to content

Commit c0c14a0

Browse files
committed
STYLE: Simplify code by ProcessObject::SetRequiredOutputs(*this, 3)
Reduced amount of duplicate code.
1 parent e919e91 commit c0c14a0

File tree

4 files changed

+8
-31
lines changed

4 files changed

+8
-31
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/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)