00001 #pragma once 00002 00003 #ifndef __v_volume_h 00004 #define __v_volume_h 00005 00006 #include <string> 00007 #include <vector> 00008 #include <map> 00009 00010 #include "VVoxel.h" 00011 #include "VMatrix.h" 00012 00016 struct gradientMagnitudeInfo 00017 { 00018 float m_GradientMagnitude; 00019 int m_Count; 00020 }; 00021 00022 class VVolume 00023 { 00024 public: 00028 VVolume(); 00029 00034 VVolume(std::string filepath); 00035 00039 ~VVolume(); 00040 00044 bool loadVolume(std::string filepath, int *volsize); 00045 00049 bool saveVolume(std::string filepath); 00050 00055 std::vector<int> * getHistogramPtr() 00056 { 00057 return &m_Histogram; 00058 } 00059 00064 unsigned char * get2DHistogramPtr() 00065 { 00066 return &m_histogram2d_texture[0]; 00067 } 00068 00073 std::vector<VVoxel> * getVolumeDataPtr() 00074 { 00075 return &m_VolumeData; 00076 } 00077 00082 int getDimX(); 00083 00088 int getDimY(); 00089 00094 int getDimZ(); 00095 00096 00101 unsigned int getGLVolumeHandle() 00102 { 00103 return m_GLVolumeHandle; 00104 } 00105 00110 float * getModelMatrix() 00111 { 00112 return &m_ModelMatrix[0]; 00113 } 00114 00118 void clear(); 00119 00123 void flipVolumeX(); 00124 00128 void flipVolumeY(); 00129 00133 void flipVolumeZ(); 00134 00135 private: 00136 00140 bool bindVolumeInOpenGL(); 00141 00147 const int getNextPowerOfTwo(const int number) 00148 { 00149 int iPowerOfTwo = 1; 00150 00151 while (iPowerOfTwo < number) 00152 iPowerOfTwo = iPowerOfTwo * 2; 00153 00154 return iPowerOfTwo; 00155 }; 00156 00162 bool loadDat(std::string filename, int *volsize); 00163 00169 bool loadGDat(std::string filename, int *volsize); 00170 00171 00172 std::string m_VolumeFilePath; 00173 unsigned int m_GLVolumeHandle; 00174 std::vector<VVoxel> m_VolumeData; 00175 std::vector<int> m_Histogram; 00176 int m_DimX; 00177 int m_DimY; 00178 int m_DimZ; 00179 float m_maxdensity; 00181 VMatrix m_ModelMatrix; 00182 VMatrix m_NormalMatrix; 00184 std::vector<unsigned char> m_histogram2d_texture; 00185 float maxGradientLength; 00186 }; 00187 00188 #endif // __v_volume_h