ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkImageSpatialObject_h 00019 #define __itkImageSpatialObject_h 00020 00021 #include "itkImage.h" 00022 #include "itkSpatialObject.h" 00023 #include "itkNearestNeighborInterpolateImageFunction.h" 00024 00025 namespace itk 00026 { 00037 template< unsigned int TDimension = 3, 00038 class TPixelType = unsigned char 00039 > 00040 class ITK_EXPORT ImageSpatialObject: 00041 public SpatialObject< TDimension > 00042 { 00043 public: 00044 00045 typedef double ScalarType; 00046 typedef ImageSpatialObject< TDimension, TPixelType > Self; 00047 typedef SpatialObject< TDimension > Superclass; 00048 typedef SmartPointer< Self > Pointer; 00049 typedef SmartPointer< const Self > ConstPointer; 00050 00051 typedef TPixelType PixelType; 00052 typedef Image< PixelType, TDimension > ImageType; 00053 typedef typename ImageType::ConstPointer ImagePointer; 00054 typedef typename ImageType::IndexType IndexType; 00055 typedef typename ImageType::RegionType RegionType; 00056 typedef typename Superclass::TransformType TransformType; 00057 typedef typename Superclass::PointType PointType; 00058 typedef typename Superclass::BoundingBoxType BoundingBoxType; 00059 typedef InterpolateImageFunction< ImageType > InterpolatorType; 00060 00061 typedef NearestNeighborInterpolateImageFunction< ImageType > 00062 NNInterpolatorType; 00063 00064 typedef VectorContainer< IdentifierType, PointType > PointContainerType; 00065 typedef typename PointContainerType::Pointer PointContainerPointer; 00066 00068 itkNewMacro(Self); 00069 00071 itkTypeMacro(ImageSpatialObject, SpatialObject); 00072 00074 void SetImage(const ImageType *image); 00075 00077 const ImageType * GetImage(void) const; 00078 00081 bool IsEvaluableAt(const PointType & point, 00082 unsigned int depth = 0, char *name = NULL) const; 00083 00087 bool ValueAt(const PointType & point, double & value, 00088 unsigned int depth = 0, char *name = NULL) const; 00089 00091 bool IsInside(const PointType & point, 00092 unsigned int depth, char *name) const; 00093 00097 bool IsInside(const PointType & point) const; 00098 00100 bool ComputeLocalBoundingBox() const; 00101 00103 unsigned long GetMTime(void) const; 00104 00106 void SetSlicePosition(unsigned int dimension, int position); 00107 00109 int GetSlicePosition(unsigned int dimension) 00110 { return m_SlicePosition[dimension]; } 00111 00112 const char * GetPixelType() 00113 { 00114 return m_PixelType.c_str(); 00115 } 00116 00118 void SetInterpolator(InterpolatorType *interpolator); 00119 00120 itkGetObjectMacro(Interpolator, InterpolatorType); 00121 protected: 00122 ImageSpatialObject(const Self &); //purposely not implemented 00123 void operator=(const Self &); //purposely not implemented 00124 00125 ImagePointer m_Image; 00126 00127 ImageSpatialObject(); 00128 virtual ~ImageSpatialObject(); 00129 00130 void PrintSelf(std::ostream & os, Indent indent) const; 00131 00132 int * m_SlicePosition; 00133 std::string m_PixelType; 00134 00135 typename InterpolatorType::Pointer m_Interpolator; 00136 template <typename T> 00137 void InternalSetPixelType(const T *) 00138 { 00139 itkWarningMacro("itk::ImageSpatialObject() : PixelType not recognized"); 00140 } 00141 void InternalSetPixelType(const short *) 00142 { 00143 m_PixelType = "short"; 00144 } 00145 void InternalSetPixelType(const unsigned char *) 00146 { 00147 m_PixelType = "unsigned char"; 00148 } 00149 void InternalSetPixelType(const unsigned short *) 00150 { 00151 m_PixelType = "unsigned short"; 00152 } 00153 void InternalSetPixelType(const float *) 00154 { 00155 m_PixelType = "float"; 00156 } 00157 void InternalSetPixelType(const double *) 00158 { 00159 m_PixelType = "double"; 00160 } 00161 }; 00162 } // end of namespace itk 00163 00164 #ifndef ITK_MANUAL_INSTANTIATION 00165 #include "itkImageSpatialObject.hxx" 00166 #endif 00167 00168 #endif //__itkImageSpatialObject_h 00169