RTK  1.4.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  * 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 #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_EXPORT ConstantImageSource : public itk::ImageSource<TOutputImage>
52 {
53 public:
59 
61  typedef TOutputImage OutputImageType;
62 
64  typedef typename TOutputImage::PixelType OutputImagePixelType;
65 
67  typedef typename TOutputImage::RegionType OutputImageRegionType;
68 
71 
73  itkNewMacro(Self);
74 
76  typedef typename TOutputImage::SizeType SizeType;
77  typedef typename TOutputImage::IndexType IndexType;
78  typedef typename TOutputImage::SpacingType SpacingType;
79  typedef typename TOutputImage::PointType PointType;
80  typedef typename SizeType::SizeValueType SizeValueType;
81  typedef SizeValueType SizeValueArrayType[TOutputImage::ImageDimension];
82  typedef typename TOutputImage::SpacingValueType SpacingValueType;
83  typedef SpacingValueType SpacingValueArrayType[TOutputImage::ImageDimension];
84  typedef typename TOutputImage::PointValueType PointValueType;
85  typedef PointValueType PointValueArrayType[TOutputImage::ImageDimension];
86  typedef typename TOutputImage::DirectionType DirectionType;
87 
89  itkSetMacro( Size, SizeType );
90  itkGetMacro( Size, SizeType );
91  virtual void SetSize( SizeValueArrayType sizeArray );
92  virtual const SizeValueType * GetSize() const;
94 
96  itkSetMacro( Spacing, SpacingType );
97  itkGetMacro( Spacing, SpacingType );
99 
101  itkSetMacro( Origin, PointType );
102  itkGetMacro( Origin, PointType );
104 
106  itkSetMacro( Direction, DirectionType );
107  itkGetMacro( Direction, DirectionType );
109 
111  itkSetMacro( Index, IndexType );
112  itkGetMacro( Index, IndexType );
114 
116  itkSetMacro(Constant, OutputImagePixelType);
117  itkGetConstMacro(Constant, OutputImagePixelType);
119 
121  void SetInformationFromImage(const itk::ImageBase<TOutputImage::ImageDimension>* image);
122 
123 protected:
125  virtual ~ConstantImageSource() ITK_OVERRIDE;
126  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
127 
128 #if ITK_VERSION_MAJOR<5
129  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
130 #else
131  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) ITK_OVERRIDE;
132 #endif
133 
134  void GenerateOutputInformation() ITK_OVERRIDE;
135 
136  SizeType m_Size;
137  SpacingType m_Spacing;
138  PointType m_Origin;
139  DirectionType m_Direction;
140  IndexType m_Index;
141 
142  OutputImagePixelType m_Constant;
143 
144 private:
145  ConstantImageSource(const ConstantImageSource&); //purposely not implemented
146  void operator=(const ConstantImageSource&); //purposely not implemented
147 };
148 
149 } // end namespace rtk
150 
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "rtkConstantImageSource.hxx"
153 #endif
154 
155 #endif
TOutputImage::IndexType IndexType
TOutputImage::PixelType OutputImagePixelType
TOutputImage::SpacingType SpacingType
TOutputImage::RegionType OutputImageRegionType
Generate an n-dimensional image with constant pixel values.
itk::SmartPointer< const Self > ConstPointer
STL namespace.
itk::ImageSource< TOutputImage > Superclass
itk::SmartPointer< Self > Pointer
TOutputImage::PointType PointType
TOutputImage::SizeType SizeType
unsigned int ThreadIdType
TOutputImage::PointValueType PointValueType
SizeType::SizeValueType SizeValueType
TOutputImage::DirectionType DirectionType
TOutputImage::SpacingValueType SpacingValueType
#define itkSetMacro(name, type)