#include <data.h>
Public Methods | |
Data () | |
~Data () | |
bool | SetPreCalc (bool pc) |
void | SetFileThreshold (int dFileThreshold) |
void | SetDataPackets (int dDataPack) |
short | GetXDim () |
gibt den maximalen X-Wert meines Volumens zurück | |
short | GetYDim () |
gibt den maximalen Y-Wert meines Volumens zurück | |
short | GetZDim () |
gibt den maximalen Z-Wert meines Volumens zurück | |
int | GetHistogram (int density) |
int | GetDensity (int x, int y, int z) |
void | LoadData (char *fname) |
gradient_t | CalcGrad (int x, int y, int z) |
Public Attributes | |
string | filename |
Private Methods | |
bool | CalcDensityHistogram () |
bool | CalcGradients () |
Berechnet alle Gradienten vor. | |
Private Attributes | |
int | m_FileThreshold |
int | m_DataPackets |
short | xDim |
short | yDim |
short | zDim |
int | xyDim |
int | size |
short * | data |
gradient_t * | gradients |
int | histogram [4096] |
bool | precalc |
|
Definition at line 39 of file data.h. References MB_TO_DATASET_THRES.
00039 { xDim = 0; 00040 yDim = 0; 00041 zDim = 0; 00042 xyDim = 0; 00043 size = 0; 00044 data = NULL; 00045 gradients = NULL; 00046 precalc = false; 00047 m_FileThreshold = 40; 00048 m_DataPackets = MB_TO_DATASET_THRES(10); 00049 }; |
|
Definition at line 51 of file data.h.
|
|
berechnet für jede Dichte die Anzahl der Datenpunkte, die diese Dichte aufweisen und gibt diese Wert in ein histogrammarray ein. Definition at line 44 of file data.cpp. References data, histogram, and size. Referenced by LoadData().
|
|
berechnet für einen Datenpunkt mit ganzzahligen Koordinaten innerhalb des Volumens den Gradientenvektor Definition at line 73 of file data.cpp. References CalcGradients(), GetDensity(), gradients, precalc, gradient_t::x, xDim, xyDim, gradient_t::y, yDim, gradient_t::z, and zDim. Referenced by Trilinear::CalcGradTrilinear(), and Ray::Lighting().
00073 { 00074 if(precalc && gradients == NULL) CalcGradients(); 00075 if(x < 0) x = 0; 00076 if(x > xDim-1) x = xDim-1; 00077 if(z < 0) z = 0; 00078 if(z > zDim-1) z = zDim-1; 00079 if(y < 0) y = 0; 00080 if(y > yDim-1) y = yDim-1; 00081 gradient_t res; 00082 if(!precalc) { 00083 res.x = ((float)(GetDensity(x+1,y,z) - GetDensity(x-1,y,z)))/2.0; 00084 res.y = ((float)(GetDensity(x,y+1,z) - GetDensity(x,y-1,z)))/2.0; 00085 res.z = ((float)(GetDensity(x,y,z+1) - GetDensity(x,y,z-1)))/2.0; 00086 } else { 00087 res = gradients[z*xyDim+y*xDim+x]; 00088 } 00089 return res; 00090 } |
|
Berechnet alle Gradienten vor.
Definition at line 94 of file data.cpp. References GetDensity(), gradients, xDim, xyDim, yDim, and zDim. Referenced by CalcGrad().
00094 { 00095 if (gradients != NULL) return false; 00096 gradients = new gradient_t[xDim*yDim*zDim]; 00097 00098 for(int z = 0; z < zDim; z++) { 00099 for(int y = 0; y < yDim; y++) { 00100 for(int x = 0; x < xDim; x++) { 00101 gradients[z*xyDim+y*xDim+x].x = ((float)(GetDensity(x+1,y,z) - GetDensity(x-1,y,z)))/2.0; 00102 gradients[z*xyDim+y*xDim+x].y = ((float)(GetDensity(x,y+1,z) - GetDensity(x,y-1,z)))/2.0; 00103 gradients[z*xyDim+y*xDim+x].z = ((float)(GetDensity(x,y,z+1) - GetDensity(x,y,z-1)))/2.0; 00104 } 00105 } 00106 } 00107 00108 return true; 00109 } |
|
gibt die Dichte an einem diskreten Punkt mit ganzzahligen Koordinaten im Datenvolumen als integer Wert zwischen 0 und 4095 zurück Definition at line 30 of file data.cpp. References data, xDim, xyDim, yDim, and zDim. Referenced by Trilinear::CalcAlphaTrilinear(), Trilinear::CalcColorTrilinear(), CalcGrad(), CalcGradients(), XRayNN::CastNext(), MaxIntensityNN::CastNext(), FirstHitNN::CastNext(), Ray::CastNext(), FirstHitTRI::GetDensity(), and Slice::SetPixels().
|
|
gibt den Wert des Histogramms bei einer bestimmten Dichte zurück
Definition at line 62 of file data.cpp. References histogram. Referenced by transferfuncform::m_DrawHistogram().
00063 { 00064 if(density < 0) density = 0; 00065 if(density >= 4096) density = 4095; 00066 return histogram[density]; 00067 } |
|
gibt den maximalen X-Wert meines Volumens zurück
Definition at line 206 of file data.cpp. References xDim. Referenced by Slice::GetSliceNumber(), Ray::Initialize(), Raycaster::Raycast(), Slice::SetPixels(), and Raycaster::Zoom().
00207 { 00208 return xDim; 00209 } |
|
gibt den maximalen Y-Wert meines Volumens zurück
Definition at line 213 of file data.cpp. References yDim. Referenced by Slice::GetSliceNumber(), Ray::Initialize(), Raycaster::Raycast(), Slice::SetPixels(), and Raycaster::Zoom().
00214 { 00215 return yDim; 00216 } |
|
gibt den maximalen Z-Wert meines Volumens zurück
Definition at line 220 of file data.cpp. References zDim. Referenced by Slice::GetSliceNumber(), Ray::Initialize(), Raycaster::Raycast(), Slice::SetPixels(), and Raycaster::Zoom().
00221 { 00222 return zDim; 00223 } |
|
Lädt das Datenfile (*.dat) die CT-Daten in ein eindimensionales Array mit der Größe maxX*maxY*maxZ Definition at line 114 of file data.cpp. References CalcDensityHistogram(), data, DATASET_TO_MB, filename, m_DataPackets, m_FileThreshold, size, xDim, xyDim, yDim, and zDim.
00115 { 00116 00117 char *filename = (char *)fname; 00118 00119 FILE *filePtr; 00120 00121 // open File 00122 filePtr = fopen(filename, "rb"); 00123 if(!filePtr) return;// false; 00124 00125 //getting headerinfo 00126 fread(&xDim, sizeof(short),1,filePtr); 00127 fread(&yDim, sizeof(short),1,filePtr); 00128 fread(&zDim, sizeof(short),1,filePtr); 00129 00130 00131 xyDim = (int)xDim*yDim; 00132 00133 00134 size = xyDim * zDim; 00135 data = new short[size]; 00136 00137 00138 CWnd* pFrame = AfxGetMainWnd(); 00139 00140 int loadSize = (size) / 100; 00141 int counter = loadSize; 00142 int pos = 0; 00143 int fileSize = 0; 00144 00145 /* 00146 size means the size in data-sets!! 00147 partially loading if approx filesize is greater than 40MB 00148 (size * 16) / 8 / 1024 / 1024 = (size >> 19) 00149 */ 00150 if ((m_FileThreshold != 0) && 00151 (fileSize = DATASET_TO_MB(size)) >= m_FileThreshold) { 00152 int pieces = size / m_DataPackets; 00153 00154 00155 00156 00157 pFrame->SendMessage(MYWM_PROGRESS_MIN_MAX, 0, pieces); 00158 00159 int tempSize = size; 00160 00161 for (int i = 0; i < pieces; i++) { 00162 pFrame->SendMessage(MYWM_PROGRESS, i); 00163 fread(data + i * m_DataPackets, sizeof(short), m_DataPackets, filePtr); 00164 tempSize -= m_DataPackets; 00165 } 00166 00167 pFrame->SendMessage(MYWM_PROGRESS, i); 00168 if (tempSize > 0) 00169 fread(data + i * m_DataPackets, sizeof(short), tempSize, filePtr); 00170 } 00171 else { 00172 fread(data,sizeof(short),size,filePtr); 00173 } 00174 00175 fclose(filePtr); 00176 00177 pFrame->SendMessage(MYWM_PROGRESS_MIN_MAX, 0, 100); 00178 00179 //only 12 bit of data are used for each voxel (4096 density values) 00180 for(int z=0; z < zDim; z++) { 00181 for(int y=0; y < yDim; y++) { 00182 for(int x=0; x < xDim; x++) { 00183 data[z*xyDim+y*xDim+x] &= 0x0fff; 00184 00185 //progressbar 00186 if (counter-- <= 0) { 00187 counter = loadSize; 00188 pFrame->SendMessage(MYWM_PROGRESS, pos++); 00189 } 00190 } 00191 } 00192 } 00193 00194 pFrame->SendMessage(MYWM_PROGRESS, 0); 00195 00196 00197 this->filename = filename; 00198 00199 if(!CalcDensityHistogram()) return;// false; 00200 00201 // return true; 00202 } |
|
Definition at line 54 of file data.h. References MB_TO_DATASET_THRES.
00054 { m_DataPackets = MB_TO_DATASET_THRES(dDataPack); }; |
|
Definition at line 53 of file data.h.
00053 { m_FileThreshold = dFileThreshold; }; |
|
Definition at line 52 of file data.h. Referenced by Raycaster::Raycast().
00052 { precalc = pc; return true;} |
|
Definition at line 32 of file data.h. Referenced by CalcDensityHistogram(), GetDensity(), and LoadData(). |
|
Definition at line 64 of file data.h. Referenced by LoadData(). |
|
Definition at line 33 of file data.h. Referenced by CalcGrad(), and CalcGradients(). |
|
Definition at line 35 of file data.h. Referenced by CalcDensityHistogram(), and GetHistogram(). |
|
Definition at line 27 of file data.h. Referenced by LoadData(). |
|
Definition at line 25 of file data.h. Referenced by LoadData(). |
|
Definition at line 36 of file data.h. Referenced by CalcGrad(). |
|
Definition at line 31 of file data.h. Referenced by CalcDensityHistogram(), and LoadData(). |
|
Definition at line 29 of file data.h. Referenced by CalcGrad(), CalcGradients(), GetDensity(), GetXDim(), and LoadData(). |
|
Definition at line 30 of file data.h. Referenced by CalcGrad(), CalcGradients(), GetDensity(), and LoadData(). |
|
Definition at line 29 of file data.h. Referenced by CalcGrad(), CalcGradients(), GetDensity(), GetYDim(), and LoadData(). |
|
Definition at line 29 of file data.h. Referenced by CalcGrad(), CalcGradients(), GetDensity(), GetZDim(), and LoadData(). |