IGSTK
igstkImageSpatialObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkImageSpatialObject.h,v $
5  Language: C++
6  Date: $Date: 2010-10-29 21:06:42 $
7  Version: $Revision: 1.16 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __igstkImageSpatialObject_h
18 #define __igstkImageSpatialObject_h
19 
20 #include "igstkSpatialObject.h"
21 
22 #include "itkImageSpatialObject.h"
23 
24 // itkOrientedImage was remove and consolidated into itkImage since itk V4.0
25 #ifdef ITK_PRE4_VERSION
26 #include "itkOrientedImage.h"
27 #else
28 #include "itkImage.h"
29 #endif
30 
31 #include "itkVTKImageExport.h"
32 #include "vtkImageImport.h"
33 #include "vtkImageData.h"
34 
35 namespace igstk
36 {
37 
38 namespace Friends
39 {
40 class ImageReaderToImageSpatialObject;
41 class UltrasoundImageSimulatorToImageSpatialObject;
42 }
43 
44 
57 template < class TPixelType, unsigned int TDimension >
59 : public SpatialObject
60 {
61 
62 public:
63 
66 
67 public:
68 
69  typedef itk::ImageSpatialObject< TDimension, TPixelType >
70  ImageSpatialObjectType;
71 
72 #ifdef ITK_PRE4_VERSION
73  typedef typename itk::OrientedImage< TPixelType, TDimension > ImageType;
74 #else
75  typedef typename itk::Image< TPixelType, TDimension > ImageType;
76 #endif
77 
78  typedef typename ImageType::ConstPointer ImageConstPointer;
80  typedef typename ImageType::IndexType IndexType;
81  typedef typename itk::ContinuousIndex< double, 3 > ContinuousIndexType;
82 
84  virtual bool IsInside( const PointType & point ) const;
85 
87  virtual void TransformIndexToPhysicalPoint ( const IndexType & index,
88  PointType & point ) const;
89 
91  virtual bool TransformPhysicalPointToIndex ( const PointType & point,
92  IndexType & index ) const;
93 
96  const PointType & point,
97  ContinuousIndexType & index ) const;
98 
100  virtual bool IsEmpty() const;
101 
105 
110 
113  void RequestGetITKImage();
114  void RequestGetITKImage() const;
115 
118  void RequestGetVTKImage();
119  void RequestGetVTKImage() const;
120 
123  void RequestGetImageExtent();
124  void RequestGetImageExtent() const;
125 
131  void RequestGetImageTransform() const;
132 
134  igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent,
135  IGSTKEvent, ImageType);
136 
137  igstkEventMacro( ImageNotAvailableEvent, IGSTKErrorEvent );
138 
139 protected:
140 
144  virtual bool IsInternalTransformRequired();
145 
149  virtual Transform GetInternalTransform() const;
150 
151  ImageSpatialObject( void );
152  ~ImageSpatialObject( void );
153 
155  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
156 
157 private:
158 
160  typename ImageSpatialObjectType::Pointer m_ImageSpatialObject;
161 
163  void RequestSetImage( const ImageType * image );
164 
167 
168 
169 private:
170 
173  ImageSpatialObject(const Self&); //purposely not implemented
174  void operator=(const Self&); //purposely not implemented
175 
176 private:
177 
179  igstkDeclareInputMacro( ValidImage );
180  igstkDeclareInputMacro( InvalidImage );
181  igstkDeclareInputMacro( RequestITKImage );
182  igstkDeclareInputMacro( RequestVTKImage );
183  igstkDeclareInputMacro( RequestImageExtent );
184  igstkDeclareInputMacro( RequestImageTransform );
185 
187  igstkDeclareStateMacro( Initial );
188  igstkDeclareStateMacro( ImageSet );
189 
191  void SetImageProcessing();
192  void ReportInvalidImageProcessing();
193 
195  void ReportITKImageProcessing();
196  void ReportVTKImageProcessing();
197  void ReportImageExtentProcessing();
198  void ReportImageNotAvailableProcessing();
199 
203  void ReportImageTransformProcessing();
204 
207  ImageConstPointer m_ImageToBeSet;
208  ImageConstPointer m_Image;
209 
212  typedef itk::VTKImageExport< ImageType > ITKExportFilterType;
213  typedef vtkImageImport VTKImportFilterType;
214 
215  typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer;
216  typedef VTKImportFilterType * VTKImportFilterPointer;
217 
219  ITKExportFilterPointer m_ItkExporter;
220  VTKImportFilterPointer m_VtkImporter;
221 
222  Transform m_ImageTransform;
223  CoordinateSystem::Pointer m_DICOMCoordinateSystem;
224 
225 };
226 
227 } // end namespace igstk
228 
229 #ifndef IGSTK_MANUAL_INSTANTIATION
230 #include "igstkImageSpatialObject.txx"
231 #endif
232 
233 #endif // __igstkImageSpatialObject_h