IGSTK
igstkUltrasoundImageSimulator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkUltrasoundImageSimulator.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:51 $
7  Version: $Revision: 1.4 $
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 __igstkUltrasoundImageSimulator_h
18 #define __igstkUltrasoundImageSimulator_h
19 
20 #include "igstkMacros.h"
22 #include "igstkUSImageObject.h"
23 #include "igstkStateMachine.h"
24 
25 
26 #include "vtkImageReslice.h"
27 #include "itkVTKImageImport.h"
28 #include "vtkImageExport.h"
29 
30 namespace igstk
31 {
32 
33 namespace Friends
34 {
35 
48 {
49 
50 public:
51  template < class TUltrasoundImageSimulator, class TImageSpatialObject >
52  static void
53  GetVTKImage( const TImageSpatialObject * imageSpatialObject,
54  TUltrasoundImageSimulator * ultrasoundImageSimulator )
55  {
56  ultrasoundImageSimulator->SetImage(imageSpatialObject->GetVTKImageData());
57  }
58 
59  template < class TUltrasoundImageSimulator, class TImageSpatialObject >
60  static void
61  SetITKImage( const TUltrasoundImageSimulator * simulator,
62  TImageSpatialObject * imageSpatialObject )
63  {
64  imageSpatialObject->RequestSetImage( simulator->GetITKImage() );
65  }
66 
67 }; // end of UltrasoundImageSimulatorToImageSpatialObject class
68 
69 } // end of Friend namespace
70 
71 
87 template < class TImageGeometricModel >
89 {
90 
91 public:
92 
96 
97 public:
98 
99  typedef TImageGeometricModel ImageGeometricModelType;
100  typedef Transform TransformType;
101 
102 
104  void RequestSetTransform( const TransformType & transform );
105 
107  void RequestSetImageGeometricModel( const ImageGeometricModelType *
108  imageGeometricObject );
109 
111  void RequestReslice();
112 
114  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
115 
118  igstkFriendClassMacro( igstk::Friends::\
119  UltrasoundImageSimulatorToImageSpatialObject );
120 
122  void RequestGetImage();
123 
125  igstkLoadedObjectEventMacro( ImageModifiedEvent, IGSTKEvent, USImageObject);
126 
127 protected:
128 
131 
133  ~UltrasoundImageSimulator();
134 
136  typedef typename ImageGeometricModelType::ConstPointer
138 
139  typedef typename ImageGeometricModelType::PointType PointType;
140  typedef typename USImageObject::ImageType USImageType;
141  typedef typename ImageGeometricModelType::ImageType MRImageType;
142 
143 private:
144 
145  UltrasoundImageSimulator(const Self&); // purposely not implemented
146  void operator=(const Self&); // purposely not implemented
147 
149  ImageGeometricModelConstPointer m_ImageGeometricModel;
150  ImageGeometricModelConstPointer m_ImageGeometricModelToAdd;
151 
153  vtkImageData * m_ImageData;
154  vtkImageData * m_ReslicedImageData;
155  vtkImageReslice * m_ImageReslice;
156 
157  typedef itk::VTKImageImport<MRImageType> VTKImageImporterType;
158 
159  typename VTKImageImporterType::Pointer m_VTKImageImporter;
160 
161  TransformType m_Transform;
162  TransformType m_TransformToBeSet;
163 
164  USImageObject::Pointer m_USImage;
165  USImageType::Pointer m_RescaledUSImage;
166  vtkImageExport* m_VTKExporter;
167 
169  void NoProcessing();
170 
173  void SetImageGeometricModelProcessing();
174 
176  void SetTransformProcessing();
177 
179  void ResliceProcessing ();
180 
183  void SetImage( const vtkImageData * image );
184 
186  void ReportImageProcessing();
187 
190  igstkObserverMacro( VTKImage, VTKImageModifiedEvent,
191  EventHelperType::VTKImagePointerType);
192 
193 private:
194 
196  igstkDeclareInputMacro( ValidImageSpatialObject );
197  igstkDeclareInputMacro( NullImageSpatialObject );
198 
199  igstkDeclareInputMacro( ValidTransform );
200  igstkDeclareInputMacro( InvalidTransform );
201 
202  igstkDeclareInputMacro( EmptyImageSpatialObject );
203  igstkDeclareInputMacro( ConnectVTKPipeline );
204 
205  igstkDeclareInputMacro( Reslice );
206  igstkDeclareInputMacro( GetImage );
207 
209  igstkDeclareStateMacro( NullImageSpatialObject );
210  igstkDeclareStateMacro( ValidImageSpatialObject );
211 
212  igstkDeclareStateMacro( NullTransform );
213  igstkDeclareStateMacro( ValidTransform );
214 
215  // FIXME : This must be replaced with StateMachine logic
216  const USImageType * GetITKImage() const;
217 
218  typename VTKImageObserver::Pointer m_VTKImageObserver;
219 
220 };
221 
222 } // end namespace igstk
223 
224 #ifndef IGSTK_MANUAL_INSTANTIATION
225 #include "igstkUltrasoundImageSimulator.txx"
226 #endif
227 
228 
229 #endif // __igstkUltrasoundImageSimulator_h
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print the object information in a stream.
void RequestSetImageGeometricModel(const ImageGeometricModelType *imageGeometricObject)
Connect this representation class to the spatial object.
#define igstkFriendClassMacro(type)
Create a Macro for friend class.
Definition: igstkMacros.h:137
#define igstkStandardTemplatedClassTraitsMacro(classname, superclassname)
Convenience macro for the traits of a templated class.
Definition: igstkMacros.h:286
ImageGeometricModelType::PointType PointType
ImageGeometricModelType::ImageType MRImageType
Base class for all the IGSTK classes.
Definition: igstkObject.h:40
void RequestGetImage()
Declare the UltrasoundImageSimulator class to be a friend in order to give it access to the private m...
defines standard system-wide macros, constants, and other common parameters in the IGSTK Library...
void RequestReslice()
Request reslice a 3D image.
::itk::SmartPointer< Self > Pointer
Definition: igstkObject.h:50
static void GetVTKImage(const TImageSpatialObject *imageSpatialObject, TUltrasoundImageSimulator *ultrasoundImageSimulator)
A class representing a 3D Rigid transform.
void RequestSetTransform(const TransformType &transform)
Request to set vector 2 on the plane.
Represents an Ultrasound Image Object in physical space.
igstkLoadedObjectEventMacro(ImageModifiedEvent, IGSTKEvent, USImageObject)
Event type.
static void SetITKImage(const TUltrasoundImageSimulator *simulator, TImageSpatialObject *imageSpatialObject)
ImageGeometricModelType::ConstPointer ImageGeometricModelConstPointer
Types required for internal implementation.
This class is intended to make the connection between the UltrasoundImageSimulator and its output the...
::itk::SmartPointer< const Self > ConstPointer
Definition: igstkObject.h:51
igstkStandardTemplatedClassTraitsMacro(UltrasoundImageSimulator, Object) public typedef Transform TransformType
Macro with standard traits declarations.
vtkImageData * VTKImagePointerType
Definition: igstkEvents.h:61
This class simulates an ultrasound image by extracting a slice from a 3D MR or CT image...