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

mitkOoCVolumeRendererRayCastingEx.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 __mitkOoCVolumeRendererRayCastingEx_h
00012 #define __mitkOoCVolumeRendererRayCastingEx_h
00013 
00014 #include "mitkVolumeRenderer.h"
00015 #include "mitkRCPtr.h"
00016 #include "mitkVolumeRayCastFunction.h"
00017 #include "mitkEncodedGradientEstimator.h"
00018 #include "mitkEncodedGradientShader.h"
00019 #include "mitkVolumeDivider.h"
00020 class mitkMatrix;
00021 class mitkVolumeProperty;
00022 
00031 class MITK_VISUALIZATION_API mitkOoCVolumeRendererRayCastingEx : public mitkVolumeRenderer
00032 {
00033 public:
00034     MITK_TYPE(mitkOoCVolumeRendererRayCastingEx, mitkVolumeRenderer)
00035 
00036     virtual void PrintSelf(ostream &os);
00037 
00041     mitkOoCVolumeRendererRayCastingEx();
00042 
00046     virtual int Render(mitkScene *scene, mitkVolumeModel *vol);
00047 
00057     void SetSubVolumeSize(int wmin, int wmax, int hmin, int hmax, int dmin, int dmax);
00058 
00068     void SetSubVolumeSize(int sizemin[3], int sizemax[3]);
00069     
00070     void SplitYFirst(bool yf=true) { m_SplitYFirst = yf; m_SubVolSizeChanged = true; }
00071 
00072 protected:
00073     virtual ~mitkOoCVolumeRendererRayCastingEx();
00074 
00075     void _deleteCastingRays();
00076     void _clearCastingRays();
00077     int _newCastingRays();
00078     int _initCastingRays(mitkScene *scene, mitkVolumeModel *vol);
00079 
00080     int _computeClippingPlanes(int planeCount, mitkVector *planeEqus);
00081     int _computeRowBounds(mitkScene *scene, mitkVolumeModel *vol);
00082     int _clipRayAgainstVolume(mitkVector &rayStart, mitkVector &rayEnd, float bounds[6]);
00083     int _clipRayAgainstClippingPlanes(mitkVector &rayStart, mitkVector &rayEnd, int planeCount, mitkVector *planeEqus); 
00084 
00085     int _updateShadingTables(mitkScene *scene, mitkVolumeModel *vol);
00086     
00087     void _drawBSPTree(CuboidBSPTree *tree, float eye[3], mitkScene *scene, mitkVolumeModel *vol);
00088 
00089     void _renderTexture(mitkScene *scene, mitkVolumeModel *vol);
00090 
00091     bool _initBlocks(mitkVolumeProperty *prop);
00092     //by xiang dehui
00093     //void _classifyBlocks(CuboidBSPTree *tree, float *sotf, float *gotf);
00094     void _classifyBlocks(CuboidBSPTree *tree, mitkVolumeProperty *prop);
00095 
00096     bool _initBuffers(int pixbytes);
00097     void _deleteBuffers();
00098 
00099     // Get the ZBuffer value corresponding to location (x,y) where (x,y)
00100     // are indexing into the ImageInUse image. This must be converted to
00101     // the zbuffer image coordinates. Nearest neighbor value is returned.
00102     float _getZBufferValue(int x, int y);   
00103 
00104     mitkRCPtr<mitkVolumeRayCastFunction> m_VolumeRayCastFunction;
00105     mitkRCPtr<mitkEncodedGradientEstimator> m_GradientEstimator;
00106     mitkRCPtr<mitkEncodedGradientShader> m_GradientShader;
00107 
00108     mitkRay *m_Ray;
00109     mitkVector *m_RayCurPos;
00110 //  mitkVector *m_RayEndPos;
00111     mitkVector *m_RayCastStep;
00112     int *m_RayStepsLeft;
00113     int *m_RayStatus;
00114 
00115     mitkMatrix *m_WorldToViewMatrix;
00116     mitkMatrix *m_ViewToWorldMatrix;
00117     mitkMatrix *m_ViewToVoxelsMatrix;
00118     mitkMatrix *m_VoxelsToViewMatrix;
00119     mitkMatrix *m_WorldToVoxelsMatrix;
00120     mitkMatrix *m_VoxelsToWorldMatrix;
00121 
00122     // This is how big the image would be if it covered the entire viewport
00123     int m_ImageViewportSize[2];
00124     
00125     // This is how big the allocated memory for image is. This may be bigger
00126     // or smaller than ImageFullSize - it will be bigger if necessary to 
00127     // ensure a power of 2, it will be smaller if the volume only covers a
00128     // small region of the viewport
00129     int m_ImageMemorySize[2];
00130 
00131     // This is the size of subregion in ImageSize image that we are using for
00132     // the current image. Since ImageSize is a power of 2, there is likely
00133     // wasted space in it. This number will be used for things such as clearing
00134     // the image if necessary.
00135     int m_ImageInUseSize[2];
00136     
00137     // This is the location in ImageFullSize image where our ImageSize image
00138     // is located.
00139     int m_ImageOrigin[2];
00140     
00141     // This is the allocated image
00142     unsigned char *m_Image;
00143     float *m_AccumColors;
00144     
00145     int *m_RowBounds;
00146     int *m_OldRowBounds;    
00147 
00148     float m_MinimumViewDistance;
00149 
00150     // The distance between sample points along the ray
00151     float m_SampleDistance;
00152     
00153     float *m_ZBuffer;
00154     int   m_ZBufferSize[2];
00155     int   m_ZBufferOrigin[2];
00156 
00157     float m_ImageSampleDistance;
00158     float m_MinimumImageSampleDistance;
00159     float m_MaximumImageSampleDistance;
00160 
00161     mitkVolume *m_EncodedNormalsVol;
00162     mitkVolume *m_GradientMagnitudesVol;
00163 
00164     unsigned int m_BlockNum;
00165     unsigned char *m_BlockFlags;
00166 
00167     void *m_SrcBuf;
00168     unsigned short *m_NormBuf;
00169     unsigned char *m_GradBuf;
00170 
00171     int m_SubVolSizeMin[3];
00172     int m_SubVolSizeMax[3];
00173 
00174     int m_Shading;
00175     int m_GradOn;
00176 
00177     mitkVolumeDivider *m_VolDivider;
00178 
00179     bool m_SplitYFirst;
00180     bool m_FirstRendering;
00181 
00182     bool m_AutoAdjustSampleDistances;
00183     bool m_IntermixIntersectingGeometry;
00184 
00185     bool m_SubVolSizeChanged;
00186 
00187 
00188 private:
00189     mitkOoCVolumeRendererRayCastingEx(const mitkOoCVolumeRendererRayCastingEx&);
00190     void operator = (const mitkOoCVolumeRendererRayCastingEx&);
00191 
00192 };
00193 
00194 
00195 //#define DEFINED_mitkOoCVolumeRendererRayCastingEx
00196 
00197 
00198 
00199 #endif
00200 

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