ITK  4.2.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"
33 
34 namespace itk
35 {
63 template< class TOutputImage >
64 class ITK_EXPORT ImageSource:public ProcessObject
65 {
66 public:
68  typedef ImageSource Self;
72 
75 
76  typedef Superclass::DataObjectIdentifierType DataObjectIdentifierType;
77  typedef Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
78 
80  itkTypeMacro(ImageSource, ProcessObject);
81 
83  typedef TOutputImage OutputImageType;
84  typedef typename OutputImageType::Pointer OutputImagePointer;
85  typedef typename OutputImageType::RegionType OutputImageRegionType;
86  typedef typename OutputImageType::PixelType OutputImagePixelType;
87 
89  itkStaticConstMacro(OutputImageDimension, unsigned int,
90  TOutputImage::ImageDimension);
91 
139  OutputImageType * GetOutput(void);
140  const OutputImageType * GetOutput(void) const;
142 
143  OutputImageType * GetOutput(unsigned int idx);
144 
180  virtual void GraftOutput(DataObject *output);
181 
187  virtual void GraftOutput(const DataObjectIdentifierType & key, DataObject *output);
188 
195  virtual void GraftNthOutput(unsigned int idx, DataObject *output);
196 
210  using Superclass::MakeOutput;
213 
214 protected:
215  ImageSource();
216  virtual ~ImageSource() {}
217 
233  virtual void GenerateData();
234 
257  virtual
258  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
259  ThreadIdType threadId);
260 
266  virtual void AllocateOutputs();
267 
278  virtual void BeforeThreadedGenerateData() {}
279 
290  virtual void AfterThreadedGenerateData() {}
291 
297  virtual
298  unsigned int SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType & splitRegion);
299 
303  static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg);
304 
307  struct ThreadStruct {
309  };
310 private:
311  ImageSource(const Self &); //purposely not implemented
312  void operator=(const Self &); //purposely not implemented
313 };
314 } // end namespace itk
316 
317 // Define instantiation macro for this template.
318 #define ITK_TEMPLATE_ImageSource(_, EXPORT, TypeX, TypeY) \
319  namespace itk \
320  { \
321  _( 1 ( class EXPORT ImageSource< ITK_TEMPLATE_1 TypeX > ) ) \
322  namespace Templates \
323  { \
324  typedef ImageSource< ITK_TEMPLATE_1 TypeX > ImageSource##TypeY; \
325  } \
326  }
327 
328 #if ITK_TEMPLATE_EXPLICIT
329 #include "Templates/itkImageSource+-.h"
330 #endif
331 
332 #if ITK_TEMPLATE_TXX
333 #include "itkImageSource.hxx"
334 #endif
335 
336 #endif
337