00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitk2DBackProjectionUsingGPU_h
00012 #define __mitk2DBackProjectionUsingGPU_h
00013
00014 #include "mitkBackProjectionUsingGPU.h"
00015 #include <GL/glew.h>
00016 #include <GL/glut.h>
00017 #include <Cg/cgGL.h>
00018
00019 #define BLOCKNUM 7
00020 #define FANWINDOWSIZE 7
00021
00022
00023
00024
00025
00026
00031 class MITK_RECONSTRUCTION_CG_API mitk2DBackProjectionUsingGPU : public mitkBackProjectionUsingGPU
00032 {
00033 public:
00034 MITK_TYPE(mitk2DBackProjectionUsingGPU,mitkBackProjectionUsingGPU)
00035
00036 mitk2DBackProjectionUsingGPU();
00037
00038 virtual void PrintSelf(ostream& os);
00039
00040 virtual void InputProjectionData(float * data);
00041
00042 virtual void Draw (int mBottom);
00043
00044 virtual void Rotate(float angle);
00045
00046 virtual void ReadResult(int mSubSliceNum,float * result);
00047
00048 virtual void SetParameter(int xrayNum,int angleNum,int sliceNum,double begenAngle,double endAngle,double SOD,double SDD,double lengthDetector,double *fov,int interpolationModel,int width,int height);
00049
00050 virtual bool CreateTexture();
00051
00052
00053 private:
00054 void initWindow();
00055
00056 void initFBO();
00057
00058 void initCG();
00059
00060 bool _createTexture();
00061
00062 void AttachFBO();
00063
00064 void EnableFshader();
00065
00066 void EnableVshader();
00067
00068 void SetDtheta(float m) {dthetaDegree = m;}
00069
00070 void SetFrustum(float zn,float zf,float zc, float detectorLength);
00071
00072 void DestroyAll();
00073
00074 void CheckForCgError(const char *situation);
00075
00076 void _bindCurrentFBO();
00077 void _unBind();
00078 void _scanTexParams(CGprogram m_prog);
00079 void _setTexture(char *name, GLuint tex);
00080 void _bindTextures();
00081
00082
00083
00084 void SetXrayNum(int m){xrayNum = m;}
00085 void SetAngleNum(int m){angleNum = m;}
00086 void SetWidth(int m){width = m;}
00087 void SetHeight(int m){height = m;}
00088 void SetImgslice(int m){imgslice = m;}
00089 void SetFov(double *m)
00090 {
00091 fov[0] = m[0];
00092 fov[1] = m[1];
00093 fov[2] = m[2];
00094 fov[3] = m[3];
00095 }
00096 void SetFov(double xmin,double xmax,double ymin,double ymax)
00097 {
00098 fov[0] = xmin;
00099 fov[1] = xmax;
00100 fov[2] = ymin;
00101 fov[3] = ymax;
00102 }
00103 int xrayNum;
00104 int angleNum;
00105 int width;
00106 int height;
00107 int imgslice;
00108 double fov[4];
00109
00110
00111
00112 struct TexParam
00113 {
00114 const char *name;
00115 int unit;
00116 int target;
00117 int tex;
00118 };
00119 std::vector<TexParam> m_texParams;
00120
00121 float dthetaDegree;
00122 float zNear;
00123 float zFar;
00124 float zCenter;
00125 float nearDetectorLengthX;
00126 GLfloat frustum[16];
00127
00128 GLuint windowHandle;
00129 CGcontext cgContext;
00130 CGprofile fProfile ,vProfile;
00131 CGprogram fProgram ,vProgram;
00132 CGparameter mvpMatrixParam,preResultTexParam,
00133 texMatrixParam[BLOCKNUM];
00134
00135 GLuint *projectDataID, fbotex, *ResultID;
00136 GLuint fb;
00137 GLint m_preFboId;
00138
00139
00140 protected:
00141 virtual ~mitk2DBackProjectionUsingGPU();
00142
00143 private:
00144
00145 mitk2DBackProjectionUsingGPU(const mitk2DBackProjectionUsingGPU&);
00146 void operator=(const mitk2DBackProjectionUsingGPU&);
00147 };
00148
00149
00150
00151
00152 #endif
00153