| 54 | |
| 55 | template <class T> |
| 56 | void Array2Poly(const T* box, const size_t box_size, funcs::gpc_polygon* poly) { |
| 57 | size_t pts_num = box_size / 2; |
| 58 | (*poly).num_contours = 1; |
| 59 | (*poly).hole = reinterpret_cast<int*>(malloc(sizeof(int))); // NOLINT |
| 60 | (*poly).hole[0] = 0; |
| 61 | (*poly).contour = (funcs::gpc_vertex_list*)malloc( // NOLINT |
| 62 | sizeof(funcs::gpc_vertex_list)); |
| 63 | (*poly).contour->num_vertices = static_cast<int>(pts_num); |
| 64 | (*poly).contour->vertex = (funcs::gpc_vertex*)malloc( // NOLINT |
| 65 | sizeof(funcs::gpc_vertex) * pts_num); |
| 66 | for (size_t i = 0; i < pts_num; ++i) { |
| 67 | (*poly).contour->vertex[i].x = box[2 * i]; |
| 68 | (*poly).contour->vertex[i].y = box[2 * i + 1]; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | template <class T> |
| 73 | void PointVec2Poly(const std::vector<Point_<T>>& vec, |