Skip to content

Commit

Permalink
STYLE: Simplify code by ProcessObject::SetRequiredOutputs(*this, 3)
Browse files Browse the repository at this point in the history
Reduced amount of duplicate code.
  • Loading branch information
N-Dekker committed May 21, 2024
1 parent e919e91 commit c0c14a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@ namespace itk
template <typename TInputImage, typename TOutputImage, typename TVoronoiImage>
DanielssonDistanceMapImageFilter<TInputImage, TOutputImage, TVoronoiImage>::DanielssonDistanceMapImageFilter()
{
this->SetNumberOfRequiredOutputs(3);

// distance map
this->SetNthOutput(0, this->MakeOutput(0));

// voronoi map
this->SetNthOutput(1, this->MakeOutput(1));

// distance vectors
this->SetNthOutput(2, this->MakeOutput(2));
// distance map, voronoi map, distance vectors
ProcessObject::SetRequiredOutputs(*this, 3);

m_SquaredDistance = false;
m_InputIsBinary = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,8 @@ template <typename TInputImage, typename TOutputImage, typename TVoronoiImage>
SignedDanielssonDistanceMapImageFilter<TInputImage, TOutputImage, TVoronoiImage>::
SignedDanielssonDistanceMapImageFilter()
{
this->SetNumberOfRequiredOutputs(3);

// distance map
this->SetNthOutput(0, static_cast<OutputImageType *>(this->MakeOutput(0).GetPointer()));

// voronoi map
this->SetNthOutput(1, static_cast<VoronoiImageType *>(this->MakeOutput(1).GetPointer()));

// distance vectors
this->SetNthOutput(2, static_cast<VectorImageType *>(this->MakeOutput(2).GetPointer()));
// distance map, voronoi map, distance vectors
ProcessObject::SetRequiredOutputs(*this, 3);

// Default values
this->m_SquaredDistance = false; // Should we remove this ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ template <typename TInputImage, typename TEigenValueImage, typename TEigenVector
EigenAnalysis2DImageFilter<TInputImage, TEigenValueImage, TEigenVectorImage>::EigenAnalysis2DImageFilter()
{
this->SetNumberOfRequiredInputs(3);
this->SetNumberOfRequiredOutputs(3);
this->SetNthOutput(0, this->MakeOutput(0));
this->SetNthOutput(1, this->MakeOutput(1));
this->SetNthOutput(2, this->MakeOutput(2));
ProcessObject::SetRequiredOutputs(*this, 3);
static_assert(EigenVectorType::Dimension == 2, "Error: PixelType of EigenVector Image must have exactly 2 elements!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,9 @@ Segmenter<TInputImage>::Segmenter()
m_SortEdgeLists = true;
m_Connectivity.direction = nullptr;
m_Connectivity.index = nullptr;
typename OutputImageType::Pointer img = static_cast<OutputImageType *>(this->MakeOutput(0).GetPointer());
typename SegmentTableType::Pointer st = static_cast<SegmentTableType *>(this->MakeOutput(1).GetPointer());
typename BoundaryType::Pointer bd = static_cast<BoundaryType *>(this->MakeOutput(2).GetPointer());
this->SetNumberOfRequiredOutputs(3);
this->ProcessObject::SetNthOutput(0, img.GetPointer());
this->ProcessObject::SetNthOutput(1, st.GetPointer());
this->ProcessObject::SetNthOutput(2, bd.GetPointer());

// OutputImage, SegmentTable, Boundary
ProcessObject::SetRequiredOutputs(*this, 3);

// Allocate memory for connectivity
m_Connectivity.size = 2 * ImageDimension;
Expand Down

0 comments on commit c0c14a0

Please sign in to comment.