<HTML dir=ltr><HEAD><TITLE>[vtkusers] Compute distance between line and vtkPolyData</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY><FONT color=#008000 size=2>
<P><FONT color=#000000>Hello Che,</FONT></P>
<P><FONT color=#000000>I don't know of any way in VTK to get directly the distance between a line and a vtkPolyData.</FONT></P>
<P><FONT color=#000000>However, using vtkCellLocator is pretty fast, and running its FindClosestPoint method in a loop on each </FONT></P>
<P><FONT color=#000000>point along the line is probably a good solution.</FONT></P>
<P>// Create the Cell Locator.</P></FONT><FONT size=2>
<P>vtkCellLocator *cellLocator = vtkCellLocator::New();</P>
<P>cellLocator->SetDataSet(Source);</P>
<P>cellLocator->BuildLocator();</P></FONT>
<DIV id=idOWAReplyText28541 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2><FONT color=#008000 size=2>
<P>// Compute the distance d between the point m and the closest point c on the surface.</P></FONT><FONT size=2>
<P>cellLocator->FindClosestPoint(m, c, cellId, subId, d);</P>
<P> </P>
<P>Tron</P></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT> </DIV></DIV>
<DIV id=idSignature57102 dir=ltr>
<DIV><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#000000 size=2>Tron Darvann</FONT></DIV>
<DIV><FONT face=Arial size=2>Research Engineer, PhD, 3D-Laboratory</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><U>Tel:</U> (+45) 35 32 67 58 (lab) / (+45) 28 20 03 12 (mobile)</FONT></DIV>
<DIV><FONT face=Arial size=2><U>E-mail:</U> <A href="mailto:trd@odont.ku.dk">trd@odont.ku.dk</A></FONT></DIV>
<DIV><FONT face=Arial size=2><U>Skype:</U> tron.darvann</FONT></DIV>
<DIV><FONT face=Arial size=2><U>Fax:</U> (+45) 35 32 65 05</FONT></DIV>
<DIV><FONT face=Arial size=2><U>Mailing and Visiting Address:</U></FONT></DIV>
<DIV><FONT face=Arial size=2>3D-Lab, School of Dentistry</FONT></DIV>
<DIV><FONT face=Arial size=2>University of Copenhagen</FONT></DIV>
<DIV><FONT face=Arial size=2>Nørre Alle 20</FONT></DIV>
<DIV><FONT face=Arial size=2>DK-2200 Copenhagen N</FONT></DIV>
<DIV><FONT face=Arial size=2>Denmark</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Fra:</B> vtkusers-bounces+trd=odont.ku.dk@vtk.org på vegne af Chavdar Papazov<BR><B>Sendt:</B> ma 13-11-2006 16:40<BR><B>Til:</B> vtkusers@vtk.org<BR><B>Emne:</B> [vtkusers] Compute distance between line and vtkPolyData<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hi,<BR><BR>I want to compute the distance between a straight line<BR>(ray) and an vtkPolyData-object.<BR><BR>There is an obvious (but bad) solution:<BR>I could compute the distance between every point in<BR>the vtkPolyData-object and the line and then take the<BR>minimum, but this will be very slow...<BR><BR>Is there a function in VTK, that does this maybe in<BR>some better way?<BR><BR>Thanks a lot!<BR><BR>Greetings,<BR>Che<BR><BR><BR><BR><BR>____________________________________________________________________________________<BR>Yahoo! Music Unlimited<BR>Access over 1 million songs.<BR><A href="http://music.yahoo.com/unlimited">http://music.yahoo.com/unlimited</A><BR>_______________________________________________<BR>This is the private VTK discussion list.<BR>Please keep messages on-topic. Check the FAQ at: <A href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A><BR>Follow this link to subscribe/unsubscribe:<BR><A href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A><BR></FONT></P></DIV></BODY></HTML>