Skip to content
Merged
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
14 changes: 14 additions & 0 deletions Modules/Core/Common/include/itkProcessObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,20 @@ class ITKCommon_EXPORT ProcessObject : public Object
return static_cast<uint32_t>(temp);
};


/** Sets the required number of outputs, and creates each of them by MakeOutput. */
template <typename TSourceObject>
static void
MakeRequiredOutputs(TSourceObject & sourceObject, const DataObjectPointerArraySizeType numberOfRequiredOutputs)
{
sourceObject.ProcessObject::SetNumberOfRequiredOutputs(numberOfRequiredOutputs);

for (unsigned int i{}; i < numberOfRequiredOutputs; ++i)
{
sourceObject.ProcessObject::SetNthOutput(i, sourceObject.TSourceObject::MakeOutput(i));
}
}

/** These ivars are made protected so filters like itkStreamingImageFilter
* can access them directly. */

Expand Down
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));
// Make the outputs (distance map, voronoi map, distance vectors).
ProcessObject::MakeRequiredOutputs(*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()));
// Make the outputs (distance map, voronoi map, distance vectors).
ProcessObject::MakeRequiredOutputs(*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::MakeRequiredOutputs(*this, 3);
static_assert(EigenVectorType::Dimension == 2, "Error: PixelType of EigenVector Image must have exactly 2 elements!");
}

Expand Down
12 changes: 6 additions & 6 deletions Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ class ITK_TEMPLATE_EXPORT CovarianceSampleFilter : public ProcessObject
MeasurementVectorSizeType
GetMeasurementVectorSize() const;

protected:
CovarianceSampleFilter();
~CovarianceSampleFilter() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;

/** DataObject pointer */
using DataObjectPointer = DataObject::Pointer;

Expand All @@ -135,6 +129,12 @@ class ITK_TEMPLATE_EXPORT CovarianceSampleFilter : public ProcessObject
DataObjectPointer
MakeOutput(DataObjectPointerArraySizeType index) override;

protected:
CovarianceSampleFilter();
~CovarianceSampleFilter() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;

void
GenerateData() override;
}; // end of class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ template <typename TSample>
CovarianceSampleFilter<TSample>::CovarianceSampleFilter()
{
this->ProcessObject::SetNumberOfRequiredInputs(1);
this->ProcessObject::SetNumberOfRequiredOutputs(2);

this->ProcessObject::SetNthOutput(0, this->MakeOutput(0));
this->ProcessObject::SetNthOutput(1, this->MakeOutput(1));
ProcessObject::MakeRequiredOutputs(*this, 2);
}

template <typename TSample>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ class ITK_TEMPLATE_EXPORT StandardDeviationPerComponentSampleFilter : public Pro
const MeasurementVectorRealDecoratedType *
GetMeanPerComponentOutput() const;

protected:
StandardDeviationPerComponentSampleFilter();
~StandardDeviationPerComponentSampleFilter() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;

/** DataObject pointer */
using DataObjectPointer = DataObject::Pointer;

Expand All @@ -112,6 +106,12 @@ class ITK_TEMPLATE_EXPORT StandardDeviationPerComponentSampleFilter : public Pro
DataObjectPointer
MakeOutput(DataObjectPointerArraySizeType index) override;

protected:
StandardDeviationPerComponentSampleFilter();
~StandardDeviationPerComponentSampleFilter() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;

void
GenerateData() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ template <typename TSample>
StandardDeviationPerComponentSampleFilter<TSample>::StandardDeviationPerComponentSampleFilter()
{
this->ProcessObject::SetNumberOfRequiredInputs(1);
this->ProcessObject::SetNumberOfRequiredOutputs(2);

this->ProcessObject::SetNthOutput(0, this->MakeOutput(0));
this->ProcessObject::SetNthOutput(1, this->MakeOutput(1));
ProcessObject::MakeRequiredOutputs(*this, 2);
}

template <typename TSample>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ class ITK_TEMPLATE_EXPORT BlockMatchingImageFilter : public MeshToMeshFilter<TFe
return dynamic_cast<SimilaritiesType *>(this->ProcessObject::GetOutput(1));
}

protected:
/** MakeOutput is provided for handling multiple outputs */
using Superclass::MakeOutput;
DataObject::Pointer
MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override;

protected:
/** We need to create our own GenerateOutputInformation because the
* default version from ProcessObject result in a dynamic_cast of the input
* pointer to the output pointer type in PointSet::CopyInformation. This does
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ BlockMatchingImageFilter<TFixedImage, TMovingImage, TFeatures, TDisplacements, T
this->m_BlockRadius.Fill(2);
this->m_SearchRadius.Fill(3);

// make the outputs
this->ProcessObject::SetNumberOfRequiredOutputs(2);
typename DisplacementsType::Pointer displacements =
static_cast<DisplacementsType *>(this->MakeOutput(0).GetPointer());
this->SetNthOutput(0, displacements.GetPointer());
typename SimilaritiesType::Pointer similarities = static_cast<SimilaritiesType *>(this->MakeOutput(1).GetPointer());
this->SetNthOutput(1, similarities.GetPointer());
// Make the outputs (Displacements, Similarities).
ProcessObject::MakeRequiredOutputs(*this, 2);

// all inputs are required
this->SetPrimaryInputName("FeaturePoints");
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());

// Make the outputs (OutputImage, SegmentTable, Boundary).
ProcessObject::MakeRequiredOutputs(*this, 3);

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