ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkImageSource.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkImageSource_h
29 #define __itkImageSource_h
30 
31 #include "itkProcessObject.h"
32 #include "itkImage.h"
34 
35 namespace itk
36 {
37 
50 struct ITKCommon_EXPORT ImageSourceCommon
51 {
55  static const ImageRegionSplitterBase* GetGlobalDefaultSplitter(void);
56 };
57 
85 template< class TOutputImage >
86 class ITK_EXPORT ImageSource
87  : public ProcessObject, private ImageSourceCommon
88 {
89 public:
91  typedef ImageSource Self;
95 
98 
99  typedef Superclass::DataObjectIdentifierType DataObjectIdentifierType;
100  typedef Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
101 
103  itkTypeMacro(ImageSource, ProcessObject);
104 
106  typedef TOutputImage OutputImageType;
107  typedef typename OutputImageType::Pointer OutputImagePointer;
108  typedef typename OutputImageType::RegionType OutputImageRegionType;
109  typedef typename OutputImageType::PixelType OutputImagePixelType;
110 
112  itkStaticConstMacro(OutputImageDimension, unsigned int,
113  TOutputImage::ImageDimension);
114 
162  OutputImageType * GetOutput(void);
163  const OutputImageType * GetOutput(void) const;
165 
166  OutputImageType * GetOutput(unsigned int idx);
167 
203  virtual void GraftOutput(DataObject *output);
204 
210  virtual void GraftOutput(const DataObjectIdentifierType & key, DataObject *output);
211 
218  virtual void GraftNthOutput(unsigned int idx, DataObject *output);
219 
233  using Superclass::MakeOutput;
236 
237 protected:
238  ImageSource();
239  virtual ~ImageSource() {}
240 
256  virtual void GenerateData();
257 
280  virtual
281  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
282  ThreadIdType threadId);
283 
289  virtual void AllocateOutputs();
290 
301  virtual void BeforeThreadedGenerateData() {}
302 
313  virtual void AfterThreadedGenerateData() {}
314 
320  static const ImageRegionSplitterBase* GetGlobalDefaultSplitter()
321  {
323  }
324 
335  virtual const ImageRegionSplitterBase* GetImageRegionSplitter(void) const;
336 
351  virtual
352  unsigned int SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType & splitRegion);
353 
357  static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg);
358 
361  struct ThreadStruct {
363  };
364 
365 private:
366  ImageSource(const Self &); //purposely not implemented
367  void operator=(const Self &); //purposely not implemented
368 };
369 } // end namespace itk
370 
371 #ifndef ITK_MANUAL_INSTANTIATION
372 #include "itkImageSource.hxx"
373 #endif
374 
375 #endif
376