ITK  5.4.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  * 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 #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;
57  using ValueType = typename OutputImageType::ValueType;
58  using SpacingType = typename OutputImageType::SpacingType;
60 
62  itkNewMacro(Self);
63 
65  itkOverrideGetNameOfClassMacro(SpatialObjectToImageFilter);
66 
68  using typename Superclass::OutputImageRegionType;
69 
71  using InputSpatialObjectType = TInputSpatialObject;
74  using ChildrenListType = typename TInputSpatialObject::ChildrenListType;
75 
77  static constexpr unsigned int ObjectDimension = InputSpatialObjectType::ObjectDimension;
78 
79  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
80 
82  using Superclass::SetInput;
83  virtual void
84  SetInput(const InputSpatialObjectType * input);
85 
86  virtual void
87  SetInput(unsigned int, const InputSpatialObjectType * object);
88 
90  GetInput();
91 
93  GetInput(unsigned int idx);
94 
97  template <class TReferenceImage>
98  void
99  SetReferenceImage(TReferenceImage * refImage)
100  {
101  this->SetOrigin(refImage->GetOrigin());
102  this->SetSpacing(refImage->GetSpacing());
103  this->SetDirection(refImage->GetDirection());
104  this->SetIndex(refImage->GetLargestPossibleRegion().GetIndex());
105  this->SetSize(refImage->GetLargestPossibleRegion().GetSize());
106  }
113  virtual void
114  SetSpacing(const SpacingType & spacing);
115 
116  virtual void
117  SetSpacing(const double * spacing);
118 
119  virtual void
120  SetSpacing(const float * spacing);
121 
122  virtual const double *
123  GetSpacing() const;
124 
127  virtual void
128  SetDirection(const DirectionType & dir);
129 
130  virtual const DirectionType &
131  GetDirection() const;
132 
139  itkSetMacro(InsideValue, ValueType);
140  itkGetConstMacro(InsideValue, ValueType);
149  itkSetMacro(OutsideValue, ValueType);
150  itkGetConstMacro(OutsideValue, ValueType);
157  virtual void
158  SetOrigin(const PointType & origin);
159 
160  virtual void
161  SetOrigin(const double * origin);
162 
163  virtual void
164  SetOrigin(const float * origin);
165 
166  virtual const double *
167  GetOrigin() const;
168 
172  itkSetMacro(Index, IndexType);
173  itkGetConstMacro(Index, IndexType);
180  itkSetMacro(ChildrenDepth, unsigned int);
181  itkGetConstMacro(ChildrenDepth, unsigned int);
185  itkSetMacro(Size, SizeType);
186  itkGetConstMacro(Size, SizeType);
191  itkSetMacro(UseObjectValue, bool);
192  itkGetConstMacro(UseObjectValue, bool);
193  itkBooleanMacro(UseObjectValue);
196 protected:
198  ~SpatialObjectToImageFilter() override = default;
199 
200  void
202  {} // do nothing
203  void
204  GenerateData() override;
205 
206  IndexType m_Index{};
207  SizeType m_Size{};
208  double m_Spacing[OutputImageDimension]{};
209  double m_Origin[OutputImageDimension]{};
210  DirectionType m_Direction{};
211 
212  unsigned int m_ChildrenDepth{};
213 
214  ValueType m_InsideValue{};
215  ValueType m_OutsideValue{};
216 
217  bool m_UseObjectValue{};
218 
219  void
220  PrintSelf(std::ostream & os, Indent indent) const override;
221 
222 private:
223 };
224 } // end namespace itk
225 
226 #ifndef ITK_MANUAL_INSTANTIATION
227 # include "itkSpatialObjectToImageFilter.hxx"
228 #endif
229 
230 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::SpatialObjectToImageFilter::InputSpatialObjectConstPointer
typename InputSpatialObjectType::ConstPointer InputSpatialObjectConstPointer
Definition: itkSpatialObjectToImageFilter.h:73
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:70
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::ChildrenListType
typename TInputSpatialObject::ChildrenListType ChildrenListType
Definition: itkSpatialObjectToImageFilter.h:74
itkImageSource.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
itk::SpatialObjectToImageFilter::InputSpatialObjectType
TInputSpatialObject InputSpatialObjectType
Definition: itkSpatialObjectToImageFilter.h:71
itk::SpatialObjectToImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkSpatialObjectToImageFilter.h:54
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::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkSpatialObjectToImageFilter.h:53
itk::SpatialObjectToImageFilter::PointType
typename OutputImageType::PointType PointType
Definition: itkSpatialObjectToImageFilter.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
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:57
itk::SpatialObjectToImageFilter::SetReferenceImage
void SetReferenceImage(TReferenceImage *refImage)
Definition: itkSpatialObjectToImageFilter.h:99
itk::SpatialObjectToImageFilter::GenerateOutputInformation
void GenerateOutputInformation() override
Definition: itkSpatialObjectToImageFilter.h:201
itk::SpatialObjectToImageFilter::DirectionType
typename OutputImageType::DirectionType DirectionType
Definition: itkSpatialObjectToImageFilter.h:59
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:139
itk::SpatialObjectToImageFilter::InputSpatialObjectPointer
typename InputSpatialObjectType::Pointer InputSpatialObjectPointer
Definition: itkSpatialObjectToImageFilter.h:72
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::SpatialObjectToImageFilter::SpacingType
typename OutputImageType::SpacingType SpacingType
Definition: itkSpatialObjectToImageFilter.h:58