/*========================================================================= Program: vv Module: $RCSfile: clitkImageToImageGenericFilter.txx,v $ Language: C++ Date: $Date: 2010/03/24 20:35:08 $ Version: $Revision: 1.9 $ Author : Joel Schaerer David Sarrut Copyright (C) 2008 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr CREATIS-LRMN http://www.creatis.insa-lyon.fr This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =========================================================================*/ // //-------------------------------------------------------------------- // template // void clitk::ImageToImageGenericFilterBase::SetNextOutput(typename ImageType::Pointer output) { // if (mOutputFilenames.size()) // { // clitk::writeImage(output, mOutputFilenames.front(), mIOVerbose); // mOutputFilenames.pop_front(); // } // if (mInputVVImages.size()) //We assume that if a vv image is set as input, we want one as the output // mOutputVVImages.push_back(vvImageFromITK(output)); // } // //-------------------------------------------------------------------- // //-------------------------------------------------------------------- // template // typename ImageType::Pointer clitk::ImageToImageGenericFilterBase::GetInput(unsigned int n) { // if (mInputFilenames.size() > n) { // return clitk::readImage(mInputFilenames[n], mIOVerbose); // } // else if (mInputVVImages.size() > n) // return typename ImageType::Pointer(const_cast(vvImageToITK(mInputVVImages[n]).GetPointer())); // else // { // assert(false); //No input, this shouldn't happen // return typename ImageType::Pointer(NULL); // } // } // //-------------------------------------------------------------------- //-------------------------------------------------------------------- template clitk::ImageToImageGenericFilter::ImageToImageGenericFilter(std::string filterName) : ImageToImageGenericFilterBase(filterName), mImageTypesManager(static_cast(this)) { } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template bool clitk::ImageToImageGenericFilter::Update() { GetInputImageDimensionAndPixelType(mDim,mPixelTypeName,mNbOfComponents); // Check ImageType if (!CheckImageType()) { if (mFailOnImageTypeError) ImageTypeError(); else SetImageTypeError(); return false; } // Go ! Call the right templatized function mImageTypesManager.DoIt(mDim, mNbOfComponents, mPixelTypeName); return true; } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template bool clitk::ImageToImageGenericFilter::CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) { return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[dim][ncomp][pixeltype]); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template bool clitk::ImageToImageGenericFilter::CheckImageType() { return static_cast(mImageTypesManager.mMapOfImageTypeToFunction[mDim][mNbOfComponents][mPixelTypeName]); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- template std::string clitk::ImageToImageGenericFilter::GetAvailableImageTypes() { std::ostringstream oss; oss << "The filter <" << mFilterName << "> manages:" << std::endl; typedef typename ImageTypesManager::MapOfImageComponentsToFunctionType::const_iterator MCompItType; typedef typename ImageTypesManager::MapOfImageDimensionToFunctionType::const_iterator MDimItType; typedef typename ImageTypesManager::MapOfPixelTypeToFunctionType::const_iterator MPixelItType; for (MDimItType i=mImageTypesManager.mMapOfImageTypeToFunction.begin(); i!=mImageTypesManager.mMapOfImageTypeToFunction.end(); i++) { for (MCompItType j=(*i).second.begin(); j!= (*i).second.end(); j++) { for (MPixelItType k=(*j).second.begin(); k!= (*j).second.end(); k++) { oss << "Dim: " << (*i).first; if ((*j).first != 1) oss << ", Components: " << (*j).first; oss << ", Type: " << (*k).first << std::endl; } } } return oss.str(); } //--------------------------------------------------------------------