IGSTK
igstkImageResliceObjectRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkImageResliceObjectRepresentation.h,v $
5  Language: C++
6  Date: $Date: 2011-02-09 10:13:37 $
7  Version: $Revision: 1.3 $
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 __igstkImageResliceObjectRepresentation_h
18 #define __igstkImageResliceObjectRepresentation_h
19 
20 #include "igstkMacros.h"
23 #include "igstkStateMachine.h"
25 
26 class vtkLookupTable;
27 class vtkImageMapToColors;
28 class vtkImageReslice;
29 class vtkTexture;
30 class vtkActor;
31 class vtkPlaneSource;
32 class vtkOutlineFilter;
33 class vtkPlane;
34 class vtkPolyData;
35 class vtkCutter;
36 class vtkSphereSource;
37 class vtkProperty;
38 class vtkImageMapToColors;
39 
40 
41 namespace igstk
42 {
43 
44 #define VTK_NEAREST_RESLICE 0
45 #define VTK_LINEAR_RESLICE 1
46 #define VTK_CUBIC_RESLICE 2
47 
54 template < class TImageSpatialObject >
56 {
57 
58 public:
59 
63 
64 public:
65 
66  typedef TImageSpatialObject ImageSpatialObjectType;
67 
68  typedef typename ImageSpatialObjectType::ConstPointer
70 
71  typedef typename ImageSpatialObjectType::PointType PointType;
72 
74 
75  typedef ReslicerPlaneType::Pointer ReslicerPlanePointerType;
76 
77  typedef ReslicerPlaneType::VectorType VectorType;
78 
80  Pointer Copy() const;
81 
82  void RequestSetReslicePlaneSpatialObject( const ReslicerPlaneType *
83  planeSpatialObject);
84 
86  void RequestSetImageSpatialObject( const ImageSpatialObjectType *
88 
90  void SetWindowLevel( double window, double level );
91 
94 
96  void SetRestrictPlaneToVolume(int value);
97 
99  void SetTextureInterpolate(int value);
100 
105  void SetResliceInterpolate(int value);
106 
108  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
109 
110 
111 protected:
112 
115 
117  ~ImageResliceObjectRepresentation();
118 
120  void DeleteActors();
121 
123  void CreateActors();
124 
126  ColorScalarType GetFrameRed() const;
129 
132  virtual bool VerifyTimeStamp() const;
133 
134 private:
135 
136  ImageResliceObjectRepresentation(const Self&);
137  void operator=(const Self&); //purposely not implemented
138 
140  ImageSpatialObjectConstPointer m_ImageSpatialObject;
141  ImageSpatialObjectConstPointer m_ImageSpatialObjectToAdd;
142 
144  ReslicerPlanePointerType m_ReslicePlaneSpatialObjectToBeSet;
145  ReslicerPlanePointerType m_ReslicePlaneSpatialObject;
146 
148  vtkImageData *m_ImageData;
149  vtkImageReslice *m_ImageReslicer;
150  vtkMatrix4x4 *m_ResliceAxes;
151  vtkActor *m_ImageActor;
152  vtkProperty *m_PlaneProperty;
153  vtkImageMapToColors *m_ColorMap;
154  vtkTexture *m_Texture;
155  vtkLookupTable *m_LookupTable;
156  vtkPlaneSource *m_PlaneSource;
157  vtkPlane *m_Plane;
158  vtkImageData *m_Box;
159  vtkCutter *m_Cutter;
160 
161 
164  ColorScalarType m_FrameColor[3];
165 
166  int m_ResliceInterpolate;
167  int m_TextureInterpolate;
168  int m_RestrictPlaneToVolume;
169 
171  double m_Level;
172  double m_Window;
173 
175  double m_ImageSpacing[3];
176  double m_ImageOrigin[3];
177  int m_ImageExtent[6];
178  double m_xbounds[2];
179  double m_ybounds[2];
180  double m_zbounds[2];
181 
183  virtual void UpdateRepresentationProcessing();
184 
186  void NoProcessing();
187 
189  void SetReslicePlaneSpatialObjectProcessing();
190 
193  void SetImageSpatialObjectProcessing();
194 
196  void ReportInvalidImageSpatialObjectProcessing( void );
197 
199  void ReportInvalidReslicePlaneSpatialObjectProcessing( void );
200 
202  void ReportInvalidRequestProcessing( void );
203 
205  void UpdatePlane();
206 
208  void GetVector1(double v1[3]);
209 
211  void GetVector2(double v1[3]);
212 
215  void SetImage( const vtkImageData * image );
216 
218  void ConnectVTKPipelineProcessing();
219 
222  igstkObserverMacro( VTKImage, VTKImageModifiedEvent,
223  EventHelperType::VTKImagePointerType);
224 
228  igstkObserverMacro( ReslicerPlaneCenter,
229  ReslicerPlaneType::ReslicerPlaneCenterEvent,
230  ReslicerPlaneType::VectorType);
231 
232  typename ReslicerPlaneCenterObserver::Pointer m_ReslicerPlaneCenterObserver;
233 
234  igstkObserverMacro( ReslicerPlaneNormal,
235  ReslicerPlaneType::ReslicerPlaneNormalEvent,
236  ReslicerPlaneType::VectorType);
237 
238  typename ReslicerPlaneNormalObserver::Pointer m_ReslicerPlaneNormalObserver;
239 
240 
242  igstkObserverMacro( ImageTransform, CoordinateSystemTransformToEvent,
244 
245  typename VTKImageObserver::Pointer m_VTKImageObserver;
246 
247 private:
248 
250  igstkDeclareInputMacro( ValidImageSpatialObject );
251  igstkDeclareInputMacro( InValidImageSpatialObject );
252  igstkDeclareInputMacro( ValidReslicePlaneSpatialObject );
253  igstkDeclareInputMacro( InValidReslicePlaneSpatialObject );
254  igstkDeclareInputMacro( ConnectVTKPipeline );
255 
257  igstkDeclareStateMacro( Initial );
258  igstkDeclareStateMacro( ImageSpatialObjectSet );
259  igstkDeclareStateMacro( ReslicePlaneSpatialObjectSet );
260 };
261 
262 } // end namespace igstk
263 
264 #ifndef IGSTK_MANUAL_INSTANTIATION
265 #include "igstkImageResliceObjectRepresentation.txx"
266 #endif
267 
268 
269 #endif // __igstkImageResliceObjectRepresentation_h