Hello,<br><br>Now the things are going more weird. If I load the scatter file in UTM format, then it shows all the points in the bounding box. If i load data in Geographic format(lat/long) then, it doesnt show any point within the polygon..<br>
<br>Any clues, or suggestions whats going wrong here?<br><br>Thanks<br><br>Warm Regards<br>Rakesh Patil<br><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 5:25 PM, rakesh patil <span dir="ltr"><<a href="mailto:prakeshofficial@gmail.com">prakeshofficial@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi<div><br></div><div>I am using points and not vertex points. Also the example given by David, is instructing me the similar method to use. </div>
<div><br></div><div>In the above code i made a small change. Instead of.</div><div class="im">
<div><br></div><div>newPoints->InsertNextPoint( points->GetPoint(id));</div><div><br></div></div><div>I wrote</div><div><br></div><div>double pt[3];</div><div>points->GetPoint(id, pt);</div><div>newPoints->InsertNextPoint(pt);</div>
<div><br></div><div>After this change i am getting strange result. The result in "newPoints" is all the points that fall inside a region defined by bounds. i.e. a rectangular region which is formed by the bounds.</div>
<div><br></div><div>This is really getting interesting and strange.. :-)</div><div><br></div><div>Thanks</div><div><br></div><div>Warm Regards</div><div>Rakesh Patil<div><div></div><div class="h5"><br><br><div class="gmail_quote">
On Wed, Sep 29, 2010 at 5:09 PM, Jothy <span dir="ltr"><<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">Are you using vertex points instead of points inside the polygon. I mean, in case of a sphere, are using surface points rather than points inside the sphere.<br>
<br>I think there is some difficulty in accurately calculating whether a point is inside or outside a polygon, if you submit a point which lies on or very close to the surface due to round-off errors in the ray-tracing used.<br>
<font color="#888888">
<br><br>Jothy</font><div><div></div><div><br><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 12:23 PM, rakesh patil <span dir="ltr"><<a href="mailto:prakeshofficial@gmail.com" target="_blank">prakeshofficial@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
hi,<div><br></div><div>Below is the sample code what i was trying.</div><div><br></div><div>int num = polyPd->GetNumberOfPoints(); </div><div>// polyPd is a polydata containing points that forms a polygon</div><div><br>
</div><div>vtkPoints* points = this->del->GetOutput()->GetPoints();</div><div>// del is an instance of vtkDelaunay2d class. Out of this object is used to display</div><div>// scattered points</div><div><br></div>
<div>vtkPoints *newPoints = vtkPoints::New();</div><div>// To store selected points</div><div><br></div><div>double bnds[6], n[3];</div><div><br></div><div>// Get the bounds in 'bnds'</div><div>polyPd->GetPoints()->GetBounds(bnds);</div>
<div><br></div><div>// To get normal direction in 'n'</div><div>vtkPolygon::ComputeNormal(num, </div><div> static_cast<double *>(polyPd->GetPoints()->GetData()->GetVoidPointer(0)), n);</div><div><br>
</div><div>for( int id = 0; id < points->GetNumberOfPoints(); id++ )</div><div>{</div><div> if( vtkPolygon::PointInPolygon( points->GetPoint(id), num, </div><div> static_cast<double *>(polyPd->GetPoints()->GetData()->GetVoidPointer(0)), n) == 1 )</div>
<div> newPoints->InsertNextPoint(points->GetPoint(id));</div><div>}</div><div><br></div><div>// code to create a mapper and actor with </div><div>// the help of newPoints</div><div><br></div><div>I hope there is no difficulty in understanding the other part of code. I got this logic from the mailing list when i searched for PoinInPolygon here</div>
<div><br></div><div><a href="http://public.kitware.com/pipermail/vtkusers/2010-April/107974.html" target="_blank">http://public.kitware.com/pipermail/vtkusers/2010-April/107974.html</a></div><div><div><br></div>
<div>Thanks</div><div><br></div>
<div>Warm Regards</div><div>Rakesh Patil</div><div><br></div></div><div><div></div><div><div><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 3:49 PM, Jothy <span dir="ltr"><<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">Could you please post your code?<br><br>Jothy<br><br><div class="gmail_quote">
<div><div></div><div>
On Wed, Sep 29, 2010 at 11:09 AM, rakesh patil <span dir="ltr"><<a href="mailto:prakeshofficial@gmail.com" target="_blank">prakeshofficial@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div>Hi,<div><br></div><div>I have been trying to find whether a given point is within a polygon or not. I have been doing this using,</div>
<div><br></div><div>vtkPolygon::PointInPolygon() </div><div><br></div><div>function. But out of 10 runs, in 1 run, i get only few points inside, the polygon. Others just fails and shows 0 points selected.</div>
<div><br></div><div>Can anyone come up with a small example, for this?</div><div><br></div><div>Thanks</div><div><br></div><div>Warm Regards</div><div>Rakesh Patil</div>
<br></div></div>_______________________________________________<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>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">PhD Student<br>Dept. of Medical Physics<br>Clatterbridge Centre for Oncology<br>UK<br></div><br>
</div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">PhD Student<br>Dept. of Medical Physics<br>Clatterbridge Centre for Oncology<br>UK<br></div><br>
</div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br>