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

mitkVolumeRendererRayCastingLoD.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 __mitkVolumeRendererRayCastingLoD_h
00012 #define __mitkVolumeRendererRayCastingLoD_h
00013 
00014 #include "mitkVolumeRendererRayCasting.h"
00015 #include "mitkSPMD.h"
00016 
00023 class MITK_VISUALIZATION_API mitkVolumeRendererRayCastingLoD : public mitkVolumeRenderer
00024 {
00025 public:
00026     MITK_TYPE(mitkVolumeRendererRayCastingLoD, mitkVolumeRenderer)
00027 
00028     virtual void PrintSelf(ostream &os);
00029 
00030     mitkVolumeRendererRayCastingLoD();
00031 
00035     virtual int Render(mitkScene *scene, mitkVolumeModel *vol);
00036     
00041     void  SetSampleDistance(float fVal) { m_SampleDistance = fVal; }
00042 
00047     float GetSampleDistance() { return m_SampleDistance; }
00048 
00054     void SetVolumeRayCastFunction(mitkVolumeRayCastFunction* oVal)
00055     {
00056         m_VolumeRayCastFunction = oVal;
00057     }
00058 
00063     mitkVolumeRayCastFunction* GetVolumeRayCastFunction()
00064     {
00065         return m_VolumeRayCastFunction;
00066     }   
00067 
00072     void SetGradientEstimator(mitkEncodedGradientEstimator *gradest);
00073 
00078     mitkEncodedGradientEstimator* GetGradientEstimator(){return m_GradientEstimator;};
00079     
00084     mitkEncodedGradientShader* GetEncodedGradientShader()
00085     {
00086         return m_GradientShader;
00087     }
00088     
00093     float GetImageSampleDistanceMinValue() { return 0.1f; }
00094 
00099     float GetImageSampleDistanceMaxValue() { return 100.0f; }
00100 
00105     void SetImageSampleDistance(float fVal)
00106     {
00107         m_ImageSampleDistance = fVal < GetImageSampleDistanceMinValue()
00108             ? GetImageSampleDistanceMinValue()
00109             : (fVal > GetImageSampleDistanceMaxValue()
00110             ? GetImageSampleDistanceMaxValue() : fVal);
00111     }
00112 
00117     float GetImageSampleDistance() { return m_ImageSampleDistance; }
00118     
00123     float GetMinimumImageSampleDistanceMinValue() { return 0.1f; }
00124 
00129     float GetMinimumImageSampleDistanceMaxValue() { return 100.0f; }
00130 
00135     float GetMaximumImageSampleDistanceMinValue() { return 0.1f; }
00136 
00141     float GetMaximumImageSampleDistanceMaxValue() { return 100.0f; }
00142 
00147     void SetMinimumImageSampleDistance(float fVal)
00148     {
00149         m_MinimumImageSampleDistance = fVal < GetMinimumImageSampleDistanceMinValue()
00150             ? GetMinimumImageSampleDistanceMinValue()
00151             : (fVal > GetMinimumImageSampleDistanceMaxValue() 
00152             ? GetMinimumImageSampleDistanceMaxValue() : fVal);
00153     }
00154 
00159     void SetMaximumImageSampleDistance(float fVal)
00160     {
00161         m_MaximumImageSampleDistance = fVal < GetMaximumImageSampleDistanceMinValue()
00162             ? GetMaximumImageSampleDistanceMinValue()
00163             : (fVal > GetMaximumImageSampleDistanceMaxValue()
00164             ? GetMaximumImageSampleDistanceMaxValue() : fVal);
00165     }
00166 
00171     float GetMinimumImageSampleDistance() { return m_MinimumImageSampleDistance; }  
00172     
00177     float GetMaximumImageSampleDistance() { return m_MaximumImageSampleDistance; }  
00178     
00184     void SetAutoAdjustSampleDistances(int val)
00185     {
00186         m_AutoAdjustSampleDistances = val < 0 ? 0 : (val > 1 ? 1 : val);
00187     }
00188     
00194     int GetAutoAdjustSampleDistances() { return m_AutoAdjustSampleDistances; }
00195 
00199     void AutoAdjustSampleDistancesOn() { SetAutoAdjustSampleDistances(1); }
00200 
00204     void AutoAdjustSampleDistancesOff() { SetAutoAdjustSampleDistances(0); }
00205 
00211     void SetIntermixIntersectingGeometry(int fVal)
00212     {
00213         m_IntermixIntersectingGeometry = fVal < 0 ? 0 : (fVal > 1 ? 1 : fVal);
00214     }   
00215     
00220     int GetIntermixIntersectingGeometry() { return m_IntermixIntersectingGeometry; }    
00221 
00225     void IntermixIntersectingGeometryOn() { SetIntermixIntersectingGeometry(1); }
00226 
00230     void IntermixIntersectingGeometryOff() { SetIntermixIntersectingGeometry(0); }  
00231 
00236     virtual float GetGradientMagnitudeScale();
00237     
00242     virtual float GetGradientMagnitudeBias();
00243 
00244 protected:
00245     virtual ~mitkVolumeRendererRayCastingLoD();
00246     void _updateShadingTables(mitkScene *scene, mitkVolumeModel *vol);  
00247     void _renderTexture(mitkVolumeModel *vol, mitkScene *scene, unsigned char *img);
00248     int _computeClippingPlanes(float *planes, mitkScene *scene);
00249     int _computeRowBounds(mitkVolumeModel *vol, mitkScene *scene);
00250     int _clipRayAgainstVolume(mitkRay *rayInfo, float bounds[6] );
00251     int _clipRayAgainstClippingPlanes(int planeCount, float *planeEqus, mitkRay *rayInfo);  
00252             
00253     // Get the ZBuffer value corresponding to location (x,y) where (x,y)
00254     // are indexing into the ImageInUse image. This must be converted to
00255     // the zbuffer image coordinates. Nearest neighbor value is returned.
00256     float _getZBufferValue(int x, int y);   
00257 
00258     void _castRayMT(int tid,int tnum,void*,mitkBarrier*);
00259     
00260     void _castRaysClipOffCropOff(int tid,int tnum); 
00261     void _castRaysClipOnCropOff(int tid,int tnum); 
00262     void _castRaysClipOffCropSub(int tid,int tnum); 
00263     void _castRaysClipOffCropNonSub(int tid,int tnum); 
00264     void _castRaysClipOnCropSub(int tid,int tnum); 
00265     void _castRaysClipOnCropNonSub(int tid,int tnum); 
00266 
00267     mitkScene *m_curscene;
00268     mitkVolumeModel *m_curvol;
00269 
00270     mitkRCPtr<mitkVolumeRayCastFunction>     m_VolumeRayCastFunction;
00271     mitkRCPtr<mitkEncodedGradientEstimator>  m_GradientEstimator;
00272     mitkRCPtr<mitkEncodedGradientShader>     m_GradientShader;
00273 
00274     mitkVolumeModel **m_RenderVolumeTable;
00275     mitkScene        **m_RenderSceneTable;
00276     
00277     mitkMatrix *m_PerspectiveMatrix;
00278     mitkMatrix *m_ViewToWorldMatrix;
00279     mitkMatrix *m_ViewToVoxelsMatrix;
00280     mitkMatrix *m_VoxelsToViewMatrix;
00281     mitkMatrix *m_WorldToVoxelsMatrix;
00282     mitkMatrix *m_VoxelsToWorldMatrix;
00283     
00284     // This is how big the image would be if it covered the entire viewport
00285     int m_ImageViewportSize[2];
00286     
00287     // This is how big the allocated memory for image is. This may be bigger
00288     // or smaller than ImageFullSize - it will be bigger if necessary to 
00289     // ensure a power of 2, it will be smaller if the volume only covers a
00290     // small region of the viewport
00291     int m_ImageMemorySize[2];
00292     
00293     // This is the size of subregion in ImageSize image that we are using for
00294     // the current image. Since ImageSize is a power of 2, there is likely
00295     // wasted space in it. This number will be used for things such as clearing
00296     // the image if necessary.
00297     int m_ImageInUseSize[2];
00298     
00299     // This is the location in ImageFullSize image where our ImageSize image
00300     // is located.
00301     int m_ImageOrigin[2];
00302     
00303     // This is the allocated image
00304     unsigned char *m_Image;
00305     
00306     int *m_RowBounds;
00307     int *m_OldRowBounds;    
00308     
00309     int m_RenderTableSize;
00310     int m_RenderTableEntries;
00311     
00312     int m_IntermixIntersectingGeometry;
00313     
00314     float *m_ZBuffer;
00315     int   m_ZBufferSize[2];
00316     int   m_ZBufferOrigin[2];
00317     
00318     float m_MinimumViewDistance;
00319     
00320     // The distance between sample points along the ray
00321     float m_SampleDistance;
00322 
00323     float m_ImageSampleDistance;
00324     float m_oldImageSampleDistance ;
00325     float m_MinimumImageSampleDistance;
00326     float m_MaximumImageSampleDistance;
00327     int   m_AutoAdjustSampleDistances;
00328     
00329     float m_WorldSampleDistance;
00330     int   m_ScalarDataType;
00331     void  *m_ScalarDataPointer;
00332     mitkRay *m_Ray;
00333 
00334     // information needed for interactive clipping. 
00335     bool m_DepthTest;
00336     bool *m_Clips;
00337     bool m_AutoReslice;
00338     bool m_Break;
00339     
00340 private:
00341     mitkVolumeRendererRayCastingLoD(const mitkVolumeRendererRayCastingLoD&);
00342     void operator = (const mitkVolumeRendererRayCastingLoD&);
00343 
00344 };
00345 
00346 
00347 //#define DEFINED_mitkVolumeRendererRayCastingLoD
00348 
00349 
00350 
00351 #endif
00352 

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