IGSTK

/build/buildd/igstk-4.2.0/Source/igstkImageSpatialObject.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Image Guided Surgery Software Toolkit
00004   Module:    $RCSfile: igstkImageSpatialObject.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-30 18:24:31 $
00007   Version:   $Revision: 1.15 $
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 #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 void TransformIndexToPhysicalPoint ( const IndexType & index, 
00077                                               PointType & point ) const;
00078 
00080   virtual bool TransformPhysicalPointToIndex ( const PointType & point, 
00081                                              IndexType & index ) const;
00082 
00084   virtual bool TransformPhysicalPointToContinuousIndex ( 
00085                                      const PointType & point, 
00086                                      ContinuousIndexType & index ) const;
00087 
00089   virtual bool IsEmpty() const;
00090 
00093   igstkFriendClassMacro( igstk::Friends::ImageReaderToImageSpatialObject );
00094 
00097   igstkFriendClassMacro( 
00098       igstk::Friends::UltrasoundImageSimulatorToImageSpatialObject );
00099 
00102   void RequestGetITKImage();
00103   void RequestGetITKImage() const;
00104 
00107   void RequestGetVTKImage();
00108   void RequestGetVTKImage() const;
00109 
00112   void RequestGetImageExtent();
00113   void RequestGetImageExtent() const;
00114 
00119   void RequestGetImageTransform();
00120   void RequestGetImageTransform() const;
00121 
00123   igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent, 
00124                                              IGSTKEvent, ImageType);
00125 
00126   igstkEventMacro( ImageNotAvailableEvent, IGSTKErrorEvent );
00127 
00128 protected:
00129 
00133   virtual bool IsInternalTransformRequired();
00134 
00138   virtual Transform GetInternalTransform() const;
00139 
00140   ImageSpatialObject( void );
00141   ~ImageSpatialObject( void );
00142 
00144   virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 
00145 
00146 private:
00147 
00149   typename ImageSpatialObjectType::Pointer       m_ImageSpatialObject;
00150 
00152   void RequestSetImage( const ImageType * image );
00153 
00155   igstkLoggerMacro();
00156 
00157 
00158 private:
00159  
00162   ImageSpatialObject(const Self&);     //purposely not implemented
00163   void operator=(const Self&);         //purposely not implemented
00164 
00165 private:
00166 
00168   igstkDeclareInputMacro( ValidImage );
00169   igstkDeclareInputMacro( InvalidImage );
00170   igstkDeclareInputMacro( RequestITKImage );
00171   igstkDeclareInputMacro( RequestVTKImage );
00172   igstkDeclareInputMacro( RequestImageExtent );
00173   igstkDeclareInputMacro( RequestImageTransform );
00174   
00176   igstkDeclareStateMacro( Initial );
00177   igstkDeclareStateMacro( ImageSet );
00178 
00180   void SetImageProcessing();
00181   void ReportInvalidImageProcessing();
00182 
00184   void ReportITKImageProcessing();
00185   void ReportVTKImageProcessing();
00186   void ReportImageExtentProcessing();
00187   void ReportImageNotAvailableProcessing();
00188 
00192   void ReportImageTransformProcessing();
00193 
00196   ImageConstPointer  m_ImageToBeSet;
00197   ImageConstPointer  m_Image;
00198 
00201   typedef itk::VTKImageExport< ImageType >      ITKExportFilterType;
00202   typedef vtkImageImport                        VTKImportFilterType;
00203 
00204   typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer;
00205   typedef          VTKImportFilterType      *   VTKImportFilterPointer;
00206 
00208   ITKExportFilterPointer             m_ItkExporter;
00209   VTKImportFilterPointer             m_VtkImporter;
00210 
00211   Transform                          m_ImageTransform;
00212   CoordinateSystem::Pointer          m_DICOMCoordinateSystem;  
00213 
00214 };
00215 
00216 } // end namespace igstk
00217 
00218 #ifndef IGSTK_MANUAL_INSTANTIATION
00219 #include "igstkImageSpatialObject.txx"
00220 #endif
00221 
00222 #endif // __igstkImageSpatialObject_h