ITK  6.0.0
Insight Toolkit
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:
66 ITK_DISALLOW_COPY_AND_MOVE(MultiTransform);
67
73
75 itkOverrideGetNameOfClassMacro(MultiTransform);
76
80
81 /* Types common to both container and sub transforms */
82
84 using typename Superclass::ParametersType;
85 using typename Superclass::ParametersValueType;
86 using typename Superclass::FixedParametersType;
87 using typename Superclass::FixedParametersValueType;
89
91 using typename Superclass::DerivativeType;
92
94 using typename Superclass::JacobianType;
95 using typename Superclass::JacobianPositionType;
96 using typename Superclass::InverseJacobianPositionType;
97
99 using typename Superclass::TransformCategoryEnum;
100
101 /* Types relative to the container transform. */
102
104 using typename Superclass::InverseTransformBasePointer;
105
107 using typename Superclass::InputPointType;
108 using typename Superclass::OutputPointType;
109
111 using typename Superclass::InputVectorType;
112 using typename Superclass::OutputVectorType;
113
115 using typename Superclass::InputCovariantVectorType;
116 using typename Superclass::OutputCovariantVectorType;
117
119 using typename Superclass::InputVnlVectorType;
120 using typename Superclass::OutputVnlVectorType;
121
123 using typename Superclass::InputVectorPixelType;
124 using typename Superclass::OutputVectorPixelType;
125
127 using typename Superclass::InputDiffusionTensor3DType;
128 using typename Superclass::OutputDiffusionTensor3DType;
129
131 using typename Superclass::InputSymmetricSecondRankTensorType;
132 using typename Superclass::OutputSymmetricSecondRankTensorType;
133
134 /* Types relative to the sub transform type. */
135
138
140 using TransformQueueType = std::deque<TransformTypePointer>;
141
143 using typename Superclass::NumberOfParametersType;
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
157 virtual void
159 {
160 this->PushBackTransform(t);
161 }
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 }
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
347 mutable TransformQueueType m_TransformQueue{};
348
350 mutable NumberOfParametersType m_NumberOfLocalParameters{};
351 mutable ModifiedTimeType m_LocalParametersUpdateTime{};
352};
353
354} // end namespace itk
355
356#ifndef ITK_MANUAL_INSTANTIATION
357# include "itkMultiTransform.hxx"
358#endif
359
360#endif // itkMultiTransform_h
Array class with size defined at construction time.
Definition: itkArray.h:48
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
This abstract class contains a list of transforms and provides basic methods.
typename TransformType::Pointer TransformTypePointer
ParametersValueType ScalarType
NumberOfParametersType GetNumberOfFixedParameters() const override
void SetParameters(const ParametersType &inputParameters) override
virtual bool IsTransformQueueEmpty() const
virtual void AppendTransform(TransformType *t)
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
std::deque< TransformTypePointer > TransformQueueType
const ParametersType & GetParameters() const override
virtual void ClearTransformQueue()
virtual void PopFrontTransform()
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void PopBackTransform()
TransformCategoryEnum GetTransformCategory() const override
virtual const TransformType * GetBackTransform() const
bool IsLinear() const override
typename TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
MultiTransform()=default
const FixedParametersType & GetFixedParameters() const override
virtual void PushBackTransform(TransformTypePointer t)
bool GetInverse(Self *inverse) const
virtual void PushFrontTransform(TransformTypePointer t)
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
void UpdateTransformParameters(const DerivativeType &update, ScalarType factor=1.0) override
virtual const TransformQueueType & GetTransformQueue() const
virtual void AddTransform(TransformType *t)
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
virtual SizeValueType GetNumberOfTransforms() const
Class to hold and manage different parameter types used during optimization.
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:84
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:167
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
unsigned long SizeValueType
Definition: itkIntTypes.h:86