ITK  4.4.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  class TPixelType = unsigned char
39  >
40 class ITK_EXPORT ImageSpatialObject:
41  public SpatialObject< TDimension >
42 {
43 public:
44 
45  typedef double ScalarType;
50 
51  typedef TPixelType PixelType;
54  typedef typename ImageType::IndexType IndexType;
56  typedef typename Superclass::TransformType TransformType;
57  typedef typename Superclass::PointType PointType;
58  typedef typename Superclass::BoundingBoxType BoundingBoxType;
60 
63 
66 
68  itkNewMacro(Self);
69 
71  itkTypeMacro(ImageSpatialObject, SpatialObject);
72 
74  void SetImage(const ImageType *image);
75 
77  const ImageType * GetImage(void) const;
78 
81  bool IsEvaluableAt(const PointType & point,
82  unsigned int depth = 0, char *name = NULL) const;
83 
87  bool ValueAt(const PointType & point, double & value,
88  unsigned int depth = 0, char *name = NULL) const;
89 
91  bool IsInside(const PointType & point,
92  unsigned int depth, char *name) const;
93 
97  bool IsInside(const PointType & point) const;
98 
100  bool ComputeLocalBoundingBox() const;
101 
103  ModifiedTimeType GetMTime(void) const;
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;
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
170