// polygon_region_filler.h
#ifndef POLYGON_REGION_FILLER_H
#define POLYGON_REGION_FILLER_H
#include <vector>
#include "polygon_offset.h" // 你的头文件
struct RegionInfo {
std::vector<Point> boundary; // 子区域的边界点(闭合)
Point centroid; // 种子点(重心)
bool is_valid; // 区域是否有效(面积足够大)
};
class PolygonRegionFiller {
public:
// 构造函数
PolygonRegionFiller(const std::vector<Point>& points, double line_width = 4.0);
// 分解多边形并获取所有可填充区域
std::vector<RegionInfo> getFillableRegions();
private:
// 原始多边形点
std::vector<Point> original_points_;
// 线宽
double line_width_;
// 内部辅助函数
std::vector<Point> findIntersectionPoints();
std::vector<std::vector<Point>> splitAtIntersections(const std::vector<Point>& points);
Point calculateCentroid(const std::vector<Point>& polygon);
double calculateArea(const std::vector<Point>& polygon);
bool isPointInsidePolygon(const Point& p, const std::vector<Point>& polygon);
bool isPolygonClockwise(const std::vector<Point>& polygon);
std::vector<std::vector<Point>> extractSimplePolygons(const std::vector<Point>& points);
void removeDuplicatePoints(std::vector<Point>& points);
double distanceBetweenPoints(const Point& a, const Point& b);
};
#endif // POLYGON_REGION_FILLER_H