00001
00002
00003
00004
00005
00006
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
00093
00094 void _classifyBlocks(CuboidBSPTree *tree, mitkVolumeProperty *prop);
00095
00096 bool _initBuffers(int pixbytes);
00097 void _deleteBuffers();
00098
00099
00100
00101
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
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
00123 int m_ImageViewportSize[2];
00124
00125
00126
00127
00128
00129 int m_ImageMemorySize[2];
00130
00131
00132
00133
00134
00135 int m_ImageInUseSize[2];
00136
00137
00138
00139 int m_ImageOrigin[2];
00140
00141
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
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
00196
00197
00198
00199 #endif
00200