From cd69dc49b0a9bef7d113ca4264778df8b71f83ba Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Thu, 19 Apr 2012 16:30:31 +0200 Subject: [PATCH] Bug clitkAffineTransform make rotate/translate options usable separately - Allow the use of rotate and translate alone by setting missing parameters to 0. --- tools/clitkAffineTransformGenericFilter.txx | 50 ++++++++++++++------- 1 file changed, 34 insertions(+), 16 deletions(-) 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(); -- 2.47.1