ITK  4.8.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 "itkSpatialObject.h"
24 
25 namespace itk
26 {
37 template< unsigned int TDimension = 3,
38  typename TPixelType = unsigned char
39  >
41  public SpatialObject< TDimension >
42 {
43 public:
44 
45  typedef double ScalarType;
50 
51  typedef TPixelType PixelType;
54  typedef typename ImageType::IndexType IndexType;
57  typedef typename Superclass::PointType PointType;
60 
63 
66 
68  itkNewMacro(Self);
69 
71  itkTypeMacro(ImageSpatialObject, SpatialObject);
72 
74  void SetImage(const ImageType *image);
75 
77  const ImageType * GetImage() const;
78 
81  bool IsEvaluableAt(const PointType & point,
82  unsigned int depth = 0, char *name = ITK_NULLPTR) const ITK_OVERRIDE;
83 
87  bool ValueAt(const PointType & point, double & value,
88  unsigned int depth = 0, char *name = ITK_NULLPTR) const ITK_OVERRIDE;
89 
91  bool IsInside(const PointType & point,
92  unsigned int depth, char *name) const ITK_OVERRIDE;
93 
97  bool IsInside(const PointType & point) const;
98 
100  bool ComputeLocalBoundingBox() const ITK_OVERRIDE;
101 
103  ModifiedTimeType GetMTime(void) const ITK_OVERRIDE;
104 
106  void SetSlicePosition(unsigned int dimension, int position);
107 
109  int GetSlicePosition(unsigned int dimension)
110  { return m_SlicePosition[dimension]; }
111 
112  const char * GetPixelType()
113  {
114  return m_PixelType.c_str();
115  }
116 
118  void SetInterpolator(InterpolatorType *interpolator);
119  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
121 
122 protected:
123  ImageSpatialObject(const Self &); //purposely not implemented
124  void operator=(const Self &); //purposely not implemented
125 
127 
129  virtual ~ImageSpatialObject();
130 
131  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
132 
134  std::string m_PixelType;
135 
137  template <typename T>
138  void InternalSetPixelType(const T *)
139  {
140  itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized");
141  }
142  void InternalSetPixelType(const short *)
143  {
144  m_PixelType = "short";
145  }
146  void InternalSetPixelType(const unsigned char *)
147  {
148  m_PixelType = "unsigned char";
149  }
150  void InternalSetPixelType(const unsigned short *)
151  {
152  m_PixelType = "unsigned short";
153  }
154  void InternalSetPixelType(const float *)
155  {
156  m_PixelType = "float";
157  }
158  void InternalSetPixelType(const double *)
159  {
160  m_PixelType = "double";
161  }
162 };
163 } // end of namespace itk
164 
165 #ifndef ITK_MANUAL_INSTANTIATION
166 #include "itkImageSpatialObject.hxx"
167 #endif
168 
169 #endif //itkImageSpatialObject_h
Point< ScalarType, VDimension > PointType
Superclass::RegionType RegionType
Definition: itkImage.h:140
ImageType::IndexType IndexType
Image< PixelType, TDimension > ImageType
BoundingBox< IdentifierType, VDimension, ScalarType, VectorContainerType > BoundingBoxType
void PrintSelf(std::ostream &os, Indent indent) const override
void operator=(const Self &)
void SetImage(const ImageType *image)
bool ValueAt(const PointType &point, double &value, unsigned int depth=0, char *name=nullptr) const override
ImageSpatialObject< TDimension, TPixelType > Self
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
int GetSlicePosition(unsigned int dimension)
Nearest neighbor interpolation of a scalar image.
void SetSlicePosition(unsigned int dimension, int position)
Superclass::BoundingBoxType BoundingBoxType
ImageType::ConstPointer ImagePointer
ModifiedTimeType GetMTime(void) const override
void InternalSetPixelType(const double *)
void SetInterpolator(InterpolatorType *interpolator)
InterpolateImageFunction< ImageType > InterpolatorType
PointContainerType::Pointer PointContainerPointer
void InternalSetPixelType(const short *)
const ImageType * GetImage() const
VectorContainer< IdentifierType, PointType > PointContainerType
Superclass::IndexType IndexType
Definition: itkImage.h:122
Implementation of the composite pattern.
SpatialObject< TDimension > Superclass
Superclass::PointType PointType
ImageType::RegionType RegionType
void InternalSetPixelType(const T *)
void InternalSetPixelType(const float *)
Superclass::TransformType TransformType
Base class for all image interpolaters.
SmartPointer< const Self > ConstPointer
Implementation of an image as spatial object.
void InternalSetPixelType(const unsigned short *)
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
ScalableAffineTransform< double, VDimension > TransformType
bool ComputeLocalBoundingBox() const override
SmartPointer< Self > Pointer
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75
NearestNeighborInterpolateImageFunction< ImageType > NNInterpolatorType
InterpolatorType::Pointer m_Interpolator
bool IsEvaluableAt(const PointType &point, unsigned int depth=0, char *name=nullptr) const override
bool IsInside(const PointType &point, unsigned int depth, char *name) const override
void InternalSetPixelType(const unsigned char *)