| 99 | } |
| 100 | |
| 101 | bool polygonContainsPoint(const stats::Polygon &polygon, const Point &pt) |
| 102 | { |
| 103 | if (polygon.empty()) |
| 104 | return false; |
| 105 | |
| 106 | auto numPts = polygon.size(); |
| 107 | // Test the ray against all sides |
| 108 | unsigned intersections = 0; |
| 109 | for (size_t i = 0; i < numPts - 1; i++) |
| 110 | { |
| 111 | Line side = Line(polygon.at(i), polygon.at(i + 1)); |
| 112 | // Test if current side intersects with ray. |
| 113 | if (doesLineIntersectWithHorizontalLine(side, pt)) |
| 114 | intersections++; |
| 115 | } |
| 116 | // close polygon |
| 117 | if (polygon.front() != polygon.back()) |
| 118 | { |
| 119 | auto side = Line(polygon.front(), polygon.back()); |
| 120 | // Test if current side intersects with ray. |
| 121 | if (doesLineIntersectWithHorizontalLine(side, pt)) |
| 122 | intersections++; |
| 123 | } |
| 124 | |
| 125 | if ((intersections & 1) == 1) |
| 126 | { |
| 127 | // Inside of polygon |
| 128 | return true; |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | // Outside of polygon |
| 133 | return false; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | FrameTypeData StatisticsData::getFrameTypeData(int typeID) |
| 138 | { |
no test coverage detected