Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "itkVtkAbstractTransform.h"
00019 #include <vtkAbstractTransform.h>
00020 #include <mitkVector.h>
00021
00022 namespace itk {
00023
00024 template <class TScalarType>
00025 itk::VtkAbstractTransform<TScalarType>::VtkAbstractTransform() :
00026 Superclass(3, 0),
00027 m_VtkAbstractTransform(NULL), m_InverseVtkAbstractTransform(NULL),
00028 m_LastVtkAbstractTransformTimeStamp(0)
00029 {
00030
00031 }
00032
00033 template <class TScalarType>
00034 itk::VtkAbstractTransform<TScalarType>::~VtkAbstractTransform()
00035 {
00036 if(m_VtkAbstractTransform!=NULL)
00037 m_VtkAbstractTransform->UnRegister(NULL);
00038 }
00039
00040 template <class TScalarType>
00041 vtkAbstractTransform* itk::VtkAbstractTransform<TScalarType>::GetVtkAbstractTransform() const
00042 {
00043 return m_VtkAbstractTransform;
00044 }
00045
00046 template <class TScalarType>
00047 vtkAbstractTransform* itk::VtkAbstractTransform<TScalarType>::GetInverseVtkAbstractTransform() const
00048 {
00049 return m_InverseVtkAbstractTransform;
00050 }
00051
00052 template <class TScalarType>
00053 void itk::VtkAbstractTransform<TScalarType>::SetVtkAbstractTransform(vtkAbstractTransform* aVtkAbstractTransform)
00054 {
00055 if(m_VtkAbstractTransform==aVtkAbstractTransform)
00056 return;
00057
00058 if(m_VtkAbstractTransform!=NULL)
00059 m_VtkAbstractTransform->UnRegister(NULL);
00060
00061 m_VtkAbstractTransform=aVtkAbstractTransform;
00062 if(m_VtkAbstractTransform!=NULL)
00063 {
00064 m_VtkAbstractTransform->Register(NULL);
00065 m_InverseVtkAbstractTransform=m_VtkAbstractTransform->GetInverse();
00066 }
00067
00068 m_LastVtkAbstractTransformTimeStamp = m_VtkAbstractTransform->GetMTime();
00069
00070 this->Modified();
00071 }
00072
00073
00074 template<class TScalarType>
00075 typename itk::VtkAbstractTransform<TScalarType>::OutputPointType
00076 itk::VtkAbstractTransform<TScalarType>::
00077 TransformPoint(const InputPointType &point) const
00078 {
00079 assert(m_VtkAbstractTransform!=NULL);
00080
00081 OutputPointType outputpoint;
00082 vnl_vector<TScalarType> vnl_vec;
00083 float vtkpt[3];
00084 mitk::itk2vtk(point, vtkpt);
00085 m_VtkAbstractTransform->TransformPoint(vtkpt, vtkpt);
00086 mitk::vtk2itk(vtkpt, outputpoint);
00087 return outputpoint;
00088 }
00089
00090
00091
00092 template<class TScalarType>
00093 typename itk::VtkAbstractTransform<TScalarType>::OutputVectorType
00094 itk::VtkAbstractTransform<TScalarType>::
00095 TransformVector(const InputVectorType &vect) const
00096 {
00097 assert(m_VtkAbstractTransform!=NULL);
00098
00099 OutputVectorType outputvector;
00100 vnl_vector<TScalarType> vnl_vec;
00101 float vtkpt[3]={0,0,0};
00102 float vtkvec[3];
00103 mitk::vnl2vtk<TScalarType, float>(vect.Get_vnl_vector(), vtkvec);
00104 m_VtkAbstractTransform->TransformVectorAtPoint(vtkpt, vtkvec, vtkvec);
00105 mitk::vtk2itk(vtkvec, outputvector);
00106 return outputvector;
00107 }
00108
00109
00110
00111 template<class TScalarType>
00112 typename itk::VtkAbstractTransform<TScalarType>::OutputVnlVectorType
00113 itk::VtkAbstractTransform<TScalarType>::
00114 TransformVector(const InputVnlVectorType &vect) const
00115 {
00116 assert(m_VtkAbstractTransform!=NULL);
00117
00118 OutputVnlVectorType outputvector;
00119 float vtkpt[3]={0,0,0};
00120 float vtkvec[3];
00121 mitk::vnl2vtk<TScalarType, float>(vect, vtkvec);
00122 m_VtkAbstractTransform->TransformVectorAtPoint(vtkpt, vtkvec, vtkvec);
00123 mitk::vtk2itk(vtkvec, outputvector);
00124 return outputvector;
00125 }
00126
00127
00128 template<class TScalarType>
00129 typename itk::VtkAbstractTransform<TScalarType>::OutputCovariantVectorType
00130 itk::VtkAbstractTransform<TScalarType>::
00131 TransformCovariantVector(const InputCovariantVectorType &) const
00132 {
00133 itkExceptionMacro( << "implement before using!" );
00134 OutputCovariantVectorType result;
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 return result;
00145 }
00146
00147
00148 template<class TScalarType>
00149 typename VtkAbstractTransform<TScalarType>::InputPointType
00150 itk::VtkAbstractTransform<TScalarType>::
00151 BackTransform(const OutputPointType &point) const
00152 {
00153 assert(m_VtkAbstractTransform!=NULL);
00154
00155 OutputPointType outputpoint;
00156 float vtkpt[3];
00157 mitk::itk2vtk(point, vtkpt);
00158 m_InverseVtkAbstractTransform->TransformPoint(vtkpt, vtkpt);
00159 mitk::vtk2itk(vtkpt, outputpoint);
00160 return outputpoint;
00161 }
00162
00163
00164 template<class TScalarType>
00165 typename VtkAbstractTransform<TScalarType>::InputVectorType
00166 itk::VtkAbstractTransform<TScalarType>::
00167 BackTransform(const OutputVectorType &vect ) const
00168 {
00169 assert(m_VtkAbstractTransform!=NULL);
00170
00171 OutputVectorType outputvector;
00172 float vtkpt[3]={0,0,0};
00173 float vtkvec[3];
00174 mitk::itk2vtk(vect, vtkvec);
00175 m_InverseVtkAbstractTransform->TransformVectorAtPoint(vtkpt, vtkvec, vtkvec);
00176 mitk::vtk2itk(vtkvec, outputvector);
00177 return outputvector;
00178 }
00179
00180
00181 template<class TScalarType>
00182 typename VtkAbstractTransform<TScalarType>::InputVnlVectorType
00183 itk::VtkAbstractTransform<TScalarType>::
00184 BackTransform(const OutputVnlVectorType &vect ) const
00185 {
00186 assert(m_InverseVtkAbstractTransform!=NULL);
00187
00188 OutputVnlVectorType outputvector;
00189 float vtkpt[3]={0,0,0};
00190 float vtkvec[3];
00191 mitk::itk2vtk(vect, vtkvec);
00192 m_InverseVtkAbstractTransform->TransformVectorAtPoint(vtkpt, vtkvec, vtkvec);
00193 mitk::vtk2itk(vtkvec, outputvector);
00194 return outputvector;
00195 }
00196
00197
00198 template<class TScalarType>
00199 typename VtkAbstractTransform<TScalarType>::InputCovariantVectorType
00200 itk::VtkAbstractTransform<TScalarType>::
00201 BackTransform(const OutputCovariantVectorType &vec) const
00202 {
00203 itkExceptionMacro( << "implement before using!" );
00204
00205
00206
00207
00208
00209
00210
00211
00212 return vec;
00213 }
00214
00215 template<class TScalarType>
00216 unsigned long
00217 itk::VtkAbstractTransform<TScalarType>::GetMTime() const
00218 {
00219 if((m_VtkAbstractTransform != NULL) && (m_LastVtkAbstractTransformTimeStamp < m_VtkAbstractTransform->GetMTime()))
00220 {
00221 m_LastVtkAbstractTransformTimeStamp=m_VtkAbstractTransform->GetMTime();
00222 this->Modified();
00223 }
00224
00225 return Superclass::GetMTime();
00226 }
00227
00228 }