Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkOoCVolumeRendererShearWarp.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 #ifndef __mitkOoCVolumeRendererShearWarp_h
00012 #define __mitkOoCVolumeRendererShearWarp_h
00013 
00014 #include "mitkVolumeRenderer.h"
00015 #include "mitkOoCVolumeShearFunction.h"
00016 #include "mitkRCPtr.h"
00017 #include "mitkEncodedGradientEstimator.h"
00018 #include "mitkEncodedGradientShader.h"
00019 
00020 // Macro for absolute x
00021 //#define mitkAbsMacro(x)     (((x) > 0.0)?(x):(-(x)))
00022 //#define mitkFloorMacro(x)   (((x) < 0.0)?((int)((x)-1.0)):((int)(x)))
00023 //#define mitkCeilingMacro(x)   (((x) < 0.0)?((int)(x)):((int)((x)+1.0)))
00024 //#define mitkRoundMacro(x)   (((x) < 0.0)?((int)((x)-0.5)):((int)((x)+0.5)))
00025 
00027 class mitkMatrix;
00052 class MITK_VISUALIZATION_API mitkOoCVolumeRendererShearWarp : public mitkVolumeRenderer
00053 {
00054 public:
00055     MITK_TYPE(mitkOoCVolumeRendererShearWarp, mitkVolumeRenderer)
00056 
00057     virtual void PrintSelf(ostream &os);
00058 
00059     mitkOoCVolumeRendererShearWarp();
00060 
00064     virtual int Render(mitkScene *scene, mitkVolumeModel *vol);
00065 
00070     void SetGradientEstimator(mitkEncodedGradientEstimator *gradest)
00071     { 
00072         m_GradientEstimator = gradest; 
00073     }
00074 
00079     mitkEncodedGradientEstimator* GetGradientEstimator(){return m_GradientEstimator;}
00080     
00085     mitkEncodedGradientShader* GetEncodedGradientShader()
00086     {
00087         return m_GradientShader;
00088     }
00089 
00094     void SetPerspectiveShearer(mitkOoCVolumeShearFunction *shearer);
00095 
00100     void SetParallelShearer(mitkOoCVolumeShearFunction *shearer);
00101 
00106     mitkOoCVolumeShearFunction* GetPerspectiveShearer();
00107     
00112     mitkOoCVolumeShearFunction* GetParallelShearer();
00113 
00118     void SetImageSampleDistance(float val)
00119     {
00120         m_ImageSampleDistance = val;
00121     }
00122 
00127     float GetImageSampleDistance() {return m_ImageSampleDistance;}
00128 
00133     float GetMinimumImageSampleDistance(){return m_MinimumImageSampleDistance;} 
00134 
00139     float GetMaximumImageSampleDistance(){return m_MaximumImageSampleDistance;} 
00140     
00146     bool GetAutoAdjustImageSampleDistances(){return m_AutoAdjustImageSampleDistances;}
00147 
00151     void AutoAdjustImageSampleDistancesOn(){ m_AutoAdjustImageSampleDistances = true;}
00152 
00156     void AutoAdjustImageSampleDistancesOff(){ m_AutoAdjustImageSampleDistances = false;}
00157         
00162     virtual float GetGradientMagnitudeScale();
00163 
00168     virtual float GetGradientMagnitudeBias();
00169 
00173     void SetModeIntegral(){ m_Mode = INTEGRAL; }
00174 
00181     void SetModeMop(){ m_Mode = MOP; }
00182 
00189     int GetMode(){ return m_Mode; }
00190 
00202     void SetLevelOfDetail(bool lod){ m_LOD = lod; }
00203 
00204 protected:
00205     virtual ~mitkOoCVolumeRendererShearWarp();
00206 
00207     int _computeClippingPlanes(int planeCount, mitkScene *scene);
00208     void _updateShadingTables(mitkScene *scene, mitkVolumeModel *vol);  
00209     void _renderTexture(mitkVolumeModel *vol, mitkScene *scene, unsigned char *img);
00210     void _getTransformMatrix(mitkScene *scene, mitkVolumeModel *vol);
00211     int  _computeGridBounds(mitkVolumeModel *vol, mitkScene *scene);
00212     void _shear(mitkScene *scene, mitkVolumeModel *vol, mitkShear *m_Shear);
00213     void _getShearOrder(mitkScene *scene);
00214 //  bool _cullVoxel(float x, float y, float z, float *clipPlane, int pCount);
00215 
00216     mitkRCPtr<mitkOoCVolumeShearFunction>       m_ParallelShearer;
00217     mitkRCPtr<mitkOoCVolumeShearFunction>       m_PerspectiveShearer;
00218     mitkRCPtr<mitkEncodedGradientEstimator>  m_GradientEstimator;
00219     mitkRCPtr<mitkEncodedGradientShader>     m_GradientShader;
00220 
00221     // Transformation information
00222     mitkMatrix *m_GridToWorld;
00223     mitkMatrix *m_ViewToGrid;
00224     mitkMatrix *m_ShearMatrix;
00225     mitkMatrix *m_InverseShearMatrix;
00226     mitkMatrix *m_ShearOnlyMatrix;
00227 
00228     // The distance between sample points along shear space.
00229     float m_ImageSampleDistance;
00230     float   m_MinimumImageSampleDistance;
00231     float   m_MaximumImageSampleDistance;   
00232     bool  m_AutoAdjustImageSampleDistances;
00233     float m_AdjustDistance;
00234     
00235     // This is the size of the intermediate image region in sheared space. 
00236     int m_GridSize[2];
00237     
00238     // This is the location in sheared space where the intermediate image region
00239     // is located.
00240     int m_GridOrigin[2];
00241 
00242     // This is the size of samples in intermediate image that we use for real display.
00243     int m_ImageSize[2];
00244     int m_OldImageSize[2];
00245 
00246     // This is the size of the allocated memory for image. This may be bigger
00247     // or smaller than Intermediate Image's full size - it will be bigger if necessary to 
00248     // ensure a power of 2, it will be smaller if the intermediate image region only covers 
00249     // a small region of the allocated memory.
00250     int m_ImageMemorySize[2];
00251 
00252     // This is allocated for final displayed image.
00253     unsigned char *m_Image;
00254         
00255     // This is allocated for compositing of sheared slices.
00256     float *m_CompositeBuffer;
00257 
00258     //shear related information.
00259     mitkShear *m_Shear;
00260     int m_Mode;
00261     enum
00262     {
00263         INTEGRAL,
00264         MOP
00265     };
00266 
00267     int m_SlicePtrNum;
00268     void const **m_Slices;
00269     int m_BufSliceNum;
00270     unsigned short const **m_EncodedNormalSlices;
00271     unsigned char const **m_GradientMagnitudeSlices;
00272 
00273     mitkVolume *m_EncodedNormalsVol;
00274     mitkVolume *m_GradientMagnitudesVol;
00275 
00276     // information needed for interactive clipping. 
00277     bool m_DepthTest;
00278     bool *m_Clips;
00279     bool m_AutoReslice;
00280 
00281     // information needed for level-of-detail display.
00282     bool m_LOD;
00283 
00284 private:
00285     mitkOoCVolumeRendererShearWarp(const mitkOoCVolumeRendererShearWarp&);
00286     void operator = (const mitkOoCVolumeRendererShearWarp&);
00287 
00288 };
00289 
00290 
00291 //#define DEFINED_mitkOoCVolumeRendererShearWarp
00292 
00293 
00294 
00295 #endif
00296 

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3