ITK  6.0.0
Insight Toolkit
itkImageSpatialObject.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 itkImageSpatialObject_h
19#define itkImageSpatialObject_h
20
21#include "itkImage.h"
22#include "itkContinuousIndex.h"
23#include "itkSpatialObject.h"
25
26namespace itk
27{
39template <unsigned int TDimension = 3, typename TPixelType = unsigned char>
40class ITK_TEMPLATE_EXPORT ImageSpatialObject : public SpatialObject<TDimension>
41{
42public:
43 ITK_DISALLOW_COPY_AND_MOVE(ImageSpatialObject);
44
45 using ScalarType = double;
50
52 using PixelType = TPixelType;
56 using typename Superclass::PointType;
58
60
61 static constexpr unsigned int ObjectDimension = TDimension;
62
64 itkNewMacro(Self);
65
67 itkOverrideGetNameOfClassMacro(ImageSpatialObject);
68
71 void
72 Clear() override;
73
75 void
76 SetImage(const ImageType * image);
77
79 const ImageType *
80 GetImage() const;
81
83 bool
84 IsInsideInObjectSpace(const PointType & point) const override;
85
86 /* Avoid hiding the overload that supports depth and name arguments */
87 using Superclass::IsInsideInObjectSpace;
88
95 bool
97 double & value,
98 unsigned int depth = 0,
99 const std::string & name = "") const override;
100
103 GetMTime() const override;
104
106 itkSetMacro(SliceNumber, IndexType);
107 void
108 SetSliceNumber(unsigned int dimension, int position);
112 itkGetConstMacro(SliceNumber, IndexType);
113 int
114 GetSliceNumber(unsigned int dimension)
115 {
116 return m_SliceNumber[dimension];
117 }
120#if !defined(ITK_LEGACY_REMOVE)
121 itkLegacyMacro(const char * GetPixelTypeName())
122 {
123 return m_PixelType.c_str();
124 }
125#endif
126
128 void
130 itkGetConstMacro(Interpolator, InterpolatorType *);
134 void
135 Update() override;
136
137protected:
139 void
141
144
145 void
146 PrintSelf(std::ostream & os, Indent indent) const override;
147
148 typename LightObject::Pointer
149 InternalClone() const override;
150
151private:
152 ImagePointer m_Image{};
153
154 IndexType m_SliceNumber{};
155
156#if !defined(ITK_LEGACY_REMOVE)
157 std::string m_PixelType{};
158#endif
159
160 typename InterpolatorType::Pointer m_Interpolator{};
161
163 void
165
166#if !defined(ITK_LEGACY_REMOVE)
167 template <typename T>
168 void
169 SetPixelTypeName(const T *)
170 {
171 itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized");
172 }
173
174 void
175 SetPixelTypeName(const short *)
176 {
177 m_PixelType = "short";
178 }
179
180 void
181 SetPixelTypeName(const unsigned char *)
182 {
183 m_PixelType = "unsigned char";
184 }
185
186 void
187 SetPixelTypeName(const unsigned short *)
188 {
189 m_PixelType = "unsigned short";
190 }
191
192 void
193 SetPixelTypeName(const float *)
194 {
195 m_PixelType = "float";
196 }
197
198 void
199 SetPixelTypeName(const double *)
200 {
201 m_PixelType = "double";
202 }
203#endif
204};
205} // end of namespace itk
206
207#ifndef ITK_MANUAL_INSTANTIATION
208# include "itkImageSpatialObject.hxx"
209#endif
210
211#endif // itkImageSpatialObject_h
A templated class holding a point in n-Dimensional image space.
Base class for all data objects in ITK.
Implementation of an image as spatial object.
~ImageSpatialObject() override
void SetInterpolator(InterpolatorType *interpolator)
const ImageType * GetImage() const
ModifiedTimeType GetMTime() const override
void SetImage(const ImageType *image)
void Clear() override
void Update() override
LightObject::Pointer InternalClone() const override
bool IsInsideInObjectSpace(const PointType &point) const override
typename ImageType::ConstPointer ImagePointer
typename ImageType::IndexType IndexType
bool ValueAtInObjectSpace(const PointType &point, double &value, unsigned int depth=0, const std::string &name="") const override
void SetSliceNumber(unsigned int dimension, int position)
int GetSliceNumber(unsigned int dimension)
void ComputeMyBoundingBox() override
void PrintSelf(std::ostream &os, Indent indent) const override
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for all image interpolators.
Nearest neighbor interpolation of a scalar image.
Base class for most ITK classes.
Definition: itkObject.h:62
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Implementation of the composite pattern.
SmartPointer< const Self > ConstPointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105