Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FVR.h

Go to the documentation of this file.
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 //#define FVR_NO_SLICE_COPY
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     // Default constructor, copy constructor,
00035     // and destructor.
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     // Assignment operator for the volume class.
00060     vu1112117& operator=(const vu1112117& rhs);
00061 
00062     // Set the interpolation filter.
00063     void setFilter(Filter* filter);
00064 
00065     // Set the scale and bias for the slice extraction
00066     // stage of the algorithm.
00067     void setSliceScale(t_data scale);
00068     void setSliceBias(t_data bias);
00069 
00070     // Rotate the slice about its x, y, or z axis.
00071     // The rotations are local to the slice (it carries
00072     // its own coordinate axis system).
00073     void rotateSliceX(t_data alpha);
00074     void rotateSliceY(t_data alpha);
00075     void rotateSliceZ(t_data alpha);
00076 
00077     // Compute the slice for the current angle and
00078     // return the rgb's in a byte*.
00079     // Stop is middle section, pass is bandwidth
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     // Get the dimensions of the current slice (for
00085     // the current version, the same values are returned
00086     // for all angles.)
00087     dword getImageWidth(void) const;
00088     dword getImageHeight(void) const;
00089 
00090     dword getSliceWidth(void) const;
00091     dword getSliceHeight(void) const;
00092 
00093     // set oversampling -- 2 uses twice the number of samples
00094     void setOversampling(t_data s);
00095     float* getScale();
00096     float* getLightIntensity();
00097 private:
00098     // Set the width of the wrap in the frequency
00099     // domain.  Should be half the filter size.
00100     void setWrap(dword wrap);
00101 
00102     // Fix the frequency volume so that it wraps its
00103     // values periodically to half of the filter width.
00104     void wrapVolume(t_data* &_volume);
00105 
00106     // Interpolate the slice, using the currently
00107     // selected filter.
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);// const;
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         // Scale and bias the frequency slice into the rgb
00135         // slice.
00136         void scaleAndBias(t_data* _slice, const vuColourRGBa &color);
00137         
00138         // set light position in world coords
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     // Variables for the volume.
00159     int m_volumeNumber;
00160     t_data* m_Yarray[VOLUME_MAX_NUM];    // arrays of spherical harmonics basis
00161     void deleteVolumes();
00162     t_data m_shLight[VOLUME_MAX_NUM];  // spherical harmonics light
00163     bool   m_depthCue;
00164     dword  m_Wrap;         // Width of the wrap on the volume
00165     vuVector m_currLight;  // holds the current light in the current coordinate system
00166 
00167     // colour
00168     vuColourRGBa m_AmbientColour;
00169     vuColourRGBa m_DiffuseColour;
00170 
00171     // Variables for the interpolation filter
00172     Filter* m_Filter;
00173 
00174     // Variables for the slice
00175     t_data* m__SliceArray[VOLUME_MAX_NUM]; //for parallel computing of slices
00176     t_data* m_Slice; // used by drawImageFormSlices()
00177 
00178     vuVector m_XStep;        // Xstep for sampling
00179     vuVector m_YStep;        // Ystep for sampling
00180     dword    m_SliceXSize;   // Slice x-size
00181     dword    m_SliceYSize;   // Slice y-size
00182     vuVector m_XAxis;        // Slice x-axis
00183     vuVector m_YAxis;        // Slice y-axis
00184     vuVector m_ZAxis;        // Slice z-axis
00185     vuVector m_Origin;       // Bottom left corner of slice
00186 
00187     // image vars
00188     vuImage m_Image;
00189     float m_Scale;          // Slice scale factor
00190     t_data m_Bias;          // Slice bias factor
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     // threads
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

Generated on Wed Dec 15 21:20:28 2004 for vuVolume by  doxygen 1.3.9.1