ITK  5.2.0
Insight Toolkit
itkSpatialObjectToImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 #ifndef itkSpatialObjectToImageFilter_h
19 #define itkSpatialObjectToImageFilter_h
20 
21 #include "itkImageSource.h"
22 #include "itkConceptChecking.h"
23 
24 namespace itk
25 {
40 template <typename TInputSpatialObject, typename TOutputImage>
41 class ITK_TEMPLATE_EXPORT SpatialObjectToImageFilter : public ImageSource<TOutputImage>
42 {
43 public:
44  ITK_DISALLOW_COPY_AND_MOVE(SpatialObjectToImageFilter);
45 
51 
52  using OutputImageType = TOutputImage;
55  using OutputImagePointer = typename OutputImageType::Pointer;
56  using ValueType = typename OutputImageType::ValueType;
57  using SpacingType = typename OutputImageType::SpacingType;
59 
61  itkNewMacro(Self);
62 
65 
67  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
68 
70  using InputSpatialObjectType = TInputSpatialObject;
71  using InputSpatialObjectPointer = typename InputSpatialObjectType::Pointer;
72  using InputSpatialObjectConstPointer = typename InputSpatialObjectType::ConstPointer;
73  using ChildrenListType = typename TInputSpatialObject::ChildrenListType;
74 
76  static constexpr unsigned int ObjectDimension = InputSpatialObjectType::ObjectDimension;
77 
78  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
79 
81  using Superclass::SetInput;
82  virtual void
83  SetInput(const InputSpatialObjectType * input);
84 
85  virtual void
86  SetInput(unsigned int, const InputSpatialObjectType * object);
87 
89  GetInput();
90 
92  GetInput(unsigned int idx);
93 
96  template <class TReferenceImage>
97  void
98  SetReferenceImage(TReferenceImage * refImage)
99  {
100  this->SetOrigin(refImage->GetOrigin());
101  this->SetSpacing(refImage->GetSpacing());
102  this->SetDirection(refImage->GetDirection());
103  this->SetSize(refImage->GetLargestPossibleRegion().GetSize());
104  }
106 
111  virtual void
112  SetSpacing(const SpacingType & spacing);
113 
114  virtual void
115  SetSpacing(const double * spacing);
116 
117  virtual void
118  SetSpacing(const float * spacing);
119 
120  virtual const double *
121  GetSpacing() const;
122 
125  virtual void
126  SetDirection(const DirectionType & dir);
127 
128  virtual const DirectionType &
129  GetDirection() const;
130 
137  itkSetMacro(InsideValue, ValueType);
138  itkGetConstMacro(InsideValue, ValueType);
140 
147  itkSetMacro(OutsideValue, ValueType);
148  itkGetConstMacro(OutsideValue, ValueType);
150 
155  virtual void
156  SetOrigin(const PointType & origin);
157 
158  virtual void
159  SetOrigin(const double * origin);
160 
161  virtual void
162  SetOrigin(const float * origin);
163 
164  virtual const double *
165  GetOrigin() const;
166 
171  itkSetMacro(ChildrenDepth, unsigned int);
172  itkGetConstMacro(ChildrenDepth, unsigned int);
174 
176  itkSetMacro(Size, SizeType);
177  itkGetConstMacro(Size, SizeType);
179 
182  itkSetMacro(UseObjectValue, bool);
183  itkGetConstMacro(UseObjectValue, bool);
184  itkBooleanMacro(UseObjectValue);
186 
187 protected:
189  ~SpatialObjectToImageFilter() override = default;
190 
191  void
193  {} // do nothing
194  void
195  GenerateData() override;
196 
198  double m_Spacing[OutputImageDimension];
199  double m_Origin[OutputImageDimension];
201 
202  unsigned int m_ChildrenDepth;
203 
206 
208 
209  void
210  PrintSelf(std::ostream & os, Indent indent) const override;
211 
212 private:
213 };
214 } // end namespace itk
215 
216 #ifndef ITK_MANUAL_INSTANTIATION
217 # include "itkSpatialObjectToImageFilter.hxx"
218 #endif
219 
220 #endif
itk::SpatialObjectToImageFilter::InputSpatialObjectConstPointer
typename InputSpatialObjectType::ConstPointer InputSpatialObjectConstPointer
Definition: itkSpatialObjectToImageFilter.h:72
itk::SpatialObjectToImageFilter::m_InsideValue
ValueType m_InsideValue
Definition: itkSpatialObjectToImageFilter.h:204
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::SpatialObjectToImageFilter::m_OutsideValue
ValueType m_OutsideValue
Definition: itkSpatialObjectToImageFilter.h:205
itk::SpatialObjectToImageFilter::ChildrenListType
typename TInputSpatialObject::ChildrenListType ChildrenListType
Definition: itkSpatialObjectToImageFilter.h:73
itkImageSource.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:69
itk::SpatialObjectToImageFilter::InputSpatialObjectType
TInputSpatialObject InputSpatialObjectType
Definition: itkSpatialObjectToImageFilter.h:70
itk::SpatialObjectToImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkSpatialObjectToImageFilter.h:53
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkConceptChecking.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SpatialObjectToImageFilter
Base class for filters that take a SpatialObject as input and produce an image as output....
Definition: itkSpatialObjectToImageFilter.h:41
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SpatialObjectToImageFilter::PointType
typename OutputImageType::PointType PointType
Definition: itkSpatialObjectToImageFilter.h:54
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::SpatialObjectToImageFilter::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkSpatialObjectToImageFilter.h:56
itk::SpatialObjectToImageFilter::m_Size
SizeType m_Size
Definition: itkSpatialObjectToImageFilter.h:197
itk::SpatialObjectToImageFilter::SetReferenceImage
void SetReferenceImage(TReferenceImage *refImage)
Definition: itkSpatialObjectToImageFilter.h:98
itk::SpatialObjectToImageFilter::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: itkSpatialObjectToImageFilter.h:192
itk::SpatialObjectToImageFilter::DirectionType
typename OutputImageType::DirectionType DirectionType
Definition: itkSpatialObjectToImageFilter.h:58
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::SpatialObjectToImageFilter::m_Direction
DirectionType m_Direction
Definition: itkSpatialObjectToImageFilter.h:200
itk::SpatialObjectToImageFilter::m_ChildrenDepth
unsigned int m_ChildrenDepth
Definition: itkSpatialObjectToImageFilter.h:202
itk::SpatialObjectToImageFilter::InputSpatialObjectPointer
typename InputSpatialObjectType::Pointer InputSpatialObjectPointer
Definition: itkSpatialObjectToImageFilter.h:71
itk::SpatialObjectToImageFilter::m_UseObjectValue
bool m_UseObjectValue
Definition: itkSpatialObjectToImageFilter.h:207
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::SpatialObjectToImageFilter::SpacingType
typename OutputImageType::SpacingType SpacingType
Definition: itkSpatialObjectToImageFilter.h:57