[vtkusers] PointInPolygon works strange
shinpei
noro_shinpei at web.de
Tue Jul 9 20:27:48 EDT 2013
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.
More information about the vtkusers
mailing list