IGSTK

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

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Image Guided Surgery Software Toolkit
00004   Module:    $RCSfile: igstkImageResliceObjectRepresentation.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-06-15 20:29:05 $
00007   Version:   $Revision: 1.2 $
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 __igstkImageResliceObjectRepresentation_h
00018 #define __igstkImageResliceObjectRepresentation_h
00019 
00020 #include "igstkMacros.h"
00021 #include "igstkObjectRepresentation.h"
00022 #include "igstkImageSpatialObject.h"
00023 #include "igstkStateMachine.h"
00024 #include "igstkReslicerPlaneSpatialObject.h"
00025 
00026 class vtkLookupTable;
00027 class vtkImageMapToColors;
00028 class vtkImageReslice;
00029 class vtkTexture;
00030 class vtkActor;
00031 class vtkPlaneSource;
00032 class vtkOutlineFilter;
00033 class vtkPlane;
00034 class vtkPolyData;
00035 class vtkCutter;
00036 class vtkSphereSource;
00037 class vtkProperty;
00038 class vtkImageMapToColors;
00039 
00040 
00041 namespace igstk
00042 {
00043  
00044 #define VTK_NEAREST_RESLICE 0
00045 #define VTK_LINEAR_RESLICE  1
00046 #define VTK_CUBIC_RESLICE   2
00047 
00054 template < class TImageSpatialObject >
00055 class ImageResliceObjectRepresentation : public ObjectRepresentation
00056 {
00057 
00058 public:
00059 
00061   igstkStandardTemplatedClassTraitsMacro( 
00062                 ImageResliceObjectRepresentation,ObjectRepresentation )
00063 
00064 public:
00065 
00066   typedef TImageSpatialObject                  ImageSpatialObjectType;
00067 
00068   typedef typename ImageSpatialObjectType::ConstPointer 
00069                                                ImageSpatialObjectConstPointer;
00070 
00071   typedef typename ImageSpatialObjectType::PointType  PointType;
00072 
00073   typedef ReslicerPlaneSpatialObject           ReslicerPlaneType;
00074 
00075   typedef ReslicerPlaneType::Pointer           ReslicerPlanePointerType;  
00076 
00077   typedef ReslicerPlaneType::VectorType        VectorType;
00078 
00080   Pointer Copy() const;
00081 
00082   void RequestSetReslicePlaneSpatialObject( const ReslicerPlaneType *
00083                                                     planeSpatialObject);
00084 
00086   void RequestSetImageSpatialObject( const ImageSpatialObjectType * 
00087                                                  ImageSpatialObject );
00088 
00090   void SetWindowLevel( double window, double level );
00091 
00093   void SetFrameColor(ColorScalarType r, ColorScalarType g, ColorScalarType b);
00094 
00096   virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 
00097 
00098 
00099 protected:
00100 
00102   ImageResliceObjectRepresentation();
00103   
00105   ~ImageResliceObjectRepresentation();
00106 
00108   void DeleteActors();
00109 
00111   void CreateActors();
00112 
00114   ColorScalarType GetFrameRed() const; 
00115   ColorScalarType GetFrameGreen() const;
00116   ColorScalarType GetFrameBlue() const;
00117 
00120   virtual bool VerifyTimeStamp() const;
00121 
00122 private:
00123 
00124   ImageResliceObjectRepresentation(const Self&);
00125   void operator=(const Self&);   //purposely not implemented
00126 
00128   ImageSpatialObjectConstPointer         m_ImageSpatialObject;
00129   ImageSpatialObjectConstPointer         m_ImageSpatialObjectToAdd;
00130 
00132   ReslicerPlanePointerType               m_ReslicePlaneSpatialObjectToBeSet;
00133   ReslicerPlanePointerType               m_ReslicePlaneSpatialObject;
00134     
00136   vtkImageData         *m_ImageData;
00137   vtkImageReslice      *m_ImageReslicer;
00138   vtkMatrix4x4         *m_ResliceAxes;
00139   vtkActor             *m_ImageActor;
00140   vtkProperty          *m_PlaneProperty;
00141   vtkImageMapToColors  *m_ColorMap;
00142   vtkTexture           *m_Texture;
00143   vtkLookupTable       *m_LookupTable;
00144   vtkPlaneSource       *m_PlaneSource;
00145   vtkPlane             *m_Plane;
00146   vtkImageData         *m_Box;
00147   vtkCutter            *m_Cutter;
00148   
00149 
00152   ColorScalarType                         m_FrameColor[3];
00153 
00154   int    m_ResliceInterpolate;
00155   int    m_TextureInterpolate;
00156   int    m_RestrictPlaneToVolume;
00157 
00159   double                                 m_Level;
00160   double                                 m_Window;
00161 
00163   double                                 m_ImageSpacing[3];
00164   double                                 m_ImageOrigin[3];
00165   int                                    m_ImageExtent[6];
00166   double                                 m_xbounds[2];
00167   double                                 m_ybounds[2];
00168   double                                 m_zbounds[2];
00169 
00171   virtual void UpdateRepresentationProcessing();
00172 
00174   void NoProcessing(); 
00175 
00177   void SetReslicePlaneSpatialObjectProcessing();
00178 
00181   void SetImageSpatialObjectProcessing();
00182 
00184   void ReportInvalidImageSpatialObjectProcessing( void );
00185 
00187   void ReportInvalidReslicePlaneSpatialObjectProcessing( void );
00188 
00190   void ReportInvalidRequestProcessing( void );
00191 
00193   void SetResliceInterpolate(int i);
00194 
00196   void UpdatePlane();
00197 
00199   void GetVector1(double v1[3]);
00200 
00202   void GetVector2(double v1[3]);
00203 
00206   void SetImage( const vtkImageData * image );
00207   
00209   void ConnectVTKPipelineProcessing();
00210     
00213   igstkObserverMacro( VTKImage, VTKImageModifiedEvent,
00214                       EventHelperType::VTKImagePointerType);
00215 
00219   igstkObserverMacro( ReslicerPlaneCenter, 
00220                                     ReslicerPlaneType::ReslicerPlaneCenterEvent,
00221                                                  ReslicerPlaneType::VectorType);
00222 
00223   typename ReslicerPlaneCenterObserver::Pointer  m_ReslicerPlaneCenterObserver;
00224 
00225   igstkObserverMacro( ReslicerPlaneNormal, 
00226                                     ReslicerPlaneType::ReslicerPlaneNormalEvent,
00227                                                  ReslicerPlaneType::VectorType);
00228 
00229   typename ReslicerPlaneNormalObserver::Pointer  m_ReslicerPlaneNormalObserver;
00230 
00231 
00233   igstkObserverMacro( ImageTransform, CoordinateSystemTransformToEvent, 
00234      CoordinateSystemTransformToResult );
00235 
00236   typename VTKImageObserver::Pointer  m_VTKImageObserver;
00237 
00238 private:
00239 
00241   igstkDeclareInputMacro( ValidImageSpatialObject );
00242   igstkDeclareInputMacro( InValidImageSpatialObject );
00243   igstkDeclareInputMacro( ValidReslicePlaneSpatialObject );
00244   igstkDeclareInputMacro( InValidReslicePlaneSpatialObject );
00245   igstkDeclareInputMacro( ConnectVTKPipeline );
00246 
00248   igstkDeclareStateMacro( Initial );
00249   igstkDeclareStateMacro( ImageSpatialObjectSet );
00250   igstkDeclareStateMacro( ReslicePlaneSpatialObjectSet );
00251 };
00252 
00253 } // end namespace igstk
00254 
00255 #ifndef IGSTK_MANUAL_INSTANTIATION
00256 #include "igstkImageResliceObjectRepresentation.txx"
00257 #endif
00258 
00259 
00260 #endif // __igstkImageResliceObjectRepresentation_h