SimpleITK  
sitkBSplineTransform.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  * http://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 sitkBSplineTransform_h
19 #define sitkBSplineTransform_h
20 
21 #include "sitkCommon.h"
22 #include "sitkTransform.h"
23 
24 namespace itk::simple
25 {
26 
34 {
35 public:
38 
39  ~BSplineTransform() override;
40 
41  explicit BSplineTransform(unsigned int dimensions, unsigned int order = 3);
42 
52  explicit BSplineTransform(const std::vector<Image> & coefficientImages, unsigned int order = 3);
53 
55 
56  explicit BSplineTransform(const Transform &);
57 
59  operator=(const BSplineTransform &);
60 
62  std::string
63  GetName() const override
64  {
65  return std::string("BSplineTransform");
66  }
67 
71  SITK_RETURN_SELF_TYPE_HEADER
72  SetTransformDomainDirection(const std::vector<double> &);
73  std::vector<double>
74  GetTransformDomainDirection() const;
75  SITK_RETURN_SELF_TYPE_HEADER
76  SetTransformDomainMeshSize(const std::vector<unsigned int> &);
77  std::vector<unsigned int>
78  GetTransformDomainMeshSize() const;
79  SITK_RETURN_SELF_TYPE_HEADER
80  SetTransformDomainOrigin(const std::vector<double> &);
81  std::vector<double>
82  GetTransformDomainOrigin() const;
83  SITK_RETURN_SELF_TYPE_HEADER
84  SetTransformDomainPhysicalDimensions(const std::vector<double> &);
85  std::vector<double>
86  GetTransformDomainPhysicalDimensions() const;
87 
88  /* additional methods */
89 
97  std::vector<Image>
98  GetCoefficientImages() const;
99 
100  unsigned int
101  GetOrder() const;
102 
103 protected:
104  void
105  SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform) override;
106 
107 private:
108  struct MyVisitor
109  {
112  template <typename TransformType>
113  void
114  operator()() const
115  {
116  TransformType * t = dynamic_cast<TransformType *>(transform);
117  if (t && (typeid(*t) == typeid(TransformType)))
118  {
119  that->InternalInitialization<TransformType>(t);
120  }
121  }
122  };
123 
124  void
125  InternalInitialization(itk::TransformBase * transform);
126 
127  template <typename TransformType>
128  void
129  InternalInitialization(TransformType * transform);
130 
131  static PimpleTransformBase *
132  CreateBSplinePimpleTransform(unsigned int dimension, unsigned int order);
133 
134  template <unsigned int ND>
135  static PimpleTransformBase *
136  CreateBSplinePimpleTransform(unsigned int order);
137 
138  std::function<std::vector<double>()> m_pfGetTransformDomainDirection;
139  std::function<void(const std::vector<double> &)> m_pfSetTransformDomainDirection;
140  std::function<std::vector<unsigned int>()> m_pfGetTransformDomainMeshSize;
141  std::function<void(const std::vector<unsigned int> &)> m_pfSetTransformDomainMeshSize;
142  std::function<std::vector<double>()> m_pfGetTransformDomainOrigin;
143  std::function<void(const std::vector<double> &)> m_pfSetTransformDomainOrigin;
144  std::function<std::vector<double>()> m_pfGetTransformDomainPhysicalDimensions;
145  std::function<void(const std::vector<double> &)> m_pfSetTransformDomainPhysicalDimensions;
146 
147  std::function<std::vector<Image>()> m_pfGetCoefficientImages;
148  std::function<unsigned int()> m_pfGetOrder;
149 
150  std::function<void(const std::vector<Image> &)> m_pfSetCoefficientImages;
151 };
152 
153 } // namespace itk::simple
154 
155 #endif // sitkBSplineTransform_h
itk::simple::BSplineTransform::m_pfSetTransformDomainMeshSize
std::function< void(const std::vector< unsigned int > &)> m_pfSetTransformDomainMeshSize
Definition: sitkBSplineTransform.h:141
itk::simple::BSplineTransform::m_pfGetOrder
std::function< unsigned int()> m_pfGetOrder
Definition: sitkBSplineTransform.h:148
itk::simple::BSplineTransform::MyVisitor::operator()
void operator()() const
Definition: sitkBSplineTransform.h:114
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:86
itk::simple::BSplineTransform::MyVisitor::that
BSplineTransform * that
Definition: sitkBSplineTransform.h:111
itk::simple::BSplineTransform::GetName
std::string GetName() const override
Definition: sitkBSplineTransform.h:63
sitkCommon.h
itk::simple::BSplineTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkBSplineTransform.h:110
itk::simple::BSplineTransform::m_pfGetTransformDomainMeshSize
std::function< std::vector< unsigned int >)> m_pfGetTransformDomainMeshSize
Definition: sitkBSplineTransform.h:140
itk::simple::BSplineTransform::m_pfSetTransformDomainDirection
std::function< void(const std::vector< double > &)> m_pfSetTransformDomainDirection
Definition: sitkBSplineTransform.h:139
itk::simple::BSplineTransform::m_pfSetTransformDomainOrigin
std::function< void(const std::vector< double > &)> m_pfSetTransformDomainOrigin
Definition: sitkBSplineTransform.h:143
itk::simple::BSplineTransform::m_pfGetTransformDomainOrigin
std::function< std::vector< double >)> m_pfGetTransformDomainOrigin
Definition: sitkBSplineTransform.h:142
itk::simple::BSplineTransform::m_pfGetTransformDomainPhysicalDimensions
std::function< std::vector< double >)> m_pfGetTransformDomainPhysicalDimensions
Definition: sitkBSplineTransform.h:144
itk::simple::BSplineTransform::m_pfGetCoefficientImages
std::function< std::vector< Image >)> m_pfGetCoefficientImages
Definition: sitkBSplineTransform.h:147
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::BSplineTransform::m_pfGetTransformDomainDirection
std::function< std::vector< double >)> m_pfGetTransformDomainDirection
Definition: sitkBSplineTransform.h:138
itk::simple::BSplineTransform::m_pfSetCoefficientImages
std::function< void(const std::vector< Image > &)> m_pfSetCoefficientImages
Definition: sitkBSplineTransform.h:150
sitkTransform.h
itk::simple::BSplineTransform::InternalInitialization
void InternalInitialization(itk::TransformBase *transform)
itk::simple::BSplineTransform::m_pfSetTransformDomainPhysicalDimensions
std::function< void(const std::vector< double > &)> m_pfSetTransformDomainPhysicalDimensions
Definition: sitkBSplineTransform.h:145
itk::simple::BSplineTransform
A deformable transform over a bounded spatial domain using a BSpline representation for a 2D or 3D co...
Definition: sitkBSplineTransform.h:33
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::TransformBaseTemplate
Definition: sitkTransform.h:32
itk::simple::BSplineTransform::MyVisitor
Definition: sitkBSplineTransform.h:108