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

joaoroberto88 joaorobertojr88 at gmail.com
Thu Jun 4 08:12:33 EDT 2015


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.


More information about the vtkusers mailing list