/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkJoinDimensionsImageFilter.txx,v $ Language: C++ Date: $Date: 2004/11/02 15:58:28 $ Version: $Revision: 1.1 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itkJoinDimensionsImageFilter_txx #define _itkJoinDimensionsImageFilter_txx #include "itkJoinDimensionsImageFilter.h" namespace itk { /** * */ template JoinDimensionsImageFilter ::JoinDimensionsImageFilter() { } template void JoinDimensionsImageFilter ::GenerateOutputInformation() { // Superclass::GenerateOutputInformation(); unsigned int i; typename TOutputImage::RegionType outputRegion; typename TInputImage::IndexType inputIndex; typename TInputImage::SizeType inputSize; typename TOutputImage::SizeType outputSize; typename TOutputImage::IndexType outputIndex; typename TInputImage::SpacingType inSpacing; typename TInputImage::PointType inOrigin; typename TOutputImage::SpacingType outSpacing; typename TOutputImage::PointType outOrigin; itkDebugMacro("GenerateOutputInformation Start"); int outDim = OutputImageDimension; // Get pointers to the input and output typename Superclass::OutputImagePointer output = this->GetOutput(); typename Superclass::InputImagePointer input = const_cast< TInputImage * >( this->GetInput() ); inputIndex = input->GetLargestPossibleRegion().GetIndex(); inputSize = input->GetLargestPossibleRegion().GetSize(); for(int i = 0; iSetLargestPossibleRegion(outputRegion); itkDebugMacro("GenerateOutputInformation End"); } template void JoinDimensionsImageFilter ::GenerateInputRequestedRegion() { Superclass::GenerateInputRequestedRegion(); if ( this->GetInput() ) { typename TInputImage::RegionType region; typename TInputImage::RegionType InBufferedRegion; typename TOutputImage::RegionType OutBufferedRegion; typename TInputImage::SizeType inputSize; typename TInputImage::IndexType inputStartIndex; typename TInputImage::IndexType inputEndIndex; typename TOutputImage::SizeType outputLargSize; typename TInputImage::SizeType inputLargSize; typename TInputImage::IndexType inputLargIndex; typename TOutputImage::SizeType outputSize; typename TOutputImage::IndexType outputIndex; int outDim = OutputImageDimension; outputIndex = this->GetOutput()->GetRequestedRegion().GetIndex(); outputSize = this->GetOutput()->GetRequestedRegion().GetSize(); InBufferedRegion = this->GetInput()->GetBufferedRegion(); OutBufferedRegion = this->GetOutput()->GetBufferedRegion(); outputLargSize = this->GetOutput()->GetLargestPossibleRegion().GetSize(); inputLargSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); inputLargIndex = this->GetInput()->GetLargestPossibleRegion().GetIndex(); // Output size is always the same as input size for(int i = 0; i inputLargSize[outDim-1]) { inputSize[outDim-1] = inputEndIndex[outDim-1] - inputStartIndex[outDim-1] + 1; inputSize[outDim] = inputEndIndex[outDim] - inputStartIndex[outDim] + 1; } // En caso de que tenga que pedir todo un bloque de outDim-1 o más. if ( inputStartIndex[outDim] != inputEndIndex[outDim] ) { inputSize[outDim-1] = inputLargSize[outDim-1]; inputStartIndex[outDim-1] = inputLargIndex[outDim-1]; } region.SetSize(inputSize); region.SetIndex(inputStartIndex); InputImagePointer input = const_cast< TInputImage * > ( this->GetInput() ); input->SetRequestedRegion (region); } } template void JoinDimensionsImageFilter ::GenerateData() { // Get pointers to the input and output OutputImagePointer output = this->GetOutput(); InputImagePointer input = const_cast< TInputImage * >( this->GetInput()); // Shift the output's buffer region typename TOutputImage::RegionType region; typename TInputImage::IndexType inputIndex; typename TInputImage::SizeType inputSize; typename TInputImage::SizeType inputLargestSize; typename TOutputImage::SizeType outputSize; typename TOutputImage::IndexType outputIndex; inputIndex = this->GetInput()->GetBufferedRegion().GetIndex(); inputSize = this->GetInput()->GetBufferedRegion().GetSize(); inputLargestSize = this->GetInput()->GetLargestPossibleRegion().GetSize(); // Output size is always the same as input size for(int i = 0; iSetBufferedRegion(region); // No need to copy the bulk data output->SetPixelContainer(input->GetPixelContainer()); } /** * */ template void JoinDimensionsImageFilter ::PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf(os,indent); } } // end namespace itk #endif