ITK  5.1.0
Insight 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
69  , private ImageSourceCommon
70 {
71 public:
72  ITK_DISALLOW_COPY_AND_ASSIGN(ImageSource);
73 
75  using Self = ImageSource;
79 
82 
83  using DataObjectIdentifierType = Superclass::DataObjectIdentifierType;
84  using DataObjectPointerArraySizeType = Superclass::DataObjectPointerArraySizeType;
85 
87  itkTypeMacro(ImageSource, ProcessObject);
88 
90  using OutputImageType = TOutputImage;
91  using OutputImagePointer = typename OutputImageType::Pointer;
93  using OutputImagePixelType = typename OutputImageType::PixelType;
94 
96  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
97 
146  GetOutput();
147  const OutputImageType *
148  GetOutput() const;
150 
152  GetOutput(unsigned int idx);
153 
172 
193  virtual void
194  GraftOutput(DataObject * output);
195 
201  virtual void
202  GraftOutput(const DataObjectIdentifierType & key, DataObject * output);
203 
210  virtual void
211  GraftNthOutput(unsigned int idx, DataObject * output);
212 
227  MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override;
229  MakeOutput(const ProcessObject::DataObjectIdentifierType &) override;
231 
232 protected:
233  ImageSource();
234  ~ImageSource() override = default;
235 
251  void
252  GenerateData() override;
253 
257  void
258  ClassicMultiThread(ThreadFunctionType callbackFunction);
259 
301  virtual void
302  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId);
303  virtual void
304  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread);
306 
312  virtual void
313  AllocateOutputs();
314 
325  virtual void
327  {}
328 
339  virtual void
341  {}
342 
348  static const ImageRegionSplitterBase *
350  {
352  }
353 
364  virtual const ImageRegionSplitterBase *
365  GetImageRegionSplitter() const;
366 
381  virtual unsigned int
382  SplitRequestedRegion(unsigned int i, unsigned int pieces, OutputImageRegionType & splitRegion);
383 
388  ThreaderCallback(void * arg);
389 
392  {
394  };
395 
396  void
397  PrintSelf(std::ostream & os, Indent indent) const override;
398 
402  itkGetConstMacro(DynamicMultiThreading, bool);
403  itkSetMacro(DynamicMultiThreading, bool);
404  itkBooleanMacro(DynamicMultiThreading);
406 
408 };
409 } // end namespace itk
410 
411 #ifndef ITK_MANUAL_INSTANTIATION
412 # include "itkImageSource.hxx"
413 #endif
414 
415 #endif
itk::ImageSource< TIntensityImage >::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::ProcessObject::DataObjectIdentifierType
DataObject::DataObjectIdentifierType DataObjectIdentifierType
Definition: itkProcessObject.h:158
itk::ImageSource::AfterThreadedGenerateData
virtual void AfterThreadedGenerateData()
Definition: itkImageSource.h:340
itk::ImageSource::GetGlobalDefaultSplitter
static const ImageRegionSplitterBase * GetGlobalDefaultSplitter()
Returns the default image region splitter.
Definition: itkImageSource.h:349
itkImage.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ProcessObject::DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Definition: itkProcessObject.h:190
itk::ThreadFunctionType
void(*)(void *) ThreadFunctionType
Definition: itkThreadSupport.h:77
itk::ImageSource::m_DynamicMultiThreading
bool m_DynamicMultiThreading
Definition: itkImageSource.h:404
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
itk::ITK_THREAD_RETURN_TYPE ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
Definition: itkThreadSupport.h:82
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkImageSourceCommon.h
itk::ImageSource::ThreadStruct::Filter
Pointer Filter
Definition: itkImageSource.h:393
itk::ImageRegionSplitterBase
Divide an image region into several pieces.
Definition: itkImageRegionSplitterBase.h:58
itkProcessObject.h
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkImageRegionSplitterBase.h
itk::ImageSourceCommon::GetGlobalDefaultSplitter
static const ImageRegionSplitterBase * GetGlobalDefaultSplitter()
itk::ImageSource< TIntensityImage >::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:135
itk::ProcessObject
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:41
itk::ImageSource< TIntensityImage >::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::ImageSource::ThreadStruct
Definition: itkImageSource.h:391
itk::ImageSourceCommon
Secondary base class of ImageSource common between templates.
Definition: itkImageSourceCommon.h:39
itk::DataObject::Pointer
SmartPointer< Self > Pointer
Definition: itkDataObject.h:290
itk::ImageSource::BeforeThreadedGenerateData
virtual void BeforeThreadedGenerateData()
Definition: itkImageSource.h:326
itk::ImageSource< TIntensityImage >::OutputImageType
TIntensityImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:282