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
24namespace itk
25{
40template <typename TInputSpatialObject, typename TOutputImage>
41class ITK_TEMPLATE_EXPORT SpatialObjectToImageFilter : public ImageSource<TOutputImage>
42{
43public:
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
85
86 virtual void
87 SetInput(unsigned int, const InputSpatialObjectType * object);
88
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
129
130 virtual const DirectionType &
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);
196protected:
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
222private:
223};
224} // end namespace itk
225
226#ifndef ITK_MANUAL_INSTANTIATION
227# include "itkSpatialObjectToImageFilter.hxx"
228#endif
229
230#endif
Base class for all process objects that output image data.
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for filters that take a SpatialObject as input and produce an image as output....
virtual void SetOrigin(const PointType &origin)
typename OutputImageType::DirectionType DirectionType
void SetReferenceImage(TReferenceImage *refImage)
virtual const double * GetSpacing() const
virtual void SetOrigin(const float *origin)
typename OutputImageType::IndexType IndexType
virtual const double * GetOrigin() const
typename TInputSpatialObject::ChildrenListType ChildrenListType
virtual void SetSpacing(const SpacingType &spacing)
virtual void SetOrigin(const double *origin)
virtual void SetInput(unsigned int, const InputSpatialObjectType *object)
~SpatialObjectToImageFilter() override=default
const InputSpatialObjectType * GetInput()
virtual void SetInput(const InputSpatialObjectType *input)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual const DirectionType & GetDirection() const
typename OutputImageType::PointType PointType
virtual void SetSpacing(const double *spacing)
typename OutputImageType::SpacingType SpacingType
typename OutputImageType::ValueType ValueType
virtual void SetSpacing(const float *spacing)
typename InputSpatialObjectType::ConstPointer InputSpatialObjectConstPointer
typename OutputImageType::SizeType SizeType
typename InputSpatialObjectType::Pointer InputSpatialObjectPointer
const InputSpatialObjectType * GetInput(unsigned int idx)
virtual void SetDirection(const DirectionType &dir)
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:69
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:70