IGSTK
|
00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkImageSpatialObject.h,v $ 00005 Language: C++ 00006 Date: $Date: 2010-10-29 21:06:42 $ 00007 Version: $Revision: 1.16 $ 00008 00009 Copyright (c) ISC Insight Software Consortium. All rights reserved. 00010 See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __igstkImageSpatialObject_h 00018 #define __igstkImageSpatialObject_h 00019 00020 #include "igstkSpatialObject.h" 00021 00022 #include "itkImageSpatialObject.h" 00023 00024 // itkOrientedImage was remove and consolidated into itkImage since itk V4.0 00025 #ifdef ITK_PRE4_VERSION 00026 #include "itkOrientedImage.h" 00027 #else 00028 #include "itkImage.h" 00029 #endif 00030 00031 #include "itkVTKImageExport.h" 00032 #include "vtkImageImport.h" 00033 #include "vtkImageData.h" 00034 00035 namespace igstk 00036 { 00037 00038 namespace Friends 00039 { 00040 class ImageReaderToImageSpatialObject; 00041 class UltrasoundImageSimulatorToImageSpatialObject; 00042 } 00043 00044 00057 template < class TPixelType, unsigned int TDimension > 00058 class ImageSpatialObject 00059 : public SpatialObject 00060 { 00061 00062 public: 00063 00065 igstkStandardTemplatedClassTraitsMacro( ImageSpatialObject, SpatialObject ) 00066 00067 public: 00068 00069 typedef itk::ImageSpatialObject< TDimension, TPixelType > 00070 ImageSpatialObjectType; 00071 00072 #ifdef ITK_PRE4_VERSION 00073 typedef typename itk::OrientedImage< TPixelType, TDimension > ImageType; 00074 #else 00075 typedef typename itk::Image< TPixelType, TDimension > ImageType; 00076 #endif 00077 00078 typedef typename ImageType::ConstPointer ImageConstPointer; 00079 typedef typename ImageSpatialObjectType::PointType PointType; 00080 typedef typename ImageType::IndexType IndexType; 00081 typedef typename itk::ContinuousIndex< double, 3 > ContinuousIndexType; 00082 00084 virtual bool IsInside( const PointType & point ) const; 00085 00087 virtual void TransformIndexToPhysicalPoint ( const IndexType & index, 00088 PointType & point ) const; 00089 00091 virtual bool TransformPhysicalPointToIndex ( const PointType & point, 00092 IndexType & index ) const; 00093 00095 virtual bool TransformPhysicalPointToContinuousIndex ( 00096 const PointType & point, 00097 ContinuousIndexType & index ) const; 00098 00100 virtual bool IsEmpty() const; 00101 00104 igstkFriendClassMacro( igstk::Friends::ImageReaderToImageSpatialObject ); 00105 00108 igstkFriendClassMacro( 00109 igstk::Friends::UltrasoundImageSimulatorToImageSpatialObject ); 00110 00113 void RequestGetITKImage(); 00114 void RequestGetITKImage() const; 00115 00118 void RequestGetVTKImage(); 00119 void RequestGetVTKImage() const; 00120 00123 void RequestGetImageExtent(); 00124 void RequestGetImageExtent() const; 00125 00130 void RequestGetImageTransform(); 00131 void RequestGetImageTransform() const; 00132 00134 igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent, 00135 IGSTKEvent, ImageType); 00136 00137 igstkEventMacro( ImageNotAvailableEvent, IGSTKErrorEvent ); 00138 00139 protected: 00140 00144 virtual bool IsInternalTransformRequired(); 00145 00149 virtual Transform GetInternalTransform() const; 00150 00151 ImageSpatialObject( void ); 00152 ~ImageSpatialObject( void ); 00153 00155 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 00156 00157 private: 00158 00160 typename ImageSpatialObjectType::Pointer m_ImageSpatialObject; 00161 00163 void RequestSetImage( const ImageType * image ); 00164 00166 igstkLoggerMacro(); 00167 00168 00169 private: 00170 00173 ImageSpatialObject(const Self&); //purposely not implemented 00174 void operator=(const Self&); //purposely not implemented 00175 00176 private: 00177 00179 igstkDeclareInputMacro( ValidImage ); 00180 igstkDeclareInputMacro( InvalidImage ); 00181 igstkDeclareInputMacro( RequestITKImage ); 00182 igstkDeclareInputMacro( RequestVTKImage ); 00183 igstkDeclareInputMacro( RequestImageExtent ); 00184 igstkDeclareInputMacro( RequestImageTransform ); 00185 00187 igstkDeclareStateMacro( Initial ); 00188 igstkDeclareStateMacro( ImageSet ); 00189 00191 void SetImageProcessing(); 00192 void ReportInvalidImageProcessing(); 00193 00195 void ReportITKImageProcessing(); 00196 void ReportVTKImageProcessing(); 00197 void ReportImageExtentProcessing(); 00198 void ReportImageNotAvailableProcessing(); 00199 00203 void ReportImageTransformProcessing(); 00204 00207 ImageConstPointer m_ImageToBeSet; 00208 ImageConstPointer m_Image; 00209 00212 typedef itk::VTKImageExport< ImageType > ITKExportFilterType; 00213 typedef vtkImageImport VTKImportFilterType; 00214 00215 typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer; 00216 typedef VTKImportFilterType * VTKImportFilterPointer; 00217 00219 ITKExportFilterPointer m_ItkExporter; 00220 VTKImportFilterPointer m_VtkImporter; 00221 00222 Transform m_ImageTransform; 00223 CoordinateSystem::Pointer m_DICOMCoordinateSystem; 00224 00225 }; 00226 00227 } // end namespace igstk 00228 00229 #ifndef IGSTK_MANUAL_INSTANTIATION 00230 #include "igstkImageSpatialObject.txx" 00231 #endif 00232 00233 #endif // __igstkImageSpatialObject_h