File: itkGPUCompositeTransformCopier.h

package info (click to toggle)
elastix 5.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 42,480 kB
  • sloc: cpp: 68,403; lisp: 4,118; python: 1,013; xml: 182; sh: 177; makefile: 33
file content (154 lines) | stat: -rw-r--r-- 6,227 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*=========================================================================
 *
 *  Copyright UMC Utrecht and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef itkGPUCompositeTransformCopier_h
#define itkGPUCompositeTransformCopier_h

#include "itkCompositeTransform.h"
#include "itkGPUTransformCopier.h"

namespace itk
{
/** \class GPUCompositeTransformCopier
 * \brief A helper class which creates an GPU composite transform which
 * is perfect copy of the CPU composite transform.
 *
 * This class is NOT a filter. Although it has an API similar to a filter, this class
 * is not intended to be used in a pipeline. Instead, the typical use will be like
 * it is illustrated in the following code:
 *
 * \code
 *  struct OCLImageDims
 *  {
 *   itkStaticConstMacro( Support1D, bool, true );
 *   itkStaticConstMacro( Support2D, bool, true );
 *   itkStaticConstMacro( Support3D, bool, true );
 *  };
 *
 *  using OCLImageTypes = typelist::MakeTypeList< short, float >::Type;
 *  using TransformType = itk::CompositeTransform< float, 3 >;
 *  using CopierType = itk::GPUCompositeTransformCopier< OCLImageTypes, OCLImageDims, TransformType, float >;
 *  auto copier = CopierType::New();
 *  copier->SetInputTransform(CPUTransform);
 *  copier->Update();
 *  TransformType::Pointer GPUTransform = copier->GetModifiableOutput();
 * \endcode
 *
 * Note that the Update() method must be called explicitly in the filter
 * that provides the input to the GPUCompositeTransformCopier object. This is needed
 * because the GPUCompositeTransformCopier is not a pipeline filter.
 *
 * \author Denis P. Shamonin and Marius Staring. Division of Image Processing,
 * Department of Radiology, Leiden, The Netherlands
 *
 * \note This work was funded by the Netherlands Organisation for
 * Scientific Research (NWO NRG-2010.02 and NWO 639.021.124).
 *
 * \ingroup GPUCommon
 */
template <typename TTypeList,
          typename NDimensions,
          typename TCompositeTransform,
          typename TOutputTransformPrecisionType>
class ITK_TEMPLATE_EXPORT GPUCompositeTransformCopier : public Object
{
public:
  ITK_DISALLOW_COPY_AND_MOVE(GPUCompositeTransformCopier);

  /** Standard class typedefs. */
  using Self = GPUCompositeTransformCopier;
  using Superclass = Object;
  using Pointer = SmartPointer<Self>;
  using ConstPointer = SmartPointer<const Self>;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(GPUCompositeTransformCopier, Object);

  /** Type CPU definitions for the transform. */
  using CPUCompositeTransformType = TCompositeTransform;
  using CPUCompositeTransformConstPointer = typename CPUCompositeTransformType::ConstPointer;
  using CPUTransformType = typename CPUCompositeTransformType::TransformType;
  using CPUTransformPointer = typename CPUTransformType::Pointer;
  using CPUScalarType = typename CPUCompositeTransformType::ScalarType;

  /** Dimension of the domain space.
   * TCompositeTransform::InputDimension and TCompositeTransform::OutputDimension
   * are the same just pick the select one of them. */
  itkStaticConstMacro(SpaceDimension, unsigned int, CPUCompositeTransformType::InputDimension);

  /** Type GPU definitions for the transform. */
  using GPUScalarType = TOutputTransformPrecisionType;
  using GPUCompositeTransformType = CompositeTransform<GPUScalarType, SpaceDimension>;
  using GPUCompositeTransformPointer = typename GPUCompositeTransformType::Pointer;

  /** Type definitions for the transform copier. */
  using GPUTransformCopierType = GPUTransformCopier<TTypeList, NDimensions, CPUTransformType, GPUScalarType>;
  using GPUTransformCopierPointer = typename GPUTransformCopierType::Pointer;
  using GPUOutputTransformPointer = typename GPUTransformCopierType::GPUTransformPointer;

  /** Get/Set the input transform. */
  itkSetConstObjectMacro(InputTransform, CPUCompositeTransformType);

  /** Compute of the output transform. */
  itkGetModifiableObjectMacro(Output, GPUCompositeTransformType);

  /** Get/Set the explicit mode. The default is true.
   * If the explicit mode has been set to false that means that early in the
   * code the factories has been created.
   * ObjectFactoryBase::RegisterFactory( GPUAffineTransformFactory::New() );
   * ObjectFactoryBase::RegisterFactory( GPUTranslationTransformFactory::New() );
   * ObjectFactoryBase::RegisterFactory( GPUBSplineTransformFactory::New() );
   * ObjectFactoryBase::RegisterFactory( GPUEuler3DTransformFactory::New() );
   * ObjectFactoryBase::RegisterFactory( GPUSimilarity3DTransformFactory::New() ); */
  itkGetConstMacro(ExplicitMode, bool);
  itkSetMacro(ExplicitMode, bool);

  /** Update method. */
  void
  Update();

#ifdef ITK_USE_CONCEPT_CHECKING
  // Begin concept checking
  itkConceptMacro(OutputTransformPrecisionTypeIsFloatingPointCheck,
                  (Concept::IsFloatingPoint<TOutputTransformPrecisionType>));
  // End concept checking
#endif

protected:
  GPUCompositeTransformCopier();
  virtual ~GPUCompositeTransformCopier() {}
  virtual void
  PrintSelf(std::ostream & os, Indent indent) const override;

private:
  CPUCompositeTransformConstPointer m_InputTransform{};
  GPUCompositeTransformPointer      m_Output{};
  ModifiedTimeType                  m_InternalTransformTime{};
  bool                              m_ExplicitMode{};
  GPUTransformCopierPointer         m_TransformCopier{};
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#  include "itkGPUCompositeTransformCopier.hxx"
#endif

#endif /* itkGPUCompositeTransformCopier_h */