2025-09-21 22:20:24 +08:00
|
|
|
|
#ifndef POINTCLOUDIMAGEUTILS_H
|
|
|
|
|
|
#define POINTCLOUDIMAGEUTILS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QImage>
|
|
|
|
|
|
#include <QColor>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
#include "VZNL_Types.h"
|
|
|
|
|
|
#include "SG_baseDataType.h"
|
2025-10-08 21:45:37 +08:00
|
|
|
|
#include "beltTearingDetection_Export.h"
|
2025-09-21 22:20:24 +08:00
|
|
|
|
|
|
|
|
|
|
struct PointRenderData {
|
|
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
|
|
|
|
PointRenderData(double x_, double y_)
|
|
|
|
|
|
: x(x_), y(y_) {}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class PointCloudImageUtils
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
// 点云转图像 - 使用std::vector格式的扫描线数据
|
|
|
|
|
|
static QImage GeneratePointCloudImage(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
2025-10-08 21:45:37 +08:00
|
|
|
|
const std::vector<SSG_beltTearingInfo>& beltTearings,
|
2025-09-21 22:20:24 +08:00
|
|
|
|
int imageWidth, int imageHeight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
// 快速计算点云范围
|
|
|
|
|
|
static bool CalculateRangeFast(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
|
|
|
|
double& xMin, double& xMax,
|
|
|
|
|
|
double& yMin, double& yMax);
|
|
|
|
|
|
|
|
|
|
|
|
// 直接绘制点云到图像数据,避免QPainter开销
|
|
|
|
|
|
static void DrawPointCloudDirect(QImage& image,
|
|
|
|
|
|
const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
|
|
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
|
|
|
|
int imageWidth, int imageHeight);
|
|
|
|
|
|
|
|
|
|
|
|
// 计算scan lines格式点云的范围 (原始版本)
|
|
|
|
|
|
static void CalculateScanLinesRange(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
|
|
|
|
double& xMin, double& xMax,
|
|
|
|
|
|
double& yMin, double& yMax);
|
|
|
|
|
|
|
|
|
|
|
|
// 优化版本:同时计算范围和准备渲染数据
|
|
|
|
|
|
static void CalculateScanLinesRangeOptimized(const std::vector<std::vector<SVzNL3DPosition>>& scanLines,
|
|
|
|
|
|
double& xMin, double& xMax,
|
|
|
|
|
|
double& yMin, double& yMax,
|
|
|
|
|
|
std::vector<PointRenderData>& renderData);
|
|
|
|
|
|
|
|
|
|
|
|
// 绘制LapWeld检测结果
|
|
|
|
|
|
static void DrawLapWeldResults(QPainter& painter,
|
|
|
|
|
|
const std::vector<std::vector<SVzNL3DPoint>>& weldResults,
|
|
|
|
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
|
|
|
|
int imageWidth, int imageHeight);
|
|
|
|
|
|
|
2025-10-08 21:45:37 +08:00
|
|
|
|
// 绘制皮带撕裂检测结果
|
|
|
|
|
|
static void DrawBeltTearingResults(QPainter& painter,
|
|
|
|
|
|
const std::vector<SSG_beltTearingInfo>& tearings,
|
|
|
|
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
|
|
|
|
int imageWidth, int imageHeight);
|
2025-09-21 22:20:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 优化版本:批量绘制点云
|
|
|
|
|
|
static void DrawPointCloudOptimized(QPainter& painter,
|
|
|
|
|
|
const std::vector<PointRenderData>& renderData,
|
|
|
|
|
|
double xMin, double xMax, double yMin, double yMax,
|
|
|
|
|
|
int imageWidth, int imageHeight);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // POINTCLOUDIMAGEUTILS_H
|