Skip to content

Commit

Permalink
Merge pull request #1044 from v4hn/fix-extract-polygonal-prism
Browse files Browse the repository at this point in the history
fix leak in extract_polygonal_prism_data
  • Loading branch information
jspricke committed Dec 16, 2014
2 parents 0a03572 + d2f591e commit fea0ec1
Showing 1 changed file with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pcl::isXYPointIn2DXYPolygon (const PointT &point, const pcl::PointCloud<PointT>
double x1, x2, y1, y2;

int nr_poly_points = static_cast<int> (polygon.points.size ());
// start with the last point to make the check last point<->first point the first one
double xold = polygon.points[nr_poly_points - 1].x;
double yold = polygon.points[nr_poly_points - 1].y;
for (int i = 0; i < nr_poly_points; i++)
Expand Down Expand Up @@ -139,29 +140,6 @@ pcl::isXYPointIn2DXYPolygon (const PointT &point, const pcl::PointCloud<PointT>
yold = ynew;
}

// And a last check for the polygon line formed by the last and the first points
double xnew = polygon.points[0].x;
double ynew = polygon.points[0].y;
if (xnew > xold)
{
x1 = xold;
x2 = xnew;
y1 = yold;
y2 = ynew;
}
else
{
x1 = xnew;
x2 = xold;
y1 = ynew;
y2 = yold;
}

if ( (xnew < point.x) == (point.x <= xold) && (point.y - y1) * (x2 - x1) < (y2 - y1) * (point.x - x1) )
{
in_poly = !in_poly;
}

return (in_poly);
}

Expand Down

0 comments on commit fea0ec1

Please sign in to comment.