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

mitkVolumeRendererSplatting.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 __mitkVolumeRendererSplatting_h
00012 #define __mitkVolumeRendererSplatting_h
00013 
00014 #include "mitkVolumeRenderer.h"
00015 #include "mitkRCPtr.h"
00016 #include "mitkVolumeSplatFunction.h"
00017 #include "mitkEncodedGradientEstimator.h"
00018 #include "mitkEncodedGradientShader.h"
00019 
00020 // Macro for absolute x
00021 #define mitkAbsFuncMacro(x)     (((x) > 0.0)?(x):(-(x)))
00022 
00024 class mitkMatrix;
00025 
00055 class MITK_VISUALIZATION_API mitkVolumeRendererSplatting : public mitkVolumeRenderer
00056 {
00057 public:
00058     MITK_TYPE(mitkVolumeRendererSplatting, mitkVolumeRenderer)
00059 
00060     virtual void PrintSelf(ostream &os);
00061 
00062     mitkVolumeRendererSplatting();
00063 
00067     virtual int Render(mitkScene *scene, mitkVolumeModel *vol);
00068 
00073     void SetGradientEstimator(mitkEncodedGradientEstimator *gradest);
00074 
00079     void SetPerspectiveSplatter(mitkVolumeSplatFunction *splatter);
00080 
00085     void SetParallelSplatter(mitkVolumeSplatFunction *splatter);
00086 
00091     mitkEncodedGradientEstimator* GetGradientEstimator(){return m_GradientEstimator;}
00092 
00097     mitkVolumeSplatFunction* GetPerspectiveSplatter();
00098     
00103     mitkVolumeSplatFunction* GetParallelSplatter();
00104     
00109     mitkEncodedGradientShader* GetEncodedGradientShader()
00110     {
00111         return m_GradientShader;
00112     }
00113 
00118     void SetKernelRadii(float radii)
00119     {
00120         m_KernelRadii = radii < 0.01f ? 0.01f : (radii > 10.0f ? 10.0f : radii); 
00121     }
00122 
00127     void SetCoefficient(float coeff)
00128     {
00129         m_Coeff = coeff < 0.01f ? 0.01f : (coeff > 10.0f ? 10.0f : coeff);
00130     }
00131 
00136     void SetAdjustRadii(float adjustRadii)
00137     {
00138         m_AdjustRadii = adjustRadii < 0.1f ? 0.1f : (adjustRadii > 20.f ? 20.f : adjustRadii);
00139     }
00140     
00146     float GetKernelRadii(){ return m_KernelRadii; }
00147 
00153     float GetCoefficient(){ return m_Coeff; }
00154 
00160     float GetAdjustRadii(){ return m_AdjustRadii; }
00161 
00166     void SetImageSampleDistance(float fVal)
00167     {
00168         m_ImageSampleDistance = fVal < 0.1f ? 0.1f : (fVal > 100.0f ? 100.0f : fVal);
00169     }
00170 
00175     void SetGridSampleDistance(int fVal)
00176     {
00177         m_GridSampleDistance = fVal < 1 ? 1 : (fVal > 50 ? 50 : fVal);
00178     }
00179 
00184     float GetImageSampleDistance() {return m_ImageSampleDistance;}
00185     
00190     int GetGridSampleDistance() {return m_GridSampleDistance;}
00191 
00196     float GetImageSampleDistanceMinValue(){ return 0.1f; }
00197 
00202     int GetGridSampleDistanceMinValue(){ return 1; }
00203 
00208     float GetImageSampleDistanceMaxValue(){ return 100.0f; }
00209 
00214     int GetGridSampleDistanceMaxValue(){ return 50; }
00215 
00220     void SetMinimumImageSampleDistance(float fVal)
00221     {
00222         m_MinimumImageSampleDistance = fVal < 0.1f ? 0.1f : (fVal > 100.0f ? 100.0f : fVal);
00223     }
00224 
00229     void SetMinimumGridSampleDistance(int fVal)
00230     {
00231         m_MinimumGridSampleDistance = fVal < 1 ? 1 : (fVal > 50 ? 50 : fVal);
00232     }
00233 
00238     float GetMinimumImageSampleDistanceMinValue(){ return 0.1f; }
00239 
00244     int GetMinimumGridSampleDistanceMinValue(){ return 1; }
00245 
00250     float GetMinimumImageSampleDistanceMaxValue(){ return 100.0f; }
00251 
00256     int GetMinimumGridSampleDistanceMaxValue(){ return 50; }
00257 
00262     float GetMinimumImageSampleDistance(){return m_MinimumImageSampleDistance;} 
00263 
00268     int GetMinimumGridSampleDistance(){return m_MinimumGridSampleDistance;} 
00269 
00274     void SetMaximumImageSampleDistance(float fVal)
00275     {
00276         m_MaximumImageSampleDistance = fVal < 0.1f ? 0.1f : (fVal > 100.0f ? 100.0f : fVal);
00277     }
00278 
00283     void SetMaximumGridSampleDistance(int fVal)
00284     {
00285         m_MaximumGridSampleDistance = fVal < 1 ? 1 : (fVal > 50 ? 50 : fVal);
00286     }
00287 
00292     float GetMaximumImageSampleDistanceMinValue(){ return 0.1f; }
00293 
00298     int GetMaximumGridSampleDistanceMinValue(){ return 1; }
00299 
00304     float GetMaximumImageSampleDistanceMaxValue(){ return 100.0f; }
00305 
00310     int GetMaximumGridSampleDistanceMaxValue(){ return 50; }
00311 
00316     float GetMaximumImageSampleDistance(){return m_MaximumImageSampleDistance;} 
00317 
00322     int GetMaximumGridSampleDistance(){return m_MaximumGridSampleDistance;} 
00323     
00329     bool GetAutoAdjustImageSampleDistances(){return m_AutoAdjustImageSampleDistances;}
00330 
00334     void AutoAdjustImageSampleDistancesOn(){ m_AutoAdjustImageSampleDistances = true;}
00335 
00339     void AutoAdjustImageSampleDistancesOff(){ m_AutoAdjustImageSampleDistances = false;}
00340 
00346     bool GetAutoAdjustGridSampleDistances(){return m_AutoAdjustGridSampleDistances;}
00347 
00351     void AutoAdjustGridSampleDistancesOn(){ m_AutoAdjustGridSampleDistances = true;}
00352 
00356     void AutoAdjustGridSampleDistancesOff(){ m_AutoAdjustGridSampleDistances = false;}
00357         
00362     virtual float GetGradientMagnitudeScale();
00363 
00368     virtual float GetGradientMagnitudeBias();
00369 
00373     void SetModeIntegral(){ m_Mode = INTEGRAL; }
00374 
00381     void SetModeMop(){ m_Mode = MOP; }
00382 
00389     int GetMode(){ return m_Mode; }
00390 
00391 protected:
00392     virtual ~mitkVolumeRendererSplatting();
00393 
00394     void _updateShadingTables(mitkScene *scene, mitkVolumeModel *vol);  
00395     void _renderTexture(mitkVolumeModel *vol, mitkScene *scene, unsigned char *img);
00396     void _getTransformMatrix(mitkScene *scene, mitkVolumeModel *vol);
00397     int  _computeRowBounds(mitkVolumeModel *vol, mitkScene *scene);
00398     void _splatting(mitkScene *scene, mitkVolumeModel *vol);
00399     void _getSplatOrder();
00400     void _computeFootprint(float x, float y, float z, int offset);
00401     bool _cullVoxel(float x, float y, float z, float *clipPlane, int pCount);
00402 
00403     mitkRCPtr<mitkVolumeSplatFunction>       m_ParallelSplatter;
00404     mitkRCPtr<mitkVolumeSplatFunction>       m_PerspectiveSplatter;
00405     mitkRCPtr<mitkEncodedGradientEstimator>  m_GradientEstimator;
00406     mitkRCPtr<mitkEncodedGradientShader>     m_GradientShader;
00407     
00408     // Transformation information
00409     mitkMatrix *m_GridToView;
00410     mitkMatrix *m_ViewToGrid;
00411     mitkMatrix *m_GridToScreen;
00412     mitkMatrix *m_ProjectionToScreen;
00413     
00414     // This is how big the image would be if it covered the entire viewport
00415     int m_ImageViewportSize[2];
00416     
00417     // This is how big the allocated memory for image is. This may be bigger
00418     // or smaller than ImageFullSize - it will be bigger if necessary to 
00419     // ensure a power of 2, it will be smaller if the volume only covers a
00420     // small region of the viewport
00421     int m_ImageMemorySize[2];
00422     
00423     // This is the size of subregion in ImageSize image that we are using for
00424     // the current image. Since ImageSize is a power of 2, there is likely
00425     // wasted space in it. This number will be used for things such as clearing
00426     // the image if necessary.
00427     int m_ImageInUseSize[2];
00428     
00429     // This is the location in ImageFullSize image where our ImageSize image
00430     // is located.
00431     int m_ImageOrigin[2];
00432 
00433     // This is the allocated image
00434     unsigned char *m_Image;
00435     int           *m_RowBounds;
00436         
00437     // This is allocated for adding and compositing of splatting
00438     float *m_SheetBuffer;
00439     float *m_CompositeBuffer;
00440     
00441     // The distance between sample points along grid
00442     int  m_GridSampleDistance;
00443     int  m_MinimumGridSampleDistance;
00444     int  m_MaximumGridSampleDistance;
00445     bool m_AutoAdjustGridSampleDistances;
00446 
00447     // The distance between sample points along screen
00448     float m_ImageSampleDistance;
00449     float m_MinimumImageSampleDistance;
00450     float m_MaximumImageSampleDistance; 
00451     bool  m_AutoAdjustImageSampleDistances;
00452     
00453     // Splat related information
00454     float                   m_KernelRadii;
00455     float                   m_Coeff;
00456     float                   m_AdjustRadii;
00457     mitkSplat               *m_Splat;
00458     mitkFootprint2DGaussian *m_Footprint;
00459     mitkFootprint1DGaussian *m_Footprint1D;
00460     int m_Mode;
00461     enum
00462     {
00463         INTEGRAL,
00464         MOP
00465     };
00466 
00467 private:
00468     mitkVolumeRendererSplatting(const mitkVolumeRendererSplatting&);
00469     void operator = (const mitkVolumeRendererSplatting&);
00470 
00471 };
00472 
00473 
00474 //#define DEFINED_mitkVolumeRendererSplatting
00475 
00476 
00477 
00478 #endif
00479 

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