<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&nbsp; 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>&nbsp;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&amp;hl=de&amp;ct=clnk&amp;cd=5&amp;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&amp;hl=de&amp;ct=clnk&amp;cd=5&amp;gl=at</FONT></A></DIV>
<DIV><FONT size=3></FONT>&nbsp;</DIV>
<DIV><FONT size=3>static void <B style="COLOR: black; BACKGROUND-COLOR: #ffff66">vtkTrilinearInterpolation</B>(float point[3], <BR>                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float displacement[3],<BR>                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float derivatives[3][3],<BR>                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void *gridPtr, int gridType, <BR>                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int gridExt[6], int gridInc[3])<BR>{<BR>&nbsp; // change point into integer plus fraction<BR>&nbsp; float f[3];<BR>&nbsp; int floorX = vtkGridFloor(point[0],f[0]);<BR>&nbsp; int floorY = vtkGridFloor(point[1],f[1]);<BR>&nbsp; int floorZ = vtkGridFloor(point[2],f[2]);<BR><BR>&nbsp; int gridId0[3];<BR>&nbsp; gridId0[0] = floorX - gridExt[0];<BR>&nbsp; gridId0[1] = floorY - gridExt[2];<BR>&nbsp; gridId0[2] = floorZ - gridExt[4];<BR><BR>&nbsp; int gridId1[3];<BR>&nbsp; gridId1[0] = gridId0[0] + 1;<BR>&nbsp; gridId1[1] = gridId0[1] + 1;<BR>&nbsp; gridId1[2] = gridId0[2] + 1;<BR><BR>&nbsp; int ext[3];<BR>&nbsp; ext[0] =
 gridExt[1] - gridExt[0];<BR>&nbsp; ext[1] = gridExt[3] - gridExt[2];<BR>&nbsp; ext[2] = gridExt[5] - gridExt[4];<BR><BR>&nbsp; // do bounds check, most points will be inside so optimize for that<BR>&nbsp; if ((gridId0[0] | (ext[0] - gridId1[0]) |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId0[1] | (ext[1] - gridId1[1]) |<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId0[2] | (ext[2] - gridId1[2])) &lt; 0)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; 3; i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (gridId0[i] &lt; 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId0[i] = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId1[i] = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f[i] = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (gridId1[i] &gt; ext[i])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId0[i] = ext[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gridId1[i] = ext[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f[i] = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp; // do trilinear interpolation<BR>&nbsp; int factX0 = gridId0[0]*gridInc[0];<BR>&nbsp; int factY0 = gridId0[1]*gridInc[1];<BR>&nbsp; int factZ0 = gridId0[2]*gridInc[2];<BR><BR>&nbsp; int factX1 = gridId1[0]*gridInc[0];<BR>&nbsp; int factY1 = gridId1[1]*gridInc[1];<BR>&nbsp; int factZ1 = gridId1[2]*gridInc[2];<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; int i000 = factX0+factY0+factZ0;<BR>&nbsp; int i001 = factX0+factY0+factZ1;<BR>&nbsp; int i010 = factX0+factY1+factZ0;<BR>&nbsp; int i011 = factX0+factY1+factZ1;<BR>&nbsp; int i100 = factX1+factY0+factZ0;<BR>&nbsp; int i101 = factX1+factY0+factZ1;<BR>&nbsp; int i110 = factX1+factY1+factZ0;<BR>&nbsp; int i111 =
 factX1+factY1+factZ1;<BR>switch (gridType)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; case VTK_CHAR:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (char *)gridPtr,<BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i000, i001, i010, i011, i100, i101, i110, i111);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp; case VTK_UNSIGNED_CHAR:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (unsigned char *)gridPtr,<BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i000, i001, i010, i011, i100, i101, i110, i111);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp; case VTK_SHORT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (short *)gridPtr, <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i000, i001, i010, i011, i100, i101, i110,
 i111);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp; case VTK_UNSIGNED_SHORT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (unsigned short *)gridPtr,<BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i000, i001, i010, i011, i100, i101, i110, i111);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp; case VTK_FLOAT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkLinearHelper(displacement, derivatives, f[0], f[1], f[2], <BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (float *)gridPtr,<BR>                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i000, i001, i010, i011, i100, i101, i110, i111);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp; }<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>