ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMultiTransform.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkMultiTransform_h
19#define itkMultiTransform_h
20
21#include "itkTransform.h"
22
23#include <deque>
24
25namespace itk
26{
27
62template <typename TParametersValueType = double, unsigned int VDimension = 3, unsigned int VSubDimensions = VDimension>
63class ITK_TEMPLATE_EXPORT MultiTransform : public Transform<TParametersValueType, VDimension, VSubDimensions>
64{
65public:
67
73
76
80
81 /* Types common to both container and sub transforms */
82
84 using typename Superclass::ParametersType;
89
91 using typename Superclass::DerivativeType;
92
94 using typename Superclass::JacobianType;
97
100
101 /* Types relative to the container transform. */
102
105
107 using typename Superclass::InputPointType;
108 using typename Superclass::OutputPointType;
109
111 using typename Superclass::InputVectorType;
113
117
119 using typename Superclass::InputVnlVectorType;
120 using typename Superclass::OutputVnlVectorType;
121
125
129
133
134 /* Types relative to the sub transform type. */
135
138
140 using TransformQueueType = std::deque<TransformTypePointer>;
141
144
146 static constexpr unsigned int InputDimension = VDimension;
147 static constexpr unsigned int OutputDimension = VDimension;
148
149 static constexpr unsigned int SubInputDimension = VSubDimensions;
150 static constexpr unsigned int SubOutputDimension = VSubDimensions;
151
153
157 virtual void
162
164 virtual void
166 {
167 this->AddTransform(t);
168 }
169
171 virtual void
173 {
174 this->PushFrontTransform(t);
175 }
176
178 virtual void
180 {
181 this->PopBackTransform();
182 }
183
185 virtual const TransformType *
187 {
188 return this->m_TransformQueue.front().GetPointer();
189 }
190
191 virtual const TransformType *
193 {
194 return this->m_TransformQueue.back().GetPointer();
195 }
196
197 virtual const TransformTypePointer
199 {
200 // NOTE: By returning a smart pointer type, the use of this function can
201 // be a significant bottleneck in multithreaded applications.
202 return this->m_TransformQueue[n];
203 }
204
207 virtual TransformType *
209 {
210 return this->m_TransformQueue[n].GetPointer();
211 }
212
213 virtual const TransformType *
215 {
216 return this->m_TransformQueue[n].GetPointer();
217 }
218
220 virtual const TransformQueueType &
222 {
223 return this->m_TransformQueue;
224 }
225
227 virtual bool
229 {
230 return this->m_TransformQueue.empty();
231 }
232
234 virtual SizeValueType
236 {
237 return static_cast<SizeValueType>(this->m_TransformQueue.size());
238 }
239
241 virtual void
243 {
244 this->m_TransformQueue.clear();
245 this->Modified();
246 }
247
248
250 bool
251 IsLinear() const override;
252
256 GetTransformCategory() const override;
257
265 const ParametersType &
266 GetParameters() const override;
267
268 /* SetParameters for all sub-transforms.
269 * See GetParameters() for parameter ordering. */
270 void
271 SetParameters(const ParametersType & inputParameters) override;
272
273 /* GetFixedParameters for all sub-transforms.
274 * See GetParameters() for parameter ordering. */
275 const FixedParametersType &
276 GetFixedParameters() const override;
277
278 /* SetFixedParameters for all sub-transforms.
279 * See GetParameters() for parameter ordering. */
280 void
281 SetFixedParameters(const FixedParametersType & inputParameters) override;
282
283 /* Get total number of parameters. Sum of all sub-transforms. */
285 GetNumberOfParameters() const override;
286
287 /* Get total number of local parameters, the sum of all sub-transforms. */
290
291 /* Get total number of fixed parameters, the sum of all sub-transforms. */
294
297 void
298 UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
299
305 bool
306 GetInverse(Self * inverse) const;
307
309 // TODO - what do we need here?
310 // virtual void FlattenTransformQueue();
311
312protected:
313 MultiTransform() = default;
314 ~MultiTransform() override = default;
315 void
316 PrintSelf(std::ostream & os, Indent indent) const override;
317
318 virtual void
320 {
321 this->m_TransformQueue.push_front(t);
322 this->Modified();
323 }
324
325 virtual void
327 {
328 this->m_TransformQueue.push_back(t);
329 this->Modified();
330 }
331
332 virtual void
334 {
335 this->m_TransformQueue.pop_front();
336 this->Modified();
337 }
338
339 virtual void
341 {
342 this->m_TransformQueue.pop_back();
343 this->Modified();
344 }
345
348
352};
353
354} // end namespace itk
355
356#ifndef ITK_MANUAL_INSTANTIATION
357# include "itkMultiTransform.hxx"
358#endif
359
360#endif // itkMultiTransform_h
itkOverrideGetNameOfClassMacro(TransformBaseTemplate)
ITK_DISALLOW_COPY_AND_MOVE(TransformBaseTemplate)
void PushBackTransform(TransformTypePointer t) override
Control indentation during Print() invocation.
Definition itkIndent.h:50
NumberOfParametersType GetNumberOfFixedParameters() const override
SymmetricSecondRankTensor< TParametersValueType, VInputDimension > InputSymmetricSecondRankTensorType
void SetParameters(const ParametersType &inputParameters) override
virtual bool IsTransformQueueEmpty() const
VariableLengthVector< TParametersValueType > InputVectorPixelType
virtual void AppendTransform(TransformType *t)
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
const ParametersType & GetParameters() const override
virtual void ClearTransformQueue()
virtual void PopFrontTransform()
void PrintSelf(std::ostream &os, Indent indent) const override
Point< TParametersValueType, VInputDimension > InputPointType
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
TransformCategoryEnum GetTransformCategory() const override
Transform< TParametersValueType, VDimension, VSubDimensions > Superclass
CovariantVector< TParametersValueType, VOutputDimension > OutputCovariantVectorType
virtual const TransformType * GetBackTransform() const
bool IsLinear() const override
typename TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
MultiTransform()=default
const FixedParametersType & GetFixedParameters() const override
Transform< TParametersValueType, VSubDimensions, VSubDimensions > TransformType
virtual void PushBackTransform(TransformTypePointer t)
bool GetInverse(Self *inverse) const
DiffusionTensor3D< TParametersValueType > OutputDiffusionTensor3DType
DiffusionTensor3D< TParametersValueType > InputDiffusionTensor3DType
VariableLengthVector< TParametersValueType > OutputVectorPixelType
virtual void PrependTransform(TransformType *t)
virtual const TransformType * GetFrontTransform() const
NumberOfParametersType GetNumberOfLocalParameters() const override
NumberOfParametersType GetNumberOfParameters() const override
~MultiTransform() override=default
virtual void RemoveTransform()
void SetFixedParameters(const FixedParametersType &inputParameters) override
virtual const TransformTypePointer GetNthTransform(SizeValueType n) const
vnl_vector_fixed< TParametersValueType, VOutputDimension > OutputVnlVectorType
void UpdateTransformParameters(const DerivativeType &update, ScalarType factor=1.0) override
virtual const TransformQueueType & GetTransformQueue() const
Point< TParametersValueType, VOutputDimension > OutputPointType
SymmetricSecondRankTensor< TParametersValueType, VOutputDimension > OutputSymmetricSecondRankTensorType
Vector< TParametersValueType, VInputDimension > InputVectorType
virtual void AddTransform(TransformType *t)
CovariantVector< TParametersValueType, VInputDimension > InputCovariantVectorType
Vector< TParametersValueType, VOutputDimension > OutputVectorType
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
virtual SizeValueType GetNumberOfTransforms() const
Implements transparent reference counting.
OptimizerParameters< FixedParametersValueType > FixedParametersType
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
OptimizerParameters< ParametersValueType > ParametersType
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86
SizeValueType ModifiedTimeType