]> Creatis software - clitk.git/blobdiff - registration/clitkMultipleBSplineDeformableTransform.txx
First version of the builder of relpos database
[clitk.git] / registration / clitkMultipleBSplineDeformableTransform.txx
index 3a609a2e6017275c0934a60c881b8e11ac694a21..8df270661409bf8c8ed4939fa34c017db445f0f7 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 #ifndef __clitkMultipleBSplineDeformableTransform_txx
 #define __clitkMultipleBSplineDeformableTransform_txx
 
@@ -29,7 +29,11 @@ namespace clitk
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  ::MultipleBSplineDeformableTransform() : Superclass(0)
+#else
   ::MultipleBSplineDeformableTransform() : Superclass(OutputDimension, 0)
+#endif
   {
     m_nLabels = 1;
     m_labels = 0;
@@ -325,7 +329,11 @@ namespace clitk
 #undef LOOP_ON_LABELS
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  inline typename MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::NumberOfParametersType
+#else
   inline unsigned int
+#endif
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetNumberOfParameters(void) const
   {
@@ -425,15 +433,38 @@ namespace clitk
     return m_trans[lidx]->DeformablyTransformPoint(inputPoint);
   }
 
+#if ITK_VERSION_MAJOR >= 4
+  template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
+  inline void
+  MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+  ::ComputeJacobianWithRespectToParameters (const InputPointType &point, JacobianType &jacobian) const
+  {
+    if (m_LastJacobian != -1)
+      m_trans[m_LastJacobian]->ResetJacobian();
+
+    int lidx = 0;
+    if (m_labels)
+      lidx = m_labelInterpolator->Evaluate(point) - 1;
+    if (lidx == -1)
+    {
+      m_LastJacobian = lidx;
+      jacobian = this->m_SharedDataBSplineJacobian;
+      return;
+    }
+
+    JacobianType unused;
+    m_trans[lidx]->ComputeJacobianWithRespectToParameters(point, unused);
+    m_LastJacobian = lidx;
+
+    jacobian = this->m_SharedDataBSplineJacobian;
+  }
+
+#else
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline const typename MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::JacobianType &
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetJacobian( const InputPointType & point ) const
   {
-    /*
-    for (unsigned i = 0; i < m_nLabels; ++i)
-      m_trans[i]->ResetJacobian();
-      */
     if (m_LastJacobian != -1)
       m_trans[m_LastJacobian]->ResetJacobian();
 
@@ -451,6 +482,7 @@ namespace clitk
 
     return this->m_Jacobian;
   }
+#endif
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline void
@@ -465,8 +497,13 @@ namespace clitk
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions,NOutputDimensions>::InitJacobian()
   {
     unsigned numberOfParameters = this->GetNumberOfParameters();
+#if ITK_VERSION_MAJOR >= 4
+    this->m_SharedDataBSplineJacobian.set_size(OutputDimension, numberOfParameters);
+    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
+#else
     this->m_Jacobian.set_size(OutputDimension, numberOfParameters);
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
+#endif
     memset(jacobianDataPointer, 0,  numberOfParameters * sizeof (JacobianPixelType));
 
     unsigned tot = 0;