From 93ac0c35346cd2b9372b60742b467bc467e1d0e3 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Fri, 27 Sep 2024 10:13:09 +0200 Subject: [PATCH] COMP: Preserve constness of input geometry object in one-step reconstruction --- .../rtkMechlemOneStepSpectralReconstructionFilter.h | 4 ++-- ...rtkMechlemOneStepSpectralReconstructionFilter.hxx | 12 ++++++------ include/rtkReorderProjectionsImageFilter.h | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/rtkMechlemOneStepSpectralReconstructionFilter.h b/include/rtkMechlemOneStepSpectralReconstructionFilter.h index a08933f21..46d159182 100644 --- a/include/rtkMechlemOneStepSpectralReconstructionFilter.h +++ b/include/rtkMechlemOneStepSpectralReconstructionFilter.h @@ -245,7 +245,7 @@ class ITK_TEMPLATE_EXPORT MechlemOneStepSpectralReconstructionFilter #endif /** Pass the geometry to all filters needing it */ - itkSetObjectMacro(Geometry, ThreeDCircularProjectionGeometry); + itkSetConstObjectMacro(Geometry, ThreeDCircularProjectionGeometry); itkSetMacro(NumberOfIterations, int); itkGetMacro(NumberOfIterations, int); @@ -366,7 +366,7 @@ class ITK_TEMPLATE_EXPORT MechlemOneStepSpectralReconstructionFilter InstantiateHessiansBackProjectionFilter(int bptype); #endif - ThreeDCircularProjectionGeometry::Pointer m_Geometry; + ThreeDCircularProjectionGeometry::ConstPointer m_Geometry; int m_NumberOfIterations; int m_NumberOfProjectionsPerSubset; diff --git a/include/rtkMechlemOneStepSpectralReconstructionFilter.hxx b/include/rtkMechlemOneStepSpectralReconstructionFilter.hxx index 04cd0e0ff..c16bbd1a9 100644 --- a/include/rtkMechlemOneStepSpectralReconstructionFilter.hxx +++ b/include/rtkMechlemOneStepSpectralReconstructionFilter.hxx @@ -341,6 +341,7 @@ MechlemOneStepSpectralReconstructionFilterSetInputGeometry(this->m_Geometry); m_ReorderPhotonCountsFilter->SetPermutation(ReorderProjectionsFilterPhotonCountsType::SHUFFLE); m_ExtractPhotonCountsFilter->SetInput(m_ReorderPhotonCountsFilter->GetOutput()); + m_ForwardProjectionFilter->SetGeometry(m_ReorderPhotonCountsFilter->GetOutputGeometry()); m_SingleComponentForwardProjectionFilter->SetGeometry(m_ReorderPhotonCountsFilter->GetOutputGeometry()); m_GradientsBackProjectionFilter->SetGeometry(m_ReorderPhotonCountsFilter->GetOutputGeometry()); @@ -349,6 +350,11 @@ MechlemOneStepSpectralReconstructionFilterSetInput(this->GetInputPhotonCounts()); + + m_ForwardProjectionFilter->SetGeometry(this->m_Geometry); + m_SingleComponentForwardProjectionFilter->SetGeometry(this->m_Geometry); + m_GradientsBackProjectionFilter->SetGeometry(this->m_Geometry.GetPointer()); + m_HessiansBackProjectionFilter->SetGeometry(this->m_Geometry.GetPointer()); } m_ForwardProjectionFilter->SetInput(0, m_ProjectionsSource->GetOutput()); @@ -430,12 +436,6 @@ MechlemOneStepSpectralReconstructionFilterSetInformationFromImage(this->GetInputMaterialVolumes()); m_HessiansSource->SetInformationFromImage(this->GetInputMaterialVolumes()); - // For the same reason, set geometry now - m_ForwardProjectionFilter->SetGeometry(this->m_Geometry); - m_SingleComponentForwardProjectionFilter->SetGeometry(this->m_Geometry); - m_GradientsBackProjectionFilter->SetGeometry(this->m_Geometry.GetPointer()); - m_HessiansBackProjectionFilter->SetGeometry(this->m_Geometry.GetPointer()); - // Set regularization parameters m_SQSRegul->SetRegularizationWeights(m_RegularizationWeights); m_SQSRegul->SetRadius(m_RegularizationRadius); diff --git a/include/rtkReorderProjectionsImageFilter.h b/include/rtkReorderProjectionsImageFilter.h index 9e651a5ce..a56b14099 100644 --- a/include/rtkReorderProjectionsImageFilter.h +++ b/include/rtkReorderProjectionsImageFilter.h @@ -61,6 +61,7 @@ class ITK_TEMPLATE_EXPORT ReorderProjectionsImageFilter : public itk::ImageToIma using PermutationType = enum { NONE = 0, SORT = 1, SHUFFLE = 2 }; using GeometryType = ThreeDCircularProjectionGeometry; + using GeometryConstPointer = GeometryType::ConstPointer; using GeometryPointer = GeometryType::Pointer; /** Standard New method. */ @@ -75,7 +76,7 @@ class ITK_TEMPLATE_EXPORT ReorderProjectionsImageFilter : public itk::ImageToIma /** Get / Set the object pointer to projection geometry */ itkGetModifiableObjectMacro(OutputGeometry, GeometryType); - itkSetObjectMacro(InputGeometry, GeometryType); + itkSetConstObjectMacro(InputGeometry, ThreeDCircularProjectionGeometry); /** Get / Set the kind of permutation requested */ itkGetMacro(Permutation, PermutationType); @@ -104,8 +105,8 @@ class ITK_TEMPLATE_EXPORT ReorderProjectionsImageFilter : public itk::ImageToIma private: /** RTK geometry objects */ - GeometryPointer m_InputGeometry; - GeometryPointer m_OutputGeometry; + GeometryConstPointer m_InputGeometry; + GeometryPointer m_OutputGeometry; /** Input and output signal vectors */ std::vector m_InputSignal;