ITK  5.0.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 #include "itkImageSourceCommon.h"
35 
36 namespace itk
37 {
38 
66 template< typename TOutputImage >
67 class ITK_TEMPLATE_EXPORT ImageSource
68  : public ProcessObject, private ImageSourceCommon
69 {
70 public:
71  ITK_DISALLOW_COPY_AND_ASSIGN(ImageSource);
72 
74  using Self = ImageSource;
78 
81 
82  using DataObjectIdentifierType = Superclass::DataObjectIdentifierType;
83  using DataObjectPointerArraySizeType = Superclass::DataObjectPointerArraySizeType;
84 
86  itkTypeMacro(ImageSource, ProcessObject);
87 
89  using OutputImageType = TOutputImage;
90  using OutputImagePointer = typename OutputImageType::Pointer;
92  using OutputImagePixelType = typename OutputImageType::PixelType;
93 
95  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
96 
144  OutputImageType * GetOutput();
145  const OutputImageType * GetOutput() const;
147 
148  OutputImageType * GetOutput(unsigned int idx);
149 
168 
189  virtual void GraftOutput(DataObject *output);
190 
196  virtual void GraftOutput(const DataObjectIdentifierType & key, DataObject *output);
197 
204  virtual void GraftNthOutput(unsigned int idx, DataObject *output);
205 
222 
223 protected:
224  ImageSource();
225  ~ImageSource() override = default;
226 
242  void GenerateData() override;
243 
247  void ClassicMultiThread(ThreadFunctionType callbackFunction);
248 
290  virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
291  ThreadIdType threadId);
292  virtual void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
294 
300  virtual void AllocateOutputs();
301 
312  virtual void BeforeThreadedGenerateData() {}
313 
324  virtual void AfterThreadedGenerateData() {}
325 
332  {
334  }
335 
346  virtual const ImageRegionSplitterBase* GetImageRegionSplitter() const;
347 
362  virtual
363  unsigned int SplitRequestedRegion(unsigned int i, unsigned int pieces, OutputImageRegionType & splitRegion);
364 
368  static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ThreaderCallback(void *arg);
369 
372  {
374  };
375 
376  void PrintSelf(std::ostream & os, Indent indent) const override;
377 
381  itkGetConstMacro(DynamicMultiThreading, bool);
382  itkSetMacro(DynamicMultiThreading, bool);
383  itkBooleanMacro(DynamicMultiThreading);
385 
387 };
388 } // end namespace itk
389 
390 #ifndef ITK_MANUAL_INSTANTIATION
391 #include "itkImageSource.hxx"
392 #endif
393 
394 #endif
void(* ThreadFunctionType)(void *)
DataObject::DataObjectIdentifierType DataObjectIdentifierType
static const ImageRegionSplitterBase * GetGlobalDefaultSplitter()
typename OutputImageType::Pointer OutputImagePointer
Light weight base class for most itk classes.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void BeforeThreadedGenerateData()
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Base class for all process objects that output image data.
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:40
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
Divide an image region into several pieces.
Secondary base class of ImageSource common between templates.
static const ImageRegionSplitterBase * GetGlobalDefaultSplitter()
Returns the default image region splitter.
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
virtual void AfterThreadedGenerateData()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SmartPointer< Self > Pointer
Base class for all data objects in ITK.