1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| int CVolume::RasterizeSliceNearest(void* aiSlice,
const double* adOrigVOL,
const double* adVectorDepVOL,
const double* adResVOL,
const int iNbWidthVIEW,
const int iNbHeightVIEW,
const int iValMinVOL)
{
double adCurPosVOL[3];
double adOrigPosVOL[3];
double adVectorPosVOLX[3];
double adVectorPosVOLY[3];
int aiVoxelVOL[3];
short* aiVolumeTemp;
unsigned char* acVolumeTemp;
int iPos=0;
for(int k = 0 ; k<3;k++)
{
adOrigPosVOL[k] = adOrigVOL[k]/adResVOL[k];
adVectorPosVOLX[k] = adVectorDepVOL[k]/adResVOL[k];
adVectorPosVOLY[k] = adVectorDepVOL[k+3]/adResVOL[k];
}
aiVolumeTemp = (short*)m_aiPixelsValue;
for(int i=0; i<iNbHeightVIEW;i++)
{
adOrigPosVOL[0]+=adVectorPosVOLY[0];
adOrigPosVOL[1]+=adVectorPosVOLY[1];
adOrigPosVOL[2]+=adVectorPosVOLY[2];
adCurPosVOL[0] = adOrigPosVOL[0];
adCurPosVOL[1] = adOrigPosVOL[1];
adCurPosVOL[2] = adOrigPosVOL[2];
for(int j=0;j<iNbWidthVIEW;j++)
{
adCurPosVOL[0] += adVectorPosVOLX[0];
adCurPosVOL[1] += adVectorPosVOLX[1];
adCurPosVOL[2] += adVectorPosVOLX[2];
aiVoxelVOL[0] = (int)adCurPosVOL[0];
aiVoxelVOL[1] = (int)adCurPosVOL[1];
aiVoxelVOL[2] = (int)adCurPosVOL[2];
if(adCurPosVOL[0]>=0&&adCurPosVOL[1]>=0&&adCurPosVOL[2]>=0
&&aiVoxelVOL[0]<GetVolDimWidth()&&aiVoxelVOL[1]<GetVolDimHeight()&&aiVoxelVOL[2]<GetVolDimDepth())
{
((short*)aiSlice)[iPos] = (short)aiVolumeTemp[aiVoxelVOL[0]+m_aiDecalInWidthPos[aiVoxelVOL[1]]+m_aiDecalInWidthHeightPos[aiVoxelVOL[2]]];//Aislice est de type void * (tableau à 1 dimension)
//m_aiDecalInWidthHeightPos contient les déplacement de mon tableau
}
else
{
((short*)aiSlice)[iPos] = (short)iValMinVOL;
}
iPos++;
}
}
return 0;
} |
Partager