00001 #ifndef RAY_H
00002 #define RAY_H
00003
00004 #include <assert.h>
00005 #include "vector.h"
00006 #include "transfunc.h"
00007 #include "data.h"
00008 #include "plane.h"
00009
00010
00011 #define ROUND(x) (((fabs(x - floor(x))) < 0.5) ? floor(x) : ceil(x))
00012
00013 class Ray {
00014 protected:
00015 bool m_light;
00016 VECTOR m_lightpos;
00017
00018 virtual Color Lighting(Color color);
00019
00020
00021 VECTOR m_currentpos;
00022
00023 float m_ambient;
00024
00025 float m_diffuse;
00026
00027 float m_specular;
00028
00029 int m_highlight;
00030
00031 Transfunc *m_tf;
00032
00033 Data *m_data;
00034
00035 Color m_backgroundcolor;
00036
00037 Color m_currentcolor;
00038
00039 float m_alpha;
00040
00041 VECTOR m_startpoint;
00042
00043 VECTOR m_direction;
00044 float m_steplength;
00045 Plane * m_viewingplane;
00046
00047 float mx,my,mz, m_radius;
00048 public:
00049 Ray();
00050 ~Ray();
00051
00052 bool SetViewingCondition(VECTOR lightpos, float ambient, float diffuse, float specular, int highlight);
00053
00054 bool Initialize(Color background, Color current, float steplength, Plane* viewingplane, Data *data, Transfunc *tf);
00055 bool SetPosDir(VECTOR currentpos, VECTOR direction);
00056 Color GetCurrentColor();
00057 float GetAlpha() { return m_alpha;};
00058 void SetLight(bool light) { m_light = light;};
00059 virtual bool CastNext();
00060 bool Reset() {m_alpha = 0.0; m_currentcolor = m_backgroundcolor; return true;};
00061 };
00062
00063 class Trilinear : public Ray {
00064 protected:
00065 Color CalcColorTrilinear(VECTOR pos);
00066 gradient_t CalcGradTrilinear(VECTOR pos);
00067 float CalcAlphaTrilinear(VECTOR pos);
00068 Color Lighting(Color color);
00069
00070 public:
00071 Trilinear() {};
00072 bool CastNext();
00073 };
00074
00075
00076
00077
00078 class FirstHitNN : public Ray {
00079 protected:
00080 int m_treshold;
00081 public:
00082 FirstHitNN(){m_treshold = 0.0;};
00083 bool SetTreshold(int treshold) { m_treshold = treshold; return true;};
00084 virtual bool CastNext();
00085 };
00086
00087 class FirstHitTRI : public Trilinear {
00088 protected:
00089 int m_treshold;
00090 float GetDensity(VECTOR pos);
00091 public:
00092 FirstHitTRI(){m_treshold = 0.0;};
00093 bool SetTreshold(int treshold) { m_treshold = treshold; return true;};
00094 bool CastNext();
00095 };
00096
00097
00098 class MaxIntensityNN : public Ray {
00099 public:
00100 MaxIntensityNN(){};
00101 ~MaxIntensityNN(){};
00102 bool CastNext();
00103 };
00104
00105
00106
00107 class MaxIntensityTRI : public FirstHitTRI {
00108 public:
00109 MaxIntensityTRI(){};
00110 ~MaxIntensityTRI(){};
00111 bool CastNext();
00112 };
00113
00114 class XRayNN : public Ray {
00115 public:
00116 XRayNN(){};
00117 ~XRayNN(){};
00118 bool CastNext();
00119 };
00120
00121 class XRayTRI : public FirstHitTRI {
00122 public:
00123 XRayTRI(){};
00124 ~XRayTRI(){};
00125 bool CastNext();
00126 };
00127
00128 class AverageNN : public Ray {
00129 public:
00130 AverageNN(){};
00131 ~AverageNN(){};
00132 bool CastNext();
00133 };
00134
00135 class AverageTRI : public FirstHitTRI {
00136 public:
00137 AverageTRI(){};
00138 ~AverageTRI(){};
00139 bool CastNext();
00140 };
00141
00142 #endif