ITK  6.0.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 
125  virtual const SpacingType &
126  GetSpacingVector() const;
127 
130  virtual void
131  SetDirection(const DirectionType & dir);
132 
133  virtual const DirectionType &
134  GetDirection() const;
135 
142  itkSetMacro(InsideValue, ValueType);
143  itkGetConstMacro(InsideValue, ValueType);
152  itkSetMacro(OutsideValue, ValueType);
153  itkGetConstMacro(OutsideValue, ValueType);
160  virtual void
161  SetOrigin(const PointType & origin);
162 
163  virtual void
164  SetOrigin(const double * origin);
165 
166  virtual void
167  SetOrigin(const float * origin);
168 
169  virtual const double *
170  GetOrigin() const;
171 
172  virtual const PointType &
173  GetOriginPoint() const;
174 
178  itkSetMacro(Index, IndexType);
179  itkGetConstMacro(Index, IndexType);
186  itkSetMacro(ChildrenDepth, unsigned int);
187  itkGetConstMacro(ChildrenDepth, unsigned int);
191  itkSetMacro(Size, SizeType);
192  itkGetConstMacro(Size, SizeType);
197  itkSetMacro(UseObjectValue, bool);
198  itkGetConstMacro(UseObjectValue, bool);
199  itkBooleanMacro(UseObjectValue);
202 protected:
204  ~SpatialObjectToImageFilter() override = default;
205 
206  void
208  {} // do nothing
209  void
210  GenerateData() override;
211 
212  IndexType m_Index{};
213  SizeType m_Size{};
214  double m_Spacing[OutputImageDimension]{};
215  double m_Origin[OutputImageDimension]{};
216  DirectionType m_Direction{};
217 
218  mutable SpacingType m_SpacingVector{};
219  mutable PointType m_OriginPoint{};
220 
221  unsigned int m_ChildrenDepth{};
222 
223  ValueType m_InsideValue{};
224  ValueType m_OutsideValue{};
225 
226  bool m_UseObjectValue{};
227 
228  void
229  PrintSelf(std::ostream & os, Indent indent) const override;
230 
231 private:
232 };
233 } // end namespace itk
234 
235 #ifndef ITK_MANUAL_INSTANTIATION
236 # include "itkSpatialObjectToImageFilter.hxx"
237 #endif
238 
239 #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:68
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:69
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:207
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