00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #ifndef IMAGESOURCE_H_HEADER_INCLUDED_C1E7D6EC 00020 #define IMAGESOURCE_H_HEADER_INCLUDED_C1E7D6EC 00021 00022 #include "mitkCommon.h" 00023 #include "mitkBaseProcess.h" 00024 #include "mitkImage.h" 00025 00026 namespace mitk { 00027 00028 //##Documentation 00029 //## @brief Superclass of all classes generating Images (instances of class 00030 //## Image) as output. 00031 //## 00032 //## In itk and vtk the generated result of a ProcessObject is only guaranteed 00033 //## to be up-to-date, when Update() of the ProcessObject or the generated 00034 //## DataObject is called immediately before access of the data stored in the 00035 //## DataObject. This is also true for subclasses of mitk::BaseProcess and thus 00036 //## for mitk::ImageSource. But there are also three access methods provided 00037 //## that guarantee an up-to-date result (by first calling Update and then 00038 //## returning the result of GetOutput()): GetData(), GetPic() and 00039 //## GetVtkImageData(). 00040 //## @ingroup Process 00041 class MITK_CORE_EXPORT ImageSource : public BaseProcess 00042 { 00043 public: 00044 mitkClassMacro(ImageSource,BaseProcess); 00045 00047 typedef itk::DataObject::Pointer DataObjectPointer; 00048 00050 itkNewMacro(Self); 00051 00053 typedef mitk::Image OutputImageType; 00054 typedef OutputImageType::Pointer OutputImagePointer; 00055 typedef SlicedData::RegionType OutputImageRegionType; 00056 00058 OutputImageType * GetOutput(void); 00059 OutputImageType * GetOutput(unsigned int idx); 00060 00066 void SetOutput(OutputImageType *output); 00067 00104 virtual void GraftOutput(OutputImageType *output); 00105 00114 virtual void GraftNthOutput(unsigned int idx, OutputImageType *output); 00115 00131 virtual DataObjectPointer MakeOutput(unsigned int idx); 00132 virtual void* GetData(); 00133 00134 virtual mitkIpPicDescriptor* GetPic(); 00135 00136 virtual vtkImageData* GetVtkImageData(); 00137 00138 protected: 00139 ImageSource(); 00140 virtual ~ImageSource() {} 00141 00159 virtual void GenerateData(); 00160 00185 virtual 00186 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, 00187 int threadId ); 00188 00189 00197 virtual void PrepareOutputs(); 00198 00206 virtual void AllocateOutputs(); 00207 00219 virtual void BeforeThreadedGenerateData() {}; 00220 00233 virtual void AfterThreadedGenerateData() {}; 00234 00242 virtual 00243 int SplitRequestedRegion(int i, int num, OutputImageRegionType& splitRegion); 00244 00249 static ITK_THREAD_RETURN_TYPE ThreaderCallback( void *arg ); 00250 00252 struct ThreadStruct 00253 { 00254 Pointer Filter; 00255 }; 00256 00257 private: 00258 void operator=(const Self&); //purposely not implemented 00259 }; 00260 00261 } // namespace mitk 00262 00263 #endif /* IMAGESOURCE_H_HEADER_INCLUDED_C1E7D6EC */