From: Vivien Delmon Date: Thu, 19 Apr 2012 14:30:31 +0000 (+0200) Subject: Bug clitkAffineTransform make rotate/translate options usable separately X-Git-Tag: v1.3.0~51 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cd69dc49b0a9bef7d113ca4264778df8b71f83ba;p=clitk.git Bug clitkAffineTransform make rotate/translate options usable separately - Allow the use of rotate and translate alone by setting missing parameters to 0. --- diff --git a/tools/clitkAffineTransformGenericFilter.txx b/tools/clitkAffineTransformGenericFilter.txx index ec9db09..93cd16c 100644 --- a/tools/clitkAffineTransformGenericFilter.txx +++ b/tools/clitkAffineTransformGenericFilter.txx @@ -143,14 +143,23 @@ AffineTransformGenericFilter::UpdateWithDimAndPixelType() return; } itk::Array transformParameters(2 * Dimension); - int pos = 0; - if (Dimension == 2) - transformParameters[pos++] = m_ArgsInfo.rotate_arg[0]; - else - for (unsigned int i = 0; i < 3; i++) - transformParameters[pos++] = m_ArgsInfo.rotate_arg[i]; - for (unsigned int i = 0; i < Dimension && i < 3; i++) - transformParameters[pos++] = m_ArgsInfo.translate_arg[i]; + transformParameters.Fill(0.0); + if (m_ArgsInfo.rotate_given) + { + if (Dimension == 2) + transformParameters[0] = m_ArgsInfo.rotate_arg[0]; + else + for (unsigned int i = 0; i < 3; i++) + transformParameters[i] = m_ArgsInfo.rotate_arg[i]; + } + if (m_ArgsInfo.translate_given) + { + int pos = 3; + if (Dimension == 2) + pos = 1; + for (unsigned int i = 0; i < Dimension && i < 3; i++) + transformParameters[pos++] = m_ArgsInfo.translate_arg[i]; + } if (Dimension == 4) { matrix.SetIdentity(); @@ -326,14 +335,23 @@ void AffineTransformGenericFilter::UpdateWithDimAndVectorType() return; } itk::Array transformParameters(2 * Dimension); - int pos = 0; - if (Dimension == 2) - transformParameters[pos++] = m_ArgsInfo.rotate_arg[0]; - else - for (unsigned int i = 0; i < 3; i++) - transformParameters[pos++] = m_ArgsInfo.rotate_arg[i]; - for (unsigned int i = 0; i < Dimension && i < 3; i++) - transformParameters[pos++] = m_ArgsInfo.translate_arg[i]; + transformParameters.Fill(0.0); + if (m_ArgsInfo.rotate_given) + { + if (Dimension == 2) + transformParameters[0] = m_ArgsInfo.rotate_arg[0]; + else + for (unsigned int i = 0; i < 3; i++) + transformParameters[i] = m_ArgsInfo.rotate_arg[i]; + } + if (m_ArgsInfo.translate_given) + { + int pos = 3; + if (Dimension == 2) + pos = 1; + for (unsigned int i = 0; i < Dimension && i < 3; i++) + transformParameters[pos++] = m_ArgsInfo.translate_arg[i]; + } if (Dimension == 4) { matrix.SetIdentity();