[vtkusers] Point in Polygon does not return correct value as expected

Bill Lorensen bill.lorensen at gmail.com
Thu Jun 4 08:39:07 EDT 2015


Please post small compilable program that illustrates the issue.
On Jun 4, 2015 8:12 AM, "joaoroberto88" <joaorobertojr88 at gmail.com> wrote:

> Hello,
>
> I have a 2D polygon and I'm trying to use the vtkPolygon::PointInPolygon
> function as follow:
>
> bool pointInPolygon(double *point) {
>     double *dataPointer =
>
> static_cast<double*>(filteredPolygon->GetPoints()->GetData()->GetVoidPointer(0));
>     int numberOfPoints = filteredPolygon->GetPoints()->GetNumberOfPoints();
>     double p[3] = { point[0], point[1], point[2] };
>     double bounds[6];
>     double normal[3];
>
>     filteredPolygon->ComputeNormal(filteredPolygon->GetPoints(), normal);
>     filteredPolygon->GetPoints()->GetBounds(bounds);
>
>     return filteredPolygon->PointInPolygon(p, numberOfPoints, dataPointer,
> bounds, normal);
> }
>
> It happens that the above function returns true for every point inside the
> polygon bounds. I've read in this mailing list that the problem can be
> related to the normal. Actually, the normal value is [0, 0, 1] in this
> piece
> of code, so the true return makes sense regarding the space dimension
> (ray-castings will never intersect a 2D object on z axis). Then I set
> manually normal values such as [1, 0, 0], [0, 1, 0] and [1, 1, 0], but I
> still having no luck.
>
> If you guys can help me, I would like to know what is going wrong on my
> implementation.
>
> Thanks a lot.
>
> Joao.
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Point-in-Polygon-does-not-return-correct-value-as-expected-tp5732164.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150604/d5da3290/attachment.html>


More information about the vtkusers mailing list