diff --git a/Modules/Core/Common/include/itkImageSource.hxx b/Modules/Core/Common/include/itkImageSource.hxx index 3103e4256eb..31dd68ea126 100644 --- a/Modules/Core/Common/include/itkImageSource.hxx +++ b/Modules/Core/Common/include/itkImageSource.hxx @@ -39,11 +39,10 @@ namespace itk template ImageSource::ImageSource() { - // Create the output. We use static_cast<> here because we know the default - // output must be of type TOutputImage - typename TOutputImage::Pointer output = static_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); - this->ProcessObject::SetNthOutput(0, output.GetPointer()); + + // Equivalent to SetNthOutput(0, MakeOutput(0)); in this case, calling MakeOutput is not necessary. + this->ProcessObject::SetNthOutput(0, TOutputImage::New()); #if defined(ITKV4_COMPATIBILITY) m_DynamicMultiThreading = false; diff --git a/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx b/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx index dd52325c777..cacb5044978 100644 --- a/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx @@ -27,11 +27,10 @@ template ImageToMeshFilter::ImageToMeshFilter() { this->ProcessObject::SetNumberOfRequiredInputs(1); - - OutputMeshPointer output = dynamic_cast(this->MakeOutput(0).GetPointer()); - this->ProcessObject::SetNumberOfRequiredOutputs(1); - this->ProcessObject::SetNthOutput(0, output.GetPointer()); + + // Equivalent to SetNthOutput(0, MakeOutput(0)); in this case, calling MakeOutput is not necessary. + this->ProcessObject::SetNthOutput(0, OutputMeshType::New()); } /** diff --git a/Modules/Core/Mesh/include/itkMeshSource.hxx b/Modules/Core/Mesh/include/itkMeshSource.hxx index b19e4e53ff2..a38054ac665 100644 --- a/Modules/Core/Mesh/include/itkMeshSource.hxx +++ b/Modules/Core/Mesh/include/itkMeshSource.hxx @@ -25,12 +25,10 @@ namespace itk template MeshSource::MeshSource() { - // Create the output. We use static_cast<> here because we know the default - // output must be of type TOutputMesh - OutputMeshPointer output = static_cast(this->MakeOutput(0).GetPointer()); - this->ProcessObject::SetNumberOfRequiredOutputs(1); - this->ProcessObject::SetNthOutput(0, output.GetPointer()); + + // Equivalent to SetNthOutput(0, MakeOutput(0)); in this case, calling MakeOutput is not necessary. + this->ProcessObject::SetNthOutput(0, TOutputMesh::New()); m_GenerateDataRegion = 0; m_GenerateDataNumberOfRegions = 0;