ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkRigid2DTransform_h 00019 #define __itkRigid2DTransform_h 00020 00021 #include <iostream> 00022 #include "itkMatrixOffsetTransformBase.h" 00023 00024 namespace itk 00025 { 00056 template <class TScalarType = double> 00057 // Data type for scalars (float or double) 00058 class ITK_EXPORT Rigid2DTransform : 00059 public MatrixOffsetTransformBase<TScalarType, 2, 2> // Dimensions of 00060 // input and output 00061 // spaces 00062 { 00063 public: 00065 typedef Rigid2DTransform Self; 00066 typedef MatrixOffsetTransformBase<TScalarType, 2, 2> Superclass; 00067 typedef SmartPointer<Self> Pointer; 00068 typedef SmartPointer<const Self> ConstPointer; 00069 00071 itkTypeMacro(Rigid2DTransform, MatrixOffsetTransformBase); 00072 00074 itkNewMacro(Self); 00075 00077 itkStaticConstMacro(InputSpaceDimension, unsigned int, 2); 00078 itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2); 00079 itkStaticConstMacro(ParametersDimension, unsigned int, 3); 00081 00083 typedef typename Superclass::ScalarType ScalarType; 00084 00086 typedef typename Superclass::ParametersType ParametersType; 00087 typedef typename Superclass::ParametersValueType ParametersValueType; 00088 00090 typedef typename Superclass::JacobianType JacobianType; 00091 00092 // / Standard matrix type for this class 00093 typedef typename Superclass::MatrixType MatrixType; 00094 typedef typename Superclass::MatrixValueType MatrixValueType; 00095 00096 // / Standard vector type for this class 00097 typedef typename Superclass::OffsetType OffsetType; 00098 typedef typename Superclass::OffsetValueType OffsetValueType; 00099 00100 // / Standard vector type for this class 00101 typedef typename Superclass::InputVectorType InputVectorType; 00102 typedef typename Superclass::OutputVectorType OutputVectorType; 00103 typedef typename Superclass::OutputVectorValueType OutputVectorValueType; 00104 00105 // / Standard covariant vector type for this class 00106 typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; 00107 typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType; 00108 00109 // / Standard vnl_vector type for this class 00110 typedef typename Superclass::InputVnlVectorType InputVnlVectorType; 00111 typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; 00112 00113 // / Standard coordinate point type for this class 00114 typedef typename Superclass::InputPointType InputPointType; 00115 typedef typename Superclass::OutputPointType OutputPointType; 00116 00119 typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType; 00120 typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer; 00121 00134 virtual void SetMatrix(const MatrixType & matrix); 00135 00141 virtual void SetRotationMatrix(const MatrixType & matrix) 00142 { 00143 this->SetMatrix(matrix); 00144 } 00145 const MatrixType & GetRotationMatrix() const 00146 { 00147 return this->GetMatrix(); 00148 } 00150 00158 void Translate(const OffsetType & offset, bool pre = false); 00159 00168 inline InputPointType BackTransform(const OutputPointType & point) const; 00169 00170 inline InputVectorType BackTransform(const OutputVectorType & vector) const; 00171 00172 inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const; 00173 00174 inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const; 00175 00177 void SetAngle(TScalarType angle); 00178 00179 itkGetConstReferenceMacro(Angle, TScalarType); 00180 00182 void SetAngleInDegrees(TScalarType angle); 00183 00187 void SetRotation(TScalarType angle) 00188 { 00189 this->SetAngle(angle); 00190 } 00191 virtual const TScalarType & GetRotation() const 00192 { 00193 return m_Angle; 00194 } 00196 00205 void SetParameters(const ParametersType & parameters); 00206 00215 const ParametersType & GetParameters(void) const; 00216 00219 virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const; 00220 00225 void CloneInverseTo(Pointer & newinverse) const; 00226 00228 bool GetInverse(Self *inverse) const; 00229 00231 virtual InverseTransformBasePointer GetInverseTransform() const; 00232 00237 void CloneTo(Pointer & clone) const; 00238 00240 virtual void SetIdentity(void); 00241 00242 protected: 00243 Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension); 00244 Rigid2DTransform(unsigned int parametersDimension); 00245 Rigid2DTransform(); 00246 00247 ~Rigid2DTransform(); 00248 00252 void PrintSelf(std::ostream & os, Indent indent) const; 00253 00257 virtual void ComputeMatrix(void); 00258 00263 virtual void ComputeMatrixParameters(void); 00264 00266 void SetVarAngle(TScalarType angle) 00267 { 00268 m_Angle = angle; 00269 } 00270 private: 00271 Rigid2DTransform(const Self &); // purposely not implemented 00272 void operator=(const Self &); // purposely not implemented 00274 00275 TScalarType m_Angle; 00276 00277 }; // class Rigid2DTransform 00278 00279 // Back transform a point 00280 template <class TScalarType> 00281 inline 00282 typename Rigid2DTransform<TScalarType>::InputPointType 00283 Rigid2DTransform<TScalarType>::BackTransform(const OutputPointType & point) const 00284 { 00285 itkWarningMacro( 00286 << 00287 "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform." 00288 ); 00289 return this->GetInverseMatrix() * ( point - this->GetOffset() ); 00290 } 00291 00292 // Back transform a vector 00293 template <class TScalarType> 00294 inline 00295 typename Rigid2DTransform<TScalarType>::InputVectorType 00296 Rigid2DTransform<TScalarType>::BackTransform(const OutputVectorType & vect) const 00297 { 00298 itkWarningMacro( 00299 << 00300 "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform." 00301 ); 00302 return this->GetInverseMatrix() * vect; 00303 } 00304 00305 // Back transform a vnl_vector 00306 template <class TScalarType> 00307 inline 00308 typename Rigid2DTransform<TScalarType>::InputVnlVectorType 00309 Rigid2DTransform<TScalarType>::BackTransform(const OutputVnlVectorType & vect) const 00310 { 00311 itkWarningMacro( 00312 << 00313 "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform." 00314 ); 00315 return this->GetInverseMatrix() * vect; 00316 } 00317 00318 // Back Transform a CovariantVector 00319 template <class TScalarType> 00320 inline 00321 typename Rigid2DTransform<TScalarType>::InputCovariantVectorType 00322 Rigid2DTransform<TScalarType>::BackTransform(const OutputCovariantVectorType & vect) const 00323 { 00324 itkWarningMacro( 00325 << 00326 "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform." 00327 ); 00328 return this->GetMatrix() * vect; 00329 } 00330 00331 } // namespace itk 00332 00333 // Define instantiation macro for this template. 00334 #define ITK_TEMPLATE_Rigid2DTransform(_, EXPORT, TypeX, TypeY) \ 00335 namespace itk \ 00336 { \ 00337 _( 1 ( class EXPORT Rigid2DTransform<ITK_TEMPLATE_1 TypeX> ) ) \ 00338 namespace Templates \ 00339 { \ 00340 typedef Rigid2DTransform<ITK_TEMPLATE_1 TypeX> Rigid2DTransform##TypeY; \ 00341 } \ 00342 } 00343 00344 #if ITK_TEMPLATE_EXPLICIT 00345 #include "Templates/itkRigid2DTransform+-.h" 00346 #endif 00347 00348 #if ITK_TEMPLATE_TXX 00349 #include "itkRigid2DTransform.hxx" 00350 #endif 00351 00352 #endif /* __itkRigid2DTransform_h */ 00353