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

mitkOoCVolumeRendererRayCasting.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 __mitkOoCVolumeRendererRayCasting_h
00012 #define __mitkOoCVolumeRendererRayCasting_h
00013 
00014 #include "mitkVolumeRenderer.h"
00015 #include "mitkRCPtr.h"
00016 #include "mitkVolumeRayCastFunction.h"
00017 #include "mitkEncodedGradientEstimator.h"
00018 #include "mitkEncodedGradientShader.h"
00019 
00020 class mitkMatrix;
00021 
00030 class MITK_VISUALIZATION_API mitkOoCVolumeRendererRayCasting : public mitkVolumeRenderer
00031 {
00032 public:
00033     MITK_TYPE(mitkOoCVolumeRendererRayCasting, mitkVolumeRenderer)
00034 
00035     virtual void PrintSelf(ostream &os);
00036 
00040     mitkOoCVolumeRendererRayCasting();
00041 
00045     virtual int Render(mitkScene *scene, mitkVolumeModel *vol);
00046 
00051     void SetGradientEstimator(mitkEncodedGradientEstimator *gradest);
00052 
00057     mitkEncodedGradientEstimator* GetGradientEstimator(){return m_GradientEstimator;};
00058 
00059 
00060 
00061 protected:
00062     virtual ~mitkOoCVolumeRendererRayCasting();
00063 
00064     void _deleteCastingRays();
00065     void _clearCastingRays();
00066     int _newCastingRays();
00067     int _initCastingRays(mitkScene *scene, mitkVolumeModel *vol);
00068 
00069     int _computeClippingPlanes(int planeCount, mitkVector *planeEqus, mitkScene *scene);
00070     int _computeRowBounds(mitkScene *scene, mitkVolumeModel *vol);
00071     int _clipRayAgainstVolume(mitkVector &rayStart, mitkVector &rayEnd, float bounds[6]);
00072     int _clipRayAgainstClippingPlanes(mitkVector &rayStart, mitkVector &rayEnd, int planeCount, mitkVector *planeEqus); 
00073 
00074     int _updateShadingTables(mitkScene *scene, mitkVolumeModel *vol);
00075     
00076     void _renderTexture(mitkScene *scene, mitkVolumeModel *vol);
00077 
00078     // Get the ZBuffer value corresponding to location (x,y) where (x,y)
00079     // are indexing into the ImageInUse image. This must be converted to
00080     // the zbuffer image coordinates. Nearest neighbor value is returned.
00081     float _getZBufferValue(int x, int y);   
00082 
00083     mitkRCPtr<mitkVolumeRayCastFunction> m_VolumeRayCastFunction;
00084     mitkRCPtr<mitkEncodedGradientEstimator> m_GradientEstimator;
00085     mitkRCPtr<mitkEncodedGradientShader> m_GradientShader;
00086 
00087     mitkRay *m_Ray;
00088     mitkVector *m_RayCurPos;
00089 //  mitkVector *m_RayEndPos;
00090     mitkVector *m_RayCastStep;
00091     int *m_RayStepsLeft;
00092     int *m_RayStatus;
00093 
00094     mitkMatrix *m_WorldToViewMatrix;
00095     mitkMatrix *m_ViewToWorldMatrix;
00096     mitkMatrix *m_ViewToVoxelsMatrix;
00097     mitkMatrix *m_VoxelsToViewMatrix;
00098     mitkMatrix *m_WorldToVoxelsMatrix;
00099     mitkMatrix *m_VoxelsToWorldMatrix;
00100 
00101     // This is how big the image would be if it covered the entire viewport
00102     int m_ImageViewportSize[2];
00103     
00104     // This is how big the allocated memory for image is. This may be bigger
00105     // or smaller than ImageFullSize - it will be bigger if necessary to 
00106     // ensure a power of 2, it will be smaller if the volume only covers a
00107     // small region of the viewport
00108     int m_ImageMemorySize[2];
00109 
00110     // This is the size of subregion in ImageSize image that we are using for
00111     // the current image. Since ImageSize is a power of 2, there is likely
00112     // wasted space in it. This number will be used for things such as clearing
00113     // the image if necessary.
00114     int m_ImageInUseSize[2];
00115     
00116     // This is the location in ImageFullSize image where our ImageSize image
00117     // is located.
00118     int m_ImageOrigin[2];
00119     
00120     // This is the allocated image
00121     unsigned char *m_Image;
00122     float *m_AccumColors;
00123     
00124     int *m_RowBounds;
00125     int *m_OldRowBounds;    
00126 
00127     float m_MinimumViewDistance;
00128 
00129     // The distance between sample points along the ray
00130     float m_SampleDistance;
00131     
00132     float *m_ZBuffer;
00133     int   m_ZBufferSize[2];
00134     int   m_ZBufferOrigin[2];
00135 
00136     float m_ImageSampleDistance;
00137     float m_MinimumImageSampleDistance;
00138     float m_MaximumImageSampleDistance;
00139 
00140     int m_SlicePtrNum;
00141     void const **m_Slices;
00142     unsigned short const **m_EncodedNormalSlices;
00143     unsigned char const **m_GradientMagnitudeSlices;
00144 
00145     mitkVolume *m_EncodedNormalsVol;
00146     mitkVolume *m_GradientMagnitudesVol;
00147 
00148     bool m_AutoAdjustSampleDistances;
00149     bool m_IntermixIntersectingGeometry;
00150     bool m_HasForwardRay;
00151     bool m_HasReverseRay;
00152 
00153     // information needed for interactive clipping. 
00154     bool m_DepthTest;
00155     bool *m_Clips;
00156     bool m_AutoReslice;
00157 
00158 private:
00159     mitkOoCVolumeRendererRayCasting(const mitkOoCVolumeRendererRayCasting&);
00160     void operator = (const mitkOoCVolumeRendererRayCasting&);
00161 
00162 };
00163 
00164 
00165 //#define DEFINED_mitkOoCVolumeRendererRayCasting
00166 
00167 
00168 
00169 #endif
00170 

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