00001 #ifndef _FVR_vu1112117_H_
00002 #define _FVR_vu1112117_H_
00003
00004 #include <string>
00005 #include <fstream.h>
00006 #include "SimpleDefs.h"
00007 #include <vuSimpleTypes.h>
00008 #include "vuVector.h"
00009 #include "Filter.h"
00010
00011 #include "../intensity.h"
00012 #include "glos.h"
00013
00014 #include <GL/gl.h>
00015 #include <GL/glu.h>
00016
00017 #include "vuImage.h"
00018 #include "vuThread.h"
00019 #include "vuColourRGBa.h"
00020
00021
00022
00023 using namespace FVR_NS;
00024
00025 #define VOLUME_MAX_NUM 10
00026
00027 class vu1112117;
00028 typedef vu1112117 vuVolumeRegularUnimodal3d1B1ValFVR;
00029
00030 class vu1112117 : public vu111211, public vuThread
00031 {
00032 public:
00033 void compareVolumes();
00034
00035
00036 vu1112117();
00037 vu1112117(vu1112117& inst);
00038 ~vu1112117();
00039
00040
00041 public:
00043 virtual bool read();
00044
00046 virtual bool readRaw(void);
00047
00049 void render();
00050
00052 void initOpenGL(void);
00053
00054 vuImage* getBuffer ();
00055
00057 void setViewVectors(const vuVector& view,const vuVector& up,const vuVector& right);
00058
00059
00060 vu1112117& operator=(const vu1112117& rhs);
00061
00062
00063 void setFilter(Filter* filter);
00064
00065
00066
00067 void setSliceScale(t_data scale);
00068 void setSliceBias(t_data bias);
00069
00070
00071
00072
00073 void rotateSliceX(t_data alpha);
00074 void rotateSliceY(t_data alpha);
00075 void rotateSliceZ(t_data alpha);
00076
00077
00078
00079
00080 void clearSlices(void);
00081 void computeSlice(void);
00082 void refineSlice(dword x_stop, dword y_stop, dword x_pass, dword y_pass);
00083
00084
00085
00086
00087 dword getImageWidth(void) const;
00088 dword getImageHeight(void) const;
00089
00090 dword getSliceWidth(void) const;
00091 dword getSliceHeight(void) const;
00092
00093
00094 void setOversampling(t_data s);
00095 float* getScale();
00096 float* getLightIntensity();
00097 private:
00098
00099
00100 void setWrap(dword wrap);
00101
00102
00103
00104 void wrapVolume(t_data* &_volume);
00105
00106
00107
00108 void interpolateSlice(t_data* &_volume, t_data* &_slice,
00109 t_data &_shLight, t_data &_currDC);
00110 void interpolateSlice(t_data* &_volume, t_data* &_slice,
00111 t_data &_shLight, t_data &_currDC,
00112 dword x_stop, dword y_stop,
00113 dword x_pass, dword y_pass);
00114
00115
00116 inline int vu1112117::vcoord(int x, int y, int z) const
00117 {
00118 return ((z * m_Dim2Size + y) * m_Dim1Size + x) * 2;
00119 }
00120
00121 inline int vu1112117::scoord(int x, int y) const
00122 {
00123 return (y * m_SliceXSize + x) * 2;
00124 }
00125
00126 void preprocess(void);
00127 void write_fvr(char* out);
00128 bool read_fvr(t_data* &_volume, ifstream& fin,
00129 dword XSize, dword YSize, dword ZSize, dword d_size);
00130 bool read_shfvr(char* in);
00131 bool doTempFilesExist(string fileName);
00132 void ensureTempDirectory();
00133 public:
00134
00135
00136 void scaleAndBias(t_data* _slice, const vuColourRGBa &color);
00137
00138
00139 void setLightPosition(const vuVector &_light);
00140 void setIsDepthCueing(bool flag);
00141 bool IsDepthCueing(void);
00142
00143 void setIsDiffuseShading(bool flag);
00144 bool IsDiffuseShading();
00145
00146 void setIsPostProcessing(bool flag);
00147 bool IsPostProcessing(void);
00148
00149 void setAmbientColour(const vuColourRGBa _colour);
00150 vuColourRGBa getAmbientColour(void);
00151
00152 void setDiffuseColour(const vuColourRGBa _colour);
00153 vuColourRGBa getDiffuseColour(void);
00154
00155 void drawImageFromSlices(void);
00156
00157 private:
00158
00159 int m_volumeNumber;
00160 t_data* m_Yarray[VOLUME_MAX_NUM];
00161 void deleteVolumes();
00162 t_data m_shLight[VOLUME_MAX_NUM];
00163 bool m_depthCue;
00164 dword m_Wrap;
00165 vuVector m_currLight;
00166
00167
00168 vuColourRGBa m_AmbientColour;
00169 vuColourRGBa m_DiffuseColour;
00170
00171
00172 Filter* m_Filter;
00173
00174
00175 t_data* m__SliceArray[VOLUME_MAX_NUM];
00176 t_data* m_Slice;
00177
00178 vuVector m_XStep;
00179 vuVector m_YStep;
00180 dword m_SliceXSize;
00181 dword m_SliceYSize;
00182 vuVector m_XAxis;
00183 vuVector m_YAxis;
00184 vuVector m_ZAxis;
00185 vuVector m_Origin;
00186
00187
00188 vuImage m_Image;
00189 float m_Scale;
00190 t_data m_Bias;
00191
00192 dword m_InnerXSize;
00193 dword m_InnerYSize;
00194
00195 bool m_isPostProcessing;
00196
00197 void updateShLight();
00198
00199 void destroySlices(void);
00200 void ensureSlices(void);
00201 void accumulateSlices(t_data* _slice, int _from, int _to);
00202 void computeSlice(int num);
00203 void refineSlice(int num,
00204 dword x_stop, dword y_stop, dword x_pass, dword y_pass);
00205
00206
00207 vuMutex m_Mutex[VOLUME_MAX_NUM];
00208
00209 void run(int whatsup, void* data);
00210 bool computeSlicesUsingThreads(void);
00211 bool refineSlicesUsingThreads(dword x_stop, dword y_stop,
00212 dword x_pass, dword y_pass);
00213
00214 void _clearSlices(void);
00215 void _ensureSliceDummy(void);
00216
00217 int computeDimension(void);
00218 void buildVolume(t_data* _volume, byte* _data, dword dim,
00219 dword XSize, dword YSize, dword ZSize);
00220
00221
00222 void _init(void);
00223 };
00224 #endif