<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:18pt"><DIV><FONT size=3>Hello All;</FONT></DIV>
<DIV><FONT size=3>Supposing that Pi(xi,yi,zi) is a position on the surface of a dataset and Ni(xi,yi,zi) is the normal calculated from the point Pi using the that<BR>dataset; I will take 50 samples though the normal vector; either positive direction or negatine direction; So I need a trilinear interpolation to get the density values(grey scale values). My problem is that how can I implement trileinear interpolation using VTK. I have found some code through the internet, I haven't understood it if it can able to implement what I would like to do. is there anybody who has done such kind of application?</FONT></DIV>
<DIV> this is the code: the link is: <A href="http://216.239.59.104/search?q=cache:lH_qNB2Ge1UJ:dit.lbl.gov/VTK/GlCache/vtk.cache/contrib/vtkGridTransform.cxx+vtkTrilinearinterpolation&hl=de&ct=clnk&cd=5&gl=at"><FONT size=3>http://216.239.59.104/search?q=cache:lH_qNB2Ge1UJ:dit.lbl.gov/VTK/GlCache/vtk.cache/contrib/vtkGridTransform.cxx+vtkTrilinearinterpolation&hl=de&ct=clnk&cd=5&gl=at</FONT></A></DIV>
<DIV><FONT size=3></FONT> </DIV>
<DIV><FONT size=3>static void <B style="COLOR: black; BACKGROUND-COLOR: #ffff66">vtkTrilinearInterpolation</B>(float point[3], <BR>                                 float displacement[3],<BR>                                 float derivatives[3][3],<BR>                                 void *gridPtr, int gridType, <BR>                                 int gridExt[6], int gridInc[3])<BR>{<BR> // change point into integer plus fraction<BR> float f[3];<BR> int floorX = vtkGridFloor(point[0],f[0]);<BR> int floorY = vtkGridFloor(point[1],f[1]);<BR> int floorZ = vtkGridFloor(point[2],f[2]);<BR><BR> int gridId0[3];<BR> gridId0[0] = floorX - gridExt[0];<BR> gridId0[1] = floorY - gridExt[2];<BR> gridId0[2] = floorZ - gridExt[4];<BR><BR> int gridId1[3];<BR> gridId1[0] = gridId0[0] + 1;<BR> gridId1[1] = gridId0[1] + 1;<BR> gridId1[2] = gridId0[2] + 1;<BR><BR> int ext[3];<BR> ext[0] =
gridExt[1] - gridExt[0];<BR> ext[1] = gridExt[3] - gridExt[2];<BR> ext[2] = gridExt[5] - gridExt[4];<BR><BR> // do bounds check, most points will be inside so optimize for that<BR> if ((gridId0[0] | (ext[0] - gridId1[0]) |<BR> gridId0[1] | (ext[1] - gridId1[1]) |<BR> gridId0[2] | (ext[2] - gridId1[2])) < 0)<BR> {<BR> for (int i = 0; i < 3; i++)<BR> {<BR> if (gridId0[i] < 0)<BR> {<BR> gridId0[i] = 0;<BR> gridId1[i] = 0;<BR> f[i] = 0;<BR> }<BR> else if (gridId1[i] > ext[i])<BR>
{<BR> gridId0[i] = ext[i];<BR> gridId1[i] = ext[i];<BR> f[i] = 0;<BR> }<BR> }<BR> }<BR><BR> // do trilinear interpolation<BR> int factX0 = gridId0[0]*gridInc[0];<BR> int factY0 = gridId0[1]*gridInc[1];<BR> int factZ0 = gridId0[2]*gridInc[2];<BR><BR> int factX1 = gridId1[0]*gridInc[0];<BR> int factY1 = gridId1[1]*gridInc[1];<BR> int factZ1 = gridId1[2]*gridInc[2];<BR> <BR> int i000 = factX0+factY0+factZ0;<BR> int i001 = factX0+factY0+factZ1;<BR> int i010 = factX0+factY1+factZ0;<BR> int i011 = factX0+factY1+factZ1;<BR> int i100 = factX1+factY0+factZ0;<BR> int i101 = factX1+factY0+factZ1;<BR> int i110 = factX1+factY1+factZ0;<BR> int i111 =
factX1+factY1+factZ1;<BR>switch (gridType)<BR> {<BR> case VTK_CHAR:<BR> vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                 (char *)gridPtr,<BR>                 i000, i001, i010, i011, i100, i101, i110, i111);<BR> break;<BR> case VTK_UNSIGNED_CHAR:<BR> vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                 (unsigned char *)gridPtr,<BR>                 i000, i001, i010, i011, i100, i101, i110, i111);<BR> break;<BR> case VTK_SHORT:<BR> vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                 (short *)gridPtr, <BR>                 i000, i001, i010, i011, i100, i101, i110,
i111);<BR> break;<BR> case VTK_UNSIGNED_SHORT:<BR> vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                 (unsigned short *)gridPtr,<BR>                 i000, i001, i010, i011, i100, i101, i110, i111);<BR> break;<BR> case VTK_FLOAT:<BR> vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                 (float *)gridPtr,<BR>                 i000, i001, i010, i011, i100, i101, i110, i111);<BR> break;<BR> }<BR>}<BR></FONT></DIV>
<DIV><FONT size=3>thank you </FONT></DIV>
<DIV><FONT size=3>Tony</DIV></FONT></div><br>
<hr size=1>Be a PS3 game guru.<br>Get your game face on with <a href="http://us.rd.yahoo.com/evt=49936/*http://videogames.yahoo.com">the latest PS3 news and previews at Yahoo! Games.</a></body></html>