From 614972920ffa1b62b7341aedeff3902419ac2afa Mon Sep 17 00:00:00 2001 From: Alexandru Eugen Ichim Date: Mon, 17 Dec 2012 21:22:09 +0000 Subject: [PATCH] bug fix for the corrected output of 2D Convex Hulls git-svn-id: svn+ssh://svn.pointclouds.org/pcl/trunk@8279 a9d63959-f2ad-4865-b262-bf0e56cfafb6 --- .../impl/extract_polygonal_prism_data.hpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/segmentation/include/pcl/segmentation/impl/extract_polygonal_prism_data.hpp b/segmentation/include/pcl/segmentation/impl/extract_polygonal_prism_data.hpp index dc63d5eb743..3ab8fc70d2a 100644 --- a/segmentation/include/pcl/segmentation/impl/extract_polygonal_prism_data.hpp +++ b/segmentation/include/pcl/segmentation/impl/extract_polygonal_prism_data.hpp @@ -138,6 +138,30 @@ pcl::isXYPointIn2DXYPolygon (const PointT &point, const pcl::PointCloud xold = xnew; 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); }