Skip to content

Commit 7b06022

Browse files
blowekamphjmjohnson
authored andcommitted
ENH: Use name process inputs and use macros
Addresses potential minor bugs with casting, modified times with non-macro versions of pipeline input accessor methods.
1 parent f59ff82 commit 7b06022

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.h

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,30 +95,20 @@ class ITK_TEMPLATE_EXPORT DisplacementFieldToBSplineImageFilter : public ImageTo
9595
using ArrayType = typename BSplineFilterType::ArrayType;
9696

9797
/** Set the displacement field */
98-
void
99-
SetDisplacementField(const InputFieldType * field)
100-
{
101-
this->SetInput(0, field);
102-
}
98+
itkSetInputMacro(DisplacementField, InputFieldType);
10399

104100
/** Get the input displacement field. */
105-
const InputFieldType *
106-
GetDisplacementField() const
107-
{
108-
return this->GetInput(0);
109-
}
101+
itkGetInputMacro(DisplacementField, InputFieldType);
110102

111103
/**
112104
* Set confidence image function. If a confidence image is specified,
113105
* estimation of the displacement field weights the contribution of each voxel
114106
* according the value of the corresponding voxel in the confidence image.
115107
*/
116108
/** @ITKStartGrouping */
117-
void
118-
SetConfidenceImage(const RealImageType * image)
119-
{
120-
this->SetNthInput(1, const_cast<RealImageType *>(image));
121-
}
109+
itkSetInputMacro(ConfidenceImage, RealImageType);
110+
itkGetInputMacro(ConfidenceImage, RealImageType);
111+
122112
void
123113
SetInput1(const RealImageType * image)
124114
{
@@ -127,33 +117,18 @@ class ITK_TEMPLATE_EXPORT DisplacementFieldToBSplineImageFilter : public ImageTo
127117
/** @ITKEndGrouping */
128118

129119
/** Get confidence image function. */
130-
const RealImageType *
131-
GetConfidenceImage() const
132-
{
133-
return static_cast<const RealImageType *>(this->ProcessObject::GetInput(1));
134-
}
135120

136121
/** Set the input point set */
137122
/** @ITKStartGrouping */
138-
void
139-
SetPointSet(const InputPointSetType * points)
140-
{
141-
this->SetNthInput(2, const_cast<InputPointSetType *>(points));
142-
}
123+
itkSetInputMacro(PointSet, InputPointSetType);
124+
itkGetInputMacro(PointSet, InputPointSetType);
143125
void
144126
SetInput2(const InputPointSetType * points)
145127
{
146128
this->SetPointSet(points);
147129
}
148130
/** @ITKEndGrouping */
149131

150-
/** Get the input point set. */
151-
const InputPointSetType *
152-
GetPointSet() const
153-
{
154-
return static_cast<const InputPointSetType *>(this->ProcessObject::GetInput(2));
155-
}
156-
157132
/** Set the confidence weights associated with the input point set*/
158133
void
159134
SetPointSetConfidenceWeights(WeightsContainerType * weights);

Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.hxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ DisplacementFieldToBSplineImageFilter<TInputImage, TInputPointSet, TOutputImage>
3434
DisplacementFieldToBSplineImageFilter()
3535

3636
{
37-
this->SetNumberOfRequiredInputs(0);
37+
38+
// Input 0 DisplacementField optional
39+
Self::SetPrimaryInputName("DisplacementField");
40+
Self::RemoveRequiredInputName("DisplacementField");
41+
// Input 1 ConfidenceImage optional
42+
Self::AddOptionalInputName("ConfidenceImage", 1);
43+
// Input 2 PointSet optional
44+
Self::AddOptionalInputName("PointSet", 2);
45+
3846

3947
this->m_NumberOfFittingLevels.Fill(1);
4048
this->m_NumberOfControlPoints.Fill(4);

0 commit comments

Comments
 (0)