ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkRigid3DPerspectiveTransform.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkRigid3DPerspectiveTransform_h
00019 #define __itkRigid3DPerspectiveTransform_h
00020 
00021 #include "itkMacro.h"
00022 #include "vnl/vnl_quaternion.h"
00023 #include <iostream>
00024 #include "itkTransform.h"
00025 #include "itkVersor.h"
00026 
00027 namespace itk
00028 {
00037 template <
00038   class TScalarType = double>
00039 // Data type for scalars (float or double)
00040 class ITK_EXPORT Rigid3DPerspectiveTransform :
00041   public Transform<TScalarType, 3, 2>
00042 {
00043 public:
00045   itkStaticConstMacro(InputSpaceDimension, unsigned int, 3);
00046   itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
00048 
00050   itkStaticConstMacro(SpaceDimension, unsigned int, 3);
00051   itkStaticConstMacro(ParametersDimension, unsigned int, 6);
00053 
00055   typedef Rigid3DPerspectiveTransform Self;
00056   typedef Transform<TScalarType,
00057                     itkGetStaticConstMacro(InputSpaceDimension),
00058                     itkGetStaticConstMacro(OutputSpaceDimension)> Superclass;
00060 
00061   typedef SmartPointer<Self>       Pointer;
00062   typedef SmartPointer<const Self> ConstPointer;
00063 
00065   itkTypeMacro(Rigid3DPerspectiveTransform, Transform);
00066 
00068   itkNewMacro(Self);
00069 
00071   typedef typename Superclass::ScalarType ScalarType;
00072 
00074   typedef typename Superclass::ParametersType ParametersType;
00075   typedef typename ParametersType::ValueType  ParameterValueType;
00076 
00078   typedef typename Superclass::JacobianType JacobianType;
00079 
00081   typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension),
00082                  itkGetStaticConstMacro(InputSpaceDimension)> MatrixType;
00083 
00085   typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> OffsetType;
00086   typedef typename OffsetType::ValueType                                   OffsetValueType;
00087 
00089   typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)>  InputVectorType;
00090   typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
00092 
00094   typedef typename Superclass::InputCovariantVectorType  InputCovariantVectorType;
00095   typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
00096 
00098   typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)>  InputPointType;
00099   typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
00101 
00103   typedef vnl_quaternion<TScalarType> VnlQuaternionType;
00104 
00106   typedef typename Superclass::InputVnlVectorType  InputVnlVectorType;
00107   typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
00108 
00110   typedef Versor<TScalarType>             VersorType;
00111   typedef typename VersorType::VectorType AxisType;
00112   typedef typename VersorType::ValueType  AngleType;
00113   typedef typename AxisType::ValueType    AxisValueType;
00114 
00118   const OffsetType & GetOffset() const
00119   {
00120     return m_Offset;
00121   }
00122 
00126   const VersorType & GetRotation() const
00127   {
00128     return m_Versor;
00129   }
00130 
00135   void SetParameters(const ParametersType & parameters);
00136 
00137   const ParametersType & GetParameters() const;
00138 
00142   virtual void SetFixedParameters(const ParametersType &)
00143   {
00144   }
00145 
00148   void SetOffset(const OffsetType & offset)
00149   {
00150     m_Offset = offset; return;
00151   }
00152 
00155   void SetRotation(const VersorType & rotation);
00156 
00161   void SetRotation(const Vector<TScalarType, 3> & axis, double angle);
00162 
00166   void SetFocalDistance(TScalarType focalDistance)
00167   {
00168     m_FocalDistance = focalDistance;
00169   }
00170 
00172   double GetFocalDistance(void) const
00173   {
00174     return m_FocalDistance;
00175   }
00176 
00180   OutputPointType  TransformPoint(const InputPointType  & point) const;
00181 
00183   using Superclass::TransformVector;
00184 
00185   virtual OutputVectorType TransformVector(const InputVectorType &) const
00186   {
00187     itkExceptionMacro(
00188       << "TransformVector(const InputVectorType &) is not implemented for Rigid3DPerspectiveTransform");
00189   }
00190 
00191   virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &) const
00192   {
00193     itkExceptionMacro(
00194       << "TransformVector(const InputVnlVectorType &) is not implemented for Rigid3DPerspectiveTransform");
00195   }
00196 
00197   using Superclass::TransformCovariantVector;
00198 
00199   virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
00200   {
00201     itkExceptionMacro(
00202       <<
00203       "TransformCovariantVector(const InputCovariantVectorType &) is not implemented for Rigid3DPerspectiveTransform");
00204   }
00205 
00207   const MatrixType & GetRotationMatrix() const
00208   {
00209     return m_RotationMatrix;
00210   }
00211 
00213   void ComputeMatrix(void);
00214 
00217   virtual void ComputeJacobianWithRespectToParameters( const InputPointType  & p, JacobianType & jacobian) const;
00218 
00219   virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
00220                                                     JacobianType &) const
00221   {
00222     itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented "
00223                        "for " << this->GetNameOfClass() );
00224   }
00225 
00227   itkGetConstReferenceMacro(FixedOffset, OffsetType);
00228   itkSetMacro(FixedOffset, OffsetType);
00230 
00232   itkSetMacro(CenterOfRotation, InputPointType);
00233   itkGetConstReferenceMacro(CenterOfRotation, InputPointType);
00234 protected:
00235   Rigid3DPerspectiveTransform();
00236   ~Rigid3DPerspectiveTransform();
00237   void PrintSelf(std::ostream & os, Indent indent) const;
00239 
00240 private:
00241   Rigid3DPerspectiveTransform(const Self &); // purposely not implemented
00242   void operator=(const Self &);              // purposely not implemented
00243 
00245   OffsetType m_Offset;
00246 
00248   VersorType m_Versor;
00249 
00251   TScalarType m_FocalDistance;
00252 
00254   MatrixType m_RotationMatrix;
00255 
00257   OffsetType m_FixedOffset;
00258 
00260   InputPointType m_CenterOfRotation;
00261 }; // class Rigid3DPerspectiveTransform:
00262 }  // namespace itk
00263 
00264 // Define instantiation macro for this template.
00265 #define ITK_TEMPLATE_Rigid3DPerspectiveTransform(_, EXPORT, TypeX, TypeY)     \
00266   namespace itk                                                               \
00267   {                                                                           \
00268   _( 1 ( class EXPORT Rigid3DPerspectiveTransform<ITK_TEMPLATE_1 TypeX> ) ) \
00269   namespace Templates                                                         \
00270   {                                                                           \
00271   typedef Rigid3DPerspectiveTransform<ITK_TEMPLATE_1 TypeX>                 \
00272   Rigid3DPerspectiveTransform##TypeY;                                       \
00273   }                                                                           \
00274   }
00275 
00276 #if ITK_TEMPLATE_EXPLICIT
00277 // template < class TScalarType> const unsigned int
00278 // itk::Rigid3DPerspectiveTransform<TScalarType>::SpaceDimension;
00279 // template < class TScalarType> const unsigned int
00280 // itk::Rigid3DPerspectiveTransform<TScalarType>::InputSpaceDimension;
00281 // template < class TScalarType> const unsigned int
00282 // itk::Rigid3DPerspectiveTransform<TScalarType>::OutputSpaceDimension;
00283 #include "Templates/itkRigid3DPerspectiveTransform+-.h"
00284 #endif
00285 
00286 #if ITK_TEMPLATE_TXX
00287 #include "itkRigid3DPerspectiveTransform.hxx"
00288 #endif
00289 
00290 #endif /* __itkRigid3DPerspectiveTransform_h */
00291