From d9b5c3f1a786b595255a9153da9ceafd88d2a189 Mon Sep 17 00:00:00 2001 From: Roman Grothausmann Date: Mon, 12 Sep 2016 11:01:45 +0200 Subject: [PATCH] try storing output pointers seperately (not compiling) --- resample.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resample.cxx b/resample.cxx index e0f0438..db6d7cd 100644 --- a/resample.cxx +++ b/resample.cxx @@ -70,20 +70,24 @@ int DoIt2(int argc, char *argv[], InterpolatorType* interpolator){ typename InputImageType::SpacingType outputSpacing; std::vector savedPointers; // to store smart-pointers outside their creation scope + typedef typename itk::ImageBase::Pointer ImagePointerType; + typename std::vector< ImagePointerType > savedOutPointers; + savedPointers.push_back(caster.GetPointer()); - typedef itk::ImageSource ISType; + savedOutPointers.push_back(caster->GetOutput().GetPointer()); for (unsigned int i= 0; i < Dimension; i++){ outputSpacing[i]= atof(argv[5+i]); typename GaussianFilterType::Pointer smoother = GaussianFilterType::New(); - smoother->SetInput(dynamic_cast(savedPointers[i].GetPointer())->GetOutput()); // similar to: https://cmake.org/pipermail/insight-users/2007-May/022374.html + smoother->SetInput(savedOutPointers[i]); // similar to: https://cmake.org/pipermail/insight-users/2007-May/022374.html smoother->SetSigma(outputSpacing[i]); smoother->SetDirection(i); smoother->ReleaseDataFlagOn(); smoother->InPlaceOn(); FilterWatcher watcherX(smoother); savedPointers.push_back(smoother.GetPointer()); + savedOutPointers.push_back(smoother->GetOutput().GetPointer()); } const typename InputImageType::SizeType& inputSize= input->GetLargestPossibleRegion().GetSize(); @@ -98,7 +102,7 @@ int DoIt2(int argc, char *argv[], InterpolatorType* interpolator){ typedef itk::ResampleImageFilter FilterType; typename FilterType::Pointer filter= FilterType::New(); - filter->SetInput(dynamic_cast(savedPointers[savedPointers.size()].GetPointer())->GetOutput()); + filter->SetInput(savedOutPointers[savedOutPointers.size()]); filter->SetTransform(transform); filter->SetInterpolator(interpolator); filter->SetOutputSpacing(outputSpacing);