00001 #pragma once 00002 00003 class Voxel 00004 { 00005 public: 00006 00007 Voxel() 00008 { 00009 }; 00010 00011 Voxel(const unsigned short uValue) 00012 { 00013 SetValue(uValue); 00014 }; 00015 00016 Voxel(const unsigned short uValue, const unsigned short *vsGradient) 00017 { 00018 SetValue(uValue); 00019 SetGradient(vsGradient); 00020 }; 00021 00022 Voxel(const unsigned short uValue, const unsigned short uGx, const unsigned short uGy, const unsigned short uGz) 00023 { 00024 SetValue(uValue); 00025 SetGradient(uGx,uGy,uGz); 00026 }; 00027 00028 Voxel(const unsigned short uValue1nx1ny1nz, const unsigned short uValue0px1ny1nz, const unsigned short uValue1px1ny1nz, const unsigned short uValue1nx0py1nz, const unsigned short uValue0px0py1nz, const unsigned short uValue1px0py1nz, const unsigned short uValue1nx1py1nz, const unsigned short uValue0px1py1nz, const unsigned short uValue1px1py1nz, const unsigned short uValue1nx1ny0pz, const unsigned short uValue0px1ny0pz, const unsigned short uValue1px1ny0pz, const unsigned short uValue1nx0py0pz, const unsigned short uValue0px0py0pz, const unsigned short uValue1px0py0pz, const unsigned short uValue1nx1py0pz, const unsigned short uValue0px1py0pz, const unsigned short uValue1px1py0pz, const unsigned short uValue1nx1ny1pz, const unsigned short uValue0px1ny1pz, const unsigned short uValue1px1ny1pz, const unsigned short uValue1nx0py1pz, const unsigned short uValue0px0py1pz, const unsigned short uValue1px0py1pz, const unsigned short uValue1nx1py1pz, const unsigned short uValue0px1py1pz, const unsigned short uValue1px1py1pz) 00029 { 00030 static const int viWeights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; 00031 static const int iWeightValue = viWeights[0][0][0] + viWeights[1][0][0] + viWeights[2][0][0] + viWeights[0][1][0] + viWeights[1][1][0] + viWeights[2][1][0] + viWeights[0][2][0] + viWeights[1][2][0] + viWeights[2][2][0] + viWeights[0][0][1] + viWeights[1][0][1] + viWeights[2][0][1] + viWeights[0][1][1] + viWeights[1][1][1] + viWeights[2][1][1] + viWeights[0][2][1] + viWeights[1][2][1] + viWeights[2][2][1] + viWeights[0][0][2] + viWeights[1][0][2] + viWeights[2][0][2] + viWeights[0][1][2] + viWeights[1][1][2] + viWeights[2][1][2] + viWeights[0][2][2] + viWeights[1][2][2] + viWeights[2][2][2]; 00032 static const int iWeightGx = viWeights[0][0][0] + viWeights[1][0][0] + viWeights[2][0][0] + viWeights[0][1][0] + viWeights[1][1][0] + viWeights[2][1][0] + viWeights[0][2][0] + viWeights[1][2][0] + viWeights[2][2][0] + viWeights[0][0][2] + viWeights[1][0][2] + viWeights[2][0][2] + viWeights[0][1][2] + viWeights[1][1][2] + viWeights[2][1][2] + viWeights[0][2][2] + viWeights[1][2][2] + viWeights[2][2][2]; 00033 static const int iWeightGy = viWeights[0][0][0] + viWeights[1][0][0] + viWeights[2][0][0] + viWeights[0][2][0] + viWeights[1][2][0] + viWeights[2][2][0] + viWeights[0][0][1] + viWeights[1][0][1] + viWeights[2][0][1] + viWeights[0][2][1] + viWeights[1][2][1] + viWeights[2][2][1] + viWeights[0][0][2] + viWeights[1][0][2] + viWeights[2][0][2] + viWeights[0][2][2] + viWeights[1][2][2] + viWeights[2][2][2]; 00034 static const int iWeightGz = viWeights[0][0][0] + viWeights[2][0][0] + viWeights[0][1][0] + viWeights[2][1][0] + viWeights[0][2][0] + viWeights[2][2][0] + viWeights[0][0][1] + viWeights[2][0][1] + viWeights[0][1][1] + viWeights[2][1][1] + viWeights[0][2][1] + viWeights[2][2][1] + viWeights[0][0][2] + viWeights[2][0][2] + viWeights[0][1][2] + viWeights[2][1][2] + viWeights[0][2][2] + viWeights[2][2][2]; 00035 00036 const int iValue((+ viWeights[0][0][0] * uValue1nx1ny1nz + viWeights[1][0][0] * uValue1nx1ny0pz + viWeights[2][0][0] * uValue1nx1ny1pz + viWeights[0][1][0] * uValue1nx0py1nz + viWeights[1][1][0] * uValue1nx0py0pz + viWeights[2][1][0] * uValue1nx0py1pz + viWeights[0][2][0] * uValue1nx1py1nz + viWeights[1][2][0] * uValue1nx1py0pz + viWeights[2][2][0] * uValue1nx1py1pz + viWeights[0][0][1] * uValue0px1ny1nz + viWeights[1][0][1] * uValue0px1ny0pz + viWeights[2][0][1] * uValue0px1ny1pz + viWeights[0][1][1] * uValue0px0py1nz + viWeights[2][1][1] * uValue0px0py1pz + viWeights[0][2][1] * uValue0px1py1nz + viWeights[1][2][1] * uValue0px1py0pz + viWeights[2][2][1] * uValue0px1py1pz + viWeights[0][0][2] * uValue1px1ny1nz + viWeights[1][0][2] * uValue1px1ny0pz + viWeights[2][0][2] * uValue1px1ny1pz + viWeights[0][1][2] * uValue1px0py1nz + viWeights[1][1][2] * uValue1px0py0pz + viWeights[2][1][2] * uValue1px0py1pz + viWeights[0][2][2] * uValue1px1py1nz + viWeights[1][2][2] * uValue1px1py0pz + viWeights[2][2][2] * uValue1px1py1pz) / iWeightValue); 00037 const int iGx((- viWeights[0][0][0] * uValue1nx1ny1nz - viWeights[1][0][0] * uValue1nx1ny0pz - viWeights[2][0][0] * uValue1nx1ny1pz - viWeights[0][1][0] * uValue1nx0py1nz - viWeights[1][1][0] * uValue1nx0py0pz - viWeights[2][1][0] * uValue1nx0py1pz - viWeights[0][2][0] * uValue1nx1py1nz - viWeights[1][2][0] * uValue1nx1py0pz - viWeights[2][2][0] * uValue1nx1py1pz + viWeights[0][0][2] * uValue1px1ny1nz + viWeights[1][0][2] * uValue1px1ny0pz + viWeights[2][0][2] * uValue1px1ny1pz + viWeights[0][1][2] * uValue1px0py1nz + viWeights[1][1][2] * uValue1px0py0pz + viWeights[2][1][2] * uValue1px0py1pz + viWeights[0][2][2] * uValue1px1py1nz + viWeights[1][2][2] * uValue1px1py0pz + viWeights[2][2][2] * uValue1px1py1pz) / iWeightGx); 00038 const int iGy((- viWeights[0][0][0] * uValue1nx1ny1nz - viWeights[1][0][0] * uValue1nx1ny0pz - viWeights[2][0][0] * uValue1nx1ny1pz + viWeights[0][2][0] * uValue1nx1py1nz + viWeights[1][2][0] * uValue1nx1py0pz + viWeights[2][2][0] * uValue1nx1py1pz - viWeights[0][0][1] * uValue0px1ny1nz - viWeights[1][0][1] * uValue0px1ny0pz - viWeights[2][0][1] * uValue0px1ny1pz + viWeights[0][2][1] * uValue0px1py1nz + viWeights[1][2][1] * uValue0px1py0pz + viWeights[2][2][1] * uValue0px1py1pz - viWeights[0][0][2] * uValue1px1ny1nz - viWeights[1][0][2] * uValue1px1ny0pz - viWeights[2][0][2] * uValue1px1ny1pz + viWeights[0][2][2] * uValue1px1py1nz + viWeights[1][2][2] * uValue1px1py0pz + viWeights[2][2][2] * uValue1px1py1pz) / iWeightGy); 00039 const int iGz((- viWeights[0][0][0] * uValue1nx1ny1nz + viWeights[2][0][0] * uValue1nx1ny1pz - viWeights[0][1][0] * uValue1nx0py1nz + viWeights[2][1][0] * uValue1nx0py1pz - viWeights[0][2][0] * uValue1nx1py1nz + viWeights[2][2][0] * uValue1nx1py1pz - viWeights[0][0][1] * uValue0px1ny1nz + viWeights[2][0][1] * uValue0px1ny1pz - viWeights[0][1][1] * uValue0px0py1nz + viWeights[2][1][1] * uValue0px0py1pz - viWeights[0][2][1] * uValue0px1py1nz + viWeights[2][2][1] * uValue0px1py1pz - viWeights[0][0][2] * uValue1px1ny1nz + viWeights[2][0][2] * uValue1px1ny1pz - viWeights[0][1][2] * uValue1px0py1nz + viWeights[2][1][2] * uValue1px0py1pz - viWeights[0][2][2] * uValue1px1py1nz + viWeights[2][2][2] * uValue1px1py1pz) / iWeightGz); 00040 00041 SetValue(unsigned short(iValue)); 00042 SetGradient(unsigned short(iGx),unsigned short(iGy),unsigned short(iGz)); 00043 } 00044 00045 ~Voxel(void) 00046 { 00047 }; 00048 00049 void SetValue(const unsigned short uValue) 00050 { 00051 m_uValue = uValue; 00052 }; 00053 00054 const unsigned short GetValue() const 00055 { 00056 return m_uValue; 00057 }; 00058 00059 void SetGradient(const unsigned short *vsGradient) 00060 { 00061 m_vsGradient[0] = vsGradient[0]; 00062 m_vsGradient[1] = vsGradient[1]; 00063 m_vsGradient[2] = vsGradient[2]; 00064 }; 00065 00066 void SetGradient(const short uGx, const short uGy, const short uGz) 00067 { 00068 m_vsGradient[0] = uGx; 00069 m_vsGradient[1] = uGy; 00070 m_vsGradient[2] = uGz; 00071 }; 00072 00073 void SetGradientX(const short uGx) 00074 { 00075 m_vsGradient[0] = uGx; 00076 }; 00077 00078 void SetGradientY(const short uGy) 00079 { 00080 m_vsGradient[1] = uGy; 00081 }; 00082 00083 void SetGradientZ(const short uGz) 00084 { 00085 m_vsGradient[2] = uGz; 00086 }; 00087 00088 void SetGradient(const int iComponent, const short uValue) 00089 { 00090 m_vsGradient[iComponent] = uValue; 00091 }; 00092 00093 const short * GetGradient() const 00094 { 00095 return m_vsGradient; 00096 }; 00097 00098 const short GetGradientX() const 00099 { 00100 return m_vsGradient[0]; 00101 }; 00102 00103 const short GetGradientY() const 00104 { 00105 return m_vsGradient[1]; 00106 }; 00107 00108 const short GetGradientZ() const 00109 { 00110 return m_vsGradient[2]; 00111 }; 00112 00113 const short GetGradient(const int iComponent) const 00114 { 00115 return m_vsGradient[iComponent]; 00116 }; 00117 00118 private: 00119 00120 unsigned short m_uValue; 00121 short *m_vsGradient; 00122 00123 };