ITK  4.2.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;
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  unsigned long 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 
120  itkGetObjectMacro(Interpolator, InterpolatorType);
121 protected:
122  ImageSpatialObject(const Self &); //purposely not implemented
123  void operator=(const Self &); //purposely not implemented
124 
126 
128  virtual ~ImageSpatialObject();
129 
130  void PrintSelf(std::ostream & os, Indent indent) const;
131 
133  std::string m_PixelType;
134 
136  template <typename T>
137  void InternalSetPixelType(const T *)
138  {
139  itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized");
140  }
141  void InternalSetPixelType(const short *)
142  {
143  m_PixelType = "short";
144  }
145  void InternalSetPixelType(const unsigned char *)
146  {
147  m_PixelType = "unsigned char";
148  }
149  void InternalSetPixelType(const unsigned short *)
150  {
151  m_PixelType = "unsigned short";
152  }
153  void InternalSetPixelType(const float *)
154  {
155  m_PixelType = "float";
156  }
157  void InternalSetPixelType(const double *)
158  {
159  m_PixelType = "double";
160  }
161 };
162 } // end of namespace itk
163 
164 #ifndef ITK_MANUAL_INSTANTIATION
165 #include "itkImageSpatialObject.hxx"
166 #endif
167 
168 #endif //__itkImageSpatialObject_h
169