00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __igstkImageSpatialObject_h
00018 #define __igstkImageSpatialObject_h
00019
00020 #include "igstkSpatialObject.h"
00021
00022 #include "itkImageSpatialObject.h"
00023 #include "itkOrientedImage.h"
00024
00025 #include "itkVTKImageExport.h"
00026 #include "vtkImageImport.h"
00027 #include "vtkImageData.h"
00028
00029 namespace igstk
00030 {
00031
00032 namespace Friends
00033 {
00034 class ImageReaderToImageSpatialObject;
00035 class UltrasoundImageSimulatorToImageSpatialObject;
00036 }
00037
00038
00051 template < class TPixelType, unsigned int TDimension >
00052 class ImageSpatialObject
00053 : public SpatialObject
00054 {
00055
00056 public:
00057
00059 igstkStandardTemplatedClassTraitsMacro( ImageSpatialObject, SpatialObject )
00060
00061 public:
00062
00063 typedef itk::ImageSpatialObject< TDimension, TPixelType >
00064 ImageSpatialObjectType;
00065
00066 typedef typename itk::OrientedImage< TPixelType, TDimension > ImageType;
00067 typedef typename ImageType::ConstPointer ImageConstPointer;
00068 typedef typename ImageSpatialObjectType::PointType PointType;
00069 typedef typename ImageType::IndexType IndexType;
00070 typedef typename itk::ContinuousIndex< double, 3 > ContinuousIndexType;
00071
00073 virtual bool IsInside( const PointType & point ) const;
00074
00076 virtual bool TransformPhysicalPointToIndex ( const PointType & point,
00077 IndexType & index ) const;
00078
00080 virtual bool TransformPhysicalPointToContinuousIndex (
00081 const PointType & point,
00082 ContinuousIndexType & index ) const;
00083
00085 virtual bool IsEmpty() const;
00086
00089 igstkFriendClassMacro( igstk::Friends::ImageReaderToImageSpatialObject );
00090
00093 igstkFriendClassMacro(
00094 igstk::Friends::UltrasoundImageSimulatorToImageSpatialObject );
00095
00098 void RequestGetITKImage();
00099 void RequestGetITKImage() const;
00100
00103 void RequestGetVTKImage();
00104 void RequestGetVTKImage() const;
00105
00110 void RequestGetImageTransform();
00111 void RequestGetImageTransform() const;
00112
00114 igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent,
00115 IGSTKEvent, ImageType);
00116
00117 igstkEventMacro( ImageNotAvailableEvent, IGSTKErrorEvent );
00118
00119 protected:
00120
00124 virtual bool IsInternalTransformRequired();
00125
00129 virtual Transform GetInternalTransform() const;
00130
00131 ImageSpatialObject( void );
00132 ~ImageSpatialObject( void );
00133
00135 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
00136
00137 private:
00138
00140 typename ImageSpatialObjectType::Pointer m_ImageSpatialObject;
00141
00143 void RequestSetImage( const ImageType * image );
00144
00146 igstkLoggerMacro();
00147
00148
00149 private:
00150
00153 ImageSpatialObject(const Self&);
00154 void operator=(const Self&);
00155
00156 private:
00157
00159 igstkDeclareInputMacro( ValidImage );
00160 igstkDeclareInputMacro( InvalidImage );
00161 igstkDeclareInputMacro( RequestITKImage );
00162 igstkDeclareInputMacro( RequestVTKImage );
00163 igstkDeclareInputMacro( RequestImageTransform );
00164
00166 igstkDeclareStateMacro( Initial );
00167 igstkDeclareStateMacro( ImageSet );
00168
00170 void SetImageProcessing();
00171 void ReportInvalidImageProcessing();
00172
00174 void ReportITKImageProcessing();
00175 void ReportVTKImageProcessing();
00176 void ReportImageNotAvailableProcessing();
00177
00181 void ReportImageTransformProcessing();
00182
00185 ImageConstPointer m_ImageToBeSet;
00186 ImageConstPointer m_Image;
00187
00190 typedef itk::VTKImageExport< ImageType > ITKExportFilterType;
00191 typedef vtkImageImport VTKImportFilterType;
00192
00193 typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer;
00194 typedef VTKImportFilterType * VTKImportFilterPointer;
00195
00197 ITKExportFilterPointer m_ItkExporter;
00198 VTKImportFilterPointer m_VtkImporter;
00199
00200 Transform m_ImageTransform;
00201 CoordinateSystem::Pointer m_DICOMCoordinateSystem;
00202
00203 };
00204
00205 }
00206
00207 #ifndef IGSTK_MANUAL_INSTANTIATION
00208 #include "igstkImageSpatialObject.txx"
00209 #endif
00210
00211 #endif // __igstkImageSpatialObject_h