<div dir="ltr">Thanks David,<br><br>But vtkPolygon::PointInPolygon, I can only define the point of interest, to check whether it is inside the given polygon or not. I want to define the starting and end points of the ray and find whether it intersects a 2D polygon, the ray will pass through the polygon in any 3D angle.<br>
<br>I will try the BSP tree.<br><br>Jothy<br><br><div class="gmail_quote">On Mon, Feb 13, 2012 at 2:10 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">On Mon, Feb 13, 2012 at 9:07 AM, Jothybasu Selvaraj <<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I want to find whether a ray passes through a 2D polygon or not. The 2D<br>
> polygon will be at any depth and orientation (rotate aboth x,y,&z axes).<br>
><br>
> Can the vtkOBBTree or vtkModifiedBSPTree do this?<br>
><br>
> Thanks<br>
><br>
> --<br>
> Jothy<br>
<br>
</div></div>Yes, and the vtkModifiedBSPTree is much much faster:<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/ModifiedBSPTree_IntersectWithLine" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/ModifiedBSPTree_IntersectWithLine</a><br>
<br>
If you just need to intersect one polygon (not a whole tree of a<br>
mesh), you can use<br>
<a href="http://www.vtk.org/doc/nightly/html/classvtkPolygon.html#aaa65561067bdaaca9f965fffcc7e7e8b" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkPolygon.html#aaa65561067bdaaca9f965fffcc7e7e8b</a><br>
directly.<br>
<font color="#888888"><br>
David<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>