00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkImageSource.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/08/22 12:57:40 $ 00007 Version: $Revision: 1.55 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkImageSource_h 00021 #define __itkImageSource_h 00022 00023 #include "itkProcessObject.h" 00024 #include "itkImage.h" 00025 00026 namespace itk 00027 { 00028 00051 template <class TOutputImage> 00052 class ITK_EXPORT ImageSource : public ProcessObject 00053 { 00054 public: 00056 typedef ImageSource Self; 00057 typedef ProcessObject Superclass; 00058 typedef SmartPointer<Self> Pointer; 00059 typedef SmartPointer<const Self> ConstPointer; 00060 00062 typedef DataObject::Pointer DataObjectPointer; 00063 00065 itkTypeMacro(ImageSource,ProcessObject); 00066 00068 typedef TOutputImage OutputImageType; 00069 typedef typename OutputImageType::Pointer OutputImagePointer; 00070 typedef typename OutputImageType::RegionType OutputImageRegionType; 00071 typedef typename OutputImageType::PixelType OutputImagePixelType; 00072 00113 OutputImageType * GetOutput(void); 00114 OutputImageType * GetOutput(unsigned int idx); 00116 00152 virtual void GraftOutput(DataObject *output); 00153 00160 virtual void GraftNthOutput(unsigned int idx, DataObject *output); 00161 00175 virtual DataObjectPointer MakeOutput(unsigned int idx); 00176 00177 protected: 00178 ImageSource(); 00179 virtual ~ImageSource() {} 00180 00196 virtual void GenerateData(); 00197 00220 virtual 00221 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, 00222 int threadId ) ITK_NO_RETURN; 00223 00224 00230 virtual void AllocateOutputs(); 00231 00242 virtual void BeforeThreadedGenerateData() {}; 00243 00254 virtual void AfterThreadedGenerateData() {}; 00255 00261 virtual 00262 int SplitRequestedRegion(int i, int num, OutputImageRegionType& splitRegion); 00263 00267 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg ); 00268 00270 struct ThreadStruct 00271 { 00272 Pointer Filter; 00273 }; 00274 00275 private: 00276 ImageSource(const Self&); //purposely not implemented 00277 void operator=(const Self&); //purposely not implemented 00278 00279 }; 00280 00281 } // end namespace itk 00282 00283 // Define instantiation macro for this template. 00284 #define ITK_TEMPLATE_ImageSource(_, EXPORT, x, y) namespace itk { \ 00285 _(1(class EXPORT ImageSource< ITK_TEMPLATE_1 x >)) \ 00286 namespace Templates { typedef ImageSource< ITK_TEMPLATE_1 x > ImageSource##y; } \ 00287 } 00288 00289 #if ITK_TEMPLATE_EXPLICIT 00290 # include "Templates/itkImageSource+-.h" 00291 #endif 00292 00293 #if ITK_TEMPLATE_TXX 00294 # include "itkImageSource.txx" 00295 #endif 00296 00297 #endif 00298 00299