ITK  5.4.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 
26 namespace itk
27 {
39 template <unsigned int TDimension = 3, typename TPixelType = unsigned char>
40 class ITK_TEMPLATE_EXPORT ImageSpatialObject : public SpatialObject<TDimension>
41 {
42 public:
43  ITK_DISALLOW_COPY_AND_MOVE(ImageSpatialObject);
44 
45  using ScalarType = double;
50 
52  using PixelType = TPixelType;
55  using IndexType = typename ImageType::IndexType;
56  using typename Superclass::PointType;
58 
60 
61  static constexpr unsigned int ObjectDimension = TDimension;
62 
64  itkNewMacro(Self);
65 
67  itkTypeMacro(ImageSpatialObject, SpatialObject);
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
96  ValueAtInObjectSpace(const PointType & point,
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()) { return m_PixelType.c_str(); }
122 #endif
123 
125  void
126  SetInterpolator(InterpolatorType * interpolator);
127  itkGetConstMacro(Interpolator, InterpolatorType *);
130 protected:
132  void
133  ComputeMyBoundingBox() override;
134 
135  ImageSpatialObject();
136  ~ImageSpatialObject() override;
137 
138  void
139  PrintSelf(std::ostream & os, Indent indent) const override;
140 
141  typename LightObject::Pointer
142  InternalClone() const override;
143 
144 private:
145  ImagePointer m_Image{};
146 
147  IndexType m_SliceNumber{};
148 
149 #if !defined(ITK_LEGACY_REMOVE)
150  std::string m_PixelType{};
151 #endif
152 
153  typename InterpolatorType::Pointer m_Interpolator{};
154 
155 #if !defined(ITK_LEGACY_REMOVE)
156  template <typename T>
157  void
158  SetPixelTypeName(const T *)
159  {
160  itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized");
161  }
162 
163  void
164  SetPixelTypeName(const short *)
165  {
166  m_PixelType = "short";
167  }
168 
169  void
170  SetPixelTypeName(const unsigned char *)
171  {
172  m_PixelType = "unsigned char";
173  }
174 
175  void
176  SetPixelTypeName(const unsigned short *)
177  {
178  m_PixelType = "unsigned short";
179  }
180 
181  void
182  SetPixelTypeName(const float *)
183  {
184  m_PixelType = "float";
185  }
186 
187  void
188  SetPixelTypeName(const double *)
189  {
190  m_PixelType = "double";
191  }
192 #endif
193 };
194 } // end of namespace itk
195 
196 #ifndef ITK_MANUAL_INSTANTIATION
197 # include "itkImageSpatialObject.hxx"
198 #endif
199 
200 #endif // itkImageSpatialObject_h
itk::ImageSpatialObject< TDimension, TPixel >::ScalarType
double ScalarType
Definition: itkImageSpatialObject.h:45
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:93
itkContinuousIndex.h
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itkSpatialObject.h
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::LightObject::Pointer
SmartPointer< Self > Pointer
Definition: itkLightObject.h:62
itkImage.h
itk::SmartPointer< Self >
itk::ImageSpatialObject
Implementation of an image as spatial object.
Definition: itkImageSpatialObject.h:40
itk::ImageSpatialObject::GetSliceNumber
int GetSliceNumber(unsigned int dimension)
Definition: itkImageSpatialObject.h:114
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSpatialObject< TDimension, TPixel >::ImagePointer
typename ImageType::ConstPointer ImagePointer
Definition: itkImageSpatialObject.h:54
itk::point
*par Constraints *The filter requires an 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
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:57
itk::ImageSpatialObject< TDimension, TPixel >::PixelType
TPixel PixelType
Definition: itkImageSpatialObject.h:52
itkNearestNeighborInterpolateImageFunction.h
itk::ImageSpatialObject< TDimension, TPixel >::IndexType
typename ImageType::IndexType IndexType
Definition: itkImageSpatialObject.h:55
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ContinuousIndex
A templated class holding a point in n-Dimensional image space.
Definition: itkContinuousIndex.h:46
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::NearestNeighborInterpolateImageFunction
Nearest neighbor interpolation of a scalar image.
Definition: itkNearestNeighborInterpolateImageFunction.h:39
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293