RTK  2.6.0
Reconstruction Toolkit
rtkConstantImageSource.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK 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  * https://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 #ifndef rtkConstantImageSource_h
20 #define rtkConstantImageSource_h
21 
22 #include "rtkConfiguration.h"
23 #include "rtkMacro.h"
24 
25 #include <itkImageSource.h>
26 #include <itkNumericTraits.h>
28 #include <itkVectorImage.h>
29 
30 namespace rtk
31 {
50 template <typename TOutputImage>
51 class ITK_TEMPLATE_EXPORT ConstantImageSource : public itk::ImageSource<TOutputImage>
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_MOVE(ConstantImageSource);
55 
61 
63  using OutputImageType = TOutputImage;
64 
66  using OutputImagePixelType = typename TOutputImage::PixelType;
67 
69  using OutputImageRegionType = typename TOutputImage::RegionType;
70 
72 #ifdef itkOverrideGetNameOfClassMacro
73  itkOverrideGetNameOfClassMacro(ConstantImageSource);
74 #else
76 #endif
77 
78 
80  itkNewMacro(Self);
81 
83  using SizeType = typename TOutputImage::SizeType;
84  using IndexType = typename TOutputImage::IndexType;
85  using SpacingType = typename TOutputImage::SpacingType;
86  using PointType = typename TOutputImage::PointType;
88  typedef SizeValueType SizeValueArrayType[TOutputImage::ImageDimension];
89  using SpacingValueType = typename TOutputImage::SpacingValueType;
90  typedef SpacingValueType SpacingValueArrayType[TOutputImage::ImageDimension];
91  using PointValueType = typename TOutputImage::PointValueType;
92  typedef PointValueType PointValueArrayType[TOutputImage::ImageDimension];
93  using DirectionType = typename TOutputImage::DirectionType;
94 
97  itkGetMacro(Size, SizeType);
98  virtual void
99  SetSize(SizeValueArrayType sizeArray);
100  virtual const SizeValueType *
101  GetSize() const;
103 
105  itkSetMacro(Spacing, SpacingType);
106  itkGetMacro(Spacing, SpacingType);
108 
110  itkSetMacro(Origin, PointType);
111  itkGetMacro(Origin, PointType);
113 
115  itkSetMacro(Direction, DirectionType);
116  itkGetMacro(Direction, DirectionType);
118 
121  itkGetMacro(Index, IndexType);
123 
126  itkGetConstMacro(Constant, OutputImagePixelType);
128 
130  void
131  SetInformationFromImage(const itk::ImageBase<TOutputImage::ImageDimension> * image);
132 
133 protected:
135  ~ConstantImageSource() override;
136  void
137  PrintSelf(std::ostream & os, itk::Indent indent) const override;
138 
139  void
140  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
141 
142  void
143  GenerateOutputInformation() override;
144 
150 
152 };
153 
154 } // end namespace rtk
155 
156 #ifndef ITK_MANUAL_INSTANTIATION
157 # include "rtkConstantImageSource.hxx"
158 #endif
159 
160 #endif
typename TOutputImage::SizeType SizeType
typename SizeType::SizeValueType SizeValueType
Generate an n-dimensional image with constant pixel values.
typename TOutputImage::SpacingType SpacingType
typename TOutputImage::DirectionType DirectionType
typename TOutputImage::PointValueType PointValueType
typename OutputImageType::PixelType OutputImagePixelType
#define itkSetMacro(name, type)
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename TOutputImage::IndexType IndexType
OutputImagePixelType m_Constant
typename TOutputImage::PointType PointType
itk::SizeValueType SizeValueType
typename TOutputImage::SpacingValueType SpacingValueType