<div dir="ltr">It required some transformations to both ray and polygon to work correctly.<br><br>Jothy<br><br><div class="gmail_quote">On Mon, Feb 13, 2012 at 5:53 PM, David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>&gt;</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 12:09 PM, Jothybasu Selvaraj<br>
&lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt; wrote:<br>
&gt; Why my ray(line) never intersects the polygon?<br>
&gt;<br>
&gt; I have a ray passing from up to down, and a polygon (like a circle at some<br>
&gt; depth around that line).<br>
&gt;<br>
&gt; Here is the code<br>
&gt;<br>
&gt; vtkSmartPointer&lt;vtkPolygon&gt; polygon =<br>
&gt;<br>
&gt;             vtkSmartPointer&lt;vtkPolygon&gt;::New();<br>
&gt;<br>
&gt;     polygon-&gt;GetPoints()-&gt;InsertNextPoint(-35.0, 91.0,7.5);<br>
&gt;<br>
&gt;     polygon-&gt;GetPoints()-&gt;InsertNextPoint(47.0, 150.0, 7.5);<br>
&gt;<br>
&gt;     polygon-&gt;GetPoints()-&gt;InsertNextPoint(47.0, 150.0,-57.0);<br>
&gt;<br>
&gt;     polygon-&gt;GetPoints()-&gt;InsertNextPoint(-36.0, 92.0, -57.0);<br>
&gt;<br>
&gt;     #polygon-&gt;GetPoints()-&gt;InsertNextPoint(-35.0, 91.0,7.5);//tried even<br>
&gt; closing the contour<br>
&gt;<br>
&gt;     // Inputs<br>
&gt;<br>
&gt;     double p1[3] = {-0.0,-884.0,-28.0};<br>
&gt;<br>
&gt;     double p2[3] = {-0.0,187.0,-28.0};<br>
&gt;<br>
&gt;     double tolerance = 0.001;<br>
&gt;<br>
&gt;     // Outputs<br>
&gt;<br>
&gt;       double t; // Parametric coordinate of intersection (0 (corresponding<br>
&gt; to p1) to 1 (corresponding to p2))<br>
&gt;<br>
&gt;       double x[3]; // The coordinate of the intersection<br>
&gt;<br>
&gt;       double pcoords[3];<br>
&gt;<br>
&gt;       int subId;<br>
&gt;<br>
&gt;<br>
&gt;       vtkIdType iD = polygon-&gt;IntersectWithLine(p1, p2, tolerance, t, x,<br>
&gt; pcoords, subId);<br>
&gt;<br>
&gt; //    if(iD!=0)<br>
&gt;<br>
&gt; //    {<br>
&gt;<br>
&gt;         qDebug() &lt;&lt; &quot;iD: &quot;;<br>
&gt;<br>
&gt; //    }<br>
<br>
</div></div>There must be something wrong with your coordinates, or something<br>
different in Python. This works as expected:<br>
<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/PolygonIntersection" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/PolygonIntersection</a><br>
<font color="#888888"><br>
David<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>