From 9d1351bcc77a1b77ec141a625aff5be8ba861e7b Mon Sep 17 00:00:00 2001 From: srit Date: Wed, 16 Mar 2011 17:19:22 +0000 Subject: [PATCH] Attempted to fix the mess of the resample fucker wrt to setting spacing and dims --- tools/clitkResampleImageGenericFilter.txx | 41 +++++++++++------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/tools/clitkResampleImageGenericFilter.txx b/tools/clitkResampleImageGenericFilter.txx index e05770e..823acb9 100644 --- a/tools/clitkResampleImageGenericFilter.txx +++ b/tools/clitkResampleImageGenericFilter.txx @@ -68,31 +68,28 @@ clitk::ResampleImageGenericFilter::UpdateWithInputImageType() else { if (mArgsInfo.spacing_given == 1) { filter->SetOutputIsoSpacing(mArgsInfo.spacing_arg[0]); - } else { - if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.size_given != 0)) { - std::cerr << "Error: use spacing or size, not both." << std::endl; + } + else if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.size_given != 0)) { + std::cerr << "Error: use spacing or size, not both." << std::endl; + exit(0); + } + else if (mArgsInfo.spacing_given) { + if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.spacing_given != dim)) { + std::cerr << "Error: spacing should have one or " << dim << " values." << std::endl; exit(0); } - - if (!((mArgsInfo.spacing_given == 0) && (mArgsInfo.size_given == 0))) { - - if ((mArgsInfo.spacing_given != 0) && (mArgsInfo.spacing_given != dim)) { - std::cerr << "Error: spacing should have one or " << dim << " values." << std::endl; - exit(0); - } - if ((mArgsInfo.size_given != 0) && (mArgsInfo.size_given != dim)) { - std::cerr << "Error: size should have " << dim << " values." << std::endl; - exit(0); - } - if (mArgsInfo.spacing_given) - for(unsigned int i=0; iSetOutputSpacing(spacing); - filter->SetOutputSize(size); + for(unsigned int i=0; iSetOutputSpacing(spacing); + } + else if (mArgsInfo.size_given) { + if ((mArgsInfo.size_given != 0) && (mArgsInfo.size_given != dim)) { + std::cerr << "Error: size should have " << dim << " values." << std::endl; + exit(0); } + for(unsigned int i=0; iSetOutputSize(size); } } -- 2.47.1