ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkImageSpatialObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 {
38 template< unsigned int TDimension = 3,
39  typename TPixelType = unsigned char
40  >
41 class ITK_TEMPLATE_EXPORT ImageSpatialObject:
42  public SpatialObject< TDimension >
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_ASSIGN(ImageSpatialObject);
46 
47  using ScalarType = double;
52 
54  using PixelType = TPixelType;
57  using IndexType = typename ImageType::IndexType;
59  using TransformType = typename Superclass::TransformType;
60  using PointType = typename Superclass::PointType;
61  using BoundingBoxType = typename Superclass::BoundingBoxType;
63 
65 
68 
69  static constexpr unsigned int ObjectDimension = TDimension;
70 
72  itkNewMacro(Self);
73 
75  itkTypeMacro(ImageSpatialObject, SpatialObject);
76 
78  void SetImage(const ImageType *image);
79 
81  const ImageType * GetImage() const;
82 
84  bool ComputeMyBoundingBox() const override;
85 
87  bool IsInsideInObjectSpace(const PointType & point, unsigned int depth=0,
88  const std::string & name = "") const override;
89 
92  bool ValueAtInObjectSpace(const PointType & point, double & value,
93  unsigned int depth = 0, const std::string & name = "") const override;
94 
96  ModifiedTimeType GetMTime() const override;
97 
99  itkSetMacro( SliceNumber, IndexType );
100  void SetSliceNumber(unsigned int dimension, int position);
102 
104  itkGetConstMacro( SliceNumber, IndexType );
105  int GetSliceNumber(unsigned int dimension)
106  { return m_SliceNumber[dimension]; }
108 
109  const char * GetPixelTypeName()
110  { return m_PixelType.c_str(); }
111 
113  void SetInterpolator(InterpolatorType *interpolator);
114  itkGetConstMacro(Interpolator, InterpolatorType *);
116 
117 protected:
118 
120  ~ImageSpatialObject() override;
121 
122  void PrintSelf(std::ostream & os, Indent indent) const override;
123 
124  typename LightObject::Pointer InternalClone() const override;
125 
126 private:
127 
129 
131  std::string m_PixelType;
132 
134 
135  template <typename T>
136  void SetPixelTypeName(const T *)
137  { itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized"); }
138 
139  void SetPixelTypeName(const short *)
140  { m_PixelType = "short"; }
141 
142  void SetPixelTypeName(const unsigned char *)
143  { m_PixelType = "unsigned char"; }
144 
145  void SetPixelTypeName(const unsigned short *)
146  { m_PixelType = "unsigned short"; }
147 
148  void SetPixelTypeName(const float *)
149  { m_PixelType = "float"; }
150 
151  void SetPixelTypeName(const double *)
152  { m_PixelType = "double"; }
153 
154 };
155 } // end of namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 #include "itkImageSpatialObject.hxx"
159 #endif
160 
161 #endif //itkImageSpatialObject_h
void SetPixelTypeName(const float *)
void SetPixelTypeName(const unsigned short *)
void SetPixelTypeName(const short *)
Nearest neighbor interpolation of a scalar image.
typename ImageType::ConstPointer ImagePointer
Implementation of the composite pattern.
typename Superclass::TransformType TransformType
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:104
typename Superclass::BoundingBoxType BoundingBoxType
void SetPixelTypeName(const double *)
int GetSliceNumber(unsigned int dimension)
Base class for all image interpolaters.
A templated class holding a point in n-Dimensional image space.
Implementation of an image as spatial object.
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename PointContainerType::Pointer PointContainerPointer
Base class for most ITK classes.
Definition: itkObject.h:60
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75
void SetPixelTypeName(const unsigned char *)
InterpolatorType::Pointer m_Interpolator