<div class="gmail_quote">On Thu, Feb 25, 2010 at 7:20 AM, Andrea Bottino <span dir="ltr"><<a href="mailto:andrea.bottino@polito.it">andrea.bottino@polito.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Verdana">Hi everybody,<br>
<br>
I solved the previous problem using vtkCellLocator. for who's
interested, given a vtkPolyData source the code is:<br>
<br>
<br>
// the cell locator<br>
vtkCellLocator* locator = vtkCellLocator::New();<br>
locator->SetDataSet(source);<br>
locator->CacheCellBoundsOn();<br>
locator->AutomaticOn();<br>
locator->BuildLocator();<br>
<br>
// init the interesection parameters<br>
double tolerance = 0.001, lineParameter, intersect[3], paraCoord[3];<br>
double startPnt[3] = {// add coordinates of start point here}, <br>
endPnt[3] = {</font></font><font size="-1"><font face="Verdana">//
add coordinates of end point here</font></font><font size="-1"><font face="Verdana">};<br>
int sub_id;<br>
<br>
<br>
if(locator->IntersectWithLine(startPnt, endPnt, tolerance,
lineParameter, intersect, paraCoord, sub_id))<br>
{<br>
printf("Point intersection: (%.2f, %.2f, %.2f)\n", intersect[0],
intersect[1], intersect[2]);<br>
// do something with the intersection point<br>
}<br>
<br>
<br>
locator->Delete();<br>
<br>
<br>
now I have a new problem (as you can see I'm not a big expert of vtk...)<br>
The vtkPolyData comes from a textured model. Is there a way to get
easily the colour of the intersection point (considering that probably
it is not a vertex of the mesh)?<br>
<br>
regards,<br>
a.<br>
</font></font></div><div bgcolor="#ffffff" text="#000000"><font size="-1"><font face="Verdana"><br></font></font></div></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">Are you cells colored? If so, there is an overloaded function:</div>
<div class="gmail_quote"><br></div><div class="gmail_quote"><a href="http://www.vtk.org/doc/nightly/html/classvtkOBBTree.html#a2b2d9174fa6fac5268b44f57f1ffb005">http://www.vtk.org/doc/nightly/html/classvtkOBBTree.html#a2b2d9174fa6fac5268b44f57f1ffb005</a></div>
<div class="gmail_quote"><br></div><div class="gmail_quote">That will give you the cellId of the intersection. You would then just have to get the color of that cell. If the cell is not colored (if only the vertices are colored), you could use</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">vtkIdList* vtkCell::GetPointIds</div><div class="gmail_quote"><br></div><div class="gmail_quote">to get the points that comprise the cell, then do some averaging of the color of those points or something like that. Maybe someone knows a better way to automatically interpolate the color of a cell at a point?</div>
<br clear="all">Thanks,<br><br><div>David</div></div>