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

mitk3DBackProjectionUsingGPU.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 __mitk3DBackProjectionUsingGPU_h
00012 #define __mitk3DBackProjectionUsingGPU_h
00013 
00014 #include "mitkBackProjectionUsingGPU.h"
00015 #include <GL/glew.h>
00016 #include <GL/glut.h>
00017 #include <Cg/cgGL.h>
00018 #include <math.h>
00019 #include <vector>
00020 
00021 #define TEXTURECHANNEL 8
00022 #define COLORATTACHMENTNUM 2
00023 #define WINDOWSIZE 8
00024 
00025 
00026 
00027 
00028 
00033 class MITK_RECONSTRUCTION_CG_API mitk3DBackProjectionUsingGPU : public mitkBackProjectionUsingGPU
00034 {
00035 public:
00036     MITK_TYPE(mitk3DBackProjectionUsingGPU,mitkBackProjectionUsingGPU)
00037 
00038     virtual void PrintSelf(ostream& os);
00039 
00040     mitk3DBackProjectionUsingGPU();  
00041 
00042     virtual void InputProjectionData(float *data);
00043 
00044     virtual bool CreateTexture();
00045 
00046     virtual void Draw (int mBottom);
00047 
00048     virtual void ReadResult(int mSubSliceNum,float * result);
00049 
00050     virtual void Rotate(float angle);
00051 
00052     virtual void SetParameter(int xrayNumx,int xrayNumz,int angleNum,double begenAngle,double endAngle,double SOD,double SDD,double detectorLengthX,double detectorLengthZ,float detectorMoveX,float detectorMoveZ,double *fov,int interpolationModel,int volumeBlockNum,int width,int height,int imgslice);
00053 
00054 private:
00055 
00056     virtual bool _createTexture();
00057 
00058     void SetDtheta(float m) {dthetaDegree = m;}
00059 
00060     void initWindow();
00061 
00062     void initFBO();
00063 
00064     void Bind();
00065 
00066     bool CheckFBOStatus();
00067 
00068     void initCG();
00069 
00070     void CheckForCgError(const char *situation);
00071 
00072     void AttachFBO(int layer);
00073 
00074     void EnableFshader();
00075 
00076     void EnableVshader();
00077 
00078     void DestroyALL();
00079 
00080     void SetVolumeBlockSize(int m) {volumeBlockSize = m; };
00081 
00082     void SetFrustum(float zn,float zf,float zc, float detectorLengthx,float detectorLengthz);
00083         
00085     // for temp use
00087     void SetFov(double *m)
00088     {
00089         fov[0] = m[0]; 
00090         fov[1] = m[1]; 
00091         fov[2] = m[2];
00092         fov[3] = m[3]; 
00093         fov[4] = m[4]; 
00094         fov[5] = m[5];
00095     }
00096     void SetFov(double xmin,double xmax,double ymin,double ymax,double zmin,double zmax)
00097     {
00098         fov[0] = xmin;
00099         fov[1] = xmax; 
00100         fov[2] = ymin;
00101         fov[3] = ymax; 
00102         fov[4] = zmin; 
00103         fov[5] = zmax;
00104     }
00105     void SetXrayNumx(int m){xrayNumx = m;}
00106     void SetXrayNumz(int m){xrayNumz = m;}
00107     void SetAngleNum(int m){angleNum = m;}
00108     void SetWidth(int m){width = m;}
00109     void SetHeight(int m){height = m;}
00110     void SetImgslice(int m){imgslice = m;}
00111 
00112     int xrayNumx;
00113     int xrayNumz;
00114     int angleNum;
00115     int width;
00116     int height;
00117     int imgslice;
00118     double fov[6];
00119     int volumeBlockSize;
00120 
00121 
00122     struct TexParam 
00123     {
00124         const char *name;
00125         int unit;
00126         int target;
00127         int tex;
00128     };
00129     std::vector<TexParam> m_texParams;
00130 
00131     void _scanTexParams(CGprogram m_prog);
00132     void _setTexture(char *name, GLuint tex);
00133     void _bindTextures();
00134 
00135     float dthetaDegree;
00136     float zNear;
00137     float zFar;     //L
00138     float zCenter;  //D
00139     float nearDetectorLengthX;
00140     float nearDetectorLengthZ;
00141     GLfloat frustum[16];
00142 
00143     float zCenter2;
00144     GLuint windowHandle;    
00145     CGcontext cgContext;
00146     CGprofile fProfile ,vProfile;
00147     CGprogram fProgram ,vProgram;
00148     CGparameter mvpMatrixParam,
00149         preResultTexParam,
00150         texMatrixParam[TEXTURECHANNEL];
00151 
00152     GLuint *projectDataID, *ResultID;
00153     GLuint fbotex;
00154     GLuint fb;
00155     GLint m_preFboId;
00156     int head;
00157     int flag;
00158     void _bindCurrentFBO();
00159     void _unBind();
00160     
00161  protected:  
00162      virtual ~mitk3DBackProjectionUsingGPU(); 
00163 
00164 private:
00165 
00166     mitk3DBackProjectionUsingGPU(const mitk3DBackProjectionUsingGPU&);
00167     void operator=(const mitk3DBackProjectionUsingGPU&);
00168 };
00169 
00170 
00171 //#define DEFINED_mitk3DBackProjectionUsingGPU
00172 #endif
00173 

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