Hello Will,<br><br>Thanks for the comments and background information.<br><br>I will modify the vtkTriangle intersection routine; at this point what would probably be the fastest would be to calculate the intersection with the 3 edges when parallelism is detected.<br>
<br>Best<br>Philippe<br><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 4:16 PM, Will Schroeder <span dir="ltr"><<a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Philippe-<div><br></div><div>I agree, if parallel, then a distance check should be performed between the line and the triangle and compared to the input tolerance. Obviously it's distance to a *finite line*, so you might start by computing distance of a infinite line to the infinite plane containing the triangle (this should be fast). Then if this is within tolerance, then take into account the finite nature of the line and triangle to return the final verdict.</div>
<div><br></div><div>Similar code should be extended to the polygon as well. </div><div><br></div><div>I suspect that this was written as a performance "feature" for picking. The nature of meshes is such that if a ray is parallel to a triangle t1, then it is likely to hit another triangle connected to t1 but with a different normal. And if t1 and all connected triangles are all parallel to the ray, then you can't see them hence pick them :-) But line intersection is being used for heavier-duty operations in VTK now, so we should beef the operation up.</div>
<div><br></div><div>W<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Sun, Nov 27, 2011 at 11:28 AM, Philippe Pebay <span dir="ltr"><<a href="mailto:philippe.pebay@kitware.com" target="_blank">philippe.pebay@kitware.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hello all,<br><br>The IntersectWithLine() routine in vtkPlane returns 0, i.e., no intersection, whenever the plane and line are parallel.<br>Specifically, this occurs in lines 171-20, copied below:<br><br> num = vtkMath::Dot(n,p0) - ( n[0]*p1[0] + n[1]*p1[1] + n[2]*p1[2] ) ;<br>
den = n[0]*p21[0] + n[1]*p21[1] + n[2]*p21[2];<br> //<br> // If denominator with respect to numerator is "zero", then the line and<br> // plane are considered parallel. <br> //<br><br> // trying to avoid an expensive call to fabs()<br>
if (den < 0.0)<br> {<br> fabsden = -den;<br> }<br> else<br> {<br> fabsden = den;<br> }<br> if (num < 0.0)<br> {<br> fabstolerance = -num*VTK_PLANE_TOL;<br> }<br> else<br> {<br> fabstolerance = num*VTK_PLANE_TOL;<br>
}<br> if ( fabsden <= fabstolerance )<br> {<br> t = VTK_DOUBLE_MAX;<br> return 0;<br> }<br><br>Nevertheless, a line may be parallel to a plane and yet be contained inside said plane. In this case, the routine will return 0 just as if the line was parallel and outside of the plane, as the calculation does not consider the plane-to-line distance.<br>
<br>It might have been intended to be like this. However, this becomes a problem in the implementation of vtkTriangle's implementation of IntersectWithLine(), which first calls vtkPlane::IntersectWithLine(): as a result, a line which goes through a vtkTriangle, while being contained in the plane of this triangle, will be considered as NOT intersecting the triangle, which is clearly an error.<br>
<br>I am therefore wondering whether this behavior of vtkPlane::IntersectWithLine is a feature, or a bug.<br><br>If it is not a bug, then I would submit that the implementation of vtkTriangle::IntersectWithLine() should be modified, by checking, for lines that ARE parallel to the triangle, whether they are contained in the same plane.<br>
<br>Please let me know what you think. Thank you,<br>Philippe<br></div></div><font color="#888888"><br><br>
<br clear="all"><br>-- <br><font color="#888888"><div><div></div><div class="h5">Philippe Pébay<br>Directeur de la Visualisation et du Calcul Haute Performance<br>
Kitware SAS<br>
20 rue de la Villette<br>
69328 Lyon cedex 03, France<br>
</div></div><a value="+33426685003"><span>+33 (0)4.26.68.50.03</span><span dir="ltr"><span> begin_of_the_skype_highlighting</span> <span dir="ltr" title="Call this phone number in France with Skype: +33426685003"><span> </span><span title="Skype actions"><span> </span> </span><span><span>+33 (0)4.26.68.50.03</span></span><span> </span></span> <span>end_of_the_skype_highlighting</span></span></a><br>
<a href="http://www.kitware.fr/" target="_blank">http://www.kitware.fr</a></font><br>
</font><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
<br></blockquote></div><font color="#888888"><br><br clear="all"><div><br></div>-- <br>William J. Schroeder, PhD<br>Kitware, Inc.<br>28 Corporate Drive<br>Clifton Park, NY 12065<br><a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br><a href="tel:%28518%29%20881-4902" value="+15188814902" target="_blank">(518) 881-4902</a><br>
</font></div>
</blockquote></div><br><br clear="all"><br>-- <br><font color="#888888">Philippe Pébay<br>Directeur de la Visualisation et du Calcul Haute Performance<br>
Kitware SAS<br>
20 rue de la Villette<br>
69328 Lyon cedex 03, France<br>
<a value="+33426685003">+33 (0)4.26.68.50.03</a><br>
<a href="http://www.kitware.fr/" target="_blank">http://www.kitware.fr</a></font><br>