ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkRigid3DPerspectiveTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 __itkRigid3DPerspectiveTransform_h
19 #define __itkRigid3DPerspectiveTransform_h
20 
21 #include "itkMacro.h"
22 #include "vnl/vnl_quaternion.h"
23 #include <iostream>
24 #include "itkTransform.h"
25 #include "itkVersor.h"
26 
27 namespace itk
28 {
37 template <
38  class TScalarType = double>
39 // Data type for scalars (float or double)
40 class ITK_EXPORT Rigid3DPerspectiveTransform :
41  public Transform<TScalarType, 3, 2>
42 {
43 public:
45  itkStaticConstMacro(InputSpaceDimension, unsigned int, 3);
46  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
48 
50  itkStaticConstMacro(SpaceDimension, unsigned int, 3);
51  itkStaticConstMacro(ParametersDimension, unsigned int, 6);
53 
56  typedef Transform<TScalarType,
57  itkGetStaticConstMacro(InputSpaceDimension),
58  itkGetStaticConstMacro(OutputSpaceDimension)> Superclass;
60 
63 
66 
68  itkNewMacro(Self);
69 
71  typedef typename Superclass::ScalarType ScalarType;
72 
74  typedef typename Superclass::ParametersType ParametersType;
75  typedef typename ParametersType::ValueType ParameterValueType;
76 
78  typedef typename Superclass::JacobianType JacobianType;
79 
81  typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
82  itkGetStaticConstMacro(InputSpaceDimension)> MatrixType;
83 
87 
92 
94  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
95  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
96 
101 
103  typedef vnl_quaternion<TScalarType> VnlQuaternionType;
104 
106  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
107  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
108 
114 
118  const OffsetType & GetOffset() const
119  {
120  return m_Offset;
121  }
122 
126  const VersorType & GetRotation() const
127  {
128  return m_Versor;
129  }
130 
135  void SetParameters(const ParametersType & parameters);
136 
137  const ParametersType & GetParameters() const;
138 
142  virtual void SetFixedParameters(const ParametersType &)
143  {
144  }
145 
148  void SetOffset(const OffsetType & offset)
149  {
150  m_Offset = offset; return;
151  }
152 
155  void SetRotation(const VersorType & rotation);
156 
161  void SetRotation(const Vector<TScalarType, 3> & axis, double angle);
162 
166  void SetFocalDistance(TScalarType focalDistance)
167  {
168  m_FocalDistance = focalDistance;
169  }
170 
172  double GetFocalDistance(void) const
173  {
174  return m_FocalDistance;
175  }
176 
180  OutputPointType TransformPoint(const InputPointType & point) const;
181 
183  using Superclass::TransformVector;
184 
185  virtual OutputVectorType TransformVector(const InputVectorType &) const
186  {
187  itkExceptionMacro(
188  << "TransformVector(const InputVectorType &) is not implemented for Rigid3DPerspectiveTransform");
189  }
190 
191  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
192  {
193  itkExceptionMacro(
194  << "TransformVector(const InputVnlVectorType &) is not implemented for Rigid3DPerspectiveTransform");
195  }
196 
197  using Superclass::TransformCovariantVector;
198 
199  virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
200  {
201  itkExceptionMacro(
202  <<
203  "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for Rigid3DPerspectiveTransform");
204  }
205 
207  const MatrixType & GetRotationMatrix() const
208  {
209  return m_RotationMatrix;
210  }
211 
213  void ComputeMatrix(void);
214 
217  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
218 
219  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
220  JacobianType &) const
221  {
222  itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
223  "for " << this->GetNameOfClass() );
224  }
225 
227  itkGetConstReferenceMacro(FixedOffset, OffsetType);
228  itkSetMacro(FixedOffset, OffsetType);
230 
232  itkSetMacro(CenterOfRotation, InputPointType);
233  itkGetConstReferenceMacro(CenterOfRotation, InputPointType);
234 protected:
237  void PrintSelf(std::ostream & os, Indent indent) const;
239 
240 private:
241  Rigid3DPerspectiveTransform(const Self &); // purposely not implemented
242  void operator=(const Self &); // purposely not implemented
243 
246 
249 
251  TScalarType m_FocalDistance;
252 
255 
258 
261 }; // class Rigid3DPerspectiveTransform:
262 } // namespace itk
263 
264 // Define instantiation macro for this template.
265 #define ITK_TEMPLATE_Rigid3DPerspectiveTransform(_, EXPORT, TypeX, TypeY) \
266  namespace itk \
267  { \
268  _( 1 ( class EXPORT Rigid3DPerspectiveTransform<ITK_TEMPLATE_1 TypeX> ) ) \
269  namespace Templates \
270  { \
271  typedef Rigid3DPerspectiveTransform<ITK_TEMPLATE_1 TypeX> \
272  Rigid3DPerspectiveTransform##TypeY; \
273  } \
274  }
275 
276 #if ITK_TEMPLATE_EXPLICIT
277 // template < class TScalarType> const unsigned int
278 // itk::Rigid3DPerspectiveTransform<TScalarType>::SpaceDimension;
279 // template < class TScalarType> const unsigned int
280 // itk::Rigid3DPerspectiveTransform<TScalarType>::InputSpaceDimension;
281 // template < class TScalarType> const unsigned int
282 // itk::Rigid3DPerspectiveTransform<TScalarType>::OutputSpaceDimension;
283 #include "Templates/itkRigid3DPerspectiveTransform+-.h"
284 #endif
285 
286 #if ITK_TEMPLATE_TXX
287 #include "itkRigid3DPerspectiveTransform.hxx"
288 #endif
289 
290 #endif /* __itkRigid3DPerspectiveTransform_h */
291