[vtkusers] PointInPolygon works strange
Marco Nawijn
nawijn at gmail.com
Wed Jul 10 05:00:11 EDT 2013
Dear Shinpei,
I have never used this class/method before, but can it be a matter of
definition? In my opinion you have the interior and the boundary defined by
the polygon. I can imagine that "PointInPolygon" checks if the point is in
the interior, so it excludes points on the boundary. Since your point is on
the boundary, it would then be outside of the polygon.
Kind regards,
Marco
On Wed, Jul 10, 2013 at 2:27 AM, shinpei <noro_shinpei at web.de> wrote:
> Hi,
>
> I tried the example PointInPolygon
> <http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/PointInPolygon> with
> the following code:
>
> int main()
> {
> vtkNew(vtkPolygon, polygon);
> polygon->GetPoints()->InsertNextPoint(0.0, 0.0, 0.0);
> polygon->GetPoints()->InsertNextPoint(0.0, 10.0, 0.0);
> polygon->GetPoints()->InsertNextPoint(10.0, 0.0, 0.0);
>
> double testIn[3] = {5.0, 0.0, 0.0};
>
> double n[3];
> polygon->ComputeNormal(polygon->GetPoints()->GetNumberOfPoints(),
>
> static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
> n);
>
> double bounds[6];
> polygon->GetPoints()->GetBounds(bounds);
>
> std::cout << "testIn in polygon? " <<
>
> polygon->PointInPolygon(testIn,polygon->GetPoints()->GetNumberOfPoints(),
>
> static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0)),
> bounds, n) << std::endl;
> return EXIT_SUCCESS;
> }
>
> But the result is: The Point (5 0 0) is not in the polygon. This could not
> be the right result. The point rests on the edge (0 0 0) - (10 0 0) of the
> triangle.
>
> What is wrong?
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/PointInPolygon-works-strange-tp5721855.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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130710/b734c3ed/attachment.htm>
More information about the vtkusers
mailing list